Skip to content

Commit

Permalink
script for running sequencer binaries based on flag
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit committed Nov 22, 2024
1 parent eab37fb commit 13c449f
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 75 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ jobs:
marketplace-builder-tag: ${{ steps.marketplace-builder.outputs.tags }}
node-validator-tag: ${{ steps.node-validator.outputs.tags }}
dev-rollup-tag: ${{ steps.dev-rollup.outputs.tags }}
sequencer-sqlite-tag: ${{ steps.sequencer-sqlite.outputs.tags }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -295,13 +294,6 @@ jobs:
with:
images: ghcr.io/espressosystems/espresso-sequencer/dev-rollup

- name: Generate sequencer-sqlite metadata
uses: docker/metadata-action@v5
id: sequencer-sqlite
with:
images: ghcr.io/espressosystems/espresso-sequencer/sequencer-sqlite


- name: Build and push sequencer docker
uses: docker/build-push-action@v6
with:
Expand Down Expand Up @@ -471,16 +463,6 @@ jobs:
tags: ${{ steps.dev-rollup.outputs.tags }}
labels: ${{ steps.dev-rollup.outputs.labels }}

- name: Build and push sequencer-sqlite docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/sequencer-sqlite.Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.sequencer-sqlite.outputs.tags }}
labels: ${{ steps.sequencer-sqlite.outputs.labels }}

test-demo:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -512,7 +494,6 @@ jobs:
docker pull ${{ needs.build-dockers.outputs.marketplace-builder-tag }}
docker pull ${{ needs.build-dockers.outputs.node-validator-tag }}
docker pull ${{ needs.build-dockers.outputs.dev-rollup-tag }}
docker pull ${{ needs.build-dockers.outputs.sequencer-sqlite-tag }}
- name: Tag new docker images
run: |
Expand All @@ -532,7 +513,6 @@ jobs:
docker tag ${{ needs.build-dockers.outputs.marketplace-builder-tag }} ghcr.io/espressosystems/espresso-sequencer/marketplace-builder:main
docker tag ${{ needs.build-dockers.outputs.node-validator-tag }} ghcr.io/espressosystems/espresso-sequencer/node-validator:main
docker tag ${{ needs.build-dockers.outputs.dev-rollup-tag }} ghcr.io/espressosystems/espresso-sequencer/dev-rollup:main
docker tag ${{ needs.build-dockers.outputs.sequencer-sqlite-tag }} ghcr.io/espressosystems/espresso-sequencer/sequencer-sqlite:main
- name: Test docker demo
run: |
Expand Down
19 changes: 1 addition & 18 deletions .github/workflows/build_static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,6 @@ jobs:
images: ghcr.io/espressosystems/espresso-sequencer/dev-rollup
flavor: suffix=musl

- name: Generate sequencer-sqlite metadata
uses: docker/metadata-action@v5
id: sequencer-sqlite
with:
images: ghcr.io/espressosystems/espresso-sequencer/sequencer-sqlite
flavor: suffix=musl

- name: Build and push sequencer docker
uses: docker/build-push-action@v6
with:
Expand Down Expand Up @@ -386,14 +379,4 @@ jobs:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.dev-rollup.outputs.tags }}
labels: ${{ steps.dev-rollup.outputs.labels }}

- name: Build and push sequencer-sqlite docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/sequencer-sqlite.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.sequencer-sqlite.outputs.tags }}
labels: ${{ steps.sequencer-sqlite.outputs.labels }}
labels: ${{ steps.dev-rollup.outputs.labels }}
15 changes: 11 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ services:
# Run the full API server with all modules, Postgres storage
command: sequencer -- storage-sql -- http -- query -- catchup -- status -- submit -- hotshot-events -- config
environment:
- ESPRESSO_SEQUENCER_EMBEDDED_DB=false
- ESPRESSO_SEQUENCER_GENESIS_FILE
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_SEQUENCER_CDN_ENDPOINT
Expand Down Expand Up @@ -278,6 +279,7 @@ services:
- "$ESPRESSO_SEQUENCER1_API_PORT:$ESPRESSO_SEQUENCER_API_PORT"
command: sequencer -- storage-sql -- http -- query -- catchup -- status -- state -- explorer
environment:
- ESPRESSO_SEQUENCER_EMBEDDED_DB=false
- ESPRESSO_SEQUENCER_GENESIS_FILE
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_SEQUENCER_CDN_ENDPOINT
Expand Down Expand Up @@ -334,6 +336,7 @@ services:
- "$ESPRESSO_SEQUENCER2_API_PORT:$ESPRESSO_SEQUENCER_API_PORT"
command: sequencer -- http -- catchup -- status
environment:
- ESPRESSO_SEQUENCER_EMBEDDED_DB=false
- ESPRESSO_SEQUENCER_GENESIS_FILE
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_SEQUENCER_CDN_ENDPOINT
Expand Down Expand Up @@ -384,6 +387,7 @@ services:
- "$ESPRESSO_SEQUENCER3_API_PORT:$ESPRESSO_SEQUENCER_API_PORT"
command: sequencer -- http -- catchup -- status
environment:
- ESPRESSO_SEQUENCER_EMBEDDED_DB=false
- ESPRESSO_SEQUENCER_GENESIS_FILE
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_SEQUENCER_CDN_ENDPOINT
Expand Down Expand Up @@ -433,6 +437,7 @@ services:
- "$ESPRESSO_SEQUENCER4_API_PORT:$ESPRESSO_SEQUENCER_API_PORT"
command: sequencer -- http -- catchup -- status
environment:
- ESPRESSO_SEQUENCER_EMBEDDED_DB=false
- ESPRESSO_SEQUENCER_GENESIS_FILE
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_SEQUENCER_CDN_ENDPOINT
Expand Down Expand Up @@ -476,13 +481,14 @@ services:
condition: service_completed_successfully

sequencer5:
image: ghcr.io/espressosystems/espresso-sequencer/sequencer-sqlite:main
image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main
ports:
- "$ESPRESSO_SEQUENCER5_API_PORT:$ESPRESSO_SEQUENCER_API_PORT"

# Run the full API server with all modules, Sqlite storage
command: sequencer-sqlite -- storage-sql -- http -- query -- catchup -- status -- submit -- config
command: sequencer -- storage-sql -- http -- query -- catchup -- status -- submit -- config
environment:
- ESPRESSO_SEQUENCER_EMBEDDED_DB=true
- ESPRESSO_SEQUENCER_GENESIS_FILE
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_SEQUENCER_CDN_ENDPOINT
Expand Down Expand Up @@ -528,11 +534,12 @@ services:
condition: service_completed_successfully

sequencer6:
image: ghcr.io/espressosystems/espresso-sequencer/sequencer-sqlite:main
image: ghcr.io/espressosystems/espresso-sequencer/sequencer:main
ports:
- "$ESPRESSO_SEQUENCER6_API_PORT:$ESPRESSO_SEQUENCER_API_PORT"
command: sequencer-sqlite -- storage-sql -- http -- query -- catchup -- status -- state -- explorer
command: sequencer -- storage-sql -- http -- query -- catchup -- status -- state -- explorer
environment:
- ESPRESSO_SEQUENCER_EMBEDDED_DB=true
- ESPRESSO_SEQUENCER_GENESIS_FILE
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
- ESPRESSO_SEQUENCER_CDN_ENDPOINT
Expand Down
21 changes: 0 additions & 21 deletions docker/sequencer-sqlite.Dockerfile

This file was deleted.

17 changes: 13 additions & 4 deletions docker/sequencer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ ENTRYPOINT ["tini", "--"]
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/sequencer /bin/sequencer
RUN chmod +x /bin/sequencer
COPY target/$TARGETARCH/release/sequencer /bin/sequencer-postgres
RUN chmod +x /bin/sequencer-postgres

COPY target/$TARGETARCH/release/sequencer-sqlite /bin/sequencer-sqlite
RUN chmod +x /bin/sequencer-sqlite

COPY target/$TARGETARCH/release/utils /bin/utils
RUN chmod +x /bin/utils
Expand All @@ -34,6 +37,12 @@ COPY data/genesis /genesis
# Set `ESPRESSO_SEQUENCER_GENESIS_SECRET`
COPY docker/scripts/sequencer-awssecretsmanager.sh /bin/sequencer-awssecretsmanager.sh

# Copy entrypoint script
COPY scripts/sequencer-entrypoint /bin/sequencer
RUN chmod +x /bin/sequencer

ENTRYPOINT ["/bin/sequencer"]

# 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 All @@ -43,6 +52,6 @@ ENV ESPRESSO_SEQUENCER_STORAGE_PATH=/store/sequencer

# We run the additional `status` and `catchup` modules by default. These are modules that require
# minimal resources (no persistent storage) but improve the functionality of the network.
CMD ["/bin/sequencer", "--", "http", "--", "status", "--", "catchup"]
CMD ["--", "http", "--", "status", "--", "catchup"]
HEALTHCHECK --interval=1s --timeout=1s --retries=100 CMD curl --fail http://localhost:${ESPRESSO_SEQUENCER_API_PORT}/healthcheck || exit 1
EXPOSE ${ESPRESSO_SEQUENCER_API_PORT}
EXPOSE ${ESPRESSO_SEQUENCER_API_PORT}
7 changes: 3 additions & 4 deletions scripts/build-docker-images-native
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ done
mkdir -p ${WORKDIR}/docker/scripts
cp -v docker/scripts/sequencer-awssecretsmanager.sh ${WORKDIR}/docker/scripts

# Copy the dev-node launch script
# Copy the dev-node and sequencer-entrypoint script
mkdir -p ${WORKDIR}/scripts
cp -v scripts/launch-dev-node-with-postgres ${WORKDIR}/scripts
cp -v scripts/{launch-dev-node-with-postgres,sequencer-entrypoint} ${WORKDIR}/scripts

export DOCKER_BUILDKIT=1
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/orchestrator:main -f docker/orchestrator.Dockerfile ${WORKDIR}
Expand All @@ -124,5 +124,4 @@ docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/marketplace-solver:main -f docker/marketplace-solver.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/marketplace-builder:main -f docker/marketplace-builder.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/node-validator:main -f docker/node-validator.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/dev-rollup:main -f docker/dev-rollup.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/sequencer-sqlite:main -f docker/sequencer-sqlite.Dockerfile ${WORKDIR}
docker build --platform $PLATFORM -t ghcr.io/espressosystems/espresso-sequencer/dev-rollup:main -f docker/dev-rollup.Dockerfile ${WORKDIR}
5 changes: 2 additions & 3 deletions scripts/build-docker-images-static
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ done
mkdir -p ${WORKDIR}/docker/scripts
cp -v docker/scripts/sequencer-awssecretsmanager.sh ${WORKDIR}/docker/scripts

# Copy the dev-node launch script
# Copy the dev-node and sequencer script
mkdir -p ${WORKDIR}/scripts
cp -v scripts/launch-dev-node-with-postgres ${WORKDIR}/scripts
cp -v scripts/{launch-dev-node-with-postgres,sequencer-entrypoint} ${WORKDIR}/scripts

export DOCKER_BUILDKIT=1
docker build -t ghcr.io/espressosystems/espresso-sequencer/orchestrator:main -f docker/orchestrator.Dockerfile ${WORKDIR}
Expand All @@ -71,4 +71,3 @@ docker build -t ghcr.io/espressosystems/espresso-sequencer/marketplace-solver:ma
docker build -t ghcr.io/espressosystems/espresso-sequencer/marketplace-builder:main -f docker/marketplace-builder.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/node-validator:main -f docker/node-validator.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/dev-rollup:main -f docker/dev-rollup.Dockerfile ${WORKDIR}
docker build -t ghcr.io/espressosystems/espresso-sequencer/sequencer-sqlite:main -f docker/sequencer-sqlite.Dockerfile ${WORKDIR}
12 changes: 12 additions & 0 deletions scripts/sequencer-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

export ESPRESSO_SEQUENCER_EMBEDDED_DB=${ESPRESSO_SEQUENCER_EMBEDDED_DB:-false}

# Decide which binary to run based on the environment variable
if [ "$ESPRESSO_SEQUENCER_EMBEDDED_DB" = "true" ]; then
echo "Starting sequencer with sqlite..."
exec /bin/sequencer-sqlite "$@"
else
echo "Starting sequencer with postgres..."
exec /bin/sequencer-postgres "$@"
fi
2 changes: 1 addition & 1 deletion sequencer/src/persistence/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ mod testing {
type Storage = Arc<TmpDb>;

async fn tmp_storage() -> Self::Storage {
Arc::new(TmpDb::persistent().await)
Arc::new(TmpDb::init().await)
}

async fn connect(db: &Self::Storage) -> Self {
Expand Down

0 comments on commit 13c449f

Please sign in to comment.