Skip to content

Commit

Permalink
fix: use correct timestamp for op receipt (paradigmxyz#12716)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 20, 2024
1 parent 04729f3 commit 8df9045
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions crates/optimism/rpc/src/eth/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ where

/// L1 fee and data gas for a non-deposit transaction, or deposit nonce and receipt version for a
/// deposit transaction.
#[derive(Debug, Default, Clone)]
#[derive(Debug, Clone)]
pub struct OpReceiptFieldsBuilder {
/// Block timestamp.
pub l1_block_timestamp: u64,
pub block_timestamp: u64,
/// The L1 fee for transaction.
pub l1_fee: Option<u128>,
/// L1 gas used by transaction.
Expand All @@ -84,8 +84,19 @@ pub struct OpReceiptFieldsBuilder {

impl OpReceiptFieldsBuilder {
/// Returns a new builder.
pub fn new(block_timestamp: u64) -> Self {
Self { l1_block_timestamp: block_timestamp, ..Default::default() }
pub const fn new(block_timestamp: u64) -> Self {
Self {
block_timestamp,
l1_fee: None,
l1_data_gas: None,
l1_fee_scalar: None,
l1_base_fee: None,
deposit_nonce: None,
deposit_receipt_version: None,
l1_base_fee_scalar: None,
l1_blob_base_fee: None,
l1_blob_base_fee_scalar: None,
}
}

/// Applies [`L1BlockInfo`](revm::L1BlockInfo).
Expand All @@ -96,7 +107,7 @@ impl OpReceiptFieldsBuilder {
l1_block_info: revm::L1BlockInfo,
) -> Result<Self, OpEthApiError> {
let raw_tx = tx.encoded_2718();
let timestamp = self.l1_block_timestamp;
let timestamp = self.block_timestamp;

self.l1_fee = Some(
l1_block_info
Expand Down Expand Up @@ -140,7 +151,7 @@ impl OpReceiptFieldsBuilder {
/// Builds the [`OpTransactionReceiptFields`] object.
pub const fn build(self) -> OpTransactionReceiptFields {
let Self {
l1_block_timestamp: _, // used to compute other fields
block_timestamp: _, // used to compute other fields
l1_fee,
l1_data_gas: l1_gas_used,
l1_fee_scalar,
Expand Down Expand Up @@ -187,6 +198,7 @@ impl OpReceiptBuilder {
all_receipts: &[Receipt],
l1_block_info: revm::L1BlockInfo,
) -> Result<Self, OpEthApiError> {
let timestamp = meta.timestamp;
let core_receipt =
build_receipt(transaction, meta, receipt, all_receipts, |receipt_with_bloom| {
match receipt.tx_type {
Expand All @@ -211,7 +223,7 @@ impl OpReceiptBuilder {
}
})?;

let op_receipt_fields = OpReceiptFieldsBuilder::default()
let op_receipt_fields = OpReceiptFieldsBuilder::new(timestamp)
.l1_block_info(chain_spec, transaction, l1_block_info)?
.deposit_nonce(receipt.deposit_nonce)
.deposit_version(receipt.deposit_receipt_version)
Expand Down

0 comments on commit 8df9045

Please sign in to comment.