diff --git a/src/eth/consensus/server.rs b/src/eth/consensus/server.rs index e370a4033..5bdbe811b 100644 --- a/src/eth/consensus/server.rs +++ b/src/eth/consensus/server.rs @@ -384,7 +384,7 @@ impl AppendEntryService for AppendEntryServiceImpl { Status::internal("Failed to get pending transactions") })?; - let transaction_executions: Vec = pending_transactions.iter().filter_map(|tx| tx.inner_local()).collect(); + let transaction_executions: Vec = pending_transactions.into_iter().filter_map(|tx| tx.as_local()).collect(); //TODO move this logic into BlockMiner and add safety checks as consensus is or isnt on follower mode there let block_result = block_from_propagation(block_entry.clone(), transaction_executions); diff --git a/src/eth/primitives/account.rs b/src/eth/primitives/account.rs index bf6d6181f..571aab732 100644 --- a/src/eth/primitives/account.rs +++ b/src/eth/primitives/account.rs @@ -89,7 +89,7 @@ impl From<&Account> for RevmAccountInfo { Self { nonce: value.nonce.into(), balance: value.balance.into(), - code_hash: value.code_hash.inner().0.into(), + code_hash: value.code_hash.0 .0.into(), code: value.bytecode.as_ref().cloned().map_into(), } } diff --git a/src/eth/primitives/code_hash.rs b/src/eth/primitives/code_hash.rs index 74ec35107..82b49b477 100644 --- a/src/eth/primitives/code_hash.rs +++ b/src/eth/primitives/code_hash.rs @@ -12,7 +12,7 @@ use crate::gen_newtype_from; /// In the case of an externally-owned account (EOA), bytecode is null /// and the code hash is fixed as the keccak256 hash of an empty string #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct CodeHash(H256); +pub struct CodeHash(pub H256); impl Dummy for CodeHash { fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { @@ -31,10 +31,6 @@ impl CodeHash { None => CodeHash::default(), } } - - pub fn inner(&self) -> H256 { - self.0 - } } // ----------------------------------------------------------------------------- diff --git a/src/eth/primitives/log_topic.rs b/src/eth/primitives/log_topic.rs index 4bac2430e..8e9ce288c 100644 --- a/src/eth/primitives/log_topic.rs +++ b/src/eth/primitives/log_topic.rs @@ -9,16 +9,12 @@ use crate::gen_newtype_from; /// Topic is part of a [`Log`](super::Log) emitted by the EVM during contract execution. #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Default, Hash)] -pub struct LogTopic(H256); +pub struct LogTopic(pub H256); impl LogTopic { pub fn new(inner: H256) -> Self { Self(inner) } - - pub fn inner(&self) -> H256 { - self.0 - } } impl Display for LogTopic { diff --git a/src/eth/primitives/transaction_execution.rs b/src/eth/primitives/transaction_execution.rs index d31c79f92..212b114e1 100644 --- a/src/eth/primitives/transaction_execution.rs +++ b/src/eth/primitives/transaction_execution.rs @@ -38,11 +38,19 @@ pub enum TransactionExecution { } impl TransactionExecution { - /// Creates a new transaction execution from a local transaction. + /// Creates a new local transaction execution. pub fn new_local(tx: TransactionInput, result: EvmExecutionResult) -> Self { Self::Local(LocalTransactionExecution { input: tx, result }) } + /// Extracts the inner [`LocalTransactionExecution`] if the execution is a local execution. + pub fn as_local(self) -> Option { + match self { + Self::Local(inner) => Some(inner), + _ => None, + } + } + /// Checks if the current transaction was completed normally. pub fn is_success(&self) -> bool { match self { @@ -90,8 +98,8 @@ impl TransactionExecution { Self::Local(LocalTransactionExecution { input, result }) => append_entry::TransactionExecutionEntry { hash: input.hash.as_fixed_bytes().to_vec(), nonce: input.nonce.as_u64(), - value: u256_to_bytes(*input.value.inner()), - gas_price: u256_to_bytes(*input.gas_price.inner()), + value: u256_to_bytes(input.value.0), + gas_price: u256_to_bytes(input.gas_price.0), input: input.input.to_vec(), v: input.v.as_u64(), r: u256_to_bytes(input.r), @@ -108,10 +116,10 @@ impl TransactionExecution { .map(|log| append_entry::Log { address: log.address.as_bytes().to_vec(), topics: vec![ - log.topic0.map_or_else(Vec::new, |t| t.inner().as_bytes().to_vec()), - log.topic1.map_or_else(Vec::new, |t| t.inner().as_bytes().to_vec()), - log.topic2.map_or_else(Vec::new, |t| t.inner().as_bytes().to_vec()), - log.topic3.map_or_else(Vec::new, |t| t.inner().as_bytes().to_vec()), + log.topic0.map_or_else(Vec::new, |t| t.0.as_bytes().to_vec()), + log.topic1.map_or_else(Vec::new, |t| t.0.as_bytes().to_vec()), + log.topic2.map_or_else(Vec::new, |t| t.0.as_bytes().to_vec()), + log.topic3.map_or_else(Vec::new, |t| t.0.as_bytes().to_vec()), ], data: log.data.to_vec(), }) @@ -185,13 +193,6 @@ impl TransactionExecution { Ok(Self::Local(LocalTransactionExecution { input, result })) } - - pub fn inner_local(&self) -> Option { - match self { - Self::Local(inner) => Some(inner.clone()), - _ => None, - } - } } #[derive(DebugAsJson, Clone, derive_new::new, serde::Serialize)] diff --git a/src/eth/primitives/wei.rs b/src/eth/primitives/wei.rs index e7a6d71bf..bde2c4d79 100644 --- a/src/eth/primitives/wei.rs +++ b/src/eth/primitives/wei.rs @@ -19,7 +19,7 @@ use crate::gen_newtype_from; #[derive( Debug, derive_more::Display, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq, derive_more::Add, derive_more::Sub, serde::Serialize, serde::Deserialize, )] -pub struct Wei(U256); +pub struct Wei(pub U256); impl Wei { pub const ZERO: Wei = Wei(U256::zero()); @@ -34,10 +34,6 @@ impl Wei { pub fn is_zero(&self) -> bool { self == &Self::ZERO } - - pub fn inner(&self) -> &U256 { - &self.0 - } } impl Dummy for Wei {