You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(l2): ignore deposits after state reconstruction (#2642)
**Motivation**
Currently, If we start our l2 node with a reconstructed state, the node
will process all deposit logs from l1 and mint them again in l2. This is
because, in a reconstructed store, we don't have the included
transactions to determine whether a deposit was previously processed or
not.
**Description**
- Fixes the reconstruct algorithm to start from batch_number=1.
- Fixes the `l2MintTxHash` emitted in the `CommonBridge` contract.
- Adds an additional check to the `integration_test` to wait for the
deposit receipt on L2.
- Reuses the emitted `l2MintTxHash` instead of recalculating it in the
watcher.
- Checks, in the `CommonBridge` contract, whether a deposit is pending
or not before minting the transaction.
- Creates `DepositData` struct in `l1_watcher`
### How to test
Here we are going to run the integration test on a node with a
reconstructed state.
You may want to lower the `commit_time_ms`.
1. Start the prover and network with:
```
make init-prover
make init
```
2. Wait until batch 6 is verified and stop the l2 node with `ctrl + c`:
```
INFO ethrex_l2::sequencer::l1_proof_sender: Sent proof for batch 6...
ctrl + c
```
> [!NOTE]
> This is because we are going to use already created blobs with 6
batches and we need
> to advance the L1 until that point.
3. Clean db:
```
make rm-db-l2
```
4. Reconstruct the state choosing a `path_to_store`:
```
cargo run --release --manifest-path ../../cmd/ethrex_l2/Cargo.toml --bin ethrex_l2 -- stack reconstruct -g ../../test_data/genesis-l2.json -b ../../test_data/blobs/ -s path_to_store -c 0x0007a881CD95B1484fca47615B64803dad620C8d
```
5. Start the l2 node using `path_to_store`:
```
make init-l2 ethrex_L2_DEV_LIBMDBX=path_to_store
```
You should observe that all deposits are skipped now.
6. In a new terminal, run the integration test:
```
cd crates/l2
make test
```
> [!WARNING]
> Before running the integration test, wait for 20 blocks to be built in
the L2.
> This is because the test currently uses
[estimate_gas_tip](https://github.com/lambdaclass/ethrex/blob/aa3c41b8da043ff5cd1ad699ce882c41edefc460/crates/networking/rpc/eth/fee_calculator.rs#L30)
that needs at least 20 blocks to estimate the gas price.
Closes#1279
0 commit comments