From a3d1f50bcc9d5e6544b8b3b12c28e480e10ddb5f Mon Sep 17 00:00:00 2001 From: amos rothberg Date: Wed, 17 Jul 2024 16:56:28 +0300 Subject: [PATCH] chore: add logs --- crates/committer/src/block_committer/commit.rs | 10 ++++++++-- crates/committer_cli/src/commands.rs | 11 +++++++++++ .../src/filled_tree_output/filled_forest.rs | 5 +++-- crates/committer_cli/src/main.rs | 7 ++++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/crates/committer/src/block_committer/commit.rs b/crates/committer/src/block_committer/commit.rs index 14ab9b07..4ad63901 100644 --- a/crates/committer/src/block_committer/commit.rs +++ b/crates/committer/src/block_committer/commit.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use tracing::info; use tracing::warn; use crate::block_committer::errors::BlockCommitmentError; @@ -42,6 +43,7 @@ pub async fn commit_block(input: Input) -> BlockCommitmentResult) -> BlockCommitmentResult( + let filled_forest = FilledForest::create::( updated_forest, actual_storage_updates, actual_classes_updates, @@ -68,7 +71,10 @@ pub async fn commit_block(input: Input) -> BlockCommitmentResult, output_path: String) { ); let output = serialized_filled_forest.forest_to_output(); write_to_file(&output_path, &output); + info!( + "Successfully committed given block. Updated Contracts Trie Root Hash: {:?}, + Updated Classes Trie Root Hash: {:?}", + output.contract_storage_root_hash, output.compiled_class_root_hash, + ); } diff --git a/crates/committer_cli/src/filled_tree_output/filled_forest.rs b/crates/committer_cli/src/filled_tree_output/filled_forest.rs index 19ccac73..b0912499 100644 --- a/crates/committer_cli/src/filled_tree_output/filled_forest.rs +++ b/crates/committer_cli/src/filled_tree_output/filled_forest.rs @@ -9,10 +9,11 @@ pub struct SerializedForest(pub FilledForest); pub struct Output { // New fact storage. storage: MapStorage, + // TODO(Amos, 1/8/2024): Rename to `contracts_trie_root_hash` & `classes_trie_root_hash`. // New contract storage root. - contract_storage_root_hash: String, + pub contract_storage_root_hash: String, // New compiled class root. - compiled_class_root_hash: String, + pub compiled_class_root_hash: String, } impl SerializedForest { diff --git a/crates/committer_cli/src/main.rs b/crates/committer_cli/src/main.rs index 1e14b82b..a9f0d51d 100644 --- a/crates/committer_cli/src/main.rs +++ b/crates/committer_cli/src/main.rs @@ -7,6 +7,7 @@ use committer_cli::tracing_utils::configure_tracing; use starknet_api::block_hash::block_hash_calculator::{ calculate_block_commitments, calculate_block_hash, }; +use tracing::info; /// Committer CLI. #[derive(Debug, Parser)] @@ -27,7 +28,6 @@ enum Command { #[clap(long, short = 'o', default_value = "stdout")] output_path: String, }, - /// Given previous state tree skeleton and a state diff, computes the new commitment. /// Calculates commitments needed for the block hash. BlockHashCommitments { /// File path to output. @@ -61,6 +61,7 @@ async fn main() { configure_tracing(); let args = CommitterCliArgs::parse(); + info!("Starting committer-cli with args \n{:?}", args); match args.command { Command::Commit { output_path } => { @@ -89,19 +90,23 @@ async fn main() { Command::BlockHash { output_path } => { let block_hash_input: BlockHashInput = load_from_stdin(); + info!("Successfully loaded block hash input."); let block_hash = calculate_block_hash(block_hash_input.header, block_hash_input.block_commitments); write_to_file(&output_path, &block_hash); + info!("Successfully computed block hash."); } Command::BlockHashCommitments { output_path } => { let commitments_input: BlockCommitmentsInput = load_from_stdin(); + info!("Successfully loaded block hash commitment input."); let commitments = calculate_block_commitments( &commitments_input.transactions_data, &commitments_input.state_diff, commitments_input.l1_da_mode, ); write_to_file(&output_path, &commitments); + info!("Successfully computed block hash commitment."); } } }