Skip to content

Commit df7c721

Browse files
check if blob size is within limits and return error (#906)
* check if blob size is within limits and return error * build L2BlockV2Draft and use can_consume_l2_block for blob size validation * bump version --------- Co-authored-by: mikhailUshakoff <75278099+mikhailUshakoff@users.noreply.github.com>
1 parent 6df4740 commit df7c721

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resolver = "2"
1313
default-members = ["node"]
1414

1515
[workspace.package]
16-
version = "1.34.7"
16+
version = "1.34.8"
1717
edition = "2024"
1818
repository = "https://github.com/NethermindEth/Catalyst"
1919
license = "MIT"

shasta/src/node/proposal_manager/proposal_builder.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,23 @@ impl ProposalBuilder {
242242
let bytes_length =
243243
crate::shared::l2_tx_lists::encode_and_compress(&tx_list)?.len() as u64;
244244

245+
let l2_draft_block = L2BlockV2Draft {
246+
prebuilt_tx_list: PreBuiltTxList {
247+
tx_list: tx_list.clone(),
248+
estimated_gas_used: 0,
249+
bytes_length,
250+
},
251+
timestamp_sec: l2_block_timestamp_sec,
252+
gas_limit_without_anchor: gas_limit,
253+
};
254+
if !self.can_consume_l2_block(&l2_draft_block) {
255+
return Err(anyhow::anyhow!(
256+
"recover_from: block does not fit in proposal {} (adding {} bytes would exceed blob size limit). Reorg needed.",
257+
proposal_id,
258+
bytes_length,
259+
));
260+
}
261+
245262
let l2_block = L2BlockV2::new_from(
246263
crate::shared::l2_tx_lists::PreBuiltTxList {
247264
tx_list,
@@ -254,10 +271,6 @@ impl ProposalBuilder {
254271
gas_limit,
255272
);
256273

257-
// TODO we add block to the current proposal.
258-
// But we should verify that it fit N blob data size
259-
// Otherwise we should do a reorg
260-
261274
// at previous step we check that proposal exists
262275
self.add_l2_block_and_get_current_proposal(l2_block)?;
263276
}

0 commit comments

Comments
 (0)