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

Feat/epoch30 #27

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 9af9c0b5b80f948e90916a45f3f316c81a7ac481
STACKS_BLOCKCHAIN_COMMIT: 74e3cedeec5215f3286af6565c1503e578a848fb

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
75 changes: 58 additions & 17 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=9af9c0b5b80f948e90916a45f3f316c81a7ac481
ARG GIT_COMMIT=74e3cedeec5215f3286af6565c1503e578a848fb
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 Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion 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 master
- &STACKS_BLOCKCHAIN_COMMIT 74e3cedeec5215f3286af6565c1503e578a848fb
- &MINER_PUB_KEY 035379aa40c02890d253cfa577964116eb5295570ae9f7287cbae5f2585f5b2c7c
- &BITCOIN_PEER_PORT 18444
- &BITCOIN_RPC_PORT 18443
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-miner.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"

x-common-vars:
- &STACKS_BLOCKCHAIN_COMMIT 9af9c0b5b80f948e90916a45f3f316c81a7ac481
- &STACKS_BLOCKCHAIN_COMMIT 74e3cedeec5215f3286af6565c1503e578a848fb
- &BTC_ADDR miEJtNKa3ASpA19v5ZhvbKTEieYjLpzCYT
- &MINER_SEED 9e446f6b0c6a96cf2190e54bcd5a8569c3e386f091605499464389b8d4e0bfc201 # stx: STEW4ZNT093ZHK4NEQKX8QJGM2Y7WWJ2FQQS5C19, btc: miEJtNKa3ASpA19v5ZhvbKTEieYjLpzCYT, pub_key: 035379aa40c02890d253cfa577964116eb5295570ae9f7287cbae5f2585f5b2c7c, wif: cStMQXkK5yTFGP3KbNXYQ3sJf2qwQiKrZwR9QJnksp32eKzef1za
- &BITCOIN_PEER_PORT 18444
Expand Down
22 changes: 16 additions & 6 deletions stacks-krypton-miner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name = "krypton-node"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
data_url = "http://127.0.0.1:20443"
p2p_address = "127.0.0.1:20443"
working_dir = "$DATA_DIR"

seed = "$MINER_SEED"
Expand All @@ -10,15 +12,20 @@ local_peer_seed = "$MINER_SEED"
miner = true
use_test_genesis_chainstate = true
pox_sync_sample_secs = 0
wait_time_for_blocks = 0
wait_time_for_microblocks = 50
wait_time_for_blocks = 200
wait_time_for_microblocks = 0
mine_microblocks = false
microblock_frequency = 1000
# mine_microblocks = true
# max_microblocks = 10

[miner]
first_attempt_time_ms = 5000
subsequent_attempt_time_ms = 5000
min_tx_fee = 1
first_attempt_time_ms = 180_000
second_attempt_time_ms = 360_000
wait_for_block_download = false
microblock_attempt_time_ms = 10
self_signing_seed = 1
$REWARD_RECIPIENT_CONF

[connection_options]
Expand All @@ -32,9 +39,12 @@ public_ip_address = "1.1.1.1:1234"

[burnchain]
chain = "bitcoin"
mode = "neon"
mode = "nakamoto-neon"
poll_time_secs = 1
pox_2_activation = $STACKS_POX2_HEIGHT
magic_bytes = "T3"
pox_prepare_length = 5
pox_reward_length = 10
burn_fee_cap = 20_000

### bitcoind-regtest connection info
peer_host = "$BITCOIN_PEER_HOST"
Expand Down
Loading