Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epoch3 interim blocks #29

Open
wants to merge 33 commits into
base: feat/epoch25
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5ca6d01
feat: almost activating epoch3
zone117x Dec 12, 2023
fb2f31b
stashing some close to working changes
kantai Dec 12, 2023
dec3fe5
okay, working-ish version
kantai Dec 13, 2023
f801252
ah, better working version
kantai Dec 13, 2023
aa53140
build for release
zone117x Dec 13, 2023
7951b47
build for release
zone117x Dec 13, 2023
8f95e53
ci: bump stacks-node commit
zone117x Dec 13, 2023
9c369a1
feat: epoch3 working with docker-compose
zone117x Dec 16, 2023
4551d13
fix: add timeout to bitcoin mining
zone117x Dec 16, 2023
0e7f57e
feat: robust stacking script
zone117x Dec 16, 2023
658bb90
chore: re-enable stacks-api
zone117x Dec 17, 2023
0bc6dc8
bump stacks-core next branch, include tx-broadcasting script
zone117x Dec 20, 2023
6913eb4
chore: bump stacks-node with stability fixes
zone117x Dec 21, 2023
eb4b12f
feat: slow down bitcoin block mining in epoch3
zone117x Dec 21, 2023
74ce0fb
chore: stack for multiple cycles to reduce pox activation flakiness
zone117x Dec 21, 2023
3d65412
update stacks core commit hash for next (#28)
rafaelcr Jan 23, 2024
269b140
fix: stacking with latest version of stack-stx (#30)
rafaelcr Jan 25, 2024
4a8c53f
fix: add `mining_key` for epoch3.0
zone117x Jan 26, 2024
c8f17f3
chore: bump stacks-api
zone117x Jan 26, 2024
ce0db11
chore: bump stacks-node
zone117x Feb 1, 2024
025ae3c
Merge branch 'feat/epoch25' into feat/epoch30
zone117x Feb 1, 2024
2b23270
chore: bump stacks-node in miner docker compose
zone117x Feb 1, 2024
ec7c627
chore: bump stacks-node
zone117x Feb 1, 2024
2fd5faf
fix: add wallet name in bitcoind command
zone117x Feb 2, 2024
ad24eb6
chore: bump stacks-api
zone117x Feb 6, 2024
c5e985e
chore: bump latest next
zone117x Feb 6, 2024
e40a25b
fix: stacks-node --config option change
zone117x Feb 6, 2024
7966530
chore: update to next and add pox signer logic
zone117x Feb 20, 2024
b0a8c8e
fix: stacks signature logic
zone117x Feb 21, 2024
1e6ad6a
chore: revert debug changes
zone117x Feb 21, 2024
a8fee88
Merge pull request #31 from hirosystems/chore/update-next-signer-keys
zone117x Feb 21, 2024
0e0672c
Merge branch 'feat/epoch25' into epoch3-interim-blocks
zone117x Feb 21, 2024
777bf36
chore: bump stacks-node next and stacks.js stacking script
zone117x Feb 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:

env:
STACKS_BLOCKCHAIN_COMMIT: 5a4b3882e6f1d80dce73302c44e87271894103b8
STACKS_BLOCKCHAIN_COMMIT: 9385b423609f0b5dabe7ffb66ed4db9f2f68a485

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stacking/node_modules
package-lock.json
6 changes: 3 additions & 3 deletions Dockerfile.btc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM debian:bullseye-backports
FROM debian:bookworm

COPY --from=ruimarinho/bitcoin-core:0.21.1 /opt/bitcoin-*/bin /usr/local/bin
COPY --from=dobtc/bitcoin:25.1 /opt/bitcoin-*/bin /usr/local/bin

RUN apt-get update && apt-get install -y curl/bullseye-backports jq zstd
RUN apt-get update && apt-get install -y curl jq zstd
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
CMD ["/bin/bash"]
79 changes: 60 additions & 19 deletions Dockerfile.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FROM rust:bookworm as builder

# A commit hash, tag, or branch
ARG GIT_COMMIT=5a4b3882e6f1d80dce73302c44e87271894103b8
ARG GIT_COMMIT=9385b423609f0b5dabe7ffb66ed4db9f2f68a485
ARG BLOCKCHAIN_REPO=https://github.com/stacks-network/stacks-blockchain.git

ARG TARGETPLATFORM
Expand Down Expand Up @@ -100,10 +100,12 @@ ENV STACKS_24_HEIGHT=$STACKS_24_HEIGHT
ARG STACKS_25_HEIGHT=112
ENV STACKS_25_HEIGHT=$STACKS_25_HEIGHT

# do not boot into epoch3.0 for now (it doesn't work yet)
ARG STACKS_30_HEIGHT=999999
ARG STACKS_30_HEIGHT=132
ENV STACKS_30_HEIGHT=$STACKS_30_HEIGHT

ARG STACKS_PREHEAT_FINISH_HEIGHT=150
ENV STACKS_PREHEAT_FINISH_HEIGHT=$STACKS_PREHEAT_FINISH_HEIGHT

# priv: 6ad9cadb42d4edbfbe0c5bfb3b8a4125ddced021c4174f829b714ccbf527f02001
# ARG REWARD_RECIPIENT=STQM73RQC4EX0A07KWG1J5ECZJYBZS4SJ4ERC6WN
ARG REWARD_RECIPIENT
Expand Down Expand Up @@ -134,6 +136,33 @@ const server = http.createServer((req, res) => {
EOM
EOF

# Create Stacking script
RUN npm init -y && npm i @stacks/stacking@6
RUN <<EOF
cat > /root/stack.js <<'EOM'
const { StackingClient } = require('@stacks/stacking');
const { StacksTestnet } = require('@stacks/network');
console.log('Stacking with args:', process.argv.slice(2));
const network = new StacksTestnet({ url: 'http://localhost:20443' });
const address = 'ST18MDW2PDTBSCR1ACXYRJP2JX70FWNM6YY2VX4SS';
const client = new StackingClient(address, network);
client.stack({
amountMicroStx: parseInt(process.argv[2]),
burnBlockHeight: parseInt(process.argv[3]),
poxAddress: 'mvuYDknzDtPgGqm2GnbAbmGMLwiyW3AwFP',
cycles: 12,
privateKey: '08c14a1eada0dd42b667b40f59f7c8dedb12113613448dc04980aea20b268ddb01',
fee: 1000,
nonce: 0,
})
.then(r => console.log('Stacked', r))
.catch(e => {
console.error('Error stacking', e);
process.exit(1);
});
EOM
EOF

# Bootstrap chainstates
SHELL ["/bin/bash", "-ce"]
RUN <<EOF
Expand All @@ -155,7 +184,7 @@ RUN <<EOF
export STACKS_EVENT_OBSERVER="127.0.0.1:3998"
mkdir -p /chainstate/stacks-blockchain-data
envsubst < config.toml.in > config.toml
stacks-node start --config=config.toml &
stacks-node start --config config.toml &
STACKS_PID=$!

while true; do
Expand All @@ -167,27 +196,39 @@ RUN <<EOF
sleep 0.5s
done

DEFAULT_TIMEOUT=$(($(date +%s) + 30))
SENT_STACKING=0
while true; do
TX=$(bitcoin-cli -rpcwallet=main listtransactions '*' 1 0 true)
CONFS=$(echo "$TX" | jq '.[].confirmations')
if [ "$CONFS" = "0" ]; then
echo "Detected Stacks mining mempool tx, mining btc block..."
if [ "$CONFS" = "0" ] || [ $(date +%s) -gt $DEFAULT_TIMEOUT ]; then
if [ $(date +%s) -gt $DEFAULT_TIMEOUT ]; then
echo "Timed out waiting for a mempool tx, mining a btc block..."
else
echo "Detected Stacks mining mempool tx, mining btc block..."
fi
bitcoin-cli generatetoaddress 1 $BTC_ADDR
DEFAULT_TIMEOUT=$(($(date +%s) + 30))
chain_height=$(bitcoin-cli getblockcount)
echo "Current Bitcoin chain height: $chain_height"

while true; do
HEIGHT=$(curl -s localhost:20443/v2/info | jq '.burn_block_height')
if [ "$HEIGHT" = "$chain_height" ]; then
echo "Stacks node caught up to Bitcoin block $HEIGHT"
break
else
echo "Stacks node burn height: $HEIGHT, waiting for $chain_height"
fi
sleep 0.1s
done

if [ "$chain_height" = "$STACKS_25_HEIGHT" ]; then
POX_CONTRACT=$(curl -s localhost:20443/v2/pox | jq -r '.contract_id')
BURN_HEIGHT=$(curl -s localhost:20443/v2/pox | jq -r '.current_burnchain_block_height')
echo "POX contract check $BURN_HEIGHT $POX_CONTRACT"
if [ "$POX_CONTRACT" = "ST000000000000000000002AMW42H.pox-4" ] && [ "$SENT_STACKING" = "0" ]; then
echo "POX contract is pox-4"
SENT_STACKING=1
# issue a stack-stx tx, required for epoch3.0 transition
POX_STATE=$(curl -s localhost:20443/v2/pox)
echo "Stack STX tx for epoch3.0 transition"
echo "$POX_STATE" | jq '.'
MIN_STACKING_AMOUNT="8500000000000000"
BURN_HEIGHT=$(echo $POX_STATE | jq '.current_burnchain_block_height + 1')
node /root/stack.js $MIN_STACKING_AMOUNT $BURN_HEIGHT
sleep 5s
fi

if [ "$chain_height" = "$STACKS_PREHEAT_FINISH_HEIGHT" ]; then
break
fi

Expand Down Expand Up @@ -233,7 +274,7 @@ cat > run.sh <<'EOM'
bitcoin-cli -rpcwait generatetoaddress 1 $BTC_ADDR

envsubst < config.toml.in > config.toml
stacks-node start --config=config.toml &
stacks-node start --config config.toml &
STACKS_PID=$!

function start_miner() {
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.stacker
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:18-bookworm as builder

RUN apt-get update && apt-get install -y curl gettext-base jq

WORKDIR /root
COPY ./stacking/stacking.js ./stacking/package.json /root/
RUN npm i

CMD ["node", "/root/stacking.js"]
5 changes: 2 additions & 3 deletions Dockerfile.stacks-api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-bullseye as builder
FROM node:18-bookworm as builder

ARG GIT_COMMIT
RUN test -n "$GIT_COMMIT" || (echo "GIT_COMMIT not set" && false)
Expand All @@ -17,9 +17,8 @@ RUN git describe --tags --abbrev=0 || git -c user.name='user' -c user.email='ema
RUN echo "GIT_TAG=$(git tag --points-at HEAD)" >> .env

RUN npm config set update-notifier false && \
npm config set unsafe-perm true && \
npm ci --audit=false && \
npm run build && \
npm prune --production
npm prune --omit=dev

CMD ["node", "./lib/index.js"]
8 changes: 4 additions & 4 deletions Dockerfile.stacks-node
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:bullseye as builder
FROM rust:bookworm as builder

# TODO: is there a built-in required arg syntax?
ARG GIT_COMMIT
Expand All @@ -18,13 +18,13 @@ RUN git init && \

RUN cargo build --package stacks-node --bin stacks-node --release

FROM debian:bullseye-backports
FROM debian:bookworm

COPY --from=builder /stacks/target/release/stacks-node /usr/local/bin/

COPY --from=ruimarinho/bitcoin-core:0.21.1 /opt/bitcoin-*/bin /usr/local/bin
COPY --from=dobtc/bitcoin:25.1 /opt/bitcoin-*/bin /usr/local/bin

RUN apt-get update && apt-get install -y curl/bullseye-backports gettext-base jq
RUN apt-get update && apt-get install -y curl gettext-base jq
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /root
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.tx-broadcaster
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:18-bookworm as builder

RUN apt-get update && apt-get install -y curl gettext-base jq

WORKDIR /root
COPY ./stacking/tx-broadcaster.js ./stacking/package.json /root/
RUN npm i

CMD ["node", "/root/tx-broadcaster.js"]
4 changes: 2 additions & 2 deletions docker-compose-follower.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"

x-common-vars:
- &STACKS_BLOCKCHAIN_COMMIT 5a4b3882e6f1d80dce73302c44e87271894103b8
- &STACKS_BLOCKCHAIN_COMMIT 9385b423609f0b5dabe7ffb66ed4db9f2f68a485
- &MINER_PUB_KEY 035379aa40c02890d253cfa577964116eb5295570ae9f7287cbae5f2585f5b2c7c
- &BITCOIN_PEER_PORT 18444
- &BITCOIN_RPC_PORT 18443
Expand Down Expand Up @@ -60,7 +60,7 @@ services:
until $(curl -o /dev/null -s stacks-node-miner:20443); do
sleep 5
done
exec stacks-node start --config=config.toml
exec stacks-node start --config config.toml

networks:
stacks:
Expand Down
Loading
Loading