Skip to content

Commit

Permalink
add tx_hash to all tables
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Nov 19, 2024
1 parent 70fcc0a commit 25e69be
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 45 deletions.
6 changes: 6 additions & 0 deletions blocks/evm/src/code_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<Co
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// transaction
tx_hash: Some(String::new()),

// code changes
address: bytes_to_hex(&code_change.address),
old_hash: bytes_to_hex(&code_change.old_hash),
Expand All @@ -41,6 +44,9 @@ pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<Co
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// transaction
tx_hash: Some(bytes_to_hex(&transaction.hash)),

// code changes
address: bytes_to_hex(&code_change.address),
old_hash: bytes_to_hex(&code_change.old_hash),
Expand Down
4 changes: 3 additions & 1 deletion blocks/evm/src/creation_traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ pub fn collect_creation_traces(block: &Block, timestamp: &BlockTimestamp) -> 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),
Expand Down
8 changes: 7 additions & 1 deletion blocks/evm/src/gas_changes.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -50,6 +50,9 @@ pub fn collect_gas_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<Gas
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// transaction
tx_hash: Some(String::new()),

// gas changes
old_value: gas_change.old_value,
new_value: gas_change.new_value,
Expand All @@ -71,6 +74,9 @@ pub fn collect_gas_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<Gas
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// transaction
tx_hash: Some(bytes_to_hex(&transaction.hash)),

// gas changes
old_value: gas_change.old_value,
new_value: gas_change.new_value,
Expand Down
6 changes: 6 additions & 0 deletions blocks/evm/src/nonce_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub fn collect_nonce_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<N
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// transaction
tx_hash: Some(String::new()),

// nonce changes
address: bytes_to_hex(&nonce_change.address),
old_value: nonce_change.old_value,
Expand All @@ -39,6 +42,9 @@ pub fn collect_nonce_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<N
block_hash: timestamp.hash.clone(),
block_date: timestamp.date.clone(),

// transaction
tx_hash: Some(bytes_to_hex(&transaction.hash)),

// nonce changes
address: bytes_to_hex(&nonce_change.address),
old_value: nonce_change.old_value,
Expand Down
52 changes: 32 additions & 20 deletions blocks/evm/src/pb/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,21 @@ pub struct StorageChange {
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>,
/// -- 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)]
Expand All @@ -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)]
Expand Down Expand Up @@ -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)]
Expand All @@ -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)]
Expand Down
6 changes: 6 additions & 0 deletions blocks/evm/src/storage_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
4 changes: 1 addition & 3 deletions blocks/evm/src/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ pub fn collect_traces(block: &Block, timestamp: &BlockTimestamp) -> Vec<Trace> {
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,
Expand Down
52 changes: 32 additions & 20 deletions proto/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 25e69be

Please sign in to comment.