From 07cb9c1b4c1e1282b4381f88b822ee72fb3ebcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 13 Nov 2025 12:09:59 -0300 Subject: [PATCH 1/7] add docs --- docs/SUMMARY.md | 1 + .../l2/state-reconstruction-blobs.md | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 docs/developers/l2/state-reconstruction-blobs.md diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index e84c710022a..02735b553a6 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -76,6 +76,7 @@ - [L2](./developers/l2/introduction.md) - [Ethrex L2 as local development mode](./developers/l2/dev-mode.md) - [Integration tests](./developers/l2/integration-tests.md) + - [Generate blobs for the state reconstruction test](./developers/l2/state-reconstruction-blobs.md) - [Debugging solidity with ethrex](./vm/levm/debug.md) - [Re-execute Ethereum with ethrex](./ethrex_replay/ethrex_replay.md) - [FAQ](./ethrex_replay/faq.md) diff --git a/docs/developers/l2/state-reconstruction-blobs.md b/docs/developers/l2/state-reconstruction-blobs.md new file mode 100644 index 00000000000..551f5d17cff --- /dev/null +++ b/docs/developers/l2/state-reconstruction-blobs.md @@ -0,0 +1,50 @@ +# Generate blobs for the state reconstruction test + +The test in `crates/l2/tests/state_reconstruct.rs` replays a fixed set of blobs to reconstruct. If you ever need to regenerate those fixtures, you need to change the files `payload_builder.rs` and `l1_committer.rs`. + +## 1. Cap block payloads at 10 transactions + +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: + +```rust +if context.payload.body.transactions.len() >= 10 { + println!("Reached max transactions per block limit"); + break; +} +``` + +That guarantees we have transactions in each block for at least 6 batches. + +## 2. Persist every blob locally when the committer sends a batch + +Still in the sequencer, open `crates/l2/sequencer/l1_committer.rs`: + +- At the end of `send_commitment` (after logging the transaction hash) dump the blob that was just submitted: + + ```rust + // Rest of the code ... + info!("Commitment sent: {commit_tx_hash:#x}"); + store_blobs(batch.blobs_bundle.blobs.clone(), batch.number); + Ok(commit_tx_hash) + ``` + +- Add this helper function: + + ```rust + fn store_blobs(blobs: Vec, current_blob: u64) { + let blob = blobs.first().unwrap(); + fs::write(format!("{current_blob}-1.blob"), blob).unwrap(); + } + ``` + +Running the node with the deposits of the rich accounts will create `N-1.blob` files (you can move them into `fixtures/blobs/` afterwards). + +## 3. Run the L2 and capture six blobs + +Start the local L2 with a 20 seconds per commit so we have at least 6 batches with transactions: + +```sh +ethrex l2 --dev --no-monitor --committer.commit-time 20000 +``` + +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). From 70038c7a8763755ba60605a667450adc89d4320f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= <112426153+tomip01@users.noreply.github.com> Date: Thu, 13 Nov 2025 12:56:02 -0300 Subject: [PATCH 2/7] Update docs/developers/l2/state-reconstruction-blobs.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/developers/l2/state-reconstruction-blobs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/l2/state-reconstruction-blobs.md b/docs/developers/l2/state-reconstruction-blobs.md index 551f5d17cff..1eca6ba925d 100644 --- a/docs/developers/l2/state-reconstruction-blobs.md +++ b/docs/developers/l2/state-reconstruction-blobs.md @@ -1,6 +1,6 @@ # Generate blobs for the state reconstruction test -The test in `crates/l2/tests/state_reconstruct.rs` replays a fixed set of blobs to reconstruct. If you ever need to regenerate those fixtures, you need to change the files `payload_builder.rs` and `l1_committer.rs`. +The test in `crates/l2/tests/state_reconstruct.rs` replays a fixed set of blobs to reconstruct the state. If you ever need to regenerate those fixtures, you need to change the files `payload_builder.rs` and `l1_committer.rs`. ## 1. Cap block payloads at 10 transactions From ca50adaed3fff7a2c8c0d3387ed32588fcdc0496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Fri, 14 Nov 2025 19:57:20 -0300 Subject: [PATCH 3/7] sadd suggestion --- docs/developers/l2/state-reconstruction-blobs.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/developers/l2/state-reconstruction-blobs.md b/docs/developers/l2/state-reconstruction-blobs.md index 551f5d17cff..6ed890c3e53 100644 --- a/docs/developers/l2/state-reconstruction-blobs.md +++ b/docs/developers/l2/state-reconstruction-blobs.md @@ -1,6 +1,12 @@ # Generate blobs for the state reconstruction test -The test in `crates/l2/tests/state_reconstruct.rs` replays a fixed set of blobs to reconstruct. If you ever need to regenerate those fixtures, you need to change the files `payload_builder.rs` and `l1_committer.rs`. +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. + +## Summary + +1. Limit every block to ten transactions to make the batches predictable. +2. Store each blob locally whenever the committer submits a batch. +3. Run the dev stack long enough to capture six blobs and move them into `fixtures/blobs/`. ## 1. Cap block payloads at 10 transactions From f3b8f0b3e8ee8d5c764e11cabffa645ea9da78fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Fri, 14 Nov 2025 20:25:19 -0300 Subject: [PATCH 4/7] fix merge --- docs/developers/l2/state-reconstruction-blobs.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/developers/l2/state-reconstruction-blobs.md b/docs/developers/l2/state-reconstruction-blobs.md index e6dd019b436..a648071afac 100644 --- a/docs/developers/l2/state-reconstruction-blobs.md +++ b/docs/developers/l2/state-reconstruction-blobs.md @@ -1,6 +1,5 @@ # Generate blobs for the state reconstruction test -<<<<<<< HEAD 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. ## Summary From 3c983b1ec8e182fc05a729c7179c3f38bbf0b984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Fri, 14 Nov 2025 20:38:20 -0300 Subject: [PATCH 5/7] add compile contracts flag --- docs/developers/l2/state-reconstruction-blobs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/l2/state-reconstruction-blobs.md b/docs/developers/l2/state-reconstruction-blobs.md index a648071afac..d0a783e4fc4 100644 --- a/docs/developers/l2/state-reconstruction-blobs.md +++ b/docs/developers/l2/state-reconstruction-blobs.md @@ -50,7 +50,7 @@ Running the node with the deposits of the rich accounts will create `N-1.blob` f Start the local L2 with a 20 seconds per commit so we have at least 6 batches with transactions: ```sh -cargo run --release --bin ethrex --features l2,l2-sql -- l2 --dev --no-monitor --committer.commit-time 20000 +COMPILE_CONTRACTS=true cargo run --release --bin ethrex --features l2,l2-sql -- l2 --dev --no-monitor --committer.commit-time 20000 ``` 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). From ddf8522f345863daffa25a6647f6c11879fceee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Fri, 14 Nov 2025 20:46:36 -0300 Subject: [PATCH 6/7] run prover step --- docs/developers/l2/state-reconstruction-blobs.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/developers/l2/state-reconstruction-blobs.md b/docs/developers/l2/state-reconstruction-blobs.md index d0a783e4fc4..dd999eafb78 100644 --- a/docs/developers/l2/state-reconstruction-blobs.md +++ b/docs/developers/l2/state-reconstruction-blobs.md @@ -53,4 +53,10 @@ Start the local L2 with a 20 seconds per commit so we have at least 6 batches wi COMPILE_CONTRACTS=true cargo run --release --bin ethrex --features l2,l2-sql -- l2 --dev --no-monitor --committer.commit-time 20000 ``` +In another terminal run: + +```sh +make init-prover-exec +``` + 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). From 113f7e9ec6ead5f02adccf07255523405b9734dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Mon, 17 Nov 2025 16:49:06 -0300 Subject: [PATCH 7/7] flip snippets --- .../developers/l2/state-reconstruction-blobs.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/developers/l2/state-reconstruction-blobs.md b/docs/developers/l2/state-reconstruction-blobs.md index dd999eafb78..13641217a08 100644 --- a/docs/developers/l2/state-reconstruction-blobs.md +++ b/docs/developers/l2/state-reconstruction-blobs.md @@ -25,15 +25,6 @@ That guarantees we have transactions in each block for at least 6 batches. Still in the sequencer, open `crates/l2/sequencer/l1_committer.rs`: -- At the end of `send_commitment` (after logging the transaction hash) dump the blob that was just submitted: - - ```rust - // Rest of the code ... - info!("Commitment sent: {commit_tx_hash:#x}"); - store_blobs(batch.blobs_bundle.blobs.clone(), batch.number); - Ok(commit_tx_hash) - ``` - - Add this helper function: ```rust @@ -43,6 +34,14 @@ Still in the sequencer, open `crates/l2/sequencer/l1_committer.rs`: } ``` +- At the end of `send_commitment` (after logging the transaction hash) dump the blob that was just submitted: + + ```rust + // Rest of the code ... + info!("Commitment sent: {commit_tx_hash:#x}"); + store_blobs(batch.blobs_bundle.blobs.clone(), batch.number); + Ok(commit_tx_hash) ``` + Running the node with the deposits of the rich accounts will create `N-1.blob` files (you can move them into `fixtures/blobs/` afterwards). ## 3. Run the L2 and capture six blobs