forked from LayerTwo-Labs/bitcoin-patched
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow configuring target block time for a signet * add Dockerfile * contrib: make block interval configurable in signet miner * doc: add note on creating signet --------- Co-authored-by: benthecarman <[email protected]> Co-authored-by: Torkel Rogstad <[email protected]>
- Loading branch information
1 parent
8592f07
commit 505c535
Showing
8 changed files
with
194 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
FROM debian:bookworm-slim AS builder | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get install -y ca-certificates curl git gnupg gosu python3 wget build-essential cmake pkg-config libevent-dev libboost-dev libsqlite3-dev libzmq3-dev libminiupnpc-dev libnatpmp-dev qtbase5-dev qttools5-dev qttools5-dev-tools \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
WORKDIR /src | ||
|
||
# Copy source files | ||
COPY . . | ||
|
||
# Remove any existing build directory | ||
RUN rm -rf build/ | ||
|
||
# Run CMake to configure the build | ||
RUN cmake -S . -B build -DBUILD_TESTS=OFF -DBUILD_UTIL:BOOL=OFF -DBUILD_TX:BOOL=OFF -DBUILD_WALLET_TOOL=OFF | ||
|
||
# Build the project | ||
RUN cmake --build build -j | ||
|
||
# Second stage | ||
FROM debian:bookworm-slim | ||
|
||
ARG UID=101 | ||
ARG GID=101 | ||
|
||
ARG TARGETPLATFORM | ||
|
||
ENV DRIVECHAIN_DATA=/home/drivechain/.drivechain | ||
ENV PATH=/opt/drivechain/bin:$PATH | ||
|
||
RUN groupadd --gid ${GID} drivechain \ | ||
&& useradd --create-home --no-log-init -u ${UID} -g ${GID} drivechain \ | ||
&& apt-get update -y \ | ||
&& apt-get --no-install-recommends -y install jq curl gnupg gosu ca-certificates pkg-config libevent-dev libboost-dev libsqlite3-dev libzmq3-dev libminiupnpc-dev libnatpmp-dev qtbase5-dev qttools5-dev qttools5-dev-tools \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
COPY --from=builder /src/build/src/bitcoind /opt/drivechain/bin/drivechaind | ||
COPY --from=builder /src/build/src/bitcoin-cli /opt/drivechain/bin/drivechain-cli | ||
|
||
COPY --chmod=755 entrypoint.sh /entrypoint.sh | ||
|
||
VOLUME ["/home/drivechain/.drivechain"] | ||
|
||
# P2P network (mainnet, testnet & regnet respectively) | ||
EXPOSE 8333 18333 18444 | ||
|
||
# RPC interface (mainnet, testnet & regnet respectively) | ||
EXPOSE 8332 18332 18443 | ||
|
||
# ZMQ ports (for transactions & blocks respectively) | ||
EXPOSE 28332 28333 | ||
|
||
HEALTHCHECK --interval=300s --start-period=60s --start-interval=10s --timeout=20s CMD gosu bitcoin bitcoin-cli -rpcwait -getinfo || exit 1 | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
RUN drivechaind -version | grep "Bitcoin Core version" | ||
|
||
CMD ["drivechaind"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ -n "${UID+x}" ] && [ "${UID}" != "0" ]; then | ||
usermod -u "$UID" drivechain | ||
fi | ||
|
||
if [ -n "${GID+x}" ] && [ "${GID}" != "0" ]; then | ||
groupmod -g "$GID" drivechain | ||
fi | ||
|
||
echo "$0: assuming uid:gid for drivechain:drivechain of $(id -u drivechain):$(id -g drivechain)" | ||
|
||
if [ "$(echo "$1" | cut -c1)" = "-" ]; then | ||
echo "$0: assuming arguments for drivechaind" | ||
|
||
set -- drivechaind "$@" | ||
fi | ||
|
||
if [ "$(echo "$1" | cut -c1)" = "-" ] || [ "$1" = "drivechaind" ]; then | ||
mkdir -p "$DRIVECHAIN_DATA" | ||
chmod 700 "$DRIVECHAIN_DATA" | ||
# Fix permissions for home dir. | ||
chown -R drivechain:drivechain "$(getent passwd drivechain | cut -d: -f6)" | ||
# Fix permissions for drivechain data dir. | ||
chown -R drivechain:drivechain "$DRIVECHAIN_DATA" | ||
|
||
echo "$0: setting data directory to $DRIVECHAIN_DATA" | ||
|
||
set -- "$@" -datadir="$DRIVECHAIN_DATA" | ||
fi | ||
|
||
if [ "$1" = "drivechaind" ] || [ "$1" = "drivechain-cli" ]; then | ||
echo | ||
exec gosu drivechain "$@" | ||
fi | ||
|
||
echo | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
Instructions on setting up the signet. This is using Fish shell, but should be | ||
easy enough to get the gist if using an inferior shell like Bash or Zsh. | ||
|
||
1. Create the appropriate configuration file for our network: | ||
|
||
```conf | ||
signet=1 | ||
# 1 minute block times. Note that /everyone/ who connects to this signet | ||
# must have this exact configuration value. | ||
signetblocktime=60 | ||
``` | ||
1. Generate the private key used to sign blocks + corresponding | ||
`signetchallenge` value. | ||
```fish | ||
$ mkdir l2l-signet | ||
$ ./build/src/bitcoind -daemon -regtest -datadir=$PWD/l2l-signet | ||
$ ./build/src/bitcoin-cli -regtest -datadir=$PWD/l2l-signet \ | ||
createwallet l2l-signet | ||
$ set signet_challenge (./build/src/bitcoin-cli -regtest -datadir=$PWD/l2l-signet \ | ||
getaddressinfo $address | jq -r .scriptPubKey) | ||
$ echo signetchallenge=$signet_challenge >> l2l-signet/bitcoin.conf | ||
# Need the wallet descriptors to be able to import the wallet into | ||
$ set descriptors (./build/src/bitcoin-cli -regtest -datadir=$PWD/l2l-signet \ | ||
listdescriptors true | jq -r .descriptors) | ||
# We're finished with the regtest wallet! | ||
$ ./build/src/bitcoin-cli -regtest -datadir=$PWD/l2l-signet stop | ||
``` | ||
1. Create the signet wallet | ||
```fish | ||
$ ./build/src/bitcoind -daemon -signet -datadir=$PWD/l2l-signet | ||
$ ./build/src/bitcoin-cli -signet -datadir=$PWD/l2l-signet \ | ||
createwallet l2l-signet | ||
$ ./build/src/bitcoin-cli signet -datadir=$PWD/l2l-signet \ | ||
importdescriptors "$descriptors" | ||
``` | ||
1. Start mining on our network: | ||
```fish | ||
$ set address (./build/src/bitcoin-cli -signet -datadir=$PWD/l2l-signet getnewaddress) | ||
$ ./contrib/signet/miner \ | ||
--cli "bitcoin-cli -signet -datadir=$PWD/l2l-signet" \ | ||
generate --address $address \ | ||
--grind-cmd "$PWD/build/src/bitcoin-util grind" \ | ||
--min-nbits --ongoing --block-interval 60 | ||
``` | ||
``` | ||
|
||
``` | ||
``` | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters