diff --git a/src/eth/storage/permanent/rocks/rocks_state.rs b/src/eth/storage/permanent/rocks/rocks_state.rs index df98295c1..765a328aa 100644 --- a/src/eth/storage/permanent/rocks/rocks_state.rs +++ b/src/eth/storage/permanent/rocks/rocks_state.rs @@ -298,11 +298,11 @@ impl RocksStorageState { } let block = block.into_inner(); - let logs = block - .transactions - .into_iter() - .flat_map(|transaction| transaction.logs.into_iter().enumerate()) - .map(|(index, log)| LogMined::from_rocks_primitives(log, block.header.number, block.header.hash, index)); + let logs = block.transactions.into_iter().enumerate().flat_map(|(tx_index, transaction)| { + transaction.logs.into_iter().enumerate().map(move |(log_index, log)| { + LogMined::from_rocks_primitives(log, block.header.number, block.header.hash, tx_index, transaction.input.hash, log_index) + }) + }); let filtered_logs = logs.filter(|log| filter.matches(log)); logs_result.extend(filtered_logs); diff --git a/src/eth/storage/permanent/rocks/types/log_mined.rs b/src/eth/storage/permanent/rocks/types/log_mined.rs index c5a3fd93f..c5db8d235 100644 --- a/src/eth/storage/permanent/rocks/types/log_mined.rs +++ b/src/eth/storage/permanent/rocks/types/log_mined.rs @@ -2,7 +2,6 @@ use std::fmt::Debug; use super::block_number::BlockNumberRocksdb; use super::hash::HashRocksdb; -use super::index::IndexRocksdb; use super::log::LogRocksdb; use crate::eth::primitives::Index; use crate::eth::primitives::LogMined; @@ -10,29 +9,30 @@ use crate::eth::primitives::LogMined; #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, fake::Dummy)] pub struct LogMinedRocksdb { pub log: LogRocksdb, - pub transaction_hash: HashRocksdb, - pub transaction_index: IndexRocksdb, } impl From for LogMinedRocksdb { fn from(item: LogMined) -> Self { - Self { - log: item.log.into(), - transaction_hash: item.transaction_hash.into(), - transaction_index: item.transaction_index.into(), - } + Self { log: item.log.into() } } } impl LogMined { - pub fn from_rocks_primitives(other: LogMinedRocksdb, block_number: BlockNumberRocksdb, block_hash: HashRocksdb, index: usize) -> Self { + pub fn from_rocks_primitives( + other: LogMinedRocksdb, + block_number: BlockNumberRocksdb, + block_hash: HashRocksdb, + tx_index: usize, + tx_hash: HashRocksdb, + log_index: usize, + ) -> Self { Self { block_number: block_number.into(), block_hash: block_hash.into(), log: other.log.into(), - transaction_hash: other.transaction_hash.into(), - transaction_index: other.transaction_index.into(), - log_index: Index::from(index as u64), + transaction_hash: tx_hash.into(), + transaction_index: Index::from(tx_index as u64), + log_index: Index::from(log_index as u64), } } } diff --git a/src/eth/storage/permanent/rocks/types/transaction_mined.rs b/src/eth/storage/permanent/rocks/types/transaction_mined.rs index 923df1e6e..a21b45f3e 100644 --- a/src/eth/storage/permanent/rocks/types/transaction_mined.rs +++ b/src/eth/storage/permanent/rocks/types/transaction_mined.rs @@ -27,19 +27,20 @@ impl From for TransactionMinedRocksdb { } impl TransactionMined { - pub fn from_rocks_primitives(other: TransactionMinedRocksdb, block_number: BlockNumberRocksdb, block_hash: HashRocksdb, index: usize) -> Self { + pub fn from_rocks_primitives(other: TransactionMinedRocksdb, block_number: BlockNumberRocksdb, block_hash: HashRocksdb, tx_index: usize) -> Self { + let logs = other + .logs + .into_iter() + .enumerate() + .map(|(log_index, log)| LogMined::from_rocks_primitives(log, block_number, block_hash, tx_index, other.input.hash, log_index)) + .collect(); Self { block_number: block_number.into(), block_hash: block_hash.into(), input: other.input.into(), execution: other.execution.into(), - logs: other - .logs - .into_iter() - .enumerate() - .map(|(log_index, log)| LogMined::from_rocks_primitives(log, block_number, block_hash, log_index)) - .collect(), - transaction_index: Index::from(index as u64), + logs, + transaction_index: Index::from(tx_index as u64), } } }