From 700c7f636794d920d5cc8247c2e2c6d12ed1f3b2 Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Wed, 21 Dec 2022 14:33:58 +0000 Subject: [PATCH] feat: add Firehose logs --- crates/pathfinder/src/state/sync/l2.rs | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/crates/pathfinder/src/state/sync/l2.rs b/crates/pathfinder/src/state/sync/l2.rs index 19a92438aa..e2df3628b4 100644 --- a/crates/pathfinder/src/state/sync/l2.rs +++ b/crates/pathfinder/src/state/sync/l2.rs @@ -274,6 +274,60 @@ where head = Some((next, block_hash, state_update.state_commitment)); blocks.push(next, block_hash, state_update.state_commitment); + // Firehose integration + // TODO: add runtime option to toggle this on and off + { + use starknet_gateway_types::reply::transaction::Transaction; + + println!("FIRE BLOCK_BEGIN {}", block.block_number); + + for (ind_tx, tx) in block.transactions.iter().enumerate() { + println!( + "FIRE BEGIN_TRX {} {}", + tx.hash().0, + match tx { + Transaction::Declare(_) => "DECLARE", + Transaction::Deploy(_) => "DEPLOY", + Transaction::DeployAccount(_) => "DEPLOY_ACCOUNT", + Transaction::Invoke(_) => "INVOKE_FUNCTION", + Transaction::L1Handler(_) => "L1_HANDLER", + } + ); + + for (ind_event, event) in + block.transaction_receipts[ind_tx].events.iter().enumerate() + { + println!( + "FIRE TRX_BEGIN_EVENT {} {}", + tx.hash().0, + event.from_address.0 + ); + + for key in event.keys.iter() { + println!("FIRE TRX_EVENT_KEY {} {} {}", tx.hash().0, ind_event, key.0); + } + + for data in event.data.iter() { + println!( + "FIRE TRX_EVENT_DATA {} {} {}", + tx.hash().0, + ind_event, + data.0 + ); + } + } + } + + println!( + "FIRE BLOCK_END {} {} {} {} {}", + block.block_number, + block.block_hash.0, + block.parent_block_hash.0, + block.timestamp, + block.transactions.len(), + ); + } + let timings = Timings { block_download: t_block, state_diff_download: t_update,