-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add signer and update versions #128
Changes from 2 commits
2b632b3
01e2381
5394a10
420794a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,7 @@ working_dir = "/root/stacks-blockchain/data" | |
rpc_bind = "0.0.0.0:20443" | ||
p2p_bind = "0.0.0.0:20444" | ||
bootstrap_node = "02196f005965cebe6ddc3901b7b1cc1aa7a88f305bb8c5893456b8f9a605923893@seed.mainnet.hiro.so:20444" | ||
|
||
[[events_observer]] | ||
endpoint = "stacks-blockchain-api:3700" | ||
events_keys = ["*"] | ||
stacker = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is optional for instances that choose to not run the signing service. What is the impact? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When starting without the signer, that line gets commented, along with the signer's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
|
||
[burnchain] | ||
chain = "bitcoin" | ||
|
@@ -16,3 +13,16 @@ username = "stacks" | |
password = "foundation" | ||
rpc_port = 8332 | ||
peer_port = 8333 | ||
|
||
[connection_options] | ||
auth_token = "1234" | ||
private_neighbors = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not using default value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is so the node doesn't announce/accept neighbors that are behind private networks - leaving it as a default ( |
||
|
||
[[events_observer]] | ||
events_keys = ["stackerdb", "block_proposal", "burn_blocks"] | ||
endpoint = "stacks-signer:30000" | ||
|
||
[[events_observer]] | ||
endpoint = "stacks-blockchain-api:3700" | ||
events_keys = ["*"] | ||
timeout_ms = 300_000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,31 @@ | |
working_dir = "/root/stacks-blockchain/data" | ||
rpc_bind = "0.0.0.0:20443" | ||
p2p_bind = "0.0.0.0:20444" | ||
bootstrap_node="029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a95682ddc@seed.testnet.hiro.so:30444" | ||
always_use_affirmation_maps = false | ||
bootstrap_node = "029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a95682ddc@seed.testnet.hiro.so:30444" | ||
always_use_affirmation_maps = true | ||
require_affirmed_anchor_blocks = true | ||
pox_sync_sample_secs = 30 | ||
stacker = true | ||
|
||
[burnchain] | ||
chain = "bitcoin" | ||
mode = "xenon" | ||
peer_host = "bitcoin.testnet.stacks.org" | ||
username = "stacks" | ||
password = "foundation" | ||
rpc_port = 18332 | ||
peer_port = 18333 | ||
mode = "krypton" | ||
peer_host = "bitcoin.regtest.hiro.so" | ||
peer_port = 18444 | ||
pox_prepare_length = 100 | ||
pox_reward_length = 900 | ||
|
||
[connection_options] | ||
auth_token = "1234" | ||
private_neighbors = false | ||
|
||
[[events_observer]] | ||
events_keys = ["stackerdb", "block_proposal", "burn_blocks"] | ||
endpoint = "stacks-signer:30000" | ||
|
||
[[events_observer]] | ||
endpoint = "stacks-blockchain-api:3700" | ||
events_keys = ["*"] | ||
timeout_ms = 60_000 | ||
|
||
[[ustx_balance]] | ||
address = "ST2QKZ4FKHAH1NQKYKYAYZPY440FEPK7GZ1R5HBP2" | ||
|
@@ -33,3 +43,39 @@ amount = 10000000000000000 | |
[[ustx_balance]] | ||
address = "ST2TFVBMRPS5SSNP98DQKQ5JNB2B6NZM91C4K3P7B" | ||
amount = 10000000000000000 | ||
|
||
[[burnchain.epochs]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these important? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the node has to know the epochs set by Hiro on their bootstrap node. These are taken from the Stacks Docs page with Sample Configuration Files. The testnet node would panic otherwise: https://docs.stacks.co/reference/sample-configuration-files#stacks-node-testnet-config There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
epoch_name = "1.0" | ||
start_height = 0 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "2.0" | ||
start_height = 0 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "2.05" | ||
start_height = 1 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "2.1" | ||
start_height = 2 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "2.2" | ||
start_height = 3 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "2.3" | ||
start_height = 4 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "2.4" | ||
start_height = 5 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "2.5" | ||
start_height = 6 | ||
|
||
[[burnchain.epochs]] | ||
epoch_name = "3.0" | ||
start_height = 56_457 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ _Note: Burnchchain environment variables defined in `./env` will overwrite value | |
|
||
- `.env` | ||
- `./conf/mainnet/Config.toml` | ||
- `./conf/mainnet/Signer.toml` | ||
- `./conf/testnet/Config.toml` | ||
- `./conf/testnet/Signer.toml` | ||
|
||
## Environment Variables | ||
|
||
|
@@ -19,10 +21,22 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish | |
| `DOCKER_NETWORK` | Name of docker network used to launch services | `stacks` | | ||
| `EXPOSE_POSTGRES` | Expose postgres service to the host OS | `false` | | ||
| `STACKS_BLOCKCHAIN_VERSION` | Stacks Blockchain Docker image version | `latest released version` | | ||
| `STACKS_SIGNER_VERSION` | Stacks Signer Docker image version | `latest released version` | | ||
| `STACKS_BLOCKCHAIN_API_VERSION` | Stacks Blockchain API Docker image version | `latest released version` | | ||
| `POSTGRES_VERSION` | Postgres Docker image version | `14` | | ||
| `NGINX_PROXY_PORT` | HTTP port for the nginx proxy | `80` | | ||
|
||
### Stacks Signer Settings | ||
|
||
#### You must set values for the _SIGNER_PRIVATE_KEY_ on the specific network if you're running a signer, otherwise they can be left empty. | ||
|
||
| Name | Description | Default Value | | ||
| ---------------------------- | ------------------------------------------------------------------------------------------------ | ------------- | | ||
| `AUTH_TOKEN` | Authorization token for HTTP requests made from the signer to your Stacks node | `1234` | | ||
| `SIGNER_PRIVATE_KEY` | The private key of the signer, on mainnet. | | | ||
| `TESTNET_SIGNER_PRIVATE_KEY` | The private key of the signer, on testnet. | | | ||
Comment on lines
+36
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious why two separate variables? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we can run a testnet instance and a mainnet instance in the same environment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's because most users have different signer private keys on mainnet vs testnet. Users shouldn't worry about modifying the key every time they switch between a mainnet and a testnet instance, but have both set in env. |
||
| `STACKS_SIGNER_PORT` | The port where the signer will expose an RPC endpoint for receiving events from your Stacks node | `30000` | | ||
|
||
### API Settings | ||
|
||
#### Recommened to leave these settings _as is_ | ||
|
@@ -81,8 +95,6 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish | |
|
||
| Name | Description | Default Value | | ||
| --------------- | ------------------------------------- | ---------------------------- | | ||
| `TBTC_HOST` | FQDN of bitcoin mainnnet host | `bitcoin.testnet.stacks.org` | | ||
| `TBTC_RPC_USER` | RPC username for bitcoin mainnet host | `stacks` | | ||
| `TBTC_RPC_PASS` | RPC password for bitcoin mainnet host | `foundation` | | ||
| `TBTC_RPC_PORT` | RPC port for bitcoin mainnet host | `18332` | | ||
| `TBTC_P2P_PORT` | P2P port for bitcoin mainnet host | `18333` | | ||
| `TBTC_HOST` | FQDN of bitcoin testnet host | `bitcoin.regtest.hiro.so` | | ||
| `TBTC_RPC_PORT` | RPC port for bitcoin testnet host | `18332` | | ||
| `TBTC_P2P_PORT` | P2P port for bitcoin testnet host | `18333` | |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ shopt -s expand_aliases | |
export NETWORK="mainnet" | ||
export ACTION="" | ||
export PROFILE="stacks-blockchain" | ||
SIGNER=false | ||
STACKS_CHAIN_ID="2147483648" | ||
STACKS_SHUTDOWN_TIMEOUT=1200 # default to 20 minutes, during sync it can take a long time to stop the runloop | ||
LOG_TAIL="100" | ||
|
@@ -154,9 +155,10 @@ usage() { | |
log " -n|--network: [ mainnet | testnet | mocknet ]" | ||
log " -a|--action: [ start | stop | logs | reset | upgrade | import | export | bns ]" | ||
log " optional args:" | ||
log " -f|--flags: [ proxy ]" | ||
log " -f|--flags: [ signer,proxy ]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add how to run this on the readme? |
||
log " export: combined with 'logs' action, exports logs to a text file" | ||
log " ex: ${COLCYAN}${0} -n mainnet -a start -f proxy${COLRESET}" | ||
log " ex: ${COLCYAN}${0} -n mainnet -a start -f signer,proxy${COLRESET}" | ||
log " ex: ${COLCYAN}${0} --network mainnet --action start --flags proxy${COLRESET}" | ||
log " ex: ${COLCYAN}${0} -n mainnet -a logs export${COLRESET}" | ||
echo | ||
|
@@ -434,14 +436,62 @@ events_file_env(){ | |
|
||
# Function that updates Config.toml | ||
update_configs(){ | ||
if [ "${NETWORK}" == "testnet" ]; then | ||
if [ "${NETWORK}" == "testnet" ]; then | ||
BTC_HOST=${TBTC_HOST} | ||
BTC_RPC_USER=${TBTC_RPC_USER} | ||
BTC_RPC_PASS=${TBTC_RPC_PASS} | ||
BTC_RPC_PORT=${TBTC_RPC_PORT} | ||
BTC_P2P_PORT=${TBTC_P2P_PORT} | ||
fi | ||
SIGNER_PRIVATE_KEY=${TESTNET_SIGNER_PRIVATE_KEY} | ||
fi | ||
CONFIG_TOML="${SCRIPTPATH}/conf/${NETWORK}/Config.toml" | ||
SIGNER_TOML="${SCRIPTPATH}/conf/${NETWORK}/Signer.toml" | ||
|
||
## update Config.toml with signer options | ||
if [ "${SIGNER}" != "true" ]; then | ||
${VERBOSE} && log "${COLYELLOW}Disabling signer options in ${CONFIG_TOML}${COLRESET}" | ||
sed -i.tmp " | ||
/^\[\[events_observer\]\]/{ | ||
:a | ||
N | ||
/endpoint.*stacks-signer/!ba | ||
s/^/#/mg | ||
} | ||
/^stacker = true/ s/^/#/ | ||
" "${CONFIG_TOML}" || { | ||
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}" | ||
} | ||
else | ||
[ ! ${SIGNER_PRIVATE_KEY} ] && log_exit "Signer private key not set!" | ||
${VERBOSE} && log "${COLYELLOW}Enabling signer options in ${CONFIG_TOML}${COLRESET}" | ||
sed -i.tmp " | ||
/^#\[\[events_observer\]\]/{ | ||
:a | ||
N | ||
/endpoint.*stacks-signer/!ba | ||
s/^#//mg | ||
} | ||
/^#stacker = true/ s/^#// | ||
" "${CONFIG_TOML}" || { | ||
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}" | ||
} | ||
|
||
## update Signer.toml with env vars | ||
[[ ! -f "${SIGNER_TOML}" ]] && cp "${SIGNER_TOML}.sample" "${SIGNER_TOML}" | ||
${VERBOSE} && log "${COLYELLOW}Updating values in ${SIGNER_TOML} from .env${COLRESET}" | ||
$(sed -i.tmp " | ||
/^node_host/s/.*/node_host = \"${STACKS_CORE_RPC_HOST}:${STACKS_CORE_RPC_PORT}\"/; | ||
/^endpoint/s/.*/endpoint = \"0.0.0.0:${STACKS_SIGNER_PORT}\"/; | ||
/^auth_password/s/.*/auth_password = \"${AUTH_TOKEN}\"/; | ||
/^stacks_private_key/s/.*/stacks_private_key = \"${SIGNER_PRIVATE_KEY}\"/; | ||
" "${SIGNER_TOML}" 2>&1) || { | ||
log_exit "Unable to update values in Signer.toml file: ${COLCYAN}${SIGNER_TOML}${COLRESET}" | ||
} | ||
${VERBOSE} && log "${COLYELLOW}Deleting temp Signer.toml file: ${SIGNER_TOML}.tmp${COLRESET}" | ||
$(rm "${SIGNER_TOML}.tmp" 2>&1) || { | ||
log_exit "Unable to delete tmp Signer.toml file: ${COLCYAN}${SIGNER_TOML}.tmp${COLRESET}" | ||
} | ||
fi | ||
|
||
## update Config.toml with btc vars | ||
[[ ! -f "${CONFIG_TOML}" ]] && cp "${CONFIG_TOML}.sample" "${CONFIG_TOML}" | ||
|
@@ -452,6 +502,8 @@ update_configs(){ | |
/^password/s/.*/password = \"${BTC_RPC_PASS}\"/; | ||
/^rpc_port/s/.*/rpc_port = ${BTC_RPC_PORT}/; | ||
/^peer_port/s/.*/peer_port = ${BTC_P2P_PORT}/; | ||
/^auth_token/s/.*/auth_token = \"${AUTH_TOKEN}\"/; | ||
/^endpoint = \"stacks-signer/s/.*/endpoint = \"stacks-signer:${STACKS_SIGNER_PORT}\"/; | ||
" "${CONFIG_TOML}" 2>&1) || { | ||
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}" | ||
} | ||
|
@@ -547,6 +599,12 @@ docker_up() { | |
if ! check_event_replay; then | ||
log_exit "Event-replay in progress. Refusing to start services" | ||
fi | ||
|
||
# Set signer env based on flag | ||
if [[ "${FLAGS_ARRAY[*]}" == *"signer"* ]]; then | ||
SIGNER=true | ||
fi | ||
|
||
# Sanity checks before starting services | ||
local param="-d" | ||
if [ "${PROFILE}" == "bns" ]; then | ||
|
@@ -567,9 +625,10 @@ docker_up() { | |
${VERBOSE} && log "created (recursive) persistent-data dir ${SCRIPTPATH}/persistent-data/${NETWORK}/event-replay" | ||
fi | ||
${VERBOSE} && log "Using existing data dir: ${SCRIPTPATH}/persistent-data/${NETWORK}" | ||
update_configs | ||
fi | ||
|
||
|
||
update_configs | ||
|
||
# # See if we can detect a Hiro API major version change requiring an event-replay import | ||
# if check_api; then | ||
# log_warn " Required to perform a stacks-blockchain-api event-replay:" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not related to signer, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's strictly from the node and API data. The node has about 250GB unarchived, while the API has 80.