Skip to content

Commit

Permalink
Add base_fee_per_gas to Epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
intoverflow committed Nov 30, 2023
1 parent a8748f6 commit 65d04d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/src/optimism/derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use serde::{Deserialize, Serialize};
use zeth_primitives::{BlockHash, BlockNumber, B256};
use zeth_primitives::{BlockHash, BlockNumber, B256, U256};

use super::config::ChainConfig;

Expand All @@ -33,6 +33,7 @@ pub struct Epoch {
pub number: BlockNumber,
pub hash: B256,
pub timestamp: u64,
pub base_fee_per_gas: U256,
}

#[derive(Debug, Clone, Default)]
Expand Down
16 changes: 6 additions & 10 deletions lib/src/optimism/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ impl<D: BatcherDb> DeriveMachine<D> {
number: eth_block_no,
hash: eth_head_hash,
timestamp: eth_head.timestamp.try_into().unwrap(),
base_fee_per_gas: eth_head.base_fee_per_gas,
},
next_epoch: None,
},
Expand Down Expand Up @@ -452,6 +453,7 @@ impl<D: BatcherDb> DeriveMachine<D> {
number: self.eth_block_no,
hash: eth_block_hash,
timestamp: eth_block.block_header.timestamp.try_into().unwrap(),
base_fee_per_gas: eth_block.block_header.base_fee_per_gas,
});
self.deque_next_epoch_if_none()?;

Expand Down Expand Up @@ -512,23 +514,17 @@ impl<D: BatcherDb> DeriveMachine<D> {
}

fn derive_system_transaction(&mut self, op_batch: &Batch) -> Transaction<OptimismTxEssence> {
let eth_block_header = &self
.derive_input
.db
.get_eth_block_header(self.op_batches.state.epoch.number)
.expect("block not found");

let batcher_hash = {
let all_zero: FixedBytes<12> = FixedBytes([0_u8; 12]);
all_zero.concat_const::<20, 32>(self.op_batches.config.system_config.batch_sender.0)
};

let set_l1_block_values =
OpSystemInfo::OpSystemInfoCalls::setL1BlockValues(OpSystemInfo::setL1BlockValuesCall {
number: eth_block_header.number,
timestamp: eth_block_header.timestamp.try_into().unwrap(),
basefee: eth_block_header.base_fee_per_gas,
hash: eth_block_header.hash(),
number: self.op_batches.state.epoch.number,
timestamp: self.op_batches.state.epoch.timestamp,
basefee: self.op_batches.state.epoch.base_fee_per_gas,
hash: self.op_batches.state.epoch.hash,
sequence_number: self.op_block_seq_no,
batcher_hash,
l1_fee_overhead: self.op_batches.config.system_config.l1_fee_overhead,
Expand Down

0 comments on commit 65d04d8

Please sign in to comment.