Skip to content
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 dev-node binary #1353

Merged
merged 52 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
64aef27
Vscode settings
ImJeremyHe Apr 19, 2024
30f9667
Add test-node binary
ImJeremyHe Apr 22, 2024
f5f072a
Run an anvil node if l1 is not provided
ImJeremyHe Apr 23, 2024
9a381c4
Add docker file
ImJeremyHe Apr 23, 2024
5e10163
Lint Cargo.toml
ImJeremyHe Apr 23, 2024
b042b8e
use default ports
ImJeremyHe Apr 24, 2024
4944bfb
Use query-sql
ImJeremyHe Apr 24, 2024
1cae4f5
Merge remote-tracking branch 'origin/main' into jh/testnode
ImJeremyHe Apr 24, 2024
381cf4d
Fix the test node test
ImJeremyHe Apr 24, 2024
e01bcb0
Add API checks
ImJeremyHe Apr 24, 2024
e105e6c
Add timeout minutes
ImJeremyHe Apr 24, 2024
6022860
Clean the stdout of db
ImJeremyHe Apr 24, 2024
3c74b4b
Merge branch 'main' into jh/testnode
ImJeremyHe Apr 24, 2024
6b97c8b
Add timeout limit
ImJeremyHe Apr 25, 2024
0489f3e
Merge remote-tracking branch 'origin/main' into jh/testnode
ImJeremyHe Apr 25, 2024
5baaeef
Fix tests
ImJeremyHe Apr 25, 2024
81c088b
Merge remote-tracking branch 'origin/main' into jh/testnode
ImJeremyHe Apr 29, 2024
87375da
Change image name to espresso-test-node
ImJeremyHe Apr 30, 2024
1d18cb1
Merge remote-tracking branch 'origin/main' into jh/testnode
ImJeremyHe Apr 30, 2024
c469b7d
Test block-state api
ImJeremyHe Apr 30, 2024
1624cd4
Docker image with dev node, postgres, anvil
sveitser Apr 30, 2024
fb89067
Consistently name dev node "espresso-dev-node"
sveitser Apr 30, 2024
10a1320
Fix the test
ImJeremyHe Apr 30, 2024
0b248a0
Rename test_node_test -> dev_node_test
sveitser Apr 30, 2024
a6097d6
Fix dev node test, don't hide logs
sveitser Apr 30, 2024
3010f7d
Merge remote-tracking branch 'origin/main' into jh/testnode
ImJeremyHe May 6, 2024
1532d87
Check the return value of submit
ImJeremyHe May 6, 2024
0702d0f
Merge remote-tracking branch 'origin/main' into jh/testnode
imabdulbasit May 20, 2024
9acea2d
Update the test
ImJeremyHe May 20, 2024
242dbd3
remove builder
imabdulbasit May 20, 2024
ca0bb09
Increase the time limit
ImJeremyHe May 20, 2024
8a5cd08
Fix the light client genesis
ImJeremyHe May 20, 2024
e773906
Merge branch 'main' into jh/testnode
imabdulbasit May 20, 2024
8997ceb
Merge remote-tracking branch 'origin' into jh/testnode
ImJeremyHe May 21, 2024
76dec30
use TmpDb for test
imabdulbasit May 21, 2024
b47398e
wait for some blocks instead of sleeping for fixed time
imabdulbasit May 21, 2024
4363b7d
change postgres username to postgres
imabdulbasit May 21, 2024
753875b
Merge branch 'main' into jh/testnode
imabdulbasit May 22, 2024
6e1b2d5
fix test
imabdulbasit May 22, 2024
43162b5
retry
imabdulbasit May 22, 2024
d3d6b3b
clippy
imabdulbasit May 22, 2024
3c7a2b0
Merge remote-tracking branch 'origin/main' into jh/testnode
tbro May 28, 2024
37cd4b6
Merge remote-tracking branch 'origin/main' into jh/testnode
tbro May 28, 2024
5226912
coerce u64 to usize
tbro May 28, 2024
805aee1
add separate build step for dev-node
tbro May 28, 2024
c4b8ce0
Merge remote-tracking branch 'origin/main' into jh/testnode
tbro May 28, 2024
c0fe216
Merge remote-tracking branch 'origin/main' into jh/testnode
tbro May 29, 2024
3bf2ff7
add builder_port param
tbro May 29, 2024
d962775
Merge remote-tracking branch 'origin/main' into jh/testnode
tbro May 29, 2024
4a4d4fa
Revert "add builder_port param"
tbro May 29, 2024
3895eb6
Merge remote-tracking branch 'origin/main' into jh/testnode
tbro May 29, 2024
7e0b102
Merge remote-tracking branch 'origin/main' into jh/testnode
tbro May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/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/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.25" }
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 @@ -35,11 +34,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" "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" "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 @@ -53,4 +59,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 @@ -86,14 +86,22 @@ cleanup(){
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
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" "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 @@ -107,4 +115,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"]
sveitser marked this conversation as resolved.
Show resolved Hide resolved

[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
Loading