Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaZ030 committed Jan 18, 2024
1 parent 7b0065b commit 115d5fe
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 41 deletions.
89 changes: 60 additions & 29 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ impl Env {
}
}


/// EVM configuration.
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -464,18 +465,6 @@ pub struct BlockEnv {
pub blob_excess_gas_and_price: Option<BlobExcessGasAndPrice>,
}

/// Structure holding block blob excess gas and it calculates blob fee.
///
/// Incorporated as part of the Cancun upgrade via [EIP-4844].
///
/// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BlobExcessGasAndPrice {
pub excess_blob_gas: u64,
pub blob_gasprice: u128,
}

impl BlobExcessGasAndPrice {
/// Takes excess blob gas and calculated blob fee with [`calc_blob_fee`]
pub fn new(excess_blob_gas: u64) -> Self {
Expand All @@ -487,23 +476,6 @@ impl BlobExcessGasAndPrice {
}
}

#[cfg(all(feature = "optimism", not(feature = "taiko")))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OptimismFields {
pub source_hash: Option<B256>,
pub mint: Option<u128>,
pub is_system_transaction: Option<bool>,
/// An enveloped EIP-2718 typed transaction. This is used
/// to compute the L1 tx cost using the L1 block info, as
/// opposed to requiring downstream apps to compute the cost
/// externally.
/// This field is optional to allow the [TxEnv] to be constructed
/// for non-optimism chains when the `optimism` feature is enabled,
/// but the [CfgEnv] `optimism` field is set to false.
pub enveloped_tx: Option<Bytes>,
}

#[cfg(all(feature = "taiko", not(feature = "optimism")))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -644,6 +616,65 @@ impl TxEnv {
}
}

/// Structure holding block blob excess gas and it calculates blob fee.
///
/// Incorporated as part of the Cancun upgrade via [EIP-4844].
///
/// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BlobExcessGasAndPrice {
/// The excess blob gas of the block.
pub excess_blob_gas: u64,
/// The calculated blob gas price based on the `excess_blob_gas`, See [calc_blob_gasprice]
pub blob_gasprice: u128,
}

impl BlobExcessGasAndPrice {
/// Creates a new instance by calculating the blob gas price with [`calc_blob_gasprice`].
pub fn new(excess_blob_gas: u64) -> Self {
let blob_gasprice = calc_blob_gasprice(excess_blob_gas);
Self {
excess_blob_gas,
blob_gasprice,
}
}
}

/// Additional [TxEnv] fields for optimism.
#[cfg(feature = "optimism")]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OptimismFields {
/// The source hash is used to make sure that deposit transactions do
/// not have identical hashes.
///
/// L1 originated deposit transaction source hashes are computed using
/// the hash of the l1 block hash and the l1 log index.
/// L1 attributes deposit source hashes are computed with the l1 block
/// hash and the sequence number = l2 block number - l2 epoch start
/// block number.
///
/// These two deposit transaction sources specify a domain in the outer
/// hash so there are no collisions.
pub source_hash: Option<B256>,
/// The amount to increase the balance of the `from` account as part of
/// a deposit transaction. This is unconditional and is applied to the
/// `from` account even if the deposit transaction fails since
/// the deposit is pre-paid on L1.
pub mint: Option<u128>,
/// Whether or not the transaction is a system transaction.
pub is_system_transaction: Option<bool>,
/// An enveloped EIP-2718 typed transaction. This is used
/// to compute the L1 tx cost using the L1 block info, as
/// opposed to requiring downstream apps to compute the cost
/// externally.
/// This field is optional to allow the [TxEnv] to be constructed
/// for non-optimism chains when the `optimism` feature is enabled,
/// but the [CfgEnv] `optimism` field is set to false.
pub enveloped_tx: Option<Bytes>,
}

impl Default for TxEnv {
fn default() -> Self {
Self {
Expand Down
12 changes: 0 additions & 12 deletions crates/revm/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ impl<'a, H: Host, EXT: 'a, DB: Database + 'a> Handler<'a, H, EXT, DB> {
}
}

/// Handler for the taiko
// #[cfg(all(feature = "taiko", not(feature = "optimism")))]
// pub fn taiko<SPEC: Spec>() -> Self {
// use crate::taiko::handler;
// Self {
// call_return: mainnet::handle_call_return::<SPEC>,
// calculate_gas_refund: mainnet::calculate_gas_refund::<SPEC>,
// reimburse_caller: handler::handle_reimburse_caller::<SPEC, DB>,
// reward_beneficiary: handler::reward_beneficiary::<SPEC, DB>,
// }
// }

/// Creates handler with variable spec id, inside it will call `mainnet::<SPEC>` for
/// appropriate spec.
pub fn mainnet_with_spec(spec_id: SpecId) -> Self {
Expand Down

0 comments on commit 115d5fe

Please sign in to comment.