Skip to content

Commit

Permalink
non exclusive op & taiko flags
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaZ030 committed Jan 18, 2024
1 parent 115d5fe commit 983db4b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 41 deletions.
2 changes: 0 additions & 2 deletions crates/interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#[cfg(all(feature = "optimism", feature = "taiko"))]
compile_error!("Features 'optimism' and 'taiko' cannot be enabled at the same time.");

extern crate alloc;

Expand Down
2 changes: 0 additions & 2 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#[cfg(all(feature = "optimism", feature = "taiko"))]
compile_error!("Features 'optimism' and 'taiko' cannot be enabled at the same time.");

#[macro_use]
extern crate alloc;
Expand Down
25 changes: 8 additions & 17 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ impl Env {
}
}


/// EVM configuration.
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -320,7 +319,8 @@ pub struct CfgEnv {
#[cfg(all(feature = "optimism", not(feature = "taiko")))]
pub optimism: bool,

#[cfg(all(feature = "taiko", not(feature = "optimism")))] pub taiko: bool,
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
pub taiko: bool,
}

impl CfgEnv {
Expand Down Expand Up @@ -389,7 +389,8 @@ impl CfgEnv {
self.optimism
}

#[cfg(all(feature = "taiko", not(feature = "optimism")))] pub fn is_taiko(&self) -> bool {
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
pub fn is_taiko(&self) -> bool {
self.taiko
}
}
Expand Down Expand Up @@ -465,17 +466,6 @@ pub struct BlockEnv {
pub blob_excess_gas_and_price: Option<BlobExcessGasAndPrice>,
}

impl BlobExcessGasAndPrice {
/// Takes excess blob gas and calculated blob fee with [`calc_blob_fee`]
pub fn new(excess_blob_gas: u64) -> Self {
let blob_gasprice = calc_blob_gasprice(excess_blob_gas);
Self {
excess_blob_gas,
blob_gasprice,
}
}
}

#[cfg(all(feature = "taiko", not(feature = "optimism")))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand All @@ -484,7 +474,6 @@ pub struct TaikoFields {
pub is_anchor: bool,
}


impl BlockEnv {
/// Takes `blob_excess_gas` saves it inside env
/// and calculates `blob_fee` with [`BlobExcessGasAndPrice`].
Expand Down Expand Up @@ -597,7 +586,8 @@ pub struct TxEnv {
pub optimism: OptimismFields,

#[cfg_attr(feature = "serde", serde(flatten))]
#[cfg(all(feature = "taiko", not(feature = "optimism")))] pub taiko: TaikoFields,
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
pub taiko: TaikoFields,
}

impl TxEnv {
Expand Down Expand Up @@ -813,7 +803,8 @@ mod tests {
.is_ok());
}

#[cfg(all(feature = "taiko", not(feature = "optimism")))] #[test]
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
#[test]
fn test_taiko() {
// TODO(Cecilia): taiko tests
}
Expand Down
2 changes: 0 additions & 2 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#[cfg(all(feature = "optimism", feature = "taiko"))]
compile_error!("Features 'optimism' and 'taiko' cannot be enabled at the same time.");

extern crate alloc;

Expand Down
8 changes: 3 additions & 5 deletions crates/primitives/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ pub enum InvalidTransaction {
HaltedDepositPostRegolith,

/// Anchor check failed
#[cfg(all(feature = "taiko", not(feature = "optimism")))] InvalidAnchorTransaction,
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
InvalidAnchorTransaction,
}

#[cfg(feature = "std")]
Expand Down Expand Up @@ -330,10 +331,7 @@ impl fmt::Display for InvalidTransaction {
}
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
InvalidTransaction::InvalidAnchorTransaction => {
write!(
f,
"Invalid Anchor transaction."
)
write!(f, "Invalid Anchor transaction.")
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions crates/primitives/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ pub use SpecId::*;
/// Specification IDs and their activation block.
///
/// Information was obtained from the [Ethereum Execution Specifications](https://github.com/ethereum/execution-specs)
#[cfg(all(not(feature = "optimism"), not(feature = "taiko")))]
#[cfg(any(
all(feature = "optimism", feature = "taiko"),
all(not(feature = "optimism"), not(feature = "taiko"))
))]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, enumn::N)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -65,7 +68,8 @@ pub enum SpecId {
/// Specification IDs and their activation block.
///
/// Information was obtained from the [Ethereum Execution Specifications](https://github.com/ethereum/execution-specs)
#[cfg(all(feature = "taiko", not(feature = "optimism")))]#[repr(u8)]
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, enumn::N)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SpecId {
Expand Down Expand Up @@ -130,7 +134,7 @@ impl From<&str> for SpecId {
"Regolith" => SpecId::REGOLITH,
#[cfg(all(feature = "optimism", not(feature = "taiko")))]
"Canyon" => SpecId::CANYON,
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
"Katla" => SpecId::KATLA,
_ => Self::LATEST,
}
Expand Down Expand Up @@ -380,10 +384,11 @@ mod optimism_tests {
}
}

#[cfg(all(feature = "taiko", not(feature = "optimism")))]#[cfg(test)]
#[cfg(all(feature = "taiko", not(feature = "optimism")))]
#[cfg(test)]
mod tests {
use super::*;

// TODO(Cecilia): update this range of bits
#[test]
fn test_katla_post_merge_hardforks() {
Expand All @@ -393,4 +398,4 @@ mod tests {
assert!(!SpecId::enabled(SpecId::LATEST));
assert!(SpecId::enabled(SpecId::KATLA));
}
}
}
2 changes: 0 additions & 2 deletions crates/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(all(feature = "optimism", feature = "taiko"))]
compile_error!("Features 'optimism' and 'taiko' cannot be enabled at the same time.");

#[macro_use]
extern crate alloc;
Expand Down
4 changes: 0 additions & 4 deletions crates/revm/src/taiko.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
//! Optimism-specific constants, types, and helpers.
mod handler_register;

pub use handler_register::{
// deduct_caller, end, handle_call_return, optimism_handle_register, output, reward_beneficiary,
};
2 changes: 1 addition & 1 deletion crates/revm/src/taiko/handler_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ use crate::{
HashMap, InvalidTransaction, Output, ResultAndState, Spec, SpecId, U256,
},
Context,
};
};

0 comments on commit 983db4b

Please sign in to comment.