diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 851fbd1..08bbf38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: env: - STACKS_BLOCKCHAIN_COMMIT: 5a4b3882e6f1d80dce73302c44e87271894103b8 + STACKS_BLOCKCHAIN_COMMIT: 9385b423609f0b5dabe7ffb66ed4db9f2f68a485 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef5738c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +stacking/node_modules +package-lock.json diff --git a/Dockerfile.btc b/Dockerfile.btc index f60b6ea..d581ebb 100644 --- a/Dockerfile.btc +++ b/Dockerfile.btc @@ -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"] diff --git a/Dockerfile.e2e b/Dockerfile.e2e index fe0b748..e66b037 100644 --- a/Dockerfile.e2e +++ b/Dockerfile.e2e @@ -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 @@ -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 @@ -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 < /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 < config.toml - stacks-node start --config=config.toml & + stacks-node start --config config.toml & STACKS_PID=$! while true; do @@ -167,27 +196,39 @@ RUN < 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() { diff --git a/Dockerfile.stacker b/Dockerfile.stacker new file mode 100644 index 0000000..ef6f0bf --- /dev/null +++ b/Dockerfile.stacker @@ -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"] \ No newline at end of file diff --git a/Dockerfile.stacks-api b/Dockerfile.stacks-api index 95749f4..9d32a7b 100644 --- a/Dockerfile.stacks-api +++ b/Dockerfile.stacks-api @@ -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) @@ -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"] diff --git a/Dockerfile.stacks-node b/Dockerfile.stacks-node index 7691a26..122d896 100644 --- a/Dockerfile.stacks-node +++ b/Dockerfile.stacks-node @@ -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 @@ -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 diff --git a/Dockerfile.tx-broadcaster b/Dockerfile.tx-broadcaster new file mode 100644 index 0000000..391d9cd --- /dev/null +++ b/Dockerfile.tx-broadcaster @@ -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"] \ No newline at end of file diff --git a/docker-compose-follower.yml b/docker-compose-follower.yml index 7190b68..1e18a4a 100644 --- a/docker-compose-follower.yml +++ b/docker-compose-follower.yml @@ -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 @@ -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: diff --git a/docker-compose-miner.yml b/docker-compose.yml similarity index 54% rename from docker-compose-miner.yml rename to docker-compose.yml index 353614f..faf7f46 100644 --- a/docker-compose-miner.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.9" x-common-vars: - - &STACKS_BLOCKCHAIN_COMMIT 5a4b3882e6f1d80dce73302c44e87271894103b8 + - &STACKS_BLOCKCHAIN_COMMIT 9385b423609f0b5dabe7ffb66ed4db9f2f68a485 - &BTC_ADDR miEJtNKa3ASpA19v5ZhvbKTEieYjLpzCYT - &MINER_SEED 9e446f6b0c6a96cf2190e54bcd5a8569c3e386f091605499464389b8d4e0bfc201 # stx: STEW4ZNT093ZHK4NEQKX8QJGM2Y7WWJ2FQQS5C19, btc: miEJtNKa3ASpA19v5ZhvbKTEieYjLpzCYT, pub_key: 035379aa40c02890d253cfa577964116eb5295570ae9f7287cbae5f2585f5b2c7c, wif: cStMQXkK5yTFGP3KbNXYQ3sJf2qwQiKrZwR9QJnksp32eKzef1za - &BITCOIN_PEER_PORT 18444 @@ -9,6 +9,7 @@ x-common-vars: - &BITCOIN_RPC_USER btc - &BITCOIN_RPC_PASS btc - &MINE_INTERVAL ${MINE_INTERVAL:-0.5s} + - &MINE_INTERVAL_EPOCH3 ${MINE_INTERVAL_EPOCH3:-600s} # 10 minute bitcoin block times in epoch 3 - &STACKS_20_HEIGHT ${STACKS_20_HEIGHT:-101} - &STACKS_2_05_HEIGHT ${STACKS_2_05_HEIGHT:-102} - &STACKS_21_HEIGHT ${STACKS_21_HEIGHT:-103} @@ -17,7 +18,7 @@ x-common-vars: - &STACKS_23_HEIGHT ${STACKS_23_HEIGHT:-106} - &STACKS_24_HEIGHT ${STACKS_24_HEIGHT:-107} - &STACKS_25_HEIGHT ${STACKS_25_HEIGHT:-108} - - &STACKS_30_HEIGHT ${STACKS_30_HEIGHT:-999999} # do not boot into epoch3.0 for now (it doesn't work yet) + - &STACKS_30_HEIGHT ${STACKS_30_HEIGHT:-122} - &REWARD_RECIPIENT ${REWARD_RECIPIENT:-STQM73RQC4EX0A07KWG1J5ECZJYBZS4SJ4ERC6WN} # priv: 6ad9cadb42d4edbfbe0c5bfb3b8a4125ddced021c4174f829b714ccbf527f02001 services: @@ -58,7 +59,9 @@ services: environment: BTC_ADDR: *BTC_ADDR MINE_INTERVAL: *MINE_INTERVAL + MINE_INTERVAL_EPOCH3: *MINE_INTERVAL_EPOCH3 INIT_BLOCKS: 101 + STACKS_30_HEIGHT: *STACKS_30_HEIGHT entrypoint: - /bin/bash - -c @@ -67,23 +70,36 @@ services: trap "exit" INT TERM trap "kill 0" EXIT bitcoin-cli -rpcconnect=bitcoind -rpcwait getmininginfo - bitcoin-cli -rpcconnect=bitcoind createwallet "" + bitcoin-cli -rpcconnect=bitcoind -named createwallet wallet_name=main descriptors=false bitcoin-cli -rpcconnect=bitcoind importaddress $${BTC_ADDR} "" false bitcoin-cli -rpcconnect=bitcoind generatetoaddress $${INIT_BLOCKS} $${BTC_ADDR} + DEFAULT_TIMEOUT=$$(($$(date +%s) + 30)) while true; do TX=$$(bitcoin-cli -rpcconnect=bitcoind 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 -rpcconnect=bitcoind generatetoaddress 1 "$${BTC_ADDR}" + DEFAULT_TIMEOUT=$$(($$(date +%s) + 30)) else echo "No Stacks mining tx detected" fi - sleep $${MINE_INTERVAL} & + + SLEEP_DURATION=$${MINE_INTERVAL} + BLOCK_HEIGHT=$$(bitcoin-cli -rpcconnect=bitcoind getblockcount) + if [ "$${BLOCK_HEIGHT}" -gt $$(( $${STACKS_30_HEIGHT} + 5 )) ]; then + echo "In Epoch3, sleeping for $${MINE_INTERVAL_EPOCH3} seconds..." + SLEEP_DURATION=$${MINE_INTERVAL_EPOCH3} + fi + sleep $${SLEEP_DURATION} & wait || exit 0 done - stacks-node-miner: + stacks-node: networks: - stacks build: @@ -103,7 +119,7 @@ services: environment: # STACKS_LOG_TRACE: 1 # uncomment for trace logging # STACKS_LOG_DEBUG: 1 - # STACKS_EVENT_OBSERVER: stacks-api:3700 # uncomment if using API + STACKS_EVENT_OBSERVER: stacks-api:3700 DATA_DIR: /chainstate/stacks-blockchain-miner-data BITCOIN_PEER_HOST: bitcoind BITCOIN_PEER_PORT: *BITCOIN_PEER_PORT @@ -132,61 +148,86 @@ services: mkdir -p $${DATA_DIR} rm -rf $${DATA_DIR}/* envsubst < config.toml.in > config.toml - # bitcoin-cli -rpcwait -rpcconnect=bitcoind getmininginfo - exec stacks-node start --config=config.toml + bitcoin-cli -rpcwait -rpcconnect=bitcoind getmininginfo + exec stacks-node start --config config.toml + + stacker: + networks: + - stacks + build: + context: . + dockerfile: Dockerfile.stacker + environment: + STACKS_CORE_RPC_HOST: stacks-node + STACKS_CORE_RPC_PORT: 20443 + STACKING_CYCLES: 2 + STACKING_KEYS: 08c14a1eada0dd42b667b40f59f7c8dedb12113613448dc04980aea20b268ddb01,ce109fee08860bb16337c76647dcbc02df0c06b455dd69bcf30af74d4eedd19301,e75dcb66f84287eaf347955e94fa04337298dbd95aa0dbb985771104ef1913db01 + depends_on: + - stacks-node - ################################## - ##### UNCOMMENT IF USING API ##### - ################################## - # postgres: - # image: "postgres:15" - # ports: - # - "5490:5490" - # volumes: - # - chainstate:/chainstate - # environment: - # POSTGRES_USER: postgres - # POSTGRES_PASSWORD: postgres - # POSTGRES_DB: stacks_blockchain_api - # PGPORT: 5490 - # PGDATA: /chainstate/pg-data + tx-broadcaster: + networks: + - stacks + build: + context: . + dockerfile: Dockerfile.tx-broadcaster + environment: + STACKS_CORE_RPC_HOST: stacks-node + STACKS_CORE_RPC_PORT: 20443 + ACCOUNT_KEYS: 0d2f965b472a82efd5a96e6513c8b9f7edc725d5c96c7d35d6c722cedeb80d1b01,975b251dd7809469ef0c26ec3917971b75c51cd73a022024df4bf3b232cc2dc001,c71700b07d520a8c9731e4d0f095aa6efb91e16e25fb27ce2b72e7b698f8127a01 + depends_on: + - stacks-node - # stacks-api: - # build: - # context: . - # dockerfile: Dockerfile.stacks-api - # args: - # GIT_COMMIT: 4a332f353ee10802fa7b04e888b32e54d010a69d - # depends_on: - # - postgres - # ports: - # - "3999:3999" - # expose: - # - "3700" - # environment: - # NODE_ENVIRONMENT: production - # STACKS_API_LOG_LEVEL: debug - # STACKS_CHAIN_ID: "0x80000000" - # STACKS_BLOCKCHAIN_API_HOST: "0.0.0.0" - # STACKS_BLOCKCHAIN_API_PORT: 3999 - # STACKS_CORE_EVENT_HOST: "0.0.0.0" - # STACKS_CORE_EVENT_PORT: 3700 - # PG_HOST: postgres - # PG_PORT: 5490 - # PG_USER: postgres - # PG_PASSWORD: postgres - # PG_DATABASE: stacks_blockchain_api - # PG_SCHEMA: public - # STACKS_CORE_RPC_HOST: stacks-node - # STACKS_CORE_RPC_PORT: 20443 - # BTC_RPC_HOST: http://bitcoind - # BTC_RPC_PORT: 18443 - # BTC_RPC_USER: btc - # BTC_RPC_PW: btc - # BTC_FAUCET_PK: *MINER_SEED - ################################## - ##### UNCOMMENT IF USING API ##### - ################################## + postgres: + networks: + - stacks + image: "postgres:15" + ports: + - "5490:5490" + volumes: + - chainstate:/chainstate + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: stacks_blockchain_api + PGPORT: 5490 + PGDATA: /chainstate/pg-data + + stacks-api: + networks: + - stacks + build: + context: . + dockerfile: Dockerfile.stacks-api + args: + GIT_COMMIT: a5487312613a3179599fb7c128af9cfadc92d9a3 + depends_on: + - postgres + ports: + - "3999:3999" + expose: + - "3700" + environment: + NODE_ENVIRONMENT: production + STACKS_API_LOG_LEVEL: debug + STACKS_CHAIN_ID: "0x80000000" + STACKS_BLOCKCHAIN_API_HOST: "0.0.0.0" + STACKS_BLOCKCHAIN_API_PORT: 3999 + STACKS_CORE_EVENT_HOST: "0.0.0.0" + STACKS_CORE_EVENT_PORT: 3700 + PG_HOST: postgres + PG_PORT: 5490 + PG_USER: postgres + PG_PASSWORD: postgres + PG_DATABASE: stacks_blockchain_api + PG_SCHEMA: public + STACKS_CORE_RPC_HOST: stacks-node + STACKS_CORE_RPC_PORT: 20443 + BTC_RPC_HOST: http://bitcoind + BTC_RPC_PORT: 18443 + BTC_RPC_USER: btc + BTC_RPC_PW: btc + BTC_FAUCET_PK: *MINER_SEED networks: stacks: diff --git a/stacking/package.json b/stacking/package.json new file mode 100644 index 0000000..a4a6a87 --- /dev/null +++ b/stacking/package.json @@ -0,0 +1,13 @@ +{ + "name": "stacking", + "version": "1.0.0", + "description": "", + "main": "stacking.js", + "scripts": {}, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@stacks/stacking": "6.11.4-pr.a8fa50e.0" + } +} diff --git a/stacking/stacking.js b/stacking/stacking.js new file mode 100644 index 0000000..a808e11 --- /dev/null +++ b/stacking/stacking.js @@ -0,0 +1,86 @@ +const { StackingClient } = require('@stacks/stacking'); +const { StacksTestnet } = require('@stacks/network'); +const { getAddressFromPrivateKey, TransactionVersion, makeRandomPrivKey } = require('@stacks/transactions'); +const { getPublicKeyFromPrivate, publicKeyToBtcAddress } = require('@stacks/encryption'); +const crypto = require('crypto'); + +const stackingInterval = process.env.STACKING_INTERVAL ?? 2; +const postTxWait = process.env.POST_TX_WAIT ?? 10; +const stackingCycles = process.env.STACKING_CYCLES ?? 1; +const url = `http://${process.env.STACKS_CORE_RPC_HOST}:${process.env.STACKS_CORE_RPC_PORT}`; +const network = new StacksTestnet({ url }); + +const accounts = process.env.STACKING_KEYS.split(',').map(privKey => { + const pubKey = getPublicKeyFromPrivate(privKey); + const stxAddress = getAddressFromPrivateKey(privKey, TransactionVersion.Testnet); + const signerPrivKey = makeRandomPrivKey(); + const signerPubKey = getPublicKeyFromPrivate(signerPrivKey.data); + return { + privKey, pubKey, stxAddress, + btcAddr: publicKeyToBtcAddress(pubKey), + signerPrivKey: signerPrivKey, + signerPubKey: signerPubKey, + client: new StackingClient(stxAddress, network), + }; +}); + +async function run() { + const poxInfo = await accounts[0].client.getPoxInfo(); + if (!poxInfo.contract_id.endsWith('.pox-4')) { + console.log(`Pox contract is not .pox-4, skipping stacking (contract=${poxInfo.contract_id})`); + return; + } + const nextCycleStx = poxInfo.next_cycle.stacked_ustx; + let minStx = poxInfo.next_cycle.min_threshold_ustx; + // Bump min threshold by 50% to avoid getting stuck if threshold increases + minStx = Math.floor(minStx * 1.5); + if (nextCycleStx >= minStx) { + console.log(`Next cycle has enough stacked, skipping stacking (stacked=${nextCycleStx}, min=${minStx})`); + return; + } + let account; + for (const a of accounts) { + const lockedHeight = await a.client.getAccountBalanceLocked(); + if (lockedHeight === 0n) { + account = a; + break; + } + } + if (!account) { + console.log(`No unlocked account available for stacking`); + return; + } + + const sigArgs = { + topic: 'stack-stx', + rewardCycle: poxInfo.reward_cycle_id, + poxAddress: account.btcAddr, + period: stackingCycles, + signerPrivateKey: account.signerPrivKey, + }; + const signerSignature = account.client.signPoxSignature(sigArgs); + const stackingArgs = { + poxAddress: account.btcAddr, + privateKey: account.privKey, + amountMicroStx: minStx, + burnBlockHeight: poxInfo.current_burnchain_block_height, + cycles: stackingCycles, + fee: 1000, + signerKey: account.signerPubKey, + signerSignature, + }; + console.log('Stacking with args:', { addr: account.stxAddress, ...stackingArgs, ...sigArgs }); + const stackResult = await account.client.stack(stackingArgs); + console.log('Stacking tx result', stackResult); + await new Promise(resolve => setTimeout(resolve, postTxWait * 1000)); +} + +async function loop() { + try { + await run(); + } catch (e) { + console.error('Error running stacking:', e); + } + setTimeout(loop, stackingInterval * 1000); +} +loop(); diff --git a/stacking/tx-broadcaster.js b/stacking/tx-broadcaster.js new file mode 100644 index 0000000..0fbcbf8 --- /dev/null +++ b/stacking/tx-broadcaster.js @@ -0,0 +1,54 @@ +const { StacksTestnet } = require('@stacks/network'); +const { TransactionVersion, getAddressFromPrivateKey, getNonce, makeSTXTokenTransfer, broadcastTransaction } = require('@stacks/transactions'); + +const broadcastInterval = process.env.BROADCAST_INTERVAL ?? 2; +const postTxWait = process.env.POST_TX_WAIT ?? 2; +const url = `http://${process.env.STACKS_CORE_RPC_HOST}:${process.env.STACKS_CORE_RPC_PORT}`; +const network = new StacksTestnet({ url }); + +const accounts = process.env.ACCOUNT_KEYS.split(',').map(privKey => ({ + privKey, + stxAddress: getAddressFromPrivateKey(privKey, TransactionVersion.Testnet), +})); + +async function run() { + const accountNonces = await Promise.all(accounts.map(async (account) => { + const nonce = await getNonce(account.stxAddress, network); + return { ...account, nonce }; + })); + + // Send from account with lowest nonce + accountNonces.sort((a, b) => Number(a.nonce) - Number(b.nonce)); + const sender = accountNonces[0]; + const recipient = accountNonces[1]; + + console.log(`Sending stx-transfer from ${sender.stxAddress} (nonce=${sender.nonce}) to ${recipient.stxAddress}`); + + const tx = await makeSTXTokenTransfer({ + recipient: recipient.stxAddress, + amount: 1000, + senderKey: sender.privKey, + network, + nonce: sender.nonce, + fee: 300, + }); + + const broadcastResult = await broadcastTransaction(tx, network); + if (broadcastResult.error) { + console.error('Error broadcasting stx-transfer', broadcastResult); + } else { + console.log(`Broadcast stx-transfer tx=${broadcastResult.txid}`); + } + + await new Promise(resolve => setTimeout(resolve, postTxWait * 1000)); +} + +async function loop() { + try { + await run(); + } catch (e) { + console.error('Error submitting stx-transfer tx:', e); + } + setTimeout(loop, broadcastInterval * 1000); +} +loop(); diff --git a/stacks-krypton-miner.toml b/stacks-krypton-miner.toml index f2daa2f..0df1544 100644 --- a/stacks-krypton-miner.toml +++ b/stacks-krypton-miner.toml @@ -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" @@ -11,14 +13,20 @@ 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_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 +mining_key = "19ec1c3e31d139c989a23a27eac60d1abfad5277d3ae9604242514c738258efa01" $REWARD_RECIPIENT_CONF [connection_options] @@ -32,9 +40,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" @@ -98,6 +109,16 @@ address = "ST1HB1T8WRNBYB0Y3T7WXZS38NKKPTBR3EG9EPJKR" amount = 10000000000000000 # secretKey = "c71700b07d520a8c9731e4d0f095aa6efb91e16e25fb27ce2b72e7b698f8127a01" +[[ustx_balance]] +address = "ST2PGGD0ZXAWEMY4EZ025RD1X47EEVH287SQKA8BC" +amount = 10000000000000000 +# secretKey = "975b251dd7809469ef0c26ec3917971b75c51cd73a022024df4bf3b232cc2dc001" + +[[ustx_balance]] +address = "ST29V10QEA7BRZBTWRFC4M70NJ4J6RJB5P1C6EE84" +amount = 10000000000000000 +# secretKey = "0d2f965b472a82efd5a96e6513c8b9f7edc725d5c96c7d35d6c722cedeb80d1b01" + [[ustx_balance]] address = "STRYYQQ9M8KAF4NS7WNZQYY59X93XEKR31JP64CP" amount = 10000000000000000