Skip to content

Commit 7e75e42

Browse files
tomip01Copilot
andauthored
docs(l2): add guide to re generate blobs (#5317)
**Motivation** We want to document how to create the blobs for the state reconstruct test. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 060a64f commit 7e75e42

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
- [L2](./developers/l2/introduction.md)
7777
- [Ethrex L2 as local development mode](./developers/l2/dev-mode.md)
7878
- [Integration tests](./developers/l2/integration-tests.md)
79+
- [Generate blobs for the state reconstruction test](./developers/l2/state-reconstruction-blobs.md)
7980
- [Debugging solidity with ethrex](./vm/levm/debug.md)
8081
- [Re-execute Ethereum with ethrex](./ethrex_replay/ethrex_replay.md)
8182
- [FAQ](./ethrex_replay/faq.md)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Generate blobs for the state reconstruction test
2+
3+
The test in `crates/l2/tests/state_reconstruct.rs` replays a fixed set of blobs to reconstruct. The fixtures need to be regenerated whenever the genesis file changes, because a new genesis alters the hash of the very first block and, by extension, all descendant blocks. Our stored blobs encode parent pointers, so stale hashes make the fixtures unusable. If you ever need to regenerate those blobs, you need to change the files `payload_builder.rs` and `l1_committer.rs` and run the sequencer to capture fresh blobs.
4+
5+
## Summary
6+
7+
1. Limit every block to ten transactions to make the batches predictable.
8+
2. Store each blob locally whenever the committer submits a batch.
9+
3. Run the dev stack long enough to capture six blobs and move them into `fixtures/blobs/`.
10+
11+
## 1. Cap block payloads at 10 transactions
12+
13+
Edit `crates/l2/sequencer/block_producer/payload_builder.rs` and, inside the `fill_transactions` loop, add the early exit that forces every L2 block to contain at most ten transactions:
14+
15+
```rust
16+
if context.payload.body.transactions.len() >= 10 {
17+
println!("Reached max transactions per block limit");
18+
break;
19+
}
20+
```
21+
22+
That guarantees we have transactions in each block for at least 6 batches.
23+
24+
## 2. Persist every blob locally when the committer sends a batch
25+
26+
Still in the sequencer, open `crates/l2/sequencer/l1_committer.rs`:
27+
28+
- Add this helper function:
29+
30+
```rust
31+
fn store_blobs(blobs: Vec<Blob>, current_blob: u64) {
32+
let blob = blobs.first().unwrap();
33+
fs::write(format!("{current_blob}-1.blob"), blob).unwrap();
34+
}
35+
```
36+
37+
- At the end of `send_commitment` (after logging the transaction hash) dump the blob that was just submitted:
38+
39+
```rust
40+
// Rest of the code ...
41+
info!("Commitment sent: {commit_tx_hash:#x}");
42+
store_blobs(batch.blobs_bundle.blobs.clone(), batch.number);
43+
Ok(commit_tx_hash) ```
44+
45+
Running the node with the deposits of the rich accounts will create `N-1.blob` files (you can move them into `fixtures/blobs/` afterwards).
46+
47+
## 3. Run the L2 and capture six blobs
48+
49+
Start the local L2 with a 20 seconds per commit so we have at least 6 batches with transactions:
50+
51+
```sh
52+
COMPILE_CONTRACTS=true cargo run --release --bin ethrex --features l2,l2-sql -- l2 --dev --no-monitor --committer.commit-time 20000
53+
```
54+
55+
In another terminal run:
56+
57+
```sh
58+
make init-prover-exec
59+
```
60+
61+
Once the sequencer has produced six batches you will see six files named `1-1.blob` through `6-1.blob`. Copy them into `fixtures/blobs/` (overwriting the existing files).

0 commit comments

Comments
 (0)