diff --git a/compose/genesis/dummy.toml b/compose/genesis/dummy.toml new file mode 100644 index 000000000..78165b928 --- /dev/null +++ b/compose/genesis/dummy.toml @@ -0,0 +1,4 @@ +# Placeholder bind-mount target used when MIDEN_GENESIS_CONFIG_FILE is not set. +# +# This file is not passed to `miden-validator bootstrap`; omitting the +# --genesis-config-file flag preserves the validator's built-in default genesis config. diff --git a/docker-compose.yml b/docker-compose.yml index 4cde0e11d..7c27db28f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,10 @@ # Environment variables: # - MIDEN_REMOTE_PROVER_URL: remote transaction prover URL. Defaults to the # bundled miden-remote-prover service at http://tx-prover:50051. +# - MIDEN_GENESIS_CONFIG_FILE: path to the genesis configuration file. +# By default, the local network bootstraps from the validator's built-in +# genesis configuration. Use this environment variable to override the +# built-in configuration. services: bootstrap-validator: @@ -8,6 +12,12 @@ services: pull_policy: if_not_present volumes: - node-data:/data + - type: bind + source: ${MIDEN_GENESIS_CONFIG_FILE:-./compose/genesis/dummy.toml} + target: /genesis.toml + read_only: true + environment: + MIDEN_NODE_VALIDATOR_USE_GENESIS_CONFIG: ${MIDEN_GENESIS_CONFIG_FILE:-} entrypoint: ["/bin/sh", "-c"] command: - | @@ -21,11 +31,22 @@ services: rm -rf /data/genesis /data/validator /data/accounts mkdir -p /data/genesis /data/validator /data/accounts + GENESIS_CONFIG_ARGS="" + if [ -n "$${MIDEN_NODE_VALIDATOR_USE_GENESIS_CONFIG:-}" ]; then + if [ ! -f /genesis.toml ]; then + echo "Genesis config requested but /genesis.toml is not mounted." + exit 1 + fi + + GENESIS_CONFIG_ARGS="--genesis-config-file /genesis.toml" + fi + echo "Bootstrapping validator..." miden-validator bootstrap \ --data-directory /data/validator \ --genesis-block-directory /data/genesis \ - --accounts-directory /data/accounts + --accounts-directory /data/accounts \ + $$GENESIS_CONFIG_ARGS touch /data/validator/.bootstrapped diff --git a/docs/external/src/local-network-development.md b/docs/external/src/local-network-development.md index ddca71b45..29ef2a24f 100644 --- a/docs/external/src/local-network-development.md +++ b/docs/external/src/local-network-development.md @@ -86,6 +86,25 @@ The network monitor at `http://localhost:3001` provides a compact health view fo The default stack spins up an internal prover instance which means proving will happen locally. This can be overridden to use an external prover by setting `MIDEN_REMOTE_PROVER_URL` when starting the stack. +## Genesis Config Override + +By default, the local network bootstraps from the validator's built-in genesis configuration. To bootstrap from a custom +genesis configuration file, set `MIDEN_GENESIS_CONFIG_FILE` to the host path of the TOML file: + +```bash +MIDEN_GENESIS_CONFIG_FILE=/absolute/path/to/genesis.toml make local-network-up +``` + +The override bind mounts the host file into the bootstrap validator container as `/genesis.toml` and passes that +in-container path to `miden-validator bootstrap --genesis-config-file`. + +This only affects validator bootstrap. If the local network has already been bootstrapped, delete the existing local +chain data before starting with a different genesis configuration: + +```bash +make local-network-delete +``` + ## Check the RPC API The RPC server exposes gRPC reflection. With `grpcurl` installed, a basic status check looks like: