From 15bab998fc26a34071c2035d764d4ed56199b685 Mon Sep 17 00:00:00 2001 From: Niven Date: Thu, 25 Jan 2024 15:15:27 +0800 Subject: [PATCH] EVM: Fix LogIndex serialization (#2796) * Fix logindex serialization * Cleanup comments * Fix typo --- lib/ain-evm/src/log.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/ain-evm/src/log.rs b/lib/ain-evm/src/log.rs index 9b5fe4d074..d890369b32 100644 --- a/lib/ain-evm/src/log.rs +++ b/lib/ain-evm/src/log.rs @@ -13,32 +13,30 @@ use crate::{ /// Log represents a contract log event. These events are generated by the LOG opcode /// and stored/indexed by the node. +/// Consensus fields: address, topics, data. +/// Derived fields (filled in by node, not secured by consensus): block number, block hash, +/// tx index, tx hash, log index, removed flag. #[derive(Serialize, Deserialize, Clone, Debug)] pub struct LogIndex { - // Consensus fields: - // Address of the contract that generated the event - pub address: H160, + // Hash of the block in which the transaction was included + pub block_hash: H256, + // Block in which the transaction was included + pub block_number: U256, // List of topics provided by the contract pub topics: Vec, // Supplied by the contract, usually ABI-encoded pub data: Vec, - - // Derived fields. These fields are filled in by the node - // but not secured by consensus. - // Block in which the transaction was included - pub block_number: U256, - // Hash of the transaction - pub transaction_hash: H256, - // Index of the transaction in the block - pub transaction_index: U256, - // Hash of the block in which the transaction was included - pub block_hash: H256, // Index of the log in the block pub log_index: U256, - + // Address of the contract that generated the event + pub address: H160, // The removed field is true if this log was reverted due to a chain reorganization. // You must pay attention to this field if you receive logs through a filter query. pub removed: bool, + // Hash of the transaction + pub transaction_hash: H256, + // Index of the transaction in the block + pub transaction_index: U256, } pub enum Notification {