Skip to content

chore: add logs #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/committer/src/block_committer/commit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use tracing::info;
use tracing::warn;

use crate::block_committer::errors::BlockCommitmentError;
Expand Down Expand Up @@ -42,6 +43,7 @@ pub async fn commit_block(input: Input<ConfigImpl>) -> BlockCommitmentResult<Fil
&forest_sorted_indices,
&input.config,
)?;
info!("Original skeleton forest created successfully.");

if input.config.warn_on_trivial_modifications() {
check_trivial_nonce_and_class_hash_updates(
Expand All @@ -59,16 +61,20 @@ pub async fn commit_block(input: Input<ConfigImpl>) -> BlockCommitmentResult<Fil
&input.state_diff.address_to_class_hash,
&input.state_diff.address_to_nonce,
)?;
info!("Updated skeleton forest created successfully.");

Ok(FilledForest::create::<TreeHashFunctionImpl>(
let filled_forest = FilledForest::create::<TreeHashFunctionImpl>(
updated_forest,
actual_storage_updates,
actual_classes_updates,
&original_contracts_trie_leaves,
&input.state_diff.address_to_class_hash,
&input.state_diff.address_to_nonce,
)
.await?)
.await?;
info!("Filled forest created successfully.");

Ok(filled_forest)
}

/// Compares the previous state's nonce and class hash with the given in the state diff.
Expand Down
11 changes: 11 additions & 0 deletions crates/committer_cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use committer::block_committer::{
commit::commit_block,
input::{ConfigImpl, Input},
};
use tracing::info;

use crate::{
filled_tree_output::filled_forest::SerializedForest,
Expand All @@ -10,6 +11,11 @@ use crate::{

pub async fn parse_and_commit(input_string: &str, output_path: String) {
let input = parse_input(input_string).expect("Failed to parse the given input.");
info!(
"Parsed commiter input successfully. Original Contracts Trie Root Hash: {:?},
Original Classes Trie Root Hash: {:?}",
input.contracts_trie_root_hash, input.classes_trie_root_hash,
);
commit(input, output_path).await;
}

Expand All @@ -21,4 +27,9 @@ pub async fn commit(input: Input<ConfigImpl>, 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,
);
}
5 changes: 3 additions & 2 deletions crates/committer_cli/src/filled_tree_output/filled_forest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion crates/committer_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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.
Expand Down Expand Up @@ -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 } => {
Expand Down Expand Up @@ -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.");
}
}
}
Loading