Skip to content

Instantly share code, notes, and snippets.

@obycode
Last active October 20, 2022 14:57
Show Gist options
  • Save obycode/9c9439707a2e5120299cecb7ad2ddb3b to your computer and use it in GitHub Desktop.
Save obycode/9c9439707a2e5120299cecb7ad2ddb3b to your computer and use it in GitHub Desktop.
How to run a Stacks mock miner

First, build stacks-node:

cd testnet/stacks-node
cargo build --features monitoring_prom,slog_json --release
# if build is successful, stacks-node is in stacks-blockchain/target/release/

Then, make sure you have the chainstate. A snapshot can be downloaded from the Hiro Archiver.

Setup the config file in stacks-node/config/mainnet/Config.toml.

  • Set the appropriate working directory:
    [node]
    working_dir = "/path/to/stacks-node/data"
    
  • Setup the connection to the Bitcoin node
    [burnchain]
    chain = "bitcoin"
    mode = "mainnet"
    peer_host = "1.2.3.4"
    username = "username"
    password = "password"
    rpc_port = 8332
    peer_port = 8333
    
  • Set the flags to enable mock mining, under [node]:
    miner = true
    mock_mining = true
    

Run the mock-miner (with output teed to mock.out):

/path/to/stacks-blockchain/target/release/stacks-node start --config=/path/to/stacks-node/config/mainnet/Config.toml 2>&1 | tee mock.out

Optionally, prefix the above command with STACKS_LOG_DEBUG=1 to enable more logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment