Skip to content

Commit 2a7d7b5

Browse files
committed
update docs
1 parent 341c038 commit 2a7d7b5

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

docs/shadow-testing/README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,117 @@ cast send $SCROLL_CHAIN --from $PROVER $(cat /tmp/finalize_calldata.hex) \
824824
3. **Fork block matters** — If the fork block is after the real finalization, you must manually reset `lastFinalizedBatchIndex` and `nextUnfinalizedQueueIndex`.
825825
4. **Public input hash must match exactly** — Any discrepancy in `msg_queue_hash`, `chain_id`, `num_batches`, or roots will cause `VerificationFailed`.
826826
5. **Anvil default account is not an EOA in fork mode** — Use a freshly generated EOA for `addProver`; `0xf39F...` has contract code and will fail the EOA check.
827+
6. **Reset `rollup_status` before relayer finalize** — The shadow DB retains mainnet rollup state (`RollupFinalized` = 5). The relayer's `GetFirstPendingBundle` only queries `rollup_status = RollupPending` (1). You must reset both `bundle` and `batch` tables before the relayer will pick up bundles for finalization.
828+
829+
## Multi-Bundle Relayer Finalize Test (5 Bundles)
830+
831+
This test demonstrates running the actual `rollup_relayer` binary against an Anvil mainnet fork to finalize **5 consecutive bundles** (17297–17301, batches 517761–517765) using shadow proofs.
832+
833+
### Prerequisites
834+
835+
- Anvil fork running with `lastFinalizedBatchIndex` reset to `517760`
836+
- Shadow proofs generated for all 5 bundles (`proving_status = 4`)
837+
- Verifier `0xb1F2C5c1ea2885278a1070350d12d3D8824265B0` registered as `latestVerifier[10]`
838+
- Prover/finalize EOA `0x410E...` authorized on `ScrollChain`
839+
840+
### Step 1: Reset DB Rollup Status
841+
842+
The shadow DB retains mainnet rollup state. Before the relayer can pick up bundles, reset their status:
843+
844+
```sql
845+
UPDATE bundle SET rollup_status = 1 WHERE index BETWEEN 17297 AND 17301;
846+
UPDATE batch SET rollup_status = 1 WHERE index BETWEEN 517761 AND 517765;
847+
```
848+
849+
(`1` = `RollupPending`; without this, `GetFirstPendingBundle` returns nothing.)
850+
851+
### Step 2: Build and Configure Relayer
852+
853+
```bash
854+
cd rollup
855+
go build -o /tmp/rollup_relayer ./cmd/rollup_relayer
856+
```
857+
858+
Create `/tmp/rollup-relayer-anvil.json`:
859+
860+
```json
861+
{
862+
"l2_config": {
863+
"l2_geth": { "endpoint": "https://mainnet-galileo.scroll.io/l2" },
864+
"relayer_config": {
865+
"sender_config": {
866+
"endpoint": "http://localhost:18545",
867+
"check_balance": false,
868+
"dry_run": false
869+
},
870+
"commit_sender_signer_config": {
871+
"private_key": "0xac09..."
872+
},
873+
"finalize_sender_signer_config": {
874+
"private_key": "0x01f1..."
875+
},
876+
"rollup_contract_address": "0xa13BAF47339d63B743e7Da8741db5456DAc1E556",
877+
"chain_monitor": { "enabled": false },
878+
"gas_oracle": { "enabled": false },
879+
"batch_committer": {
880+
"enable_test_env_bypass_features": true
881+
},
882+
"validium_mode": false
883+
}
884+
},
885+
"db_config": {
886+
"dsn": "postgresql://postgres:shadow_pass@localhost:5433/shadow_rollup"
887+
}
888+
}
889+
```
890+
891+
**Important**: `commit_sender` and `finalize_sender` must be **different addresses**. The relayer enforces this at startup.
892+
893+
### Step 3: Launch Relayer
894+
895+
```bash
896+
/tmp/rollup_relayer \
897+
--config /tmp/rollup-relayer-anvil.json \
898+
--genesis /home/scroll/zzhang/scroll/tests/prover-e2e/mainnet-galileoV2/genesis.json \
899+
--min-codec-version 7 \
900+
--verbosity 3 \
901+
2>&1 | tee /tmp/relayer.log
902+
```
903+
904+
The relayer starts all modules (L2 watcher, proposers, batch committer, bundle finalizer). The batch committer will fail with `ErrorCallerIsNotSequencer` (expected — the commit sender is not a sequencer), but the **bundle finalizer runs independently every 15 seconds** and will pick up the pending bundles.
905+
906+
### Step 4: Monitor Finalization
907+
908+
Watch `/tmp/relayer.log` for:
909+
910+
```
911+
{"msg":"Start to roll up zk proof","index":17297,...}
912+
{"msg":"finalizeBundle in layer1","index":17297,"tx hash":"0x6d62...","with proof":"true"}
913+
```
914+
915+
### Results
916+
917+
| Bundle | Batch | Transaction Hash | Status | Gas Used |
918+
|--------|-------|------------------|--------|----------|
919+
| 17297 | 517761 | `0x6d6264...cdaa725` | ✅ Success | 439,987 |
920+
| 17298 | 517762 | `0x071268...1136516` | ✅ Success | 407,455 |
921+
| 17299 | 517763 | `0x8f8894...6cabd5` | ✅ Success | 407,479 |
922+
| 17300 | 517764 | `0xa87721...302cd3` | ✅ Success | 407,419 |
923+
| 17301 | 517765 | `0x41ee42...c9cf89` | ✅ Success | 401,404 |
924+
925+
**Final `lastFinalizedBatchIndex`**: `517765` (was `517760`)
926+
927+
All 5 bundles finalized consecutively without manual intervention. Each bundle proof was verified on-chain by the `ZkEvmVerifierPostFeynman` contract deployed at `0xb1F2C5c1ea2885278a1070350d12d3D8824265B0`.
928+
929+
### Key Differences from CLI Approach
930+
931+
| Aspect | CLI (`cast send`) | Relayer |
932+
|--------|-------------------|---------|
933+
| Calldata construction | Manual Python script | Relayer reads from DB + constructs automatically |
934+
| Sender management | Single EOA | Separate commit/finalize senders |
935+
| Batch status tracking | None | Updates `bundle` and `batch` `rollup_status` in DB |
936+
| Error handling | Manual retry | Built-in retry and status polling |
937+
| Multi-bundle support | One at a time | Processes all pending bundles automatically |
827938

828939
## Known Limitations
829940

0 commit comments

Comments
 (0)