From 9c51afabf798257242a3f6ea206d6349c25da63c Mon Sep 17 00:00:00 2001 From: Jeb Bearer Date: Tue, 28 May 2024 12:00:30 -0400 Subject: [PATCH] Include genesis files in sequencer docker The idea is to include a genesis file for all officially supported networks (demo, staging, cappuccino, and eventually mainnet) so that operators can easily connect to the appropriate network just by setting the `ESPRESSO_SEQUENCER_GENESIS_FILE` environment variable to point at the appropriate bundled genesis file. Of course, operators can also connect to an unsupported chain (e.g. private testnet) by including their own genesis file via a volume. --- .env | 2 +- data/genesis/cappuccino.toml | 11 +++++++++++ data/{genesis.toml => genesis/demo.toml} | 2 +- data/genesis/staging.toml | 11 +++++++++++ docker-compose.yaml | 12 ------------ docker/sequencer.Dockerfile | 4 ++++ process-compose.yaml | 4 ++-- scripts/build-docker-images | 3 +++ scripts/build-docker-images-native | 3 +++ sequencer/src/options.rs | 2 +- 10 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 data/genesis/cappuccino.toml rename data/{genesis.toml => genesis/demo.toml} (92%) create mode 100644 data/genesis/staging.toml diff --git a/.env b/.env index 39f829186..6aad1607d 100644 --- a/.env +++ b/.env @@ -32,7 +32,7 @@ ESPRESSO_SEQUENCER3_API_PORT=24003 ESPRESSO_SEQUENCER4_API_PORT=24004 ESPRESSO_SEQUENCER_URL=http://sequencer0:${ESPRESSO_SEQUENCER_API_PORT} ESPRESSO_SEQUENCER_STORAGE_PATH=/store/sequencer -ESPRESSO_SEQUENCER_GENESIS_FILE=/genesis.toml +ESPRESSO_SEQUENCER_GENESIS_FILE=/genesis/demo.toml ESPRESSO_SEQUENCER_L1_PORT=8545 ESPRESSO_SEQUENCER_L1_WS_PORT=8546 ESPRESSO_SEQUENCER_L1_PROVIDER=http://demo-l1-network:${ESPRESSO_SEQUENCER_L1_PORT} diff --git a/data/genesis/cappuccino.toml b/data/genesis/cappuccino.toml new file mode 100644 index 000000000..4f79e5024 --- /dev/null +++ b/data/genesis/cappuccino.toml @@ -0,0 +1,11 @@ +[stake_table] +capacity = 200 + +[chain_config] +chain_id = 0 +base_fee = '0 wei' +max_block_size = '30mb' +fee_recipient = '0x0000000000000000000000000000000000000000' + +[header] +timestamp = "1970-01-01T00:00:00Z" diff --git a/data/genesis.toml b/data/genesis/demo.toml similarity index 92% rename from data/genesis.toml rename to data/genesis/demo.toml index a5b17183f..1f70a6786 100644 --- a/data/genesis.toml +++ b/data/genesis/demo.toml @@ -2,7 +2,7 @@ capacity = 10 [chain_config] -chain_id = 0 +chain_id = 999999999 base_fee = '1 wei' max_block_size = '1mb' fee_recipient = '0x0000000000000000000000000000000000000000' diff --git a/data/genesis/staging.toml b/data/genesis/staging.toml new file mode 100644 index 000000000..b45559f3a --- /dev/null +++ b/data/genesis/staging.toml @@ -0,0 +1,11 @@ +[stake_table] +capacity = 10 + +[chain_config] +chain_id = 888888888 +base_fee = '0 wei' +max_block_size = '1mb' +fee_recipient = '0x0000000000000000000000000000000000000000' + +[header] +timestamp = "1970-01-01T00:00:00Z" diff --git a/docker-compose.yaml b/docker-compose.yaml index feaaa11aa..633e54a3c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -211,8 +211,6 @@ services: ports: - "$ESPRESSO_SEQUENCER_API_PORT:$ESPRESSO_SEQUENCER_API_PORT" - "$ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_PORT:$ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_PORT" - volumes: - - "./data/genesis.toml:$ESPRESSO_SEQUENCER_GENESIS_FILE" # Run the full API server with all modules, Postgres storage command: sequencer -- storage-sql -- http -- query -- catchup -- status -- submit -- hotshot-events -- config environment: @@ -259,8 +257,6 @@ services: image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main ports: - "$ESPRESSO_SEQUENCER1_API_PORT:$ESPRESSO_SEQUENCER_API_PORT" - volumes: - - "./data/genesis.toml:$ESPRESSO_SEQUENCER_GENESIS_FILE" command: sequencer -- storage-sql -- http -- query -- catchup -- status -- state -- explorer environment: - ESPRESSO_SEQUENCER_GENESIS_FILE @@ -306,8 +302,6 @@ services: image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main ports: - "$ESPRESSO_SEQUENCER2_API_PORT:$ESPRESSO_SEQUENCER_API_PORT" - volumes: - - "./data/genesis.toml:$ESPRESSO_SEQUENCER_GENESIS_FILE" command: sequencer -- http -- catchup -- status environment: - ESPRESSO_SEQUENCER_GENESIS_FILE @@ -347,8 +341,6 @@ services: image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main ports: - "$ESPRESSO_SEQUENCER3_API_PORT:$ESPRESSO_SEQUENCER_API_PORT" - volumes: - - "./data/genesis.toml:$ESPRESSO_SEQUENCER_GENESIS_FILE" command: sequencer -- http -- catchup -- status environment: - ESPRESSO_SEQUENCER_GENESIS_FILE @@ -386,8 +378,6 @@ services: image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main ports: - "$ESPRESSO_SEQUENCER4_API_PORT:$ESPRESSO_SEQUENCER_API_PORT" - volumes: - - "./data/genesis.toml:$ESPRESSO_SEQUENCER_GENESIS_FILE" command: sequencer -- http -- catchup -- status environment: - ESPRESSO_SEQUENCER_GENESIS_FILE @@ -484,8 +474,6 @@ services: image: ghcr.io/espressosystems/espresso-sequencer/builder:main ports: - "$ESPRESSO_BUILDER_SERVER_PORT:$ESPRESSO_BUILDER_SERVER_PORT" - volumes: - - "./data/genesis.toml:$ESPRESSO_BUILDER_GENESIS_FILE" environment: - ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_URL=http://sequencer0:$ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_PORT - ESPRESSO_SEQUENCER_STATE_PEERS=http://sequencer0:$ESPRESSO_SEQUENCER_API_PORT diff --git a/docker/sequencer.Dockerfile b/docker/sequencer.Dockerfile index e84367152..125684250 100644 --- a/docker/sequencer.Dockerfile +++ b/docker/sequencer.Dockerfile @@ -23,6 +23,10 @@ RUN chmod +x /bin/keygen COPY target/$TARGETARCH/release/pub-key /bin/pub-key RUN chmod +x /bin/pub-key +# Install genesis files for all supported configurations. The desired configuration can be chosen by +# setting `ESPRESSO_SEQUENCER_GENESIS_FILE`. +COPY data/genesis /genesis + # Set a path to save the consensus config on startup. # # Upon restart, the config will be loaded from this file and the node will be able to resume diff --git a/process-compose.yaml b/process-compose.yaml index ce0fdba8b..aab26c733 100644 --- a/process-compose.yaml +++ b/process-compose.yaml @@ -5,8 +5,8 @@ environment: - ESPRESSO_SEQUENCER_ORCHESTRATOR_URL=http://localhost:$ESPRESSO_ORCHESTRATOR_PORT - ESPRESSO_SEQUENCER_URL=http://localhost:$ESPRESSO_SEQUENCER_API_PORT - ESPRESSO_SEQUENCER_L1_PROVIDER=http://localhost:$ESPRESSO_SEQUENCER_L1_PORT - - ESPRESSO_SEQUENCER_GENESIS_FILE=data/genesis.toml - - ESPRESSO_BUILDER_GENESIS_FILE=data/genesis.toml + - ESPRESSO_SEQUENCER_GENESIS_FILE=data/genesis/demo.toml + - ESPRESSO_BUILDER_GENESIS_FILE=data/genesis/demo.toml - ESPRESSO_DEMO_L1_HTTP_PROVIDER=$ESPRESSO_SEQUENCER_L1_PROVIDER - ESPRESSO_STATE_RELAY_SERVER_URL=http://localhost:$ESPRESSO_STATE_RELAY_SERVER_PORT - QUERY_SERVICE_URI=http://localhost:$ESPRESSO_SEQUENCER1_API_PORT/v0/ diff --git a/scripts/build-docker-images b/scripts/build-docker-images index 2db284553..e3e9a7132 100755 --- a/scripts/build-docker-images +++ b/scripts/build-docker-images @@ -18,6 +18,9 @@ cleanup(){ rm -rfv ${WORKDIR} } +# Copy data files to Docker context. +cp -r data/genesis ${WORKDIR}/genesis + for ARCH in "amd64" "arm64"; do case "$ARCH" in amd64) diff --git a/scripts/build-docker-images-native b/scripts/build-docker-images-native index 0be86745c..63e829b26 100755 --- a/scripts/build-docker-images-native +++ b/scripts/build-docker-images-native @@ -82,6 +82,9 @@ cleanup(){ rm -rfv "${WORKDIR}" } +# Copy data files to Docker context. +cp -r data/genesis ${WORKDIR}/genesis + mkdir -p "${WORKDIR}/target/$ARCH/release" for binary in "orchestrator" "cdn-broker" "cdn-marshal" "cdn-whitelist" "sequencer" "commitment-task" "submit-transactions" "reset-storage" "state-relay-server" "state-prover" "deploy" "keygen" "permissionless-builder" "nasty-client" "pub-key" "bridge"; do cp -v "${CARGO_TARGET_DIR}/release/$binary" "${WORKDIR}/target/$ARCH/release" diff --git a/sequencer/src/options.rs b/sequencer/src/options.rs index 6caa781d2..1a5b83e2e 100644 --- a/sequencer/src/options.rs +++ b/sequencer/src/options.rs @@ -92,7 +92,7 @@ pub struct Options { long, name = "GENESIS_FILE", env = "ESPRESSO_SEQUENCER_GENESIS_FILE", - default_value = "genesis.toml" + default_value = "/genesis/demo.toml" )] pub genesis_file: PathBuf,