feat(l1): ethrex_replay
add new command to create cache for block
#6298
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: L2 (without proving) | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["**"] | |
paths: | |
- "crates/l2/**" | |
- "fixtures/**" | |
- "crates/blockchain/dev/**" | |
- "crates/vm/levm/**" | |
- ".github/workflows/pr-main_l2.yaml" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
DOCKER_ETHREX_WORKDIR: /usr/local/bin | |
jobs: | |
lint: | |
# "Lint" is a required check, don't change the name | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Setup Rust Environment | |
uses: ./.github/actions/setup-rust | |
with: | |
components: rustfmt, clippy | |
- name: Install RISC0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
curl -L https://risczero.com/install | bash | |
~/.risc0/bin/rzup install cargo-risczero 2.3.1 | |
~/.risc0/bin/rzup install rust | |
- name: Create placeholder SP1 ELF | |
run: | | |
mkdir -p crates/l2/prover/zkvm/interface/sp1/out | |
touch crates/l2/prover/zkvm/interface/sp1/out/riscv32im-succinct-zkvm-elf | |
- name: Run cargo check | |
run: cargo check --workspace | |
- name: Run cargo clippy | |
run: | | |
cargo clippy --workspace -- -D warnings | |
make lint | |
- name: Run cargo fmt | |
run: | | |
cargo fmt --all -- --check | |
build-docker: | |
name: Build docker image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build L1 docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
tags: ethrex:unstable | |
load: true | |
outputs: type=docker,dest=/tmp/ethrex_image.tar | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ethrex_image | |
path: /tmp/ethrex_image.tar | |
integration-test: | |
name: Integration Test - ${{ matrix.name }} | |
runs-on: ubuntu-latest | |
needs: build-docker | |
strategy: | |
matrix: | |
include: | |
- name: "Validium" | |
validium: true | |
web3signer: false | |
compose_targets: [docker-compose.yaml] | |
- name: "Vanilla" | |
validium: false | |
web3signer: false | |
compose_targets: [docker-compose.yaml] | |
- name: "Vanilla with Web3signer" | |
validium: false | |
web3signer: true | |
compose_targets: | |
[docker-compose.yaml, docker-compose-l2-web3signer.yaml] | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Setup Rust Environment | |
uses: ./.github/actions/setup-rust | |
- name: Install solc | |
uses: pontem-network/get-solc@master | |
with: | |
version: v0.8.29 | |
token: ${{ secrets.GITHUB_TOKEN || '' }} | |
# also creates empty verification keys (as workflow runs with exec backend) | |
- name: Build prover | |
run: | | |
cd crates/l2 | |
make build-prover | |
mkdir -p prover/zkvm/interface/sp1/out && touch prover/zkvm/interface/sp1/out/riscv32im-succinct-zkvm-vk | |
- name: Build test | |
run: | | |
cargo test l2 --no-run --release | |
- name: Start Web3Signer | |
if: matrix.web3signer | |
run: | | |
cd crates/l2 | |
docker compose -f ${{ join(matrix.compose_targets, ' -f ') }} up --detach web3signer | |
- name: Download ethrex image artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ethrex_image | |
path: /tmp | |
- name: Load ethrex image | |
run: | | |
docker load --input /tmp/ethrex_image.tar | |
- name: Start L1 & Deploy contracts | |
run: | | |
touch cmd/.env | |
cd crates/l2 | |
DOCKER_ETHREX_WORKDIR=/usr/local/bin \ | |
ETHREX_DEPLOYER_DEPLOY_RICH=true \ | |
ETHREX_DEPLOYER_PICO_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_DEPLOYER_SP1_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_DEPLOYER_RISC0_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_L2_VALIDIUM=${{ matrix.validium }} \ | |
docker compose up contract_deployer | |
- name: Start Sequencer | |
run: | | |
cd crates/l2 | |
DOCKER_ETHREX_WORKDIR=/usr/local/bin \ | |
ETHREX_L2_VALIDIUM=${{ matrix.validium }} \ | |
ETHREX_WATCHER_BLOCK_DELAY=0 \ | |
docker compose -f ${{ join(matrix.compose_targets, ' -f ') }} up --detach --no-deps ethrex_l2 | |
- name: Run test | |
run: | | |
sudo chmod -R a+rw crates/l2 | |
cd crates/l2 | |
RUST_LOG=info,ethrex_prover_lib=debug make init-prover & | |
docker logs --follow ethrex_l2 & | |
PROPOSER_COINBASE_ADDRESS=0x0007a881CD95B1484fca47615B64803dad620C8d cargo test l2 --release -- --nocapture --test-threads=1 | |
killall ethrex -s SIGINT | |
integration-test-based: | |
name: Integration Test - Based | |
runs-on: ubuntu-latest | |
needs: build-docker | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Setup Rust Environment | |
uses: ./.github/actions/setup-rust | |
- name: Install solc | |
uses: pontem-network/get-solc@master | |
with: | |
version: v0.8.29 | |
token: ${{ secrets.GITHUB_TOKEN || '' }} | |
- name: Download ethrex image artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ethrex_image | |
path: /tmp | |
- name: Load ethrex image | |
run: | | |
docker load --input /tmp/ethrex_image.tar | |
# also creates empty verification keys (as workflow runs with exec backend) | |
- name: Build prover | |
run: | | |
cd crates/l2 | |
make build-prover | |
mkdir -p prover/zkvm/interface/sp1/out && touch prover/zkvm/interface/sp1/out/riscv32im-succinct-zkvm-vk | |
- name: Start L1 & Deploy contracts | |
run: | | |
touch cmd/.env | |
cd crates/l2 | |
DOCKER_ETHREX_WORKDIR=/usr/local/bin \ | |
ETHREX_DEPLOYER_DEPLOY_RICH=true \ | |
ETHREX_DEPLOYER_PICO_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_DEPLOYER_SP1_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_DEPLOYER_RISC0_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_DEPLOYER_DEPLOY_BASED_CONTRACTS=true \ | |
COMPILE_CONTRACTS=true \ | |
docker compose up contract_deployer | |
- name: Install rex | |
run: | | |
cd .. | |
rustup install nightly # Install the nightly toolchain needed by rex, change this in the future | |
rustup default nightly | |
git clone https://github.com/lambdaclass/rex.git | |
cd rex | |
git checkout 21763774e29e4566ccb831ea8154e94aa2ff7c0e | |
make cli | |
echo "rex install successfully at $(which rex)" | |
- name: Register sequencer | |
run: | | |
cd cmd | |
SEQUENCER_REGISTRY=$(grep ETHREX_DEPLOYER_SEQUENCER_REGISTRY .env | cut -d= -f2) | |
export SEQUENCER_REGISTRY | |
if [ -z "$SEQUENCER_REGISTRY" ]; then | |
echo "Failed to get SEQUENCER_REGISTRY from .env file" | |
exit 1 | |
fi | |
rex send "$SEQUENCER_REGISTRY" "register(address)" 0x3d1e15a1a55578f7c920884a9943b3b35d0d885b --value 1000000000000000000 -k 0x385c546456b6a603a1cfcaa9ec9494ba4832da08dd6bcf4de9a71e4a01b74924 | |
rex call "$SEQUENCER_REGISTRY" "leaderSequencer()" | |
- name: Start Sequencer | |
run: | | |
cd cmd | |
SEQUENCER_REGISTRY=$(grep ETHREX_DEPLOYER_SEQUENCER_REGISTRY .env | cut -d= -f2) | |
export SEQUENCER_REGISTRY | |
cd ../crates/l2 | |
DOCKER_ETHREX_WORKDIR=/usr/local/bin \ | |
ETHREX_COMMITTER_VALIDIUM=false \ | |
ETHREX_WATCHER_BLOCK_DELAY=0 \ | |
ETHREX_BASED=true \ | |
ETHREX_STATE_UPDATER_SEQUENCER_REGISTRY="$SEQUENCER_REGISTRY" \ | |
docker compose up --detach --no-deps ethrex_l2 | |
- name: Run test | |
run: | | |
sudo chmod -R a+rw crates/l2 | |
cd crates/l2 | |
RUST_LOG=info,ethrex_prover_lib=debug make init-prover & | |
docker logs --follow ethrex_l2 & | |
PROPOSER_COINBASE_ADDRESS=0x0007a881CD95B1484fca47615B64803dad620C8d cargo test l2 --release -- --nocapture --test-threads=1 | |
killall ethrex -s SIGINT | |
state-diff-test: | |
name: State Reconstruction Tests | |
runs-on: ubuntu-latest | |
needs: build-docker | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Setup Rust Environment | |
uses: ./.github/actions/setup-rust | |
- name: Download ethrex image artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ethrex_image | |
path: /tmp | |
- name: Load ethrex image | |
run: | | |
docker load --input /tmp/ethrex_image.tar | |
- name: Install solc | |
uses: pontem-network/get-solc@master | |
with: | |
version: v0.8.29 | |
token: ${{ secrets.GITHUB_TOKEN || '' }} | |
- name: Start L1 & Deploy contracts | |
run: | | |
touch cmd/.env | |
cd crates/l2 | |
DOCKER_ETHREX_WORKDIR=/usr/local/bin \ | |
ETHREX_DEPLOYER_DEPLOY_RICH=true \ | |
ETHREX_DEPLOYER_PICO_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_DEPLOYER_SP1_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
ETHREX_DEPLOYER_RISC0_CONTRACT_ADDRESS=0x00000000000000000000000000000000000000aa \ | |
COMPILE_CONTRACTS=true \ | |
docker compose up contract_deployer | |
- name: Run tests | |
run: | | |
cd crates/l2 | |
make state-diff-test | |
# The purpose of this job is to add it as a required check in GitHub so that we don't have to add every individual job as a required check | |
all-tests: | |
# "Integration Test" is a required check, don't change the name | |
name: Integration Test | |
runs-on: ubuntu-latest | |
needs: [integration-test, state-diff-test, integration-test-based] | |
# Make sure this job runs even if the previous jobs failed or were skipped | |
if: ${{ always() && needs.integration-test.result != 'skipped' && needs.state-diff-test.result != 'skipped' && needs.integration-test-based.result != 'skipped' }} | |
steps: | |
- name: Check if any job failed | |
run: | | |
if [ "${{ needs.integration-test.result }}" != "success" ]; then | |
echo "Job Integration Tests failed" | |
exit 1 | |
fi | |
if [ "${{ needs.state-diff-test.result }}" != "success" ]; then | |
echo "Job State Reconstruction Tests failed" | |
exit 1 | |
fi | |
if [ "${{ needs.integration-test-based.result }}" != "success" ]; then | |
echo "Job Integration Tests Based failed" | |
exit 1 | |
fi |