Skip to content

Commit

Permalink
feat: prove stdio using amqp docker compose setup (#763)
Browse files Browse the repository at this point in the history
* feat: docker compose setup for proving test

* fix: number of workers

* fix: cleanup

* fix: nit

* nit: comment

* fix: shellcheck

* fix: load strategy

* fix: update shellcheck
  • Loading branch information
atanmarko authored Nov 6, 2024
1 parent 80e1e44 commit 4646b2f
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
yamllint
--format github
-d "{extends: default, rules: {line-length: {max: 120}, truthy: {check-keys: false}}}"
.github
.github scripts
50 changes: 50 additions & 0 deletions scripts/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--- # Docker compose setup for running the leader and worker with amqp communication
version: "3"
services:

leader:
build:
context: ../
dockerfile: Dockerfile
depends_on:
rabbitmq:
condition: service_healthy
command: bash -c "leader --runtime amqp \
--load-strategy on-demand \
--proof-output-dir ./proofs \
--block-batch-size ${LEADER_BLOCK_BATCH_SIZE} stdio < /witness"
environment:
- RUST_LOG=info
- AMQP_URI=amqp://rabbitmq:5672
volumes:
- ${PROOF_OUTPUT_DIR}:/proofs/:rw
- ${LEADER_INPUT_JSON_FILE}:/witness:ro

worker:
build:
context: ../
dockerfile: Dockerfile
depends_on:
rabbitmq:
condition: service_healthy
environment:
- RUST_LOG=info
- AMQP_URI=amqp://rabbitmq:5672
- ZK_EVM_CACHE_DIR=/zk_evm_circuit_cache
command: worker
volumes:
- ${DOCKER_CIRCUITS_CACHE_DIR}/worker:/zk_evm_circuit_cache:rw
deploy:
mode: replicated
replicas: 2

rabbitmq:
image: rabbitmq:3-management
ports:
- "5672:5672"
- "15672:15672"
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 10s
timeout: 30s
retries: 3
17 changes: 17 additions & 0 deletions scripts/prove_stdio_docker_compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

export LEADER_INPUT_JSON_FILE=$1

export LEADER_BLOCK_BATCH_SIZE="${BLOCK_BATCH_SIZE:-8}"

REPO_ROOT=$(git rev-parse --show-toplevel)

export PROOF_OUTPUT_DIR="${REPO_ROOT}/proofs"
mkdir -p "$PROOF_OUTPUT_DIR"
chmod 777 "$PROOF_OUTPUT_DIR"

export DOCKER_CIRCUITS_CACHE_DIR="./docker_circuit_cache"
mkdir -p "$DOCKER_CIRCUITS_CACHE_DIR/worker"
chmod 777 "$DOCKER_CIRCUITS_CACHE_DIR/worker"

docker compose up
12 changes: 12 additions & 0 deletions zero/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,18 @@ echo "[" > $file_name && cast rpc eth_getBlockByNumber "0x<block_number>" 'false

Move the generated files to the appropriate subdirectory, and they will be automatically included in the test run.


### Proving blocks using docker compose setup and leader-worker amqp communication

To prove blocks using the docker compose setup and independent container leader and worker execution, you can use the `prove_stdio_docker_compose.sh` script:

```sh
cd scripts
prove_stdio_docker_compose.sh ../path/to/block_witness.json
```

Check the script and `docker-compose.yml` file to further customize the setup (e.g. number of workers).

## License

Licensed under either of
Expand Down

0 comments on commit 4646b2f

Please sign in to comment.