-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from pinax-network/feature/evm-parquet
EVM Parquet
- Loading branch information
Showing
29 changed files
with
1,520 additions
and
651 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,47 @@ | ||
use common::blocks::insert_timestamp; | ||
use common::structs::BlockTimestamp; | ||
use common::utils::bytes_to_hex; | ||
use substreams::pb::substreams::Clock; | ||
use substreams_database_change::pb::database::{table_change, DatabaseChanges}; | ||
use substreams_ethereum::pb::eth::v2::AccountCreation; | ||
|
||
use crate::keys::block_ordinal_keys; | ||
use substreams_ethereum::pb::eth::v2::{AccountCreation, Block, TransactionTrace}; | ||
|
||
use crate::pb::evm::AccountCreation as AccountCreationEvent; | ||
|
||
// https://github.com/streamingfast/firehose-ethereum/blob/1bcb32a8eb3e43347972b6b5c9b1fcc4a08c751e/proto/sf/ethereum/type/v2/type.proto#L736 | ||
// DetailLevel: EXTENDED | ||
pub fn insert_account_creation(tables: &mut DatabaseChanges, clock: &Clock, account_creation: &AccountCreation) { | ||
let account = bytes_to_hex(&account_creation.account); | ||
let ordinal = account_creation.ordinal; | ||
pub fn collect_account_creations(block: &Block, timestamp: &BlockTimestamp) -> Vec<AccountCreationEvent> { | ||
let mut account_creations: Vec<AccountCreationEvent> = vec![]; | ||
|
||
// Collect account creations from system calls | ||
for call in &block.system_calls { | ||
for account_creation in &call.account_creations { | ||
account_creations.push(parse_account_creation(account_creation, &TransactionTrace::default(), timestamp)); | ||
} | ||
} | ||
|
||
// Collect account creations from transaction traces | ||
for transaction in &block.transaction_traces { | ||
for call in &transaction.calls { | ||
for account_creation in &call.account_creations { | ||
account_creations.push(parse_account_creation(account_creation, transaction, timestamp)); | ||
} | ||
} | ||
} | ||
|
||
account_creations | ||
} | ||
|
||
pub fn parse_account_creation(account_creation: &AccountCreation, transaction: &TransactionTrace, timestamp: &BlockTimestamp) -> AccountCreationEvent { | ||
AccountCreationEvent { | ||
// block | ||
block_time: Some(timestamp.time), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
let keys = block_ordinal_keys(&clock, &ordinal); | ||
let row = tables | ||
.push_change_composite("account_creations", keys, 0, table_change::Operation::Create) | ||
.change("account", ("", account.as_str())) | ||
.change("ordinal", ("", ordinal.to_string().as_str())); | ||
// transaction | ||
tx_hash: Some(bytes_to_hex(&transaction.hash)), | ||
|
||
insert_timestamp(row, clock, false, true); | ||
// account creation | ||
account: bytes_to_hex(&account_creation.account), | ||
ordinal: account_creation.ordinal, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.