diff --git a/src/eth/storage/permanent/rocks/rocks_state.rs b/src/eth/storage/permanent/rocks/rocks_state.rs index 4d65f73a4..df98295c1 100644 --- a/src/eth/storage/permanent/rocks/rocks_state.rs +++ b/src/eth/storage/permanent/rocks/rocks_state.rs @@ -301,8 +301,8 @@ impl RocksStorageState { let logs = block .transactions .into_iter() - .flat_map(|transaction| transaction.logs) - .map(|log| LogMined::from_rocks_primitives(log, block.header.number, block.header.hash)); + .flat_map(|transaction| transaction.logs.into_iter().enumerate()) + .map(|(index, log)| LogMined::from_rocks_primitives(log, block.header.number, block.header.hash, 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 2f1c21d8a..c5a3fd93f 100644 --- a/src/eth/storage/permanent/rocks/types/log_mined.rs +++ b/src/eth/storage/permanent/rocks/types/log_mined.rs @@ -4,6 +4,7 @@ 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; #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, fake::Dummy)] @@ -11,7 +12,6 @@ pub struct LogMinedRocksdb { pub log: LogRocksdb, pub transaction_hash: HashRocksdb, pub transaction_index: IndexRocksdb, - pub log_index: IndexRocksdb, } impl From for LogMinedRocksdb { @@ -20,20 +20,19 @@ impl From for LogMinedRocksdb { log: item.log.into(), transaction_hash: item.transaction_hash.into(), transaction_index: item.transaction_index.into(), - log_index: item.log_index.into(), } } } impl LogMined { - pub fn from_rocks_primitives(other: LogMinedRocksdb, block_number: BlockNumberRocksdb, block_hash: HashRocksdb) -> Self { + pub fn from_rocks_primitives(other: LogMinedRocksdb, block_number: BlockNumberRocksdb, block_hash: HashRocksdb, 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: other.log_index.into(), + log_index: Index::from(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 554e568b1..923df1e6e 100644 --- a/src/eth/storage/permanent/rocks/types/transaction_mined.rs +++ b/src/eth/storage/permanent/rocks/types/transaction_mined.rs @@ -36,7 +36,8 @@ impl TransactionMined { logs: other .logs .into_iter() - .map(|log| LogMined::from_rocks_primitives(log, block_number, block_hash)) + .enumerate() + .map(|(log_index, log)| LogMined::from_rocks_primitives(log, block_number, block_hash, log_index)) .collect(), transaction_index: Index::from(index as u64), }