Skip to content

Commit

Permalink
fix: op fee fields (#10615)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Aug 29, 2024
1 parent 671adf5 commit a4f405a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions crates/optimism/rpc/src/eth/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,30 @@ pub fn op_receipt_fields(
op_fields.deposit_nonce = receipt.deposit_nonce;
op_fields.deposit_receipt_version = receipt.deposit_receipt_version;
} else if let Some(l1_block_info) = optimism_tx_meta.l1_block_info {
// always present
op_fields.l1_fee = optimism_tx_meta.l1_fee;
op_fields.l1_gas_price = Some(l1_block_info.l1_base_fee.saturating_to());
op_fields.l1_gas_used = optimism_tx_meta.l1_data_gas.map(|dg| {
dg.saturating_add(
l1_block_info.l1_fee_overhead.unwrap_or_default().saturating_to::<u128>(),
)
});
op_fields.l1_fee_scalar = Some(f64::from(l1_block_info.l1_base_fee_scalar) / 1_000_000.0);
op_fields.l1_gas_price = Some(l1_block_info.l1_base_fee.saturating_to());

// we know if we're __pre__ Ecotone by checking the l1 fee overhead value which is
// None if ecotone is active
if l1_block_info.l1_fee_overhead.is_some() {
// only pre Ecotone
op_fields.l1_fee_scalar =
Some(f64::from(l1_block_info.l1_base_fee_scalar) / 1_000_000.0);
} else {
// base fee scalar is enabled post Ecotone
op_fields.l1_base_fee_scalar = Some(l1_block_info.l1_base_fee_scalar.saturating_to());
}

// 4844 post Ecotone
op_fields.l1_blob_base_fee = l1_block_info.l1_blob_base_fee.map(|v| v.saturating_to());
op_fields.l1_blob_base_fee_scalar =
l1_block_info.l1_blob_base_fee_scalar.map(|v| v.saturating_to());
}

resp_builder.add_other_fields(op_fields.into())
Expand Down

0 comments on commit a4f405a

Please sign in to comment.