Skip to content

Commit

Permalink
Add dev-node binary (#1353)
Browse files Browse the repository at this point in the history
Add  `espresso-dev-node` binary and friends. Currently docker image includes dev node, postgres and anvil. `builder_port` will be added in follow up (#1522).




---------

Co-authored-by: sveitser <[email protected]>
Co-authored-by: Abdul Basit <[email protected]>
Co-authored-by: Abdul Basit <[email protected]>
Co-authored-by: tbro <[email protected]>
  • Loading branch information
5 people authored and jbearer committed Jun 3, 2024
1 parent 64a2cda commit ee086ea
Show file tree
Hide file tree
Showing 20 changed files with 696 additions and 144 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ jobs:
run: |
cargo build --locked --release --workspace
- name: Build Espresso Dev Node
# Espresso Dev Node currently requires testing feature, so it is built separately.
run: |
cargo build --locked --release --features testing --bin espresso-dev-node
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -72,6 +77,7 @@ jobs:
target/release/keygen
target/release/permissionless-builder
target/release/nasty-client
target/release/espresso-dev-node
target/release/pub-key
target/release/espresso-bridge
Expand All @@ -97,6 +103,11 @@ jobs:
run: |
cargo build --locked --release --workspace
- name: Build Espresso Dev Node
# Espresso Dev Node currently requires testing feature, so it is built separately.
run: |
cargo build --locked --release --features testing --bin espresso-dev-node
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -117,6 +128,7 @@ jobs:
target/release/keygen
target/release/permissionless-builder
target/release/nasty-client
target/release/espresso-dev-node
target/release/pub-key
target/release/espresso-bridge
Expand All @@ -136,6 +148,7 @@ jobs:
deploy-tag: ${{ steps.deploy.outputs.tags }}
builder-tag: ${{ steps.builder.outputs.tags }}
nasty-client-tag: ${{ steps.nasty-client.outputs.tags }}
espresso-dev-node-tag: ${{ steps.espresso-dev-node.outputs.tags }}
bridge-tag: ${{ steps.bridge.outputs.tags }}
steps:
- name: Checkout Repository
Expand Down Expand Up @@ -238,6 +251,11 @@ jobs:
with:
images: ghcr.io/espressosystems/espresso-sequencer/nasty-client

- name: Generate espresso-dev-node metadata
uses: docker/metadata-action@v5
id: espresso-dev-node
with:
images: ghcr.io/espressosystems/espresso-sequencer/espresso-dev-node
- name: Generate bridge metadata
uses: docker/metadata-action@v5
id: bridge
Expand Down Expand Up @@ -364,6 +382,15 @@ jobs:
tags: ${{ steps.nasty-client.outputs.tags }}
labels: ${{ steps.nasty-client.outputs.labels }}

- name: Build and push espresso-dev-node docker
uses: docker/build-push-action@v5
with:
context: ./
file: ./docker/nasty-client.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.espresso-dev-node.outputs.tags }}
labels: ${{ steps.espresso-dev-node.outputs.labels }}
- name: Build and push bridge docker
uses: docker/build-push-action@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
cargo build --locked --bin diff-test --release
cargo test --locked --release --workspace --all-features --no-run
cargo test --locked --release --workspace --all-features --verbose -- --test-threads 1 --nocapture
timeout-minutes: 30
timeout-minutes: 40
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ target/
# Jetbrains editor
.idea

# vscode stuff
.vscode/settings.json

node_modules/

**/*DS_Store
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.55" }
# Hotshot imports
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.23" }
hotshot-contract-adapter = { version = "0.1.0", path = "contracts/rust/adapter" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.23" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.55" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.26" }
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ services:
- ESPRESSO_SEQUENCER_API_PEERS=http://sequencer2:$ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_STATE_PEERS=http://sequencer2:$ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_POSTGRES_HOST=sequencer-db-1
- ESPRESSO_SEQUENCER_POSTGRES_PORT=$ESPRESSO_SEQUENCER_DB_PORT
- ESPRESSO_SEQUENCER_POSTGRES_USER=root
- ESPRESSO_SEQUENCER_POSTGRES_PASSWORD=password
- ESPRESSO_SEQUENCER_POSTGRES_DATABASE=sequencer
Expand Down
32 changes: 32 additions & 0 deletions docker/espresso-dev-node.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM postgres

ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl libcurl4 wait-for-it tini \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["tini", "--"]

# Download an SRS file to avoid download at runtime
ENV AZTEC_SRS_PATH=/kzg10-aztec20-srs-1048584.bin
RUN curl -LO https://github.com/EspressoSystems/ark-srs/releases/download/v0.2.0/$AZTEC_SRS_PATH

COPY target/$TARGETARCH/release/espresso-dev-node /bin/espresso-dev-node
RUN chmod +x /bin/espresso-dev-node

COPY target/$TARGETARCH/release/anvil /bin/anvil
RUN chmod +x /bin/anvil

COPY launch-dev-node-with-postgres /bin/launch-dev-node-with-postgres
RUN chmod +x /bin/launch-dev-node-with-postgres

# When running as a Docker service, we always want a healthcheck endpoint, so set a default for the
# port that the HTTP server will run on. This can be overridden in any given deployment environment.
ENV ESPRESSO_SEQUENCER_API_PORT=8770
HEALTHCHECK --interval=1s --timeout=1s --retries=100 CMD curl --fail http://localhost:${ESPRESSO_SEQUENCER_API_PORT}/status/block-height || exit 1

EXPOSE 8770
EXPOSE 8771
EXPOSE 8772

CMD [ "/bin/launch-dev-node-with-postgres"]
2 changes: 1 addition & 1 deletion hotshot-state-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ displaydoc = { version = "0.2.3", default-features = false }
es-version = { workspace = true }
ethers = { workspace = true }
futures = { workspace = true }
hotshot-contract-adapter = { path = "../contracts/rust/adapter" }
hotshot-contract-adapter = { workspace = true }
hotshot-orchestrator = { workspace = true }
hotshot-stake-table = { workspace = true }
hotshot-types = { workspace = true }
Expand Down
8 changes: 7 additions & 1 deletion hotshot-state-prover/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,17 @@ pub async fn light_client_genesis(
stake_table_capacity: usize,
) -> anyhow::Result<ParsedLightClientState> {
let st = init_stake_table_from_orchestrator(orchestrator_url, stake_table_capacity).await;
light_client_genesis_from_stake_table(st)
}

#[inline]
pub fn light_client_genesis_from_stake_table(
st: StakeTable<BLSPubKey, StateVerKey, CircuitField>,
) -> anyhow::Result<ParsedLightClientState> {
let (bls_comm, schnorr_comm, stake_comm) = st
.commitment(SnapshotVersion::LastEpochStart)
.expect("Commitment computation shouldn't fail.");
let threshold = one_honest_threshold(st.total_stake(SnapshotVersion::LastEpochStart)?);

let pi = vec![
u256_to_field(threshold),
F::from(0_u64), // Arbitrary value for view number
Expand Down
11 changes: 9 additions & 2 deletions scripts/build-docker-images
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ nix develop .#armCrossShell --ignore-environment --command cargo build --release
# The rest of the script doesn't run in a nix shell but we need to know where
# the binaries are.
CARGO_TARGET_DIR="./target/nix"
CONTRACTS_DIR="./contracts"

# Copy binaries to a temporary directory.
WORKDIR=$(mktemp -d -t espresso-docker-build-XXXXXXXX)
Expand Down Expand Up @@ -36,11 +35,18 @@ for ARCH in "amd64" "arm64"; do
;;
esac
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" "espresso-bridge"; do
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" "espresso-bridge" "espresso-dev-node"; do
cp -v "${CARGO_TARGET_DIR}/${TARGET}/release/$binary" ${WORKDIR}/target/$ARCH/release
done

# Download the latest foundry binary and extract anvil for the dev-node docker image.
curl -L https://github.com/foundry-rs/foundry/releases/download/nightly/foundry_nightly_linux_${ARCH}.tar.gz -o ${WORKDIR}/foundry.tar.gz
tar -xzvf ${WORKDIR}/foundry.tar.gz -C ${WORKDIR}/target/$ARCH/release anvil
done

# Copy the dev-node launch script
cp -v scripts/launch-dev-node-with-postgres ${WORKDIR}

export DOCKER_BUILDKIT=1
docker build -t ghcr.io/espressosystems/espresso-sequencer/orchestrator:main -f docker/orchestrator.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/cdn-broker:main -f docker/cdn-broker.Dockerfile ${WORKDIR}
Expand All @@ -54,4 +60,5 @@ docker build -t ghcr.io/espressosystems/espresso-sequencer/submit-transactions:m
docker build -t ghcr.io/espressosystems/espresso-sequencer/deploy:main -f docker/deploy.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/builder:main -f docker/permissionless-builder.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/nasty-client:main -f docker/nasty-client.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/espresso-dev-node:main -f docker/espresso-dev-node.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/bridge:main -f docker/bridge.Dockerfile ${WORKDIR}
11 changes: 10 additions & 1 deletion scripts/build-docker-images-native
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,22 @@ mkdir -p ${WORKDIR}/data
cp -rv data/genesis ${WORKDIR}/data/

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" "espresso-bridge"; do
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" "espresso-bridge" "espresso-dev-node"; do
cp -v "${CARGO_TARGET_DIR}/release/$binary" "${WORKDIR}/target/$ARCH/release"
# Patch the interpreter for running without nix inside the ubuntu based docker image.
if [ $KERNEL == "linux" ]; then
patchelf --set-interpreter "$INTERPRETER" "${WORKDIR}/target/$ARCH/release/$binary"
fi
done

# Copy the dev-node launch script
cp -v scripts/launch-dev-node-with-postgres ${WORKDIR}

# Download the latest foundry binary and extract anvil for the dev-node docker image.
curl -L https://github.com/foundry-rs/foundry/releases/download/nightly/foundry_nightly_linux_${ARCH}.tar.gz -o ${WORKDIR}/foundry.tar.gz
tar -xzvf ${WORKDIR}/foundry.tar.gz -C ${WORKDIR}/target/$ARCH/release anvil


export DOCKER_BUILDKIT=1
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/orchestrator:main -f docker/orchestrator.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/cdn-broker:main -f docker/cdn-broker.Dockerfile ${WORKDIR}
Expand All @@ -108,4 +116,5 @@ docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/deploy:main -f docker/deploy.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/builder:main -f docker/permissionless-builder.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/nasty-client:main -f docker/nasty-client.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/espresso-dev-node:main -f docker/espresso-dev-node.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/bridge:main -f docker/bridge.Dockerfile ${WORKDIR}
25 changes: 25 additions & 0 deletions scripts/launch-dev-node-with-postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euxo pipefail

export ESPRESSO_SEQUENCER_POSTGRES_HOST=${ESPRESSO_SEQUENCER_POSTGRES_HOST:-localhost}
export ESPRESSO_SEQUENCER_POSTGRES_PORT=${ESPRESSO_SEQUENCER_POSTGRES_PORT:-5432}
export ESPRESSO_SEQUENCER_POSTGRES_USER=${ESPRESSO_SEQUENCER_POSTGRES_USER:-root}
export ESPRESSO_SEQUENCER_POSTGRES_PASSWORD=${ESPRESSO_SEQUENCER_POSTGRES_PASSWORD:-password}

export POSTGRES_USER=$ESPRESSO_SEQUENCER_POSTGRES_USER
export POSTGRES_PASSWORD=$ESPRESSO_SEQUENCER_POSTGRES_PASSWORD

export RUST_LOG=${RUST_LOG:-info}

# Start postgres in the background
docker-entrypoint.sh postgres &

# Wait (twice) for postgres to be ready
# Postgres can be falsely "ready" once before running init scripts.
until pg_isready && sleep 1 && pg_isready; do
echo "Waiting for postgres..."
sleep 1
done

# Start the dev node
espresso-dev-node
6 changes: 6 additions & 0 deletions sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ edition = "2021"
testing = ["hotshot-testing"]
libp2p = []

[[bin]]
name = "espresso-dev-node"
required-features = ["testing"]

[dev-dependencies]
escargot = "0.5.10"
espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0" }
hotshot-query-service = { workspace = true, features = ["testing"] }
pretty_assertions = { workspace = true }
Expand Down Expand Up @@ -56,6 +61,7 @@ ethers-contract-derive = "2.0.10"
futures = { workspace = true }

hotshot = { workspace = true }
hotshot-contract-adapter = { workspace = true }
hotshot-events-service = { workspace = true }
hotshot-orchestrator = { workspace = true }
hotshot-query-service = { workspace = true }
Expand Down
Loading

0 comments on commit ee086ea

Please sign in to comment.