From 25e69be2f9aef958fac6cabbac3aa4d789932661 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Tue, 19 Nov 2024 14:41:55 +0100 Subject: [PATCH] add tx_hash to all tables --- blocks/evm/src/code_changes.rs | 6 ++++ blocks/evm/src/creation_traces.rs | 4 ++- blocks/evm/src/gas_changes.rs | 8 ++++- blocks/evm/src/nonce_changes.rs | 6 ++++ blocks/evm/src/pb/evm.rs | 52 +++++++++++++++++++------------ blocks/evm/src/storage_changes.rs | 6 ++++ blocks/evm/src/traces.rs | 4 +-- proto/evm.proto | 52 +++++++++++++++++++------------ 8 files changed, 93 insertions(+), 45 deletions(-) diff --git a/blocks/evm/src/code_changes.rs b/blocks/evm/src/code_changes.rs index f8ff278..9f142cc 100644 --- a/blocks/evm/src/code_changes.rs +++ b/blocks/evm/src/code_changes.rs @@ -19,6 +19,9 @@ pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec Vec Vec block_hash: timestamp.hash.clone(), block_date: timestamp.date.clone(), + // transaction + tx_hash: bytes_to_hex(&trace.hash), + // creation trace from: bytes_to_hex(&trace.from), - tx_hash: bytes_to_hex(&trace.hash), address: bytes_to_hex(&code.address), factory: factory.to_string(), code: bytes_to_hex(&code.new_code), diff --git a/blocks/evm/src/gas_changes.rs b/blocks/evm/src/gas_changes.rs index 9a172b1..be1577d 100644 --- a/blocks/evm/src/gas_changes.rs +++ b/blocks/evm/src/gas_changes.rs @@ -1,4 +1,4 @@ -use common::structs::BlockTimestamp; +use common::{structs::BlockTimestamp, utils::bytes_to_hex}; use substreams_ethereum::pb::eth::v2::Block; use crate::pb::evm::GasChange; @@ -50,6 +50,9 @@ pub fn collect_gas_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec Vec Vec Vec, /// -- storage change -- /// /// block global ordinal - #[prost(uint64, tag="5")] + #[prost(uint64, tag="6")] pub ordinal: u64, - #[prost(string, tag="6")] - pub address: ::prost::alloc::string::String, #[prost(string, tag="7")] - pub key: ::prost::alloc::string::String, + pub address: ::prost::alloc::string::String, #[prost(string, tag="8")] - pub new_value: ::prost::alloc::string::String, + pub key: ::prost::alloc::string::String, #[prost(string, tag="9")] + pub new_value: ::prost::alloc::string::String, + #[prost(string, tag="10")] pub old_value: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] @@ -365,20 +368,23 @@ pub struct CodeChange { pub block_hash: ::prost::alloc::string::String, #[prost(string, tag="4")] pub block_date: ::prost::alloc::string::String, + /// -- transaction -- + #[prost(string, optional, tag="5")] + pub tx_hash: ::core::option::Option<::prost::alloc::string::String>, /// -- code change -- /// /// block global ordinal - #[prost(uint64, tag="5")] + #[prost(uint64, tag="6")] pub ordinal: u64, - #[prost(string, tag="6")] - pub address: ::prost::alloc::string::String, #[prost(string, tag="7")] - pub old_hash: ::prost::alloc::string::String, + pub address: ::prost::alloc::string::String, #[prost(string, tag="8")] - pub old_code: ::prost::alloc::string::String, + pub old_hash: ::prost::alloc::string::String, #[prost(string, tag="9")] - pub new_hash: ::prost::alloc::string::String, + pub old_code: ::prost::alloc::string::String, #[prost(string, tag="10")] + pub new_hash: ::prost::alloc::string::String, + #[prost(string, tag="11")] pub new_code: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] @@ -416,16 +422,19 @@ pub struct NonceChange { pub block_hash: ::prost::alloc::string::String, #[prost(string, tag="4")] pub block_date: ::prost::alloc::string::String, + /// -- transaction -- + #[prost(string, optional, tag="5")] + pub tx_hash: ::core::option::Option<::prost::alloc::string::String>, /// -- nonce change -- /// /// block global ordinal - #[prost(uint64, tag="5")] + #[prost(uint64, tag="6")] pub ordinal: u64, - #[prost(string, tag="6")] + #[prost(string, tag="7")] pub address: ::prost::alloc::string::String, - #[prost(uint64, tag="7")] - pub old_value: u64, #[prost(uint64, tag="8")] + pub old_value: u64, + #[prost(uint64, tag="9")] pub new_value: u64, } #[allow(clippy::derive_partial_eq_without_eq)] @@ -440,18 +449,21 @@ pub struct GasChange { pub block_hash: ::prost::alloc::string::String, #[prost(string, tag="4")] pub block_date: ::prost::alloc::string::String, + /// -- transaction -- + #[prost(string, optional, tag="5")] + pub tx_hash: ::core::option::Option<::prost::alloc::string::String>, /// -- gas change -- /// /// block global ordinal - #[prost(uint64, tag="5")] - pub ordinal: u64, #[prost(uint64, tag="6")] - pub old_value: u64, + pub ordinal: u64, #[prost(uint64, tag="7")] + pub old_value: u64, + #[prost(uint64, tag="8")] pub new_value: u64, - #[prost(string, tag="8")] + #[prost(string, tag="9")] pub reason: ::prost::alloc::string::String, - #[prost(uint32, tag="9")] + #[prost(uint32, tag="10")] pub reason_code: u32, } #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/blocks/evm/src/storage_changes.rs b/blocks/evm/src/storage_changes.rs index 710b93b..9117e7d 100644 --- a/blocks/evm/src/storage_changes.rs +++ b/blocks/evm/src/storage_changes.rs @@ -20,6 +20,9 @@ pub fn collect_storage_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec block_hash: timestamp.hash.clone(), block_date: timestamp.date.clone(), + // transaction + tx_hash: Some(String::new()), + // storage changes address: bytes_to_hex(&storage_change.address), key: bytes_to_hex(&storage_change.key), @@ -41,6 +44,9 @@ pub fn collect_storage_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec block_hash: timestamp.hash.clone(), block_date: timestamp.date.clone(), + // transaction + tx_hash: Some(bytes_to_hex(&transaction.hash)), + // storage changes address: bytes_to_hex(&storage_change.address), key: bytes_to_hex(&storage_change.key), diff --git a/blocks/evm/src/traces.rs b/blocks/evm/src/traces.rs index 7fa8ef1..e53e859 100644 --- a/blocks/evm/src/traces.rs +++ b/blocks/evm/src/traces.rs @@ -44,9 +44,7 @@ pub fn collect_traces(block: &Block, timestamp: &BlockTimestamp) -> Vec { block_date: timestamp.date.clone(), // transaction - // As this is a system call, tx_hash is empty - // tx_index, tx_status, tx_status_code, tx_success are irrelevant as well - tx_hash: String::new(), + tx_hash: String::new(), // As this is a system call, tx_hash is empty tx_index: 0, tx_status: transaction_status_to_string(1), tx_status_code: 1, diff --git a/proto/evm.proto b/proto/evm.proto index 46251bb..5bb1322 100644 --- a/proto/evm.proto +++ b/proto/evm.proto @@ -198,12 +198,15 @@ message StorageChange { string block_hash = 3; string block_date = 4; + // -- transaction -- + optional string tx_hash = 5; + // -- storage change -- - uint64 ordinal = 5; // block global ordinal - string address = 6; - string key = 7; - string new_value = 8; - string old_value = 9; + uint64 ordinal = 6; // block global ordinal + string address = 7; + string key = 8; + string new_value = 9; + string old_value = 10; } message CodeChange { @@ -213,13 +216,16 @@ message CodeChange { string block_hash = 3; string block_date = 4; + // -- transaction -- + optional string tx_hash = 5; + // -- code change -- - uint64 ordinal = 5; // block global ordinal - string address = 6; - string old_hash = 7; - string old_code = 8; - string new_hash = 9; - string new_code = 10; + uint64 ordinal = 6; // block global ordinal + string address = 7; + string old_hash = 8; + string old_code = 9; + string new_hash = 10; + string new_code = 11; } message AccountCreation { @@ -244,11 +250,14 @@ message NonceChange { string block_hash = 3; string block_date = 4; + // -- transaction -- + optional string tx_hash = 5; + // -- nonce change -- - uint64 ordinal = 5; // block global ordinal - string address = 6; - uint64 old_value = 7; - uint64 new_value = 8; + uint64 ordinal = 6; // block global ordinal + string address = 7; + uint64 old_value = 8; + uint64 new_value = 9; } message GasChange { @@ -258,12 +267,15 @@ message GasChange { string block_hash = 3; string block_date = 4; + // -- transaction -- + optional string tx_hash = 5; + // -- gas change -- - uint64 ordinal = 5; // block global ordinal - uint64 old_value = 6; - uint64 new_value = 7; - string reason = 8; - uint32 reason_code = 9; + uint64 ordinal = 6; // block global ordinal + uint64 old_value = 7; + uint64 new_value = 8; + string reason = 9; + uint32 reason_code = 10; } message CreationTrace {