diff --git a/blocks/evm/Makefile b/blocks/evm/Makefile index 022c4ba..b464b27 100644 --- a/blocks/evm/Makefile +++ b/blocks/evm/Makefile @@ -23,7 +23,7 @@ parquet: .PHONY: s3 s3: - substreams-sink-files run eth.substreams.pinax.network:443 substreams.yaml map_events s3://pinax/eth/323b41131b4f2dc97705d80cc0b859d4a33c52de?region=us-east-1 21200000: --encoder parquet --development-mode --parquet-default-column-compression snappy --file-block-count 1 + substreams-sink-files run eth.substreams.pinax.network:443 substreams.yaml map_events s3://pinax/eth/a7483e216fa6fc6753e7d6a9809620036fcd077d?region=us-east-1 21200000: --encoder parquet --development-mode --parquet-default-column-compression snappy --file-block-count 1 .PHONY: hash hash: diff --git a/blocks/evm/README.md b/blocks/evm/README.md index 6ef474b..0835299 100644 --- a/blocks/evm/README.md +++ b/blocks/evm/README.md @@ -16,7 +16,6 @@ - [x] **Account Creation** - [x] **Gas Changes** - [x] **Nonce Changes** - - [x] **Creation Traces** ## Graph @@ -36,5 +35,5 @@ Kind: map Input: source: sf.substreams.v1.Clock Input: source: sf.ethereum.type.v2.Block Output Type: proto:evm.Events -Hash: 323b41131b4f2dc97705d80cc0b859d4a33c52de +Hash: a7483e216fa6fc6753e7d6a9809620036fcd077d ``` diff --git a/blocks/evm/schema.snowflake.sql b/blocks/evm/schema.snowflake.sql index dbc84d2..97ebf71 100644 --- a/blocks/evm/schema.snowflake.sql +++ b/blocks/evm/schema.snowflake.sql @@ -142,4 +142,19 @@ FROM "v1.0.0-traces"; CREATE OR REPLACE SECURE VIEW v1_logs AS SELECT * -FROM "v1.0.0-logs"; \ No newline at end of file +FROM "v1.0.0-logs"; + +CREATE OR REPLACE SECURE VIEW v1_account_creations AS +SELECT + * +FROM "v1.0.0-account_creations"; + +CREATE OR REPLACE SECURE VIEW v1_storage_changes AS +SELECT + * +FROM "v1.0.0-storage_changes"; + +CREATE OR REPLACE SECURE VIEW v1_code_changes AS +SELECT + * +FROM "v1.0.0-code_changes"; \ No newline at end of file diff --git a/blocks/evm/src/code_changes.rs b/blocks/evm/src/code_changes.rs index 33ac689..b69e131 100644 --- a/blocks/evm/src/code_changes.rs +++ b/blocks/evm/src/code_changes.rs @@ -1,18 +1,18 @@ use common::structs::BlockTimestamp; use common::utils::bytes_to_hex; -use substreams_ethereum::pb::eth::v2::{Block, CodeChange, TransactionTrace}; +use substreams_ethereum::pb::eth::v2::{Block, CodeChange as CodeChangeSource, TransactionTrace}; -use crate::pb::pinax::evm::v1::CodeChange as CodeChangeEvent; +use crate::pb::pinax::evm::v1::CodeChange; // https://github.com/streamingfast/firehose-ethereum/blob/1bcb32a8eb3e43347972b6b5c9b1fcc4a08c751e/proto/sf/ethereum/type/v2/type.proto#L744 // DetailLevel: EXTENDED -pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec { - let mut code_changes: Vec = vec![]; +pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec { + let mut code_changes: Vec = vec![]; // Collect code changes from system calls for call in &block.system_calls { for code_change in &call.code_changes { - code_changes.push(parse_code_change(code_change, &TransactionTrace::default(), timestamp)); + code_changes.push(parse_creation_trace(code_change, &TransactionTrace::default(), timestamp)); } } @@ -20,7 +20,7 @@ pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec Vec CodeChangeEvent { - CodeChangeEvent { +pub fn parse_creation_trace(code_change: &CodeChangeSource, transaction: &TransactionTrace, timestamp: &BlockTimestamp) -> CodeChange { + let factory = if transaction.to == code_change.address { "".to_string() } else { bytes_to_hex(&transaction.to) }; + CodeChange { // block block_time: timestamp.time.to_string(), block_number: timestamp.number, @@ -37,14 +38,12 @@ pub fn parse_code_change(code_change: &CodeChange, transaction: &TransactionTrac block_date: timestamp.date.clone(), // transaction - tx_hash: Some(bytes_to_hex(&transaction.hash)), + tx_hash: bytes_to_hex(&transaction.hash), - // code changes + // creation trace + from: bytes_to_hex(&transaction.from), address: bytes_to_hex(&code_change.address), - old_hash: bytes_to_hex(&code_change.old_hash), - old_code: bytes_to_hex(&code_change.old_code), - new_hash: bytes_to_hex(&code_change.new_hash), - new_code: bytes_to_hex(&code_change.new_code), - ordinal: code_change.ordinal, + factory: factory.to_string(), + code: bytes_to_hex(&code_change.new_code), } } diff --git a/blocks/evm/src/creation_traces.rs b/blocks/evm/src/creation_traces.rs deleted file mode 100644 index 87cc38e..0000000 --- a/blocks/evm/src/creation_traces.rs +++ /dev/null @@ -1,41 +0,0 @@ -use common::structs::BlockTimestamp; -use common::utils::bytes_to_hex; -use substreams_ethereum::pb::eth::v2::{Block, CallType}; - -use crate::pb::pinax::evm::v1::CreationTrace; - -// https://github.com/streamingfast/firehose-ethereum/blob/1bcb32a8eb3e43347972b6b5c9b1fcc4a08c751e/proto/sf/ethereum/type/v2/type.proto#L744 -// DetailLevel: EXTENDED -pub fn collect_creation_traces(block: &Block, timestamp: &BlockTimestamp) -> Vec { - let mut creation_traces: Vec = vec![]; - - // Collect code changes from system calls - for trace in block.transaction_traces.iter() { - for call in trace.calls.iter() { - if call.call_type() == CallType::Create { - for code in call.code_changes.iter() { - let factory = if trace.to == code.address { "".to_string() } else { bytes_to_hex(&trace.to) }; - - creation_traces.push(CreationTrace { - // block - block_time: timestamp.time.to_string(), - block_number: timestamp.number, - 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), - address: bytes_to_hex(&code.address), - factory: factory.to_string(), - code: bytes_to_hex(&code.new_code), - }); - } - } - } - } - - creation_traces -} diff --git a/blocks/evm/src/events.rs b/blocks/evm/src/events.rs index ff384bd..97e8440 100644 --- a/blocks/evm/src/events.rs +++ b/blocks/evm/src/events.rs @@ -8,7 +8,6 @@ use crate::account_creations::collect_account_creations; use crate::balance_changes::collect_balance_changes; use crate::blocks::collect_block; use crate::code_changes::collect_code_changes; -use crate::creation_traces::collect_creation_traces; use crate::gas_changes::collect_gas_changes; use crate::logs::collect_logs; use crate::nonce_changes::collect_nonce_changes; @@ -32,6 +31,5 @@ pub fn map_events(clock: Clock, block: Block) -> Result { account_creations: collect_account_creations(&block, ×tamp), nonce_changes: collect_nonce_changes(&block, ×tamp), gas_changes: collect_gas_changes(&block, ×tamp), - creation_traces: collect_creation_traces(&block, ×tamp), }) } diff --git a/blocks/evm/src/lib.rs b/blocks/evm/src/lib.rs index 99967b6..a35207e 100644 --- a/blocks/evm/src/lib.rs +++ b/blocks/evm/src/lib.rs @@ -2,7 +2,6 @@ mod account_creations; mod balance_changes; mod blocks; mod code_changes; -mod creation_traces; mod events; mod gas_changes; mod logs; diff --git a/blocks/evm/src/pb/pinax.evm.v1.rs b/blocks/evm/src/pb/pinax.evm.v1.rs index b60b7e2..4b4ef41 100644 --- a/blocks/evm/src/pb/pinax.evm.v1.rs +++ b/blocks/evm/src/pb/pinax.evm.v1.rs @@ -1,5 +1,7 @@ // @generated // This file is @generated by prost-build. +// import "google/protobuf/timestamp.proto"; + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Events { @@ -23,8 +25,6 @@ pub struct Events { pub nonce_changes: ::prost::alloc::vec::Vec, #[prost(message, repeated, tag="10")] pub gas_changes: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag="11")] - pub creation_traces: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -419,23 +419,17 @@ pub struct CodeChange { #[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="6")] - pub ordinal: u64, - #[prost(string, tag="7")] + #[prost(string, tag="5")] + pub tx_hash: ::prost::alloc::string::String, + /// -- creation trace -- + #[prost(string, tag="6")] pub address: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub from: ::prost::alloc::string::String, #[prost(string, tag="8")] - pub old_hash: ::prost::alloc::string::String, + pub factory: ::prost::alloc::string::String, #[prost(string, tag="9")] - 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, + pub code: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -522,31 +516,4 @@ pub struct GasChange { #[prost(uint32, tag="10")] pub reason_code: u32, } -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CreationTrace { - /// -- block -- - /// - /// TIMESTAMP - #[prost(string, tag="1")] - pub block_time: ::prost::alloc::string::String, - #[prost(uint64, tag="2")] - pub block_number: u64, - #[prost(string, tag="3")] - pub block_hash: ::prost::alloc::string::String, - #[prost(string, tag="4")] - pub block_date: ::prost::alloc::string::String, - /// -- transaction -- - #[prost(string, tag="5")] - pub tx_hash: ::prost::alloc::string::String, - /// -- creation trace -- - #[prost(string, tag="6")] - pub address: ::prost::alloc::string::String, - #[prost(string, tag="7")] - pub from: ::prost::alloc::string::String, - #[prost(string, tag="8")] - pub factory: ::prost::alloc::string::String, - #[prost(string, tag="9")] - pub code: ::prost::alloc::string::String, -} // @@protoc_insertion_point(module) diff --git a/proto/evm.proto b/proto/evm.proto index f7b82b2..89b0524 100644 --- a/proto/evm.proto +++ b/proto/evm.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package pinax.evm.v1; -import "google/protobuf/timestamp.proto"; +// import "google/protobuf/timestamp.proto"; message Events { repeated Block blocks = 1; @@ -15,7 +15,6 @@ message Events { repeated AccountCreation account_creations = 8; repeated NonceChange nonce_changes = 9; repeated GasChange gas_changes = 10; - repeated CreationTrace creation_traces = 11; } message Block { @@ -228,15 +227,13 @@ message CodeChange { string block_date = 4; // -- transaction -- - optional string tx_hash = 5; + string tx_hash = 5; - // -- code change -- - 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; + // -- creation trace -- + string address = 6; + string from = 7; + string factory = 8; + string code = 9; } message AccountCreation { @@ -288,20 +285,3 @@ message GasChange { string reason = 9; uint32 reason_code = 10; } - -message CreationTrace { - // -- block -- - string block_time = 1; // TIMESTAMP - uint64 block_number = 2; - string block_hash = 3; - string block_date = 4; - - // -- transaction -- - string tx_hash = 5; - - // -- creation trace -- - string address = 6; - string from = 7; - string factory = 8; - string code = 9; -} \ No newline at end of file