Skip to content

Commit 0b2d69d

Browse files
authored
Merge pull request #2 from alpenlabs/official-binary
Upgrade: use of latest bitcoin binary and premining
2 parents c8d8cdb + 9cd2fef commit 0b2d69d

File tree

6 files changed

+144
-9
lines changed

6 files changed

+144
-9
lines changed

docker-compose-28.1.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
services:
2+
bitcoind-miner:
3+
build:
4+
context: .
5+
dockerfile: official.Dockerfile
6+
args:
7+
TARGETPLATFORM: linux/arm64
8+
container_name: bitcoin-miner-28.1
9+
env_file:
10+
.env
11+
environment:
12+
BLOCKPRODUCTIONDELAY: 600
13+
RPCUSER: user
14+
RPCPASSWORD: password
15+
PRIVKEY: $PRIVKEY
16+
SIGNETCHALLENGE: $SIGNETCHALLENGE
17+
MINERENABLED: $MINERENABLED
18+
OFFICIAL_MINING: true
19+
20+
ports:
21+
- "28332:28332"
22+
- "28333:28333"
23+
- "28334:28334"
24+
- "38332:38332"
25+
- "38333:38333"
26+
- "38334:38334"

docker-compose.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
services:
22
bitcoind-miner:
33
container_name: bitcoin-miner
4-
image: alpen_signet:1.0
4+
# image: alpen_signet:1.0
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
58
env_file:
69
.env
710
environment:
@@ -21,7 +24,10 @@ services:
2124

2225
bitcoind-fullnode:
2326
container_name: bitcoin-fullnode
24-
image: alpen_signet:1.0
27+
# image: alpen_signet:1.0
28+
build:
29+
context: .
30+
dockerfile: Dockerfile
2531

2632
environment:
2733
BLOCKPRODUCTIONDELAY: 10

docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ else
2121
fi
2222

2323
$@ &
24-
echo "Infinate loop"
24+
echo "Infinite loop"
2525
while true
2626
do
2727
tail -f /dev/null & wait ${!}

gen-bitcoind-conf.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ zmqpubhashblock=$ZMQPUBHASHBLOCK
4646
rpcbind=$RPCBIND
4747
rpcallowip=$RPCALLOWIP
4848
whitelist=$WHITELIST
49-
fallbackfee=0.0002"
49+
fallbackfee=0.0002
50+
minrelaytxfee=0.0
51+
blockmintxfee=0.0
52+
dustRelayFee=0.0"
5053

5154
if [[ "$ADDNODE" != "" ]]; then
5255
echo $ADDNODE | tr ',' '\n' | while read node; do

mine.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
#!/bin/bash
22
NBITS=${NBITS:-"1e0377ae"} #minimum difficulty in signet
3+
if [[ -f "${BITCOIN_DIR}/MINE_ADDRESS.txt" ]]; then
4+
ADDR=$(cat ~/.bitcoin/MINE_ADDRESS.txt)
5+
else
6+
ADDR=${MINETO:-$(bitcoin-cli -rpcwallet=custom_signet getnewaddress)}
7+
fi
8+
echo "Mineto: $MINETO"
9+
echo "Initial mining address: $ADDR"
10+
11+
# Initial mining of 101 blocks if blocks count is less than 101
12+
BLOCKS_COUNT=$(bitcoin-cli -rpcwallet=custom_signet getblockcount)
13+
if [[ $BLOCKS_COUNT -lt 101 ]]; then
14+
echo "Mining initial blocks until 101"
15+
while [[ $BLOCKS_COUNT -lt 101 ]]; do
16+
echo "Mining initial block $BLOCKS_COUNT"
17+
miner --cli="bitcoin-cli" generate --grind-cmd="bitcoin-util grind" --address=$ADDR --nbits=$NBITS --set-block-time=$(date +%s)
18+
BLOCKS_COUNT=$(bitcoin-cli -rpcwallet=custom_signet getblockcount)
19+
done
20+
else
21+
echo "Starting bitcoind mining from block $BLOCKS_COUNT"
22+
fi
23+
324

425
while true; do
5-
if [[ -f "${BITCOIN_DIR}/MINE_ADDRESS.txt" ]]; then
6-
ADDR=$(cat ~/.bitcoin/MINE_ADDRESS.txt)
7-
else
8-
ADDR=${MINETO:-$(bitcoin-cli getnewaddress)}
9-
fi
1026
if [[ -f "${BITCOIN_DIR}/BLOCKPRODUCTIONDELAY.txt" ]]; then
1127
BLOCKPRODUCTIONDELAY_OVERRIDE=$(cat ~/.bitcoin/BLOCKPRODUCTIONDELAY.txt)
1228
echo "Delay OVERRIDE before next block" $BLOCKPRODUCTIONDELAY_OVERRIDE "seconds."

official.Dockerfile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
FROM debian:bookworm-slim as builder
2+
3+
ARG BITCOIN_VERSION=${BITCOIN_VERSION:-28.1}
4+
5+
ARG TARGETPLATFORM
6+
7+
RUN apt-get update && \
8+
apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget libc6 procps python3
9+
WORKDIR /tmp
10+
# install bitcoin binaries
11+
RUN case $TARGETPLATFORM in \
12+
linux/amd64) \
13+
echo "amd64" && export TRIPLET="x86_64-linux-gnu";; \
14+
linux/arm64) \
15+
echo "arm64" && export TRIPLET="aarch64-linux-gnu";; \
16+
esac && \
17+
BITCOIN_URL="https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-${TRIPLET}.tar.gz" && \
18+
BITCOIN_FILE="bitcoin-${BITCOIN_VERSION}-${TRIPLET}.tar.gz" && \
19+
wget -qO "${BITCOIN_FILE}" "${BITCOIN_URL}" && \
20+
mkdir -p bin && \
21+
tar -xzvf "${BITCOIN_FILE}" -C /tmp/bin --strip-components=2 "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-cli" "bitcoin-${BITCOIN_VERSION}/bin/bitcoind" "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-wallet" "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-util"
22+
23+
# Download zipped sourced code for the tag and extract miner.py
24+
25+
# FROM debian:buster-slim as custom-signet-bitcoin
26+
FROM debian:bookworm-slim as custom-signet-bitcoin
27+
28+
29+
LABEL org.opencontainers.image.authors="Alpenlabs"
30+
LABEL org.opencontainers.image.licenses=MIT
31+
LABEL org.opencontainers.image.source="https://github.com/alpenlabs/bitcoin_signet"
32+
33+
ENV BITCOIN_DIR /root/.bitcoin
34+
35+
36+
ENV RPCUSER=${RPCUSER:-"bitcoin"}
37+
ENV RPCPASSWORD=${RPCPASSWORD:-"bitcoin"}
38+
ENV COOKIEFILE=${COOKIEFILE:-"false"}
39+
ENV ONIONPROXY=${ONIONPROXY:-""}
40+
ENV TORPASSWORD=${TORPASSWORD:-""}
41+
ENV TORCONTROL=${TORCONTROL:-""}
42+
ENV I2PSAM=${I2PSAM:-""}
43+
44+
ENV UACOMMENT=${UACOMMENT:-"CustomSignet"}
45+
ENV ZMQPUBRAWBLOCK=${ZMQPUBRAWBLOCK:-"tcp://0.0.0.0:28332"}
46+
ENV ZMQPUBRAWTX=${ZMQPUBRAWTX:-"tcp://0.0.0.0:28333"}
47+
ENV ZMQPUBHASHBLOCK=${ZMQPUBHASHBLOCK:-"tcp://0.0.0.0:28334"}
48+
49+
ENV RPCTHREADS=${RPCTHREADS:-"16"}
50+
ENV RPCSERVERTIMEOUT=${RPCSERVERTIMEOUT:-"600"}
51+
ENV RPCWORKQUEUE=${RPCWORKQUEUE:-"50"}
52+
53+
54+
ENV RPCBIND=${RPCBIND:-"0.0.0.0:38332"}
55+
ENV RPCALLOWIP=${RPCALLOWIP:-"0.0.0.0/0"}
56+
ENV WHITELIST=${WHITELIST:-"0.0.0.0/0"}
57+
ENV ADDNODE=${ADDNODE:-""}
58+
ENV BLOCKPRODUCTIONDELAY=${BLOCKPRODUCTIONDELAY:-"30"}
59+
ENV MINERENABLED=${MINERENABLED:-"1"}
60+
ENV MINETO=${MINETO:-""}
61+
ENV EXTERNAL_IP=${EXTERNAL_IP:-""}
62+
63+
# Variable used to generate wallets used by bridge operators
64+
# TODO: update this logic to match Testnet I requirement
65+
ENV NUM_WALLETS=${NUM_WALLETS:-0}
66+
VOLUME $BITCOIN_DIR
67+
EXPOSE 28332 28333 28334 38332 38333 38334
68+
RUN apt-get update && \
69+
apt-get install -qq --no-install-recommends procps python3 python3-pip jq && \
70+
apt-get clean
71+
COPY --from=builder "/tmp/bin" /usr/local/bin
72+
COPY *.sh /usr/local/bin/
73+
74+
# TODO: figure out these imports for the miner script
75+
COPY miner_imports /usr/local/bin
76+
# FIXME: the miner script should be used from the tar file of the downloaded source code
77+
COPY miner /usr/local/bin/miner
78+
COPY rpcauth.py /usr/local/bin/rpcauth.py
79+
# RUN pip3 install setuptools
80+
RUN pip3 install --break-system-packages setuptools
81+
82+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
83+
84+
CMD ["run.sh"]

0 commit comments

Comments
 (0)