Skip to content

Commit

Permalink
Update/v26 (#132)
Browse files Browse the repository at this point in the history
* update submodule

* Add release notes and bump version

* Switch build to new SDK

* Update instructions

* Readme update

* use wildcard for s9pk

* Dockerfile refactor

* Update guides

* Add config warnings for user and password change

* Update dependencies for manager

* Adding build and release workflow

* remove Interactive terminal

* test gcc build

* No need for compat.h patching anymore

* remobe deprecated secp256k1 patching

* bring back clang as compiler and try -O1 build

* Add v2 transport protocol support

* Use online documentation

* update start-sdk link

* Release notes and readme update

* Build and Release workflows update

* return config true
  • Loading branch information
k0gen authored Dec 31, 2023
1 parent 6d62cd9 commit 224d921
Show file tree
Hide file tree
Showing 57 changed files with 604 additions and 726 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/buildService.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Service

on:
workflow_dispatch:
pull_request:
paths-ignore: ['*.md']
branches: ['main', 'master']
push:
paths-ignore: ['*.md']
branches: ['main', 'master']

jobs:
BuildPackage:
runs-on: ubuntu-latest
steps:
- name: Prepare StartOS SDK
uses: Start9Labs/sdk@v1

- name: Checkout services repository
uses: actions/checkout@v3

- name: Build the service package
id: build
run: |
git submodule update --init --recursive
start-sdk init
make
PACKAGE_ID=$(yq -oy ".id" manifest.*)
echo "::set-output name=package_id::$PACKAGE_ID"
shell: bash

- name: Upload .s9pk
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.package_id }}.s9pk
path: ./${{ steps.build.outputs.package_id }}.s9pk
71 changes: 71 additions & 0 deletions .github/workflows/releaseService.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release Service

on:
push:
tags:
- 'v*.*'

jobs:
ReleasePackage:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Prepare StartOS SDK
uses: Start9Labs/sdk@v1

- name: Checkout services repository
uses: actions/checkout@v3

- name: Build the service package
run: |
git submodule update --init --recursive
start-sdk init
make
- name: Setting package ID and title from the manifest
id: package
run: |
echo "::set-output name=package_id::$(yq -oy ".id" manifest.*)"
echo "::set-output name=package_title::$(yq -oy ".title" manifest.*)"
shell: bash

- name: Generate sha256 checksum
run: |
PACKAGE_ID=${{ steps.package.outputs.package_id }}
sha256sum ${PACKAGE_ID}.s9pk > ${PACKAGE_ID}.s9pk.sha256
shell: bash

- name: Generate changelog
run: |
PACKAGE_ID=${{ steps.package.outputs.package_id }}
echo "## What's Changed" > change-log.txt
yq e '.release-notes' manifest.yaml >> change-log.txt
echo "## SHA256 Hash" >> change-log.txt
echo '```' >> change-log.txt
sha256sum ${PACKAGE_ID}.s9pk >> change-log.txt
echo '```' >> change-log.txt
shell: bash

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: ${{ steps.package.outputs.package_title }} ${{ github.ref_name }}
prerelease: true
body_path: change-log.txt
files: |
./${{ steps.package.outputs.package_id }}.s9pk
./${{ steps.package.outputs.package_id }}.s9pk.sha256
- name: Publish to Registry
env:
S9USER: ${{ secrets.S9USER }}
S9PASS: ${{ secrets.S9PASS }}
S9REGISTRY: ${{ secrets.S9REGISTRY }}
run: |
if [[ -z "$S9USER" || -z "$S9PASS" || -z "$S9REGISTRY" ]]; then
echo "Publish skipped: missing registry credentials."
else
start-sdk publish https://$S9USER:$S9PASS@$S9REGISTRY ${{ steps.package.outputs.package_id }}.s9pk
fi
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
manager/target/
**/*.rs.bk
bitcoind.s9pk
*.s9pk
.DS_Store
.vscode/
scripts/embassy.js
Expand Down
64 changes: 33 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,57 @@
FROM lncm/berkeleydb as berkeleydb

# Build stage for Bitcoin Core
FROM alpine:3.16 as bitcoin-core
FROM alpine:3.18 as bitcoin-core

COPY --from=berkeleydb /opt /opt

RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
RUN apk --no-cache add autoconf
RUN apk --no-cache add automake
RUN apk --no-cache add boost-dev
RUN apk --no-cache add build-base
RUN apk --no-cache add chrpath
RUN apk --no-cache add file
RUN apk --no-cache add gnupg
RUN apk --no-cache add libevent-dev
RUN apk --no-cache add libressl
RUN apk --no-cache add libtool
RUN apk --no-cache add linux-headers
RUN apk --no-cache add sqlite-dev
RUN apk --no-cache add zeromq-dev
RUN apk --no-cache add \
autoconf \
automake \
boost-dev \
build-base \
clang \
chrpath \
file \
gnupg \
libevent-dev \
libressl \
libtool \
linux-headers \
sqlite-dev \
zeromq-dev

ADD ./bitcoin /bitcoin


ENV BITCOIN_PREFIX=/opt/bitcoin

WORKDIR /bitcoin

RUN sed -i '/AX_PROG_CC_FOR_BUILD/a\AR_FLAGS=cr' src/secp256k1/configure.ac
RUN ./autogen.sh
RUN ./configure LDFLAGS=-L`ls -d /opt/db*`/lib/ CPPFLAGS=-I`ls -d /opt/db*`/include/ \
# If building on Mac make sure to increase Docker VM memory, or uncomment this line. See https://github.com/bitcoin/bitcoin/issues/6658 for more info.
# CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" \
CXXFLAGS="-O1" \
CXX=clang++ CC=clang \
--prefix=${BITCOIN_PREFIX} \
--mandir=/usr/share/man \
--disable-man \
--disable-tests \
--disable-bench \
--disable-ccache \
--with-gui=no \
--with-utils \
--with-libs \
--with-sqlite=yes \
--with-daemon
RUN make -j$(($(nproc) - 1))
RUN make -j$(nproc)
RUN make install
RUN strip ${BITCOIN_PREFIX}/bin/*
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0

# Build stage for compiled artifacts
FROM alpine:3.16
FROM alpine:3.18

LABEL maintainer.0="João Fonseca (@joaopaulofonseca)" \
maintainer.1="Pedro Branco (@pedrobranco)" \
Expand All @@ -68,8 +71,8 @@ RUN apk --no-cache add \
libevent \
libzmq \
sqlite-dev \
tini\
yq
tini \
yq \
RUN rm -rf /var/cache/apk/*

ARG ARCH
Expand All @@ -79,16 +82,15 @@ ENV BITCOIN_PREFIX=/opt/bitcoin
ENV PATH=${BITCOIN_PREFIX}/bin:$PATH

COPY --from=bitcoin-core /opt /opt
ADD ./manager/target/${ARCH}-unknown-linux-musl/release/bitcoind-manager /usr/local/bin/bitcoind-manager
RUN chmod a+x /usr/local/bin/bitcoind-manager
ADD ./docker_entrypoint.sh /usr/local/bin/docker_entrypoint.sh
RUN chmod a+x /usr/local/bin/docker_entrypoint.sh
ADD ./actions/reindex.sh /usr/local/bin/reindex.sh
RUN chmod a+x /usr/local/bin/reindex.sh
ADD ./check-rpc.sh /usr/local/bin/check-rpc.sh
RUN chmod a+x /usr/local/bin/check-rpc.sh
ADD ./check-synced.sh /usr/local/bin/check-synced.sh
RUN chmod a+x /usr/local/bin/check-synced.sh
COPY ./manager/target/${ARCH}-unknown-linux-musl/release/bitcoind-manager \
./docker_entrypoint.sh \
./actions/reindex.sh \
./check-rpc.sh \
./check-synced.sh \
/usr/local/bin/

RUN chmod a+x /usr/local/bin/bitcoind-manager \
/usr/local/bin/*.sh

EXPOSE 8332 8333

Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ clean:
rm -f scripts/*.js

verify: $(PKG_ID).s9pk
@embassy-sdk verify s9pk $(PKG_ID).s9pk
@start-sdk verify s9pk $(PKG_ID).s9pk
@echo " Done!"
@echo " Filesize: $(shell du -h $(PKG_ID).s9pk) is ready"

# for rebuilding just the arm image.
arm:
@rm -f docker-images/x86_64.tar
ARCH=aarch64 $(MAKE)
@ARCH=aarch64 $(MAKE) -s

# for rebuilding just the x86 image.
x86:
@rm -f docker-images/aarch64.tar
ARCH=x86_64 $(MAKE)
@ARCH=x86_64 $(MAKE) -s

$(PKG_ID).s9pk: manifest.yaml assets/compat/* docker-images/aarch64.tar docker-images/x86_64.tar instructions.md scripts/embassy.js
ifeq ($(ARCH),aarch64)
@echo "embassy-sdk: Preparing aarch64 package ..."
@echo "start-sdk: Preparing aarch64 package ..."
else ifeq ($(ARCH),x86_64)
@echo "embassy-sdk: Preparing x86_64 package ..."
@echo "start-sdk: Preparing x86_64 package ..."
else
@echo "embassy-sdk: Preparing Universal Package ..."
@echo "start-sdk: Preparing Universal Package ..."
endif
@embassy-sdk pack
@start-sdk pack

install: $(PKG_ID).s9pk
install:
ifeq (,$(wildcard ~/.embassy/config.yaml))
@echo; echo "You must define \"host: http://embassy-server-name.local\" in ~/.embassy/config.yaml config file first"; echo
@echo; echo "You must define \"host: http://server-name.local\" in ~/.embassy/config.yaml config file first"; echo
else
embassy-cli package install $(PKG_ID).s9pk
start-cli package install $(PKG_ID).s9pk
endif

docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh manager/target/aarch64-unknown-linux-musl/release/bitcoind-manager manifest.yaml check-rpc.sh check-synced.sh actions/*
Expand All @@ -59,10 +59,10 @@ else
endif

manager/target/aarch64-unknown-linux-musl/release/bitcoind-manager: $(MANAGER_SRC)
docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/manager:/home/rust/src messense/rust-musl-cross:aarch64-musl cargo build --release
docker run --rm -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/manager:/home/rust/src messense/rust-musl-cross:aarch64-musl cargo build --release

manager/target/x86_64-unknown-linux-musl/release/bitcoind-manager: $(MANAGER_SRC)
docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/manager:/home/rust/src messense/rust-musl-cross:x86_64-musl cargo build --release
docker run --rm -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/manager:/home/rust/src messense/rust-musl-cross:x86_64-musl cargo build --release

scripts/embassy.js: scripts/**/*.ts
deno bundle scripts/embassy.ts scripts/embassy.js
49 changes: 39 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Wrapper for Bitcoin Core
<p align="center">
<img src="icon.png" alt="Project Logo" width="21%">
</p>

This project wraps [Bitcoin](https://bitcoin.org) for EmbassyOS. Bitcoin uses peer-to-peer technology to operate with no central authority or banks - managing transactions and the issuing of bitcoins is carried out collectively by the network.
# Bitcoin Core for StartOS

This project packages [Bitcoin](https://bitcoin.org) for StartOS. Bitcoin uses peer-to-peer technology to operate with no central authority or banks - managing transactions and the issuing of bitcoins is carried out collectively by the network.

## Contributing

Expand All @@ -12,7 +16,7 @@ For technical contributors, please fork this repository, make your changes accor

### Adding Config Options

To add config options, include the new config options in *both* `config_spec.yaml` and `assets/bitcoin.conf.template`, adhering to the syntax and conventions of those files. To view the full list of config options, complete with descriptions and specifications, check out this [site](https://jlopp.github.io/bitcoin-core-config-generator) from Jameson Lopp.
To add config options, include the new config options in *both* `scripts/services/getConfig.ts` and `assets/compat/bitcoin.conf.template`, adhering to the syntax and conventions of those files. To view the full list of config options, complete with descriptions and specifications, check out this [site](https://jlopp.github.io/bitcoin-core-config-generator) from Jameson Lopp.

## Dependencies

Expand All @@ -23,7 +27,7 @@ Install the following system dependencies to build this project by following the
- [rust-musl-cross](https://github.com/Start9Labs/rust-musl-cross)
- [yq](https://mikefarah.gitbook.io/yq)
- [rust](https://rustup.rs)
- [embassy-sdk](https://github.com/Start9Labs/embassy-os/blob/master/backend/install-sdk.sh)
- [start-sdk](https://github.com/Start9Labs/start-os/tree/sdk)
- [make](https://www.gnu.org/software/make/)

## Cloning
Expand All @@ -38,18 +42,43 @@ git submodule update --init

## Building

To build the project for all supported platforms, run the following command:

```
make
```

## Installing (on Embassy)
To build the project for a single platform, run:

```
scp bitcoind.s9pk root@embassy-<id>.local:/embassy-data/package-data/tmp # Copy S9PK to the external disk. Make sure to create the directory if it doesn't already exist
ssh root@embassy-<id>.local
embassy-cli auth login
embassy-cli package install /embassy-data/pacakge-data/tmp/bitcoind.s9pk # Install the sideloaded package
# for amd64
make x86
```
or
```
# for arm64
make arm
```

## Installing (on Start9 server)

Run the following commands to determine successful install:
> :information_source: Change server-name.local to your Start9 server address
```
start-cli auth login
# Enter your StartOS password
start-cli --host https://server-name.local package install bitcoind.s9pk
```

If you already have your `start-cli` config file setup with a default `host`, you can install simply by running:

```
make install
```

> **Tip:** You can also install the `bitcoind.s9pk` using **Sideload Service** under the **System > Manage** section.
## Integrations

Documentation guides for integrating with external applications can be found under [docs/integrations](/docs/integrations).
Our [documentation](https://docs.start9.com/latest/service-guides/bitcoin/bitcoin-integrations) includes guides for integrating Bitcoin with external applications.
Loading

0 comments on commit 224d921

Please sign in to comment.