Skip to content

fix(l2): ignore deposits after state reconstruction #2642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/ethrex_l2/src/commands/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl Command {
.await?;
let rollup_store = StoreRollup::new(
store_path
.join("../rollup_store")
.join("./rollup_store")
.to_str()
.expect("Invalid store path"),
EngineTypeRollup::Libmdbx,
Expand All @@ -224,11 +224,12 @@ impl Command {

// Iterate over each blob
let files: Vec<std::fs::DirEntry> = read_dir(blobs_dir)?.try_collect()?;
for (batch_number, file) in files
for (file_number, file) in files
.into_iter()
.sorted_by_key(|f| f.file_name())
.enumerate()
{
let batch_number = file_number as u64 + 1;
let blob = std::fs::read(file.path())?;

if blob.len() != BYTES_PER_BLOB {
Expand Down Expand Up @@ -294,7 +295,7 @@ impl Command {
// Store batch info in L2 storage
rollup_store
.store_batch(
batch_number as u64,
batch_number,
first_block_number,
last_block_number,
withdrawal_hashes,
Expand Down
2 changes: 1 addition & 1 deletion crates/l2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ethrex_L2_CONTRACTS_PATH=./contracts
L1_RPC_URL=http://localhost:8545
L1_PRIVATE_KEY=0x385c546456b6a603a1cfcaa9ec9494ba4832da08dd6bcf4de9a71e4a01b74924

ethrex_L2_DEV_LIBMDBX=dev_ethrex_l2
ethrex_L2_DEV_LIBMDBX?=dev_ethrex_l2
ethrex_L1_DEV_LIBMDBX=dev_ethrex_l1
L1_PORT=8545
L2_PORT=1729
Expand Down
2 changes: 1 addition & 1 deletion crates/l2/configs/sequencer_config_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ maximum_allowed_max_fee_per_gas = 10000000000
maximum_allowed_max_fee_per_blob_gas = 10000000000

[watcher]
bridge_address = "0x266ffef34e21a7c4ce2e0e42dc780c2c273ca440"
bridge_address = "0x554a14cd047c485b3ac3edbd9fbb373d6f84ad3f"
check_interval_ms = 1000
max_block_step = 5000
l2_proposer_private_key = "0x385c546456b6a603a1cfcaa9ec9494ba4832da08dd6bcf4de9a71e4a01b74924"
Expand Down
31 changes: 10 additions & 21 deletions crates/l2/contracts/src/l1/CommonBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,19 @@ contract CommonBridge is ICommonBridge, Ownable, ReentrancyGuard {
require(msg.value > 0, "CommonBridge: amount to deposit is zero");

bytes32 l2MintTxHash = keccak256(
abi.encodePacked(
msg.sender,
depositValues.to,
depositValues.recipient,
msg.value,
depositValues.gasLimit,
depositId,
depositValues.data
bytes.concat(
bytes20(depositValues.to),
bytes32(msg.value),
bytes32(depositId),
bytes20(depositValues.recipient),
bytes20(msg.sender),
bytes32(depositValues.gasLimit),
bytes32(keccak256(depositValues.data))
)
);

pendingDepositLogs.push(
keccak256(
bytes.concat(
bytes20(depositValues.to),
bytes32(msg.value),
bytes32(depositId),
bytes20(depositValues.recipient),
bytes20(msg.sender),
bytes32(depositValues.gasLimit),
bytes32(keccak256(depositValues.data))
)
)
);
pendingDepositLogs.push(l2MintTxHash);

emit DepositInitiated(
msg.value,
depositValues.to,
Expand Down
8 changes: 4 additions & 4 deletions crates/l2/sdk/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
pub mod calldata;
pub mod merkle_tree;

// 0x6bf26397c5676a208d5c4e5f35cb479bacbbe454
// 0x554a14cd047c485b3ac3edbd9fbb373d6f84ad3f
pub const DEFAULT_BRIDGE_ADDRESS: Address = H160([
0x6b, 0xf2, 0x63, 0x97, 0xc5, 0x67, 0x6a, 0x20, 0x8d, 0x5c, 0x4e, 0x5f, 0x35, 0xcb, 0x47, 0x9b,
0xac, 0xbb, 0xe4, 0x54,
0x55, 0x4a, 0x14, 0xcd, 0x04, 0x7c, 0x48, 0x5b, 0x3a, 0xc3, 0xed, 0xbd, 0x9f, 0xbb, 0x37, 0x3d,
0x6f, 0x84, 0xad, 0x3f,
]);

pub const COMMON_BRIDGE_L2_ADDRESS: Address = H160([
Expand All @@ -32,7 +32,7 @@ pub enum SdkError {
FailedToParseAddressFromHex,
}

/// BRIDGE_ADDRESS or 0x6bf26397c5676a208d5c4e5f35cb479bacbbe454
/// BRIDGE_ADDRESS or 0x554a14cd047c485b3ac3edbd9fbb373d6f84ad3f
pub fn bridge_address() -> Result<Address, SdkError> {
std::env::var("L1_WATCHER_BRIDGE_ADDRESS")
.unwrap_or(format!("{DEFAULT_BRIDGE_ADDRESS:#x}"))
Expand Down
Loading