Skip to content

Commit 54e4e90

Browse files
authored
feat: limit tx l1 data cost to u64 max (#43)
1 parent 292c8a7 commit 54e4e90

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/l1block.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const L1_COMMIT_SCALAR_SLOT: U256 = U256::from_limbs([6u64, 0, 0, 0]);
4242
/// The L1 blob scalar storage slot.
4343
const L1_BLOB_SCALAR_SLOT: U256 = U256::from_limbs([7u64, 0, 0, 0]);
4444

45+
const U64_MAX: U256 = U256::from_limbs([u64::MAX, 0, 0, 0]);
46+
4547
// L1 BLOCK INFO
4648
// ================================================================================================
4749

@@ -138,10 +140,11 @@ impl L1BlockInfo {
138140

139141
/// Calculate the gas cost of a transaction based on L1 block data posted on L2.
140142
pub fn calculate_tx_l1_cost(&self, input: &[u8], spec_id: ScrollSpecId) -> U256 {
141-
if !spec_id.is_enabled_in(ScrollSpecId::CURIE) {
143+
let l1_cost = if !spec_id.is_enabled_in(ScrollSpecId::CURIE) {
142144
self.calculate_tx_l1_cost_shanghai(input, spec_id)
143145
} else {
144146
self.calculate_tx_l1_cost_curie(input, spec_id)
145-
}
147+
};
148+
l1_cost.min(U64_MAX)
146149
}
147150
}

0 commit comments

Comments
 (0)