Skip to content

Commit

Permalink
refactor: resolve code reviews (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kien-rise committed Sep 10, 2024
1 parent ed8fdff commit ce3bb8d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2021"

[features]
default = ["optimism"]
optimism = [
"revm/optimism",
"dep:op-alloy-consensus",
Expand Down
7 changes: 6 additions & 1 deletion src/chain/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl PevmChain for PevmOptimism {
self.id
}

// TODO: allow to construct deposit transactions
fn build_tx_from_alloy_tx(&self, tx: alloy_rpc_types::Transaction) -> Self::Transaction {
Self::Transaction {
inner: tx,
Expand All @@ -145,9 +146,13 @@ impl PevmChain for PevmOptimism {
} else if header.timestamp >= 1704992401 {
Ok(SpecId::CANYON)
} else if header.number >= 105235063 {
// On Optimism Mainnet, Bedrock and Regolith are activated at the same time.
// Therefore, this function never returns SpecId::BEDROCK.
// The statement above might not be true for other network, e.g. Optimism Goerli.
Ok(SpecId::REGOLITH)
} else {
// TODO: revm does not support when L1Block is not available
// TODO: revm does not support pre-Bedrock blocks.
// https://docs.optimism.io/builders/node-operators/architecture#legacy-geth
Err(OptimismBlockSpecError::UnsupportedSpec)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ impl<'a, S: Storage, C: PevmChain> Vm<'a, S, C> {
&mut write_set,
tx,
U256::from(result_and_state.result.gas_used()),
#[cfg(feature = "optimism")]
&evm.context.evm,
);

Expand Down Expand Up @@ -689,7 +690,7 @@ impl<'a, S: Storage, C: PevmChain> Vm<'a, S, C> {
write_set: &mut WriteSet,
tx: &TxEnv,
gas_used: U256,
#[allow(unused_variables)] evm_context: &EvmContext<DB>,
#[cfg(feature = "optimism")] evm_context: &EvmContext<DB>,
) {
let mut gas_price = if let Some(priority_fee) = tx.gas_priority_fee {
std::cmp::min(tx.gas_price, priority_fee + self.block_env.basefee)
Expand Down

0 comments on commit ce3bb8d

Please sign in to comment.