Skip to content

Commit

Permalink
Include genesis files in sequencer docker
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbearer committed May 28, 2024
1 parent 54172d3 commit 9c51afa
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
11 changes: 11 additions & 0 deletions data/genesis/cappuccino.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion data/genesis.toml → data/genesis/demo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
11 changes: 11 additions & 0 deletions data/genesis/staging.toml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 0 additions & 12 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docker/sequencer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
3 changes: 3 additions & 0 deletions scripts/build-docker-images
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions scripts/build-docker-images-native
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion sequencer/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit 9c51afa

Please sign in to comment.