1use crate::{
3 constants::{
4 BASE_FEE_SCALAR_OFFSET, BLOB_BASE_FEE_SCALAR_OFFSET, DA_FOOTPRINT_GAS_SCALAR_OFFSET,
5 DA_FOOTPRINT_GAS_SCALAR_SLOT, ECOTONE_L1_BLOB_BASE_FEE_SLOT, ECOTONE_L1_FEE_SCALARS_SLOT,
6 EMPTY_SCALARS, L1_BASE_FEE_SLOT, L1_BLOCK_CONTRACT, L1_OVERHEAD_SLOT, L1_SCALAR_SLOT,
7 NON_ZERO_BYTE_COST, OPERATOR_FEE_CONSTANT_OFFSET, OPERATOR_FEE_JOVIAN_MULTIPLIER,
8 OPERATOR_FEE_SCALARS_SLOT, OPERATOR_FEE_SCALAR_DECIMAL, OPERATOR_FEE_SCALAR_OFFSET,
9 },
10 transaction::estimate_tx_compressed_size,
11 OpSpecId,
12};
13use revm::{
14 database_interface::Database,
15 interpreter::{
16 gas::{get_tokens_in_calldata, NON_ZERO_BYTE_MULTIPLIER_ISTANBUL, STANDARD_TOKEN_COST},
17 Gas,
18 },
19 primitives::{hardfork::SpecId, U256},
20};
21
22#[derive(Clone, Debug, Default, PartialEq, Eq)]
34pub struct L1BlockInfo {
35 pub l2_block: U256,
38 pub l1_base_fee: U256,
40 pub l1_fee_overhead: Option<U256>,
42 pub l1_base_fee_scalar: U256,
44 pub l1_blob_base_fee: Option<U256>,
46 pub l1_blob_base_fee_scalar: Option<U256>,
48 pub operator_fee_scalar: Option<U256>,
50 pub operator_fee_constant: Option<U256>,
52 pub da_footprint_gas_scalar: Option<u16>,
54 pub empty_ecotone_scalars: bool,
56 pub tx_l1_cost: Option<U256>,
58}
59
60impl L1BlockInfo {
61 fn try_fetch_jovian<DB: Database>(&mut self, db: &mut DB) -> Result<(), DB::Error> {
63 let da_footprint_gas_scalar_slot = db
64 .storage(L1_BLOCK_CONTRACT, DA_FOOTPRINT_GAS_SCALAR_SLOT)?
65 .to_be_bytes::<32>();
66
67 let bytes = [
69 da_footprint_gas_scalar_slot[DA_FOOTPRINT_GAS_SCALAR_OFFSET],
70 da_footprint_gas_scalar_slot[DA_FOOTPRINT_GAS_SCALAR_OFFSET + 1],
71 ];
72 self.da_footprint_gas_scalar = Some(u16::from_be_bytes(bytes));
73
74 Ok(())
75 }
76
77 fn try_fetch_isthmus<DB: Database>(&mut self, db: &mut DB) -> Result<(), DB::Error> {
79 let operator_fee_scalars = db
81 .storage(L1_BLOCK_CONTRACT, OPERATOR_FEE_SCALARS_SLOT)?
82 .to_be_bytes::<32>();
83
84 self.operator_fee_scalar = Some(U256::from_be_slice(
87 operator_fee_scalars[OPERATOR_FEE_SCALAR_OFFSET..OPERATOR_FEE_SCALAR_OFFSET + 4]
88 .as_ref(),
89 ));
90 self.operator_fee_constant = Some(U256::from_be_slice(
93 operator_fee_scalars[OPERATOR_FEE_CONSTANT_OFFSET..OPERATOR_FEE_CONSTANT_OFFSET + 8]
94 .as_ref(),
95 ));
96
97 Ok(())
98 }
99
100 fn try_fetch_ecotone<DB: Database>(&mut self, db: &mut DB) -> Result<(), DB::Error> {
102 self.l1_blob_base_fee = Some(db.storage(L1_BLOCK_CONTRACT, ECOTONE_L1_BLOB_BASE_FEE_SLOT)?);
103
104 let l1_fee_scalars = db
105 .storage(L1_BLOCK_CONTRACT, ECOTONE_L1_FEE_SCALARS_SLOT)?
106 .to_be_bytes::<32>();
107
108 self.l1_base_fee_scalar = U256::from_be_slice(
109 l1_fee_scalars[BASE_FEE_SCALAR_OFFSET..BASE_FEE_SCALAR_OFFSET + 4].as_ref(),
110 );
111
112 let l1_blob_base_fee = U256::from_be_slice(
113 l1_fee_scalars[BLOB_BASE_FEE_SCALAR_OFFSET..BLOB_BASE_FEE_SCALAR_OFFSET + 4].as_ref(),
114 );
115 self.l1_blob_base_fee_scalar = Some(l1_blob_base_fee);
116
117 self.empty_ecotone_scalars = l1_blob_base_fee.is_zero()
120 && l1_fee_scalars[BASE_FEE_SCALAR_OFFSET..BLOB_BASE_FEE_SCALAR_OFFSET + 4]
121 == EMPTY_SCALARS;
122 self.l1_fee_overhead = self
123 .empty_ecotone_scalars
124 .then(|| db.storage(L1_BLOCK_CONTRACT, L1_OVERHEAD_SLOT))
125 .transpose()?;
126
127 Ok(())
128 }
129
130 pub fn try_fetch<DB: Database>(
132 db: &mut DB,
133 l2_block: U256,
134 spec_id: OpSpecId,
135 ) -> Result<L1BlockInfo, DB::Error> {
136 if spec_id.into_eth_spec().is_enabled_in(SpecId::CANCUN) {
139 let _ = db.basic(L1_BLOCK_CONTRACT)?;
140 }
141
142 let mut out = L1BlockInfo {
143 l2_block,
144 l1_base_fee: db.storage(L1_BLOCK_CONTRACT, L1_BASE_FEE_SLOT)?,
145 ..Default::default()
146 };
147
148 if !spec_id.is_enabled_in(OpSpecId::ECOTONE) {
150 out.l1_base_fee_scalar = db.storage(L1_BLOCK_CONTRACT, L1_SCALAR_SLOT)?;
151 out.l1_fee_overhead = Some(db.storage(L1_BLOCK_CONTRACT, L1_OVERHEAD_SLOT)?);
152
153 return Ok(out);
154 }
155
156 out.try_fetch_ecotone(db)?;
157
158 if spec_id.is_enabled_in(OpSpecId::ISTHMUS) {
160 out.try_fetch_isthmus(db)?;
161 }
162
163 if spec_id.is_enabled_in(OpSpecId::JOVIAN) {
165 out.try_fetch_jovian(db)?;
166 }
167
168 Ok(out)
169 }
170
171 pub fn operator_fee_charge(&self, input: &[u8], gas_limit: U256, spec_id: OpSpecId) -> U256 {
175 if input.is_empty() || input.first() == Some(&0x7E) {
177 return U256::ZERO;
178 }
179
180 self.operator_fee_charge_inner(gas_limit, spec_id)
181 }
182
183 fn operator_fee_charge_inner(&self, gas: U256, spec_id: OpSpecId) -> U256 {
185 let operator_fee_scalar = self
186 .operator_fee_scalar
187 .expect("Missing operator fee scalar for isthmus L1 Block");
188 let operator_fee_constant = self
189 .operator_fee_constant
190 .expect("Missing operator fee constant for isthmus L1 Block");
191
192 let product = if spec_id.is_enabled_in(OpSpecId::JOVIAN) {
193 gas.saturating_mul(operator_fee_scalar)
194 .saturating_mul(U256::from(OPERATOR_FEE_JOVIAN_MULTIPLIER))
195 } else {
196 gas.saturating_mul(operator_fee_scalar) / U256::from(OPERATOR_FEE_SCALAR_DECIMAL)
197 };
198
199 product.saturating_add(operator_fee_constant)
200 }
201
202 pub fn operator_fee_refund(&self, gas: &Gas, spec_id: OpSpecId) -> U256 {
206 if !spec_id.is_enabled_in(OpSpecId::ISTHMUS) {
207 return U256::ZERO;
208 }
209
210 let operator_cost_gas_limit =
211 self.operator_fee_charge_inner(U256::from(gas.limit()), spec_id);
212 let operator_cost_gas_used = self.operator_fee_charge_inner(
213 U256::from(gas.limit() - (gas.remaining() + gas.refunded() as u64)),
214 spec_id,
215 );
216
217 operator_cost_gas_limit.saturating_sub(operator_cost_gas_used)
218 }
219
220 pub fn data_gas(&self, input: &[u8], spec_id: OpSpecId) -> U256 {
228 if spec_id.is_enabled_in(OpSpecId::FJORD) {
229 let estimated_size = self.tx_estimated_size_fjord(input);
230
231 return estimated_size
232 .saturating_mul(U256::from(NON_ZERO_BYTE_COST))
233 .wrapping_div(U256::from(1_000_000));
234 };
235
236 let mut tokens_in_transaction_data = get_tokens_in_calldata(input, true);
238
239 if !spec_id.is_enabled_in(OpSpecId::REGOLITH) {
241 tokens_in_transaction_data += 68 * NON_ZERO_BYTE_MULTIPLIER_ISTANBUL;
242 }
243
244 U256::from(tokens_in_transaction_data.saturating_mul(STANDARD_TOKEN_COST))
245 }
246
247 fn tx_estimated_size_fjord(&self, input: &[u8]) -> U256 {
251 U256::from(estimate_tx_compressed_size(input))
252 }
253
254 pub fn clear_tx_l1_cost(&mut self) {
256 self.tx_l1_cost = None;
257 }
258
259 pub fn calculate_tx_l1_cost(&mut self, input: &[u8], spec_id: OpSpecId) -> U256 {
261 if let Some(tx_l1_cost) = self.tx_l1_cost {
262 return tx_l1_cost;
263 }
264 let tx_l1_cost = if input.is_empty() || input.first() == Some(&0x7E) {
266 return U256::ZERO;
267 } else if spec_id.is_enabled_in(OpSpecId::FJORD) {
268 self.calculate_tx_l1_cost_fjord(input)
269 } else if spec_id.is_enabled_in(OpSpecId::ECOTONE) {
270 self.calculate_tx_l1_cost_ecotone(input, spec_id)
271 } else {
272 self.calculate_tx_l1_cost_bedrock(input, spec_id)
273 };
274
275 self.tx_l1_cost = Some(tx_l1_cost);
276 tx_l1_cost
277 }
278
279 fn calculate_tx_l1_cost_bedrock(&self, input: &[u8], spec_id: OpSpecId) -> U256 {
281 let rollup_data_gas_cost = self.data_gas(input, spec_id);
282 rollup_data_gas_cost
283 .saturating_add(self.l1_fee_overhead.unwrap_or_default())
284 .saturating_mul(self.l1_base_fee)
285 .saturating_mul(self.l1_base_fee_scalar)
286 .wrapping_div(U256::from(1_000_000))
287 }
288
289 fn calculate_tx_l1_cost_ecotone(&self, input: &[u8], spec_id: OpSpecId) -> U256 {
300 if self.empty_ecotone_scalars {
304 return self.calculate_tx_l1_cost_bedrock(input, spec_id);
305 }
306
307 let rollup_data_gas_cost = self.data_gas(input, spec_id);
308 let l1_fee_scaled = self.calculate_l1_fee_scaled_ecotone();
309
310 l1_fee_scaled
311 .saturating_mul(rollup_data_gas_cost)
312 .wrapping_div(U256::from(1_000_000 * NON_ZERO_BYTE_COST))
313 }
314
315 fn calculate_tx_l1_cost_fjord(&self, input: &[u8]) -> U256 {
320 let l1_fee_scaled = self.calculate_l1_fee_scaled_ecotone();
321 let estimated_size = self.tx_estimated_size_fjord(input);
322
323 estimated_size
324 .saturating_mul(l1_fee_scaled)
325 .wrapping_div(U256::from(1_000_000_000_000u64))
326 }
327
328 fn calculate_l1_fee_scaled_ecotone(&self) -> U256 {
330 let calldata_cost_per_byte = self
331 .l1_base_fee
332 .saturating_mul(U256::from(NON_ZERO_BYTE_COST))
333 .saturating_mul(self.l1_base_fee_scalar);
334 let blob_cost_per_byte = self
335 .l1_blob_base_fee
336 .unwrap_or_default()
337 .saturating_mul(self.l1_blob_base_fee_scalar.unwrap_or_default());
338
339 calldata_cost_per_byte.saturating_add(blob_cost_per_byte)
340 }
341}
342
343#[cfg(test)]
344mod tests {
345 use super::*;
346 use revm::primitives::{bytes, hex};
347
348 #[test]
349 fn test_data_gas_non_zero_bytes() {
350 let l1_block_info = L1BlockInfo {
351 l1_base_fee: U256::from(1_000_000),
352 l1_fee_overhead: Some(U256::from(1_000_000)),
353 l1_base_fee_scalar: U256::from(1_000_000),
354 ..Default::default()
355 };
356
357 let input = bytes!("FACADE");
364 let bedrock_data_gas = l1_block_info.data_gas(&input, OpSpecId::BEDROCK);
365 assert_eq!(bedrock_data_gas, U256::from(1136));
366
367 let regolith_data_gas = l1_block_info.data_gas(&input, OpSpecId::REGOLITH);
370 assert_eq!(regolith_data_gas, U256::from(48));
371
372 let fjord_data_gas = l1_block_info.data_gas(&input, OpSpecId::FJORD);
375 assert_eq!(fjord_data_gas, U256::from(1600));
376 }
377
378 #[test]
379 fn test_data_gas_zero_bytes() {
380 let l1_block_info = L1BlockInfo {
381 l1_base_fee: U256::from(1_000_000),
382 l1_fee_overhead: Some(U256::from(1_000_000)),
383 l1_base_fee_scalar: U256::from(1_000_000),
384 ..Default::default()
385 };
386
387 let input = bytes!("FA00CA00DE");
394 let bedrock_data_gas = l1_block_info.data_gas(&input, OpSpecId::BEDROCK);
395 assert_eq!(bedrock_data_gas, U256::from(1144));
396
397 let regolith_data_gas = l1_block_info.data_gas(&input, OpSpecId::REGOLITH);
400 assert_eq!(regolith_data_gas, U256::from(56));
401
402 let fjord_data_gas = l1_block_info.data_gas(&input, OpSpecId::FJORD);
405 assert_eq!(fjord_data_gas, U256::from(1600));
406 }
407
408 #[test]
409 fn test_calculate_tx_l1_cost() {
410 let mut l1_block_info = L1BlockInfo {
411 l1_base_fee: U256::from(1_000),
412 l1_fee_overhead: Some(U256::from(1_000)),
413 l1_base_fee_scalar: U256::from(1_000),
414 ..Default::default()
415 };
416
417 let input = bytes!("FACADE");
418 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::REGOLITH);
419 assert_eq!(gas_cost, U256::from(1048));
420 l1_block_info.clear_tx_l1_cost();
421
422 let input = bytes!("");
424 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::REGOLITH);
425 assert_eq!(gas_cost, U256::ZERO);
426 l1_block_info.clear_tx_l1_cost();
427
428 let input = bytes!("7EFACADE");
430 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::REGOLITH);
431 assert_eq!(gas_cost, U256::ZERO);
432 }
433
434 #[test]
435 fn test_calculate_tx_l1_cost_ecotone() {
436 let mut l1_block_info = L1BlockInfo {
437 l1_base_fee: U256::from(1_000),
438 l1_base_fee_scalar: U256::from(1_000),
439 l1_blob_base_fee: Some(U256::from(1_000)),
440 l1_blob_base_fee_scalar: Some(U256::from(1_000)),
441 l1_fee_overhead: Some(U256::from(1_000)),
442 ..Default::default()
443 };
444
445 let input = bytes!("FACADE");
449 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::ECOTONE);
450 assert_eq!(gas_cost, U256::from(51));
451 l1_block_info.clear_tx_l1_cost();
452
453 let input = bytes!("");
455 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::ECOTONE);
456 assert_eq!(gas_cost, U256::ZERO);
457 l1_block_info.clear_tx_l1_cost();
458
459 let input = bytes!("7EFACADE");
461 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::ECOTONE);
462 assert_eq!(gas_cost, U256::ZERO);
463 l1_block_info.clear_tx_l1_cost();
464
465 l1_block_info.empty_ecotone_scalars = true;
467 let input = bytes!("FACADE");
468 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::ECOTONE);
469 assert_eq!(gas_cost, U256::from(1048));
470 }
471
472 #[test]
473 fn calculate_tx_l1_cost_ecotone() {
474 let l1_block_info = L1BlockInfo {
483 l1_base_fee: U256::from_be_bytes(hex!(
484 "0000000000000000000000000000000000000000000000000000000af39ac327"
485 )), l1_base_fee_scalar: U256::from(1368),
487 l1_blob_base_fee: Some(U256::from_be_bytes(hex!(
488 "0000000000000000000000000000000000000000000000000000000d5ea528d2"
489 ))), l1_blob_base_fee_scalar: Some(U256::from(810949)),
491 ..Default::default()
492 };
493
494 const TX: &[u8] = &hex!("02f8b30a832253fc8402d11f39842c8a46398301388094dc6ff44d5d932cbd77b52e5612ba0529dc6226f180b844a9059cbb000000000000000000000000d43e02db81f4d46cdf8521f623d21ea0ec7562a50000000000000000000000000000000000000000000000008ac7230489e80000c001a02947e24750723b48f886931562c55d9e07f856d8e06468e719755e18bbc3a570a0784da9ce59fd7754ea5be6e17a86b348e441348cd48ace59d174772465eadbd1");
497
498 let expected_l1_gas_used = U256::from(2456);
501 let expected_l1_fee = U256::from_be_bytes(hex!(
502 "000000000000000000000000000000000000000000000000000006a510bd7431" ));
504
505 let gas_used = l1_block_info.data_gas(TX, OpSpecId::ECOTONE);
508
509 assert_eq!(gas_used, expected_l1_gas_used);
510
511 let l1_fee = l1_block_info.calculate_tx_l1_cost_ecotone(TX, OpSpecId::ECOTONE);
512
513 assert_eq!(l1_fee, expected_l1_fee)
514 }
515
516 #[test]
517 fn test_calculate_tx_l1_cost_fjord() {
518 let mut l1_block_info = L1BlockInfo {
522 l1_base_fee: U256::from(1_000),
523 l1_base_fee_scalar: U256::from(1_000),
524 l1_blob_base_fee: Some(U256::from(1_000)),
525 l1_blob_base_fee_scalar: Some(U256::from(1_000)),
526 ..Default::default()
527 };
528
529 let input = bytes!("FACADE");
534 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::FJORD);
538 assert_eq!(gas_cost, U256::from(1700));
539 l1_block_info.clear_tx_l1_cost();
540
541 let input = bytes!("02f901550a758302df1483be21b88304743f94f80e51afb613d764fa61751affd3313c190a86bb870151bd62fd12adb8e41ef24f3f000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000000000000000000000000000000000000003c1e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000148c89ed219d02f1a5be012c689b4f5b731827bebe000000000000000000000000c001a033fd89cb37c31b2cba46b6466e040c61fc9b2a3675a7f5f493ebd5ad77c497f8a07cdf65680e238392693019b4092f610222e71b7cec06449cb922b93b6a12744e");
546 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::FJORD);
550 assert_eq!(gas_cost, U256::from(2148));
551 l1_block_info.clear_tx_l1_cost();
552
553 let input = bytes!("");
555 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::FJORD);
556 assert_eq!(gas_cost, U256::ZERO);
557 l1_block_info.clear_tx_l1_cost();
558
559 let input = bytes!("7EFACADE");
561 let gas_cost = l1_block_info.calculate_tx_l1_cost(&input, OpSpecId::FJORD);
562 assert_eq!(gas_cost, U256::ZERO);
563 }
564
565 #[test]
566 fn calculate_tx_l1_cost_fjord() {
567 let l1_block_info = L1BlockInfo {
572 l1_base_fee: U256::from(1055991687),
573 l1_base_fee_scalar: U256::from(5227),
574 l1_blob_base_fee_scalar: Some(U256::from(1014213)),
575 l1_blob_base_fee: Some(U256::from(1)),
576 ..Default::default() };
578
579 const TX: &[u8] = &hex!("02f904940a8303fba78401d6d2798401db2b6d830493e0943e6f4f7866654c18f536170780344aa8772950b680b904246a761202000000000000000000000000087000a300de7200382b55d40045000000e5d60e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000022482ad56cb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000dc6ff44d5d932cbd77b52e5612ba0529dc6226f1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b300000000000000000000000021c4928109acb0659a88ae5329b5374a3024694c0000000000000000000000000000000000000000000000049b9ca9a6943400000000000000000000000000000000000000000000000000000000000000000000000000000000000021c4928109acb0659a88ae5329b5374a3024694c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024b6b55f250000000000000000000000000000000000000000000000049b9ca9a694340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000415ec214a3950bea839a7e6fbb0ba1540ac2076acd50820e2d5ef83d0902cdffb24a47aff7de5190290769c4f0a9c6fabf63012986a0d590b1b571547a8c7050ea1b00000000000000000000000000000000000000000000000000000000000000c080a06db770e6e25a617fe9652f0958bd9bd6e49281a53036906386ed39ec48eadf63a07f47cf51a4a40b4494cf26efc686709a9b03939e20ee27e59682f5faa536667e");
582
583 let expected_data_gas = U256::from(4471);
586 let expected_l1_fee = U256::from_be_bytes(hex!(
587 "00000000000000000000000000000000000000000000000000000005bf1ab43d"
588 ));
589
590 let data_gas = l1_block_info.data_gas(TX, OpSpecId::FJORD);
593
594 assert_eq!(data_gas, expected_data_gas);
595
596 let l1_fee = l1_block_info.calculate_tx_l1_cost_fjord(TX);
597
598 assert_eq!(l1_fee, expected_l1_fee)
599 }
600
601 #[test]
602 fn test_operator_fee_charge_formulas() {
603 let l1_block_info = L1BlockInfo {
604 operator_fee_scalar: Some(U256::from(1_000u64)),
605 operator_fee_constant: Some(U256::from(10u64)),
606 ..Default::default()
607 };
608
609 let input = [0x01u8];
610
611 let isthmus_fee =
612 l1_block_info.operator_fee_charge(&input, U256::from(1_000u64), OpSpecId::ISTHMUS);
613 assert_eq!(isthmus_fee, U256::from(11u64));
614
615 let jovian_fee =
616 l1_block_info.operator_fee_charge(&input, U256::from(1_000u64), OpSpecId::JOVIAN);
617 assert_eq!(jovian_fee, U256::from(100_000_010u64));
618 }
619
620 #[test]
621 fn test_operator_fee_refund() {
622 let gas = Gas::new(50000);
623
624 let l1_block_info = L1BlockInfo {
625 l1_base_fee: U256::from(1055991687),
626 l1_base_fee_scalar: U256::from(5227),
627 operator_fee_scalar: Some(U256::from(2000)),
628 operator_fee_constant: Some(U256::from(5)),
629 ..Default::default()
630 };
631
632 let refunded = l1_block_info.operator_fee_refund(&gas, OpSpecId::ISTHMUS);
633
634 assert_eq!(refunded, U256::from(100))
635 }
636}