From 741924c38e366d22e852623c8d8717fc6a993f91 Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Mon, 22 Apr 2024 17:34:57 -0300 Subject: [PATCH 01/16] Added trace logs for Sozo. --- Cargo.lock | 1 + bin/sozo/Cargo.toml | 1 + bin/sozo/src/args.rs | 25 +++++++++++++++++++- bin/sozo/src/commands/auth.rs | 2 ++ bin/sozo/src/commands/build.rs | 2 ++ bin/sozo/src/commands/call.rs | 2 ++ bin/sozo/src/commands/clean.rs | 2 ++ bin/sozo/src/commands/completions.rs | 2 ++ bin/sozo/src/commands/events.rs | 2 ++ bin/sozo/src/commands/execute.rs | 2 ++ bin/sozo/src/commands/init.rs | 2 ++ bin/sozo/src/commands/migrate.rs | 2 ++ bin/sozo/src/commands/mod.rs | 1 + bin/sozo/src/commands/model.rs | 2 ++ bin/sozo/src/commands/options/account.rs | 24 +++++++++++++++++-- bin/sozo/src/commands/options/starknet.rs | 11 ++++++++- bin/sozo/src/commands/options/transaction.rs | 2 ++ bin/sozo/src/commands/options/world.rs | 2 ++ bin/sozo/src/commands/register.rs | 2 ++ bin/sozo/src/main.rs | 20 ++++++++++++---- 20 files changed, 101 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fefc94553a..fc2bd71c32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11146,6 +11146,7 @@ dependencies = [ "tokio", "tracing", "tracing-log 0.1.4", + "tracing-subscriber", "url", ] diff --git a/bin/sozo/Cargo.toml b/bin/sozo/Cargo.toml index cb3d0f0def..f606233959 100644 --- a/bin/sozo/Cargo.toml +++ b/bin/sozo/Cargo.toml @@ -44,6 +44,7 @@ thiserror.workspace = true tokio.workspace = true tracing-log = "0.1.3" tracing.workspace = true +tracing-subscriber.workspace = true url.workspace = true sozo-ops.workspace = true katana-rpc-api.workspace = true diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 142d1ee90f..5b92679ef0 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -6,7 +6,8 @@ use scarb_ui::Verbosity; use smol_str::SmolStr; use tracing::level_filters::LevelFilter; use tracing_log::AsTrace; - +use tracing::Subscriber; +use tracing_subscriber::{fmt, EnvFilter}; use crate::commands::Commands; use crate::utils::generate_version; @@ -35,6 +36,10 @@ pub struct SozoArgs { #[arg(help = "Run without accessing the network.")] pub offline: bool, + #[arg(long)] + #[arg(help = "Output logs in JSON format.")] + pub json_log: bool, + #[command(subcommand)] pub command: Commands, } @@ -50,6 +55,24 @@ impl SozoArgs { Verbosity::Quiet } } + + pub fn init_logging(&self) -> Result<(), Box> { + const DEFAULT_LOG_FILTER: &str = "info,executor=trace,forked_backend=trace,server=debug,\ + blockifier=off,jsonrpsee_server=off,\ + hyper=off,messaging=debug,node=error"; + + let builder = fmt::Subscriber::builder().with_env_filter( + EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?, + ); + + let subscriber: Box = if self.json_log { + Box::new(builder.json().finish()) + } else { + Box::new(builder.finish()) + }; + + Ok(tracing::subscriber::set_global_default(subscriber)?) + } } /// Profile specifier. diff --git a/bin/sozo/src/commands/auth.rs b/bin/sozo/src/commands/auth.rs index 434e8c0313..ba0ef7d7ca 100644 --- a/bin/sozo/src/commands/auth.rs +++ b/bin/sozo/src/commands/auth.rs @@ -10,6 +10,8 @@ use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; use crate::utils; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::auth"; + #[derive(Debug, Args)] pub struct AuthArgs { #[command(subcommand)] diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 075268c40d..f1e133cfbb 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -8,6 +8,8 @@ use scarb::core::{Config, TargetKind}; use scarb::ops::CompileOpts; use sozo_ops::statistics::{get_contract_statistics_for_dir, ContractStatistics}; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::build"; + #[derive(Debug, Args)] pub struct BuildArgs { #[arg(long)] diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index 109f8af41c..b99cda1f82 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -7,6 +7,8 @@ use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; use crate::utils; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::call"; + #[derive(Debug, Args)] #[command(about = "Call a system with the given calldata.")] pub struct CallArgs { diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index f1ff03f95a..40384e99b1 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -6,6 +6,8 @@ use clap::Args; use dojo_lang::compiler::{ABIS_DIR, BASE_DIR, MANIFESTS_DIR}; use scarb::core::Config; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::clean"; + #[derive(Debug, Args)] pub struct CleanArgs { #[arg(short, long)] diff --git a/bin/sozo/src/commands/completions.rs b/bin/sozo/src/commands/completions.rs index 1f71098822..57cf0539ea 100644 --- a/bin/sozo/src/commands/completions.rs +++ b/bin/sozo/src/commands/completions.rs @@ -6,6 +6,8 @@ use clap_complete::{generate, Shell}; use crate::args::SozoArgs; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::completions"; + #[derive(Debug, Args)] pub struct CompletionsArgs { shell: Shell, diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index d08a3a74d3..d793242339 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -7,6 +7,8 @@ use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; use crate::utils; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::events"; + #[derive(Debug, Args)] pub struct EventsArgs { #[arg(help = "List of specific events to be filtered")] diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index b53ffa9691..843ec2d3c6 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -10,6 +10,8 @@ use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; use crate::utils; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::execute"; + #[derive(Debug, Args)] #[command(about = "Execute a system with the given calldata.")] pub struct ExecuteArgs { diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index f37bc70036..3609c0ccca 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -7,6 +7,8 @@ use anyhow::{ensure, Result}; use clap::Args; use scarb::core::Config; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::init"; + #[derive(Debug, Args)] pub struct InitArgs { #[arg(help = "Target directory")] diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index b392ef1014..73173981b0 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -18,6 +18,8 @@ use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::migrate"; + #[derive(Debug, Args)] pub struct MigrateArgs { #[command(subcommand)] diff --git a/bin/sozo/src/commands/mod.rs b/bin/sozo/src/commands/mod.rs index b7b2d53b64..8b0fe14144 100644 --- a/bin/sozo/src/commands/mod.rs +++ b/bin/sozo/src/commands/mod.rs @@ -32,6 +32,7 @@ use register::RegisterArgs; use test::TestArgs; #[derive(Subcommand)] +#[derive(Debug)] pub enum Commands { #[command(about = "Build the world, generating the necessary artifacts for deployment")] Build(BuildArgs), diff --git a/bin/sozo/src/commands/model.rs b/bin/sozo/src/commands/model.rs index e5e0aae244..f6dff7dd8f 100644 --- a/bin/sozo/src/commands/model.rs +++ b/bin/sozo/src/commands/model.rs @@ -8,6 +8,8 @@ use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; use crate::utils; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::model"; + #[derive(Debug, Args)] pub struct ModelArgs { #[command(subcommand)] diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index bf05c5ec11..99bdf083f7 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -7,12 +7,15 @@ use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount}; use starknet::core::types::FieldElement; use starknet::providers::Provider; use starknet::signers::{LocalWallet, SigningKey}; +use tracing::trace; use super::{ DOJO_ACCOUNT_ADDRESS_ENV_VAR, DOJO_KEYSTORE_PASSWORD_ENV_VAR, DOJO_KEYSTORE_PATH_ENV_VAR, DOJO_PRIVATE_KEY_ENV_VAR, }; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::account"; + // INVARIANT: // - For commandline: we can either specify `private_key` or `keystore_path` along with // `keystore_password`. This is enforced by Clap. @@ -56,21 +59,34 @@ impl AccountOptions { where P: Provider + Send + Sync, { + trace!("Creating account with options: {:?}", self); let account_address = self.account_address(env_metadata)?; + trace!("Account address determined: {:?}", account_address); + let signer = self.signer(env_metadata)?; + trace!("Signer obtained: {:?}", signer); let chain_id = provider.chain_id().await.with_context(|| "Failed to retrieve network chain id.")?; + trace!("Chain ID obtained: {:?}", chain_id); + let encoding = if self.legacy { + trace!("Using legacy encoding."); + ExecutionEncoding::Legacy + } else { + trace!("Using new encoding."); + ExecutionEncoding::New + }; - let encoding = if self.legacy { ExecutionEncoding::Legacy } else { ExecutionEncoding::New }; - + trace!("Creating SingleOwnerAccount with chain ID {:?} and encoding {:?}", chain_id, encoding); Ok(SingleOwnerAccount::new(provider, signer, account_address, chain_id, encoding)) } fn signer(&self, env_metadata: Option<&Environment>) -> Result { + trace!("Determining signer for account options: {:?}", self); if let Some(private_key) = self.private_key.as_deref().or_else(|| env_metadata.and_then(|env| env.private_key())) { + trace!("Using private key for signing."); return Ok(LocalWallet::from_signing_key(SigningKey::from_secret_scalar( FieldElement::from_str(private_key)?, ))); @@ -86,6 +102,7 @@ impl AccountOptions { .as_deref() .or_else(|| env_metadata.and_then(|env| env.keystore_password())) { + trace!("Using keystore for signing."); return Ok(LocalWallet::from_signing_key(SigningKey::from_keystore( path, password, )?)); @@ -101,9 +118,12 @@ impl AccountOptions { } fn account_address(&self, env_metadata: Option<&Environment>) -> Result { + trace!("Determining account address."); if let Some(address) = self.account_address { + trace!("Account address: {:?}", address); Ok(address) } else if let Some(address) = env_metadata.and_then(|env| env.account_address()) { + trace!("Account address found in environment metadata: {:?}", address); Ok(FieldElement::from_str(address)?) } else { Err(anyhow!( diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 759cacbf70..22f932bd6b 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -4,9 +4,12 @@ use dojo_world::metadata::Environment; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::JsonRpcClient; use url::Url; +use tracing::trace; use super::STARKNET_RPC_URL_ENV_VAR; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::starknet"; + #[derive(Debug, Args)] #[command(next_help_heading = "Starknet options")] pub struct StarknetOptions { @@ -21,18 +24,24 @@ impl StarknetOptions { &self, env_metadata: Option<&Environment>, ) -> Result> { - Ok(JsonRpcClient::new(HttpTransport::new(self.url(env_metadata)?))) + let url = self.url(env_metadata)?; + trace!("Creating JsonRpcClient with given RPC URL: {}", url); + Ok(JsonRpcClient::new(HttpTransport::new(url))) } // We dont check the env var because that would be handled by `clap`. // This function is made public because [`JsonRpcClient`] does not expose // the raw rpc url. pub fn url(&self, env_metadata: Option<&Environment>) -> Result { + trace!("Retrieving RPC URL for StarknetOptions."); if let Some(url) = self.rpc_url.as_ref() { + trace!("Using RPC URL from command line: {}", url); Ok(url.clone()) } else if let Some(url) = env_metadata.and_then(|env| env.rpc_url()) { + trace!("Using RPC URL from environment metadata: {}", url); Ok(Url::parse(url)?) } else { + trace!("Using default RPC URL: {}", url); Ok(Url::parse("http://localhost:5050").unwrap()) } } diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index 9783378e04..d0b95f246a 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -1,6 +1,8 @@ use clap::Args; use dojo_world::migration::TxnConfig; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::transaction"; + #[derive(Debug, Args)] #[command(next_help_heading = "Transaction options")] pub struct TransactionOptions { diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index 7a54617e7a..6279f93ffb 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -7,6 +7,8 @@ use starknet::core::types::FieldElement; use super::DOJO_WORLD_ADDRESS_ENV_VAR; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::world"; + #[derive(Debug, Args)] #[command(next_help_heading = "World options")] pub struct WorldOptions { diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index eca9d46590..07d8513ceb 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -12,6 +12,8 @@ use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; use crate::utils; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::register"; + #[derive(Debug, Args)] pub struct RegisterArgs { #[command(subcommand)] diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 18da01da73..9334e58d23 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -9,16 +9,19 @@ use dojo_lang::plugin::CairoPluginRepository; use scarb::compiler::CompilerRepository; use scarb::core::Config; use scarb_ui::{OutputFormat, Ui}; - +use tracing::trace; use crate::commands::Commands; mod args; mod commands; mod utils; +pub(crate) const LOG_TARGET: &str = "sozo::cli"; fn main() { + let args = SozoArgs::parse(); - + args.init_logging(); + trace!(target: LOG_TARGET, command = ?args.command, "Sozo CLI command started."); let ui = Ui::new(args.ui_verbosity(), OutputFormat::Text); if let Err(err) = cli_main(args) { @@ -33,9 +36,12 @@ fn cli_main(args: SozoArgs) -> Result<()> { match &args.command { Commands::Build(_) | Commands::Dev(_) | Commands::Migrate(_) => { + trace!(target: LOG_TARGET, "Adding DojoCompiler to compiler repository"); compilers.add(Box::new(DojoCompiler)).unwrap() } - _ => {} + _ => { + trace!(target: LOG_TARGET, "No additional compiler required"); + } } let manifest_path = scarb::ops::find_manifest_path(args.manifest_path.as_deref())?; @@ -51,5 +57,11 @@ fn cli_main(args: SozoArgs) -> Result<()> { .compilers(compilers) .build()?; - commands::run(args.command, &config) + trace!(target: LOG_TARGET, "Configuration built successfully"); + + commands::run(args.command, &config); + + trace!(target: LOG_TARGET, "Command execution completed"); + + Ok(()) } From 3a7bcd85d2d565955cf49d693115e9acde43dc5b Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Mon, 22 Apr 2024 20:16:42 -0300 Subject: [PATCH 02/16] Added Sozo trace logs. --- bin/sozo/src/commands/options/signer.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index 412cf1e892..59c2ce6431 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -9,6 +9,8 @@ use tracing::trace; use super::{DOJO_KEYSTORE_PASSWORD_ENV_VAR, DOJO_KEYSTORE_PATH_ENV_VAR, DOJO_PRIVATE_KEY_ENV_VAR}; +pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::signer"; + #[derive(Debug, Args)] #[command(next_help_heading = "Signer options")] // INVARIANT: From fc0bdf261ecba273cc7d43a307d44bcacea3fb00 Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Tue, 23 Apr 2024 02:57:35 -0300 Subject: [PATCH 03/16] Updated Sozo trace logs. --- bin/sozo/src/args.rs | 2 +- bin/sozo/src/commands/account.rs | 37 +++++++++----------- bin/sozo/src/commands/auth.rs | 24 ++++++------- bin/sozo/src/commands/build.rs | 18 +++++----- bin/sozo/src/commands/call.rs | 8 ++--- bin/sozo/src/commands/clean.rs | 14 ++++---- bin/sozo/src/commands/completions.rs | 2 +- bin/sozo/src/commands/dev.rs | 23 +++++------- bin/sozo/src/commands/events.rs | 17 ++++----- bin/sozo/src/commands/execute.rs | 13 +++---- bin/sozo/src/commands/init.rs | 25 +++++++------ bin/sozo/src/commands/migrate.rs | 21 +++++------ bin/sozo/src/commands/options/account.rs | 14 ++++---- bin/sozo/src/commands/options/fee.rs | 28 +++++++-------- bin/sozo/src/commands/options/signer.rs | 11 ++---- bin/sozo/src/commands/options/starknet.rs | 6 ++-- bin/sozo/src/commands/options/transaction.rs | 8 ++--- bin/sozo/src/commands/options/world.rs | 10 +++--- bin/sozo/src/commands/register.rs | 6 ++-- examples/spawn-and-move/chess | 1 - examples/spawn-and-move/dojo-starter | 1 - 21 files changed, 130 insertions(+), 159 deletions(-) delete mode 160000 examples/spawn-and-move/chess delete mode 160000 examples/spawn-and-move/dojo-starter diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 5b92679ef0..8d730d1cf2 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -57,7 +57,7 @@ impl SozoArgs { } pub fn init_logging(&self) -> Result<(), Box> { - const DEFAULT_LOG_FILTER: &str = "info,executor=trace,forked_backend=trace,server=debug,\ + const DEFAULT_LOG_FILTER: &str = "info,server=debug,\ blockifier=off,jsonrpsee_server=off,\ hyper=off,messaging=debug,node=error"; diff --git a/bin/sozo/src/commands/account.rs b/bin/sozo/src/commands/account.rs index be3209acd7..ee402ae31c 100644 --- a/bin/sozo/src/commands/account.rs +++ b/bin/sozo/src/commands/account.rs @@ -86,22 +86,20 @@ pub enum AccountCommand { impl AccountArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, "AccountArgs command: {:?}", self.command); + trace!(target: LOG_TARGET, command=?self.command, "Executing command."); let env_metadata = utils::load_metadata_from_config(config)?; - trace!(target: LOG_TARGET, "Fetched environment metadata"); config.tokio_handle().block_on(async { match self.command { AccountCommand::New { signer, force, file } => { trace!( target: LOG_TARGET, - "Executing New command with signer: {:?}, force: {}, file: {:?}", - signer, + ?signer, force, - file + ?file, + "Executing New command" ); let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; - trace!(target: LOG_TARGET, "Initialized LocalWallet for command"); account::new(signer, force, file).await } AccountCommand::Deploy { @@ -116,21 +114,19 @@ impl AccountArgs { } => { trace!( target: LOG_TARGET, - "Executing Deploy command with starknet: {:?}, signer: {:?}, fee: {:?}, simulate: {}, nonce: {:?}, poll_interval: {}, file: {:?}, no_confirmation: {}", - starknet, - signer, - fee, + ?starknet, + ?signer, + ?fee, simulate, - nonce, + ?nonce, poll_interval, - file, - no_confirmation + ?file, + no_confirmation, + "Executing Deploy command." ); let provider = starknet.provider(env_metadata.as_ref())?; - let signer = signer.signer(env_metadata.as_ref(), false)?; - trace!(target: LOG_TARGET, "Initialized LocalWallet and Provider for 'Deploy' command"); + let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; let fee_setting = fee.into_setting()?; - trace!(target: LOG_TARGET, "Converted FeeOptions to FeeSetting"); account::deploy( provider, signer, @@ -146,14 +142,13 @@ impl AccountArgs { AccountCommand::Fetch { starknet, force, output, address } => { trace!( target: LOG_TARGET, - "Executing Fetch command with starknet: {:?}, force: {}, output: {:?}, address: {:?}", - starknet, + ?starknet, force, - output, - address + ?output, + ?address, + "Executing Fetch command." ); let provider = starknet.provider(env_metadata.as_ref())?; - trace!(target: LOG_TARGET, "Initialized Provider for Fetch command"); account::fetch(provider, force, output, address).await } } diff --git a/bin/sozo/src/commands/auth.rs b/bin/sozo/src/commands/auth.rs index afc6d37b90..2ddc755286 100644 --- a/bin/sozo/src/commands/auth.rs +++ b/bin/sozo/src/commands/auth.rs @@ -59,10 +59,10 @@ pub enum AuthCommand { impl AuthArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, "Executing Auth command: {:?}", self.command); + trace!(target: LOG_TARGET, command=?self.command, "Executing Auth command.", ); let env_metadata = utils::load_metadata_from_config(config)?; - trace!(target: LOG_TARGET, "Loaded environment metadata: {:?}", env_metadata); + trace!(target: LOG_TARGET, metadata=?env_metadata, "Loaded environment."); match self.command { AuthCommand::Grant { kind, world, starknet, account, transaction } => config @@ -108,7 +108,7 @@ pub async fn grant( kind: AuthKind, transaction: TransactionOptions, ) -> Result<()> { - trace!(target: LOG_TARGET, "Executing 'Grant' command with kind: {:?}, world: {:?}, starknet: {:?}, account: {:?}, transaction: {:?}", kind, world, starknet, account, transaction); + trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing 'Grant' command."); let world = utils::world_from_env_metadata(world, account, starknet, &env_metadata).await.unwrap(); @@ -116,16 +116,16 @@ pub async fn grant( AuthKind::Writer { models_contracts } => { trace!( target: LOG_TARGET, - "Granting 'Writer' permissions for contract: {:?}", - models_contracts + contracts=?models_contracts, + "Granting 'Writer' permissions." ); auth::grant_writer(&world, models_contracts, transaction.into()).await } AuthKind::Owner { owners_resources } => { trace!( target: LOG_TARGET, - "Granting 'Owner' permissions for resources: {:?}", - owners_resources + resources=?owners_resources, + "Granting 'Owner' permissions." ); auth::grant_owner(&world, owners_resources, transaction.into()).await } @@ -140,23 +140,23 @@ pub async fn revoke( kind: AuthKind, transaction: TransactionOptions, ) -> Result<()> { - trace!(target: LOG_TARGET, "Executing 'Revoke' command with kind: {:?}, world: {:?}, starknet: {:?}, account: {:?}, transaction: {:?}", kind, world, starknet, account, transaction); + trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing 'Revoke' command."); let world = utils::world_from_env_metadata(world, account, starknet, &env_metadata).await.unwrap(); match kind { AuthKind::Writer { models_contracts } => { trace!( target: LOG_TARGET, - "Revoking 'Writer' permissions for contracts: {:?}", - models_contracts + contracts=?models_contracts, + "Revoking 'Writer' permissions." ); auth::revoke_writer(&world, models_contracts, transaction.into()).await } AuthKind::Owner { owners_resources } => { trace!( target: LOG_TARGET, - "Revoking 'Owner' permissions for resources: {:?}", - owners_resources + resources=?owners_resources, + "Revoking 'Owner' permissions." ); auth::revoke_owner(&world, owners_resources, transaction.into()).await } diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 6174d08312..25473a78fd 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -39,7 +39,7 @@ impl BuildArgs { config, CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, )?; - trace!(target: LOG_TARGET, "Compiled workspace: {:?}", compile_info); + trace!(target: LOG_TARGET, ?compile_info, "Compiled workspace."); let mut builtin_plugins = vec![]; if self.typescript { @@ -58,11 +58,9 @@ impl BuildArgs { let target_dir = &compile_info.target_dir; let contracts_statistics = get_contract_statistics_for_dir(target_dir) .context("Error getting contracts stats")?; - trace!(target: LOG_TARGET, "Contract statistics: {:?}", contracts_statistics); + trace!(target: LOG_TARGET, ?contracts_statistics, ?target_dir, "Fetched contract statistics for target directory."); let table = create_stats_table(contracts_statistics); - trace!(target: LOG_TARGET, "Displaying contract statistics"); - table.printstd() } @@ -77,13 +75,13 @@ impl BuildArgs { plugins: vec![], builtin_plugins, }; - trace!(target: LOG_TARGET, "Generating bindings with PluginManager: {:?}", bindgen); + trace!(target: LOG_TARGET, pluginManager=?bindgen, "Generating bindings."); tokio::runtime::Runtime::new() .unwrap() .block_on(bindgen.generate()) .expect("Error generating bindings"); - trace!(target: LOG_TARGET, "Completed generating bindings"); + trace!(target: LOG_TARGET, "Completed generating bindings."); Ok(()) } @@ -99,7 +97,7 @@ fn create_stats_table(contracts_statistics: Vec) -> Table { Cell::new_align("Bytecode size (felts)", format::Alignment::CENTER), Cell::new_align("Class size (bytes)", format::Alignment::CENTER), ])); - trace!(target: LOG_TARGET, "Creating table for contract statistics"); + trace!(target: LOG_TARGET, "Creating table for contract statistics."); for contract_stats in contracts_statistics { // Add table rows @@ -108,10 +106,10 @@ fn create_stats_table(contracts_statistics: Vec) -> Table { let file_size = contract_stats.file_size; trace!( target: LOG_TARGET, - "Adding row to table: contract = {}, bytecode size (felts) = {}, class size (bytes) = {}", contract_name, number_felts, - file_size + file_size, + "Adding row to table." ); table.add_row(Row::new(vec![ Cell::new_align(&contract_name, format::Alignment::LEFT), @@ -120,7 +118,7 @@ fn create_stats_table(contracts_statistics: Vec) -> Table { ])); } - trace!(target: LOG_TARGET, "Completed creating stats table"); + trace!(target: LOG_TARGET, "Completed creating stats table."); table } diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index fab928400f..4b1e9d05fc 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -38,21 +38,17 @@ pub struct CallArgs { impl CallArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, "Contract: {}, Entrypoint: {}, Calldata: {:?}, Block ID: {:?}", - self.contract, self.entrypoint, self.calldata, self.block_id); + trace!(target: LOG_TARGET, contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, block_id=self.block_id); let env_metadata = utils::load_metadata_from_config(config)?; - trace!(target: LOG_TARGET, "Fetched environment metadata"); - + trace!(target: LOG_TARGET, ?env_metadata, "Fetched environment metadata."); config.tokio_handle().block_on(async { - trace!(target: LOG_TARGET, "Initializing world reader from metadata"); let world_reader = utils::world_reader_from_env_metadata(self.world, self.starknet, &env_metadata) .await .unwrap(); - trace!(target: LOG_TARGET, "World reader initialized"); sozo_ops::call::call( world_reader, self.contract, diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index 8a198c1f94..4b28d33f74 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -24,15 +24,15 @@ impl CleanArgs { /// /// * `profile_dir` - The directory where the profile files are located. pub fn clean_manifests(&self, profile_dir: &Utf8PathBuf) -> Result<()> { - trace!(target: LOG_TARGET, "Cleaning manifests in directory: {:?}", profile_dir); + trace!(target: LOG_TARGET, ?profile_dir, "Cleaning manifests."); let dirs = vec![profile_dir.join(BASE_DIR), profile_dir.join(ABIS_DIR).join(BASE_DIR)]; for d in dirs { if d.exists() { - trace!(target: LOG_TARGET, "Removing directory: {:?}", d); + trace!(target: LOG_TARGET, directory=?d, "Removing directory."); fs::remove_dir_all(d)?; } else { - trace!(target: LOG_TARGET, "Directory does not exist: {:?}", d); + trace!(target: LOG_TARGET, directory=?d, "Directory does not exist."); } } @@ -41,7 +41,7 @@ impl CleanArgs { pub fn run(self, config: &Config) -> Result<()> { let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - trace!(target: LOG_TARGET, "Workspace read successfully"); + trace!(target: LOG_TARGET, ws=?ws, "Workspace read successfully."); let profile_name = ws.current_profile().expect("Scarb profile is expected at this point.").to_string(); @@ -53,15 +53,15 @@ impl CleanArgs { let profile_dir = manifest_dir.join(MANIFESTS_DIR).join(profile_name); // By default, this command cleans the build manifests and scarb artifacts. - trace!(target: LOG_TARGET, "Cleaning Scarb artifacts and build manifests"); + trace!(target: LOG_TARGET, "Cleaning Scarb artifacts and build manifests."); scarb::ops::clean(config)?; self.clean_manifests(&profile_dir)?; if self.all && profile_dir.exists() { - trace!(target: LOG_TARGET, "Removing entire profile directory: {:?}", profile_dir); + trace!(target: LOG_TARGET, ?profile_dir, "Removing entire profile directory."); fs::remove_dir_all(profile_dir)?; } else { - trace!(target: LOG_TARGET, "Profile directory does not exist: {:?}", profile_dir); + trace!(target: LOG_TARGET, ?profile_dir, "Profile directory does not exist."); } Ok(()) diff --git a/bin/sozo/src/commands/completions.rs b/bin/sozo/src/commands/completions.rs index f6d35588a4..d07b989dc4 100644 --- a/bin/sozo/src/commands/completions.rs +++ b/bin/sozo/src/commands/completions.rs @@ -18,7 +18,7 @@ impl CompletionsArgs { pub fn run(self) -> Result<()> { let mut command = SozoArgs::command(); let name = command.get_name().to_string(); - trace!(target: LOG_TARGET, "Command name: {}", name); + trace!(target: LOG_TARGET, name, "Executing Command."); generate(self.shell, &mut command, name, &mut io::stdout()); Ok(()) } diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index 6f3f99f9b9..291b1bb2ed 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -53,20 +53,16 @@ impl DevArgs { pub fn run(self, config: &Config) -> Result<()> { let env_metadata = if config.manifest_path().exists() { let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - - trace!(target: LOG_TARGET, "Loaded workspace"); dojo_metadata_from_workspace(&ws).env().cloned() } else { - trace!(target: LOG_TARGET, "Manifest path does not exist"); + trace!(target: LOG_TARGET, "Manifest path does not exist."); None }; let mut context = load_context(config)?; - trace!(target: LOG_TARGET, "Loaded context"); let (tx, rx) = channel(); let mut debouncer = new_debouncer(Duration::from_secs(1), None, tx)?; - trace!(target: LOG_TARGET, "Set up debouncer"); debouncer.watcher().watch( config.manifest_path().parent().unwrap().as_std_path(), @@ -90,7 +86,7 @@ impl DevArgs { )) .ok() else { - return Err(anyhow!("Failed to setup environment")); + return Err(anyhow!("Failed to setup environment.")); }; match context.ws.config().tokio_handle().block_on(migrate( @@ -179,7 +175,7 @@ fn handle_event(event: &DebouncedEvent) -> DevAction { _ => DevAction::None, }; - trace!(target: LOG_TARGET, "Determined action: {:?}", action); + trace!(target: LOG_TARGET, ?action, "Determined action."); action } @@ -190,7 +186,6 @@ struct DevContext<'a> { } fn load_context(config: &Config) -> Result> { - trace!(target: LOG_TARGET, "Loading context"); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; let packages: Vec = ws.members().map(|p| p.id).collect(); let resolve = scarb::ops::resolve_workspace(&ws)?; @@ -201,7 +196,7 @@ fn load_context(config: &Config) -> Result> { // we have only 1 unit in projects // TODO: double check if we always have one with the new version and the order if many. - trace!(target: LOG_TARGET, "Generated compilation units: {:?}", compilation_units.len()); + trace!(target: LOG_TARGET, units=compilation_units.len(), "Generated compilation."); let unit = compilation_units.first().unwrap(); let db = build_scarb_root_database(unit).unwrap(); Ok(DevContext { db, unit: unit.clone(), ws }) @@ -217,7 +212,7 @@ fn build(context: &mut DevContext<'_>) -> Result<()> { anyhow!("could not compile `{package_name}` due to previous error") })?; ws.config().ui().print("šŸ“¦ Rebuild done"); - trace!(target: LOG_TARGET, "Build completed for package `{}`", package_name); + trace!(target: LOG_TARGET, ?package_name, "Build completed."); Ok(()) } @@ -274,7 +269,7 @@ where } fn process_event(event: &DebouncedEvent, context: &mut DevContext<'_>) -> DevAction { - trace!(target: LOG_TARGET, "Processing event {:?}", event); + trace!(target: LOG_TARGET, event=?event, "Processing event."); let action = handle_event(event); match &action { DevAction::None => {} @@ -284,7 +279,7 @@ fn process_event(event: &DebouncedEvent, context: &mut DevContext<'_>) -> DevAct } } - trace!(target: LOG_TARGET, "Processed action: {:?}", action); + trace!(target: LOG_TARGET, action=?action, "Processed action."); action } @@ -301,10 +296,10 @@ fn handle_build_action(path: &Path, context: &mut DevContext<'_>) { } fn handle_reload_action(context: &mut DevContext<'_>) { - trace!(target: LOG_TARGET, "Reloading context"); + trace!(target: LOG_TARGET, "Reloading context."); let config = context.ws.config(); config.ui().print("Reloading project"); let new_context = load_context(config).expect("Failed to load context"); let _ = mem::replace(context, new_context); - trace!(target: LOG_TARGET, "Context reloaded"); + trace!(target: LOG_TARGET, "Context reloaded."); } diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index 8a3d476c14..616fbca6f7 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -46,16 +46,16 @@ pub struct EventsArgs { impl EventsArgs { pub fn run(self, config: &Config) -> Result<()> { let env_metadata = utils::load_metadata_from_config(config)?; - trace!(target: LOG_TARGET, "Fetched metadata from config"); + trace!(target: LOG_TARGET, "Fetched metadata from config."); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - trace!(target: LOG_TARGET, "Loaded workspace with {} members", ws.members().count()); + trace!(target: LOG_TARGET, ws_members_count=ws.members().count(), "Fetched workspace."); let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - trace!(target: LOG_TARGET, "manifest directory: {}", manifest_dir); + trace!(target: LOG_TARGET, ?manifest_dir, "Fetched manifest directory."); let provider = self.starknet.provider(env_metadata.as_ref())?; - trace!(target: LOG_TARGET, "Provider: {:?}", provider); + trace!(target: LOG_TARGET, ?provider, "Starknet RPC client provider"); let event_filter = events::get_event_filter( self.from_block, @@ -65,14 +65,15 @@ impl EventsArgs { ); trace!( target: LOG_TARGET, - "Created event filter with from_block = {:?}, to_block = {:?}", - self.from_block, - self.to_block + from_block=self.from_block, + to_block=self.to_block, + chunk_size=self.chunk_size, + "Created event filter" ); let profile_name = ws.current_profile().expect("Scarb profile expected at this point.").to_string(); - trace!(target: LOG_TARGET, "Current profile: {}", profile_name); + trace!(target: LOG_TARGET, profile_name, "Fetched profile name"); config.tokio_handle().block_on(async { trace!(target: LOG_TARGET, "Starting async event parsing"); diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index c70f895965..b7a444d926 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -58,16 +58,17 @@ impl ExecuteArgs { let tx_config = self.transaction.into(); trace!( target: LOG_TARGET, - "Transaction configuration initialized: {:?}", - tx_config + ?tx_config, + "Transaction configuration initialized.", + ); trace!( target: LOG_TARGET, - "Executing: contract = {}, entrypoint = {}, calldata = {:?}", - self.contract, - self.entrypoint, - self.calldata + contract=?self.contract, + entrypoint=self.entrypoint, + calldata=?self.calldata, + "Executing command." ); execute::execute(self.contract, self.entrypoint, self.calldata, &world, &tx_config) .await diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index 606cdad40a..c851e73b8e 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -24,18 +24,18 @@ impl InitArgs { let target_dir = match self.path { Some(path) => { if path.is_absolute() { - trace!(target: LOG_TARGET, "Using absolute path: {:?}", path); + trace!(target: LOG_TARGET, ?path); path } else { let mut current_path = current_dir().unwrap(); current_path.push(path); - trace!(target: LOG_TARGET, "Using relative path, resolved to: {:?}", current_path); + trace!(target: LOG_TARGET, ?current_path); current_path } } None => { let dir = current_dir().unwrap(); - trace!(target: LOG_TARGET, "Using current directory: {:?}", dir); + trace!(target: LOG_TARGET, ?dir); dir } }; @@ -55,11 +55,11 @@ impl InitArgs { let template = self.template; let repo_url = if template.starts_with("https://") { - trace!(target: LOG_TARGET, "Using Git URL: {}", template); + trace!(target: LOG_TARGET, template=%template); template } else { let url = "https://github.com/".to_string() + &template; - trace!(target: LOG_TARGET, "Constructed Git URL: {}", url); + trace!(target: LOG_TARGET, url, "Constructed Git URL."); url }; @@ -68,7 +68,7 @@ impl InitArgs { // Navigate to the newly cloned repo. let initial_dir = current_dir()?; set_current_dir(&target_dir)?; - trace!(target: LOG_TARGET, "Set current directory to: {:?}", target_dir); + trace!(target: LOG_TARGET, ?target_dir); // Modify the git history. modify_git_history(&repo_url)?; @@ -76,7 +76,7 @@ impl InitArgs { config.ui().print("\nšŸŽ‰ Successfully created a new ā›©ļø Dojo project!"); // Navigate back. - trace!(target: LOG_TARGET, "Returned to initial directory: {:?}", initial_dir); + trace!(target: LOG_TARGET, ?initial_dir, "Returned to initial directory."); set_current_dir(initial_dir)?; config.ui().print( @@ -84,7 +84,7 @@ impl InitArgs { `sozo build`", ); - trace!(target: LOG_TARGET, "Project initialization complete"); + trace!(target: LOG_TARGET, "Project initialization completed."); Ok(()) } @@ -93,18 +93,17 @@ impl InitArgs { fn clone_repo(url: &str, path: &Path, config: &Config) -> Result<()> { config.ui().print(format!("Cloning project template from {}...", url)); Command::new("git").args(["clone", "--recursive", url, path.to_str().unwrap()]).output()?; - trace!(target: LOG_TARGET, "Repository cloned successfully"); + trace!(target: LOG_TARGET, "Repository cloned successfully."); Ok(()) } fn modify_git_history(url: &str) -> Result<()> { - trace!(target: LOG_TARGET, "Modifying Git history"); + trace!(target: LOG_TARGET, "Modifying Git history."); let git_output = Command::new("git").args(["rev-parse", "--short", "HEAD"]).output()?.stdout; let commit_hash = String::from_utf8(git_output)?; trace!( target: LOG_TARGET, - "Current commit hash: {}", - commit_hash.trim() + commit_hash=commit_hash.trim() ); fs::remove_dir_all(".git")?; @@ -115,6 +114,6 @@ fn modify_git_history(url: &str) -> Result<()> { let commit_msg = format!("chore: init from {} at {}", url, commit_hash.trim()); Command::new("git").args(["commit", "-m", &commit_msg]).output()?; - trace!(target: LOG_TARGET, "Git history modified"); + trace!(target: LOG_TARGET, "Git history modified."); Ok(()) } diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index e6abe92d3d..3c4994d177 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -70,7 +70,7 @@ pub enum MigrateCommand { impl MigrateArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, "Executing command: {:?}", self.command); + trace!(target: LOG_TARGET, command=?self.command, "Executing command"); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; let env_metadata = if config.manifest_path().exists() { @@ -90,7 +90,7 @@ impl MigrateArgs { if name.is_none() { if let Some(root_package) = ws.root_package() { name = Some(root_package.id.name.to_string()); - trace!(target: LOG_TARGET, "Root package name set to: {:?}", name); + trace!(target: LOG_TARGET, name, "Setting Root package name."); } }; @@ -119,13 +119,13 @@ impl MigrateArgs { }) } MigrateCommand::Apply { mut name, world, starknet, account, transaction } => { - trace!(target: LOG_TARGET, "Applying migration with name: {:?}", name); + trace!(target: LOG_TARGET, name, "Applying migration."); let txn_config: TxnConfig = transaction.into(); if name.is_none() { if let Some(root_package) = ws.root_package() { name = Some(root_package.id.name.to_string()); - trace!(target: LOG_TARGET, "Root package name set to: {:?}", name); + trace!(target: LOG_TARGET, name, "Setting Root package."); } }; @@ -174,14 +174,14 @@ pub async fn setup_env<'a>( let ui = ws.config().ui(); let world_address = world.address(env).ok(); - trace!(target: LOG_TARGET, "World address: {:?}", world_address); + trace!(target: LOG_TARGET, ?world_address); let (account, chain_id, rpc_url) = { let provider = starknet.provider(env)?; trace!(target: LOG_TARGET, "Provider initialized."); let spec_version = provider.spec_version().await?; - trace!(target: LOG_TARGET, "RPC Spec Version: {}", spec_version); + trace!(target: LOG_TARGET, spec_version); if spec_version != RPC_SPEC_VERSION { return Err(anyhow!( @@ -192,12 +192,12 @@ pub async fn setup_env<'a>( } let rpc_url = starknet.url(env)?; - trace!(target: LOG_TARGET, "RPC URL: {}", rpc_url); + trace!(target: LOG_TARGET, ?rpc_url); let chain_id = provider.chain_id().await?; let chain_id = parse_cairo_short_string(&chain_id) .with_context(|| "Cannot parse chain_id as string")?; - trace!(target: LOG_TARGET, "Chain ID: {}", chain_id); + trace!(target: LOG_TARGET, chain_id); let mut account = account.account(provider, env).await?; account.set_block_id(BlockId::Tag(BlockTag::Pending)); @@ -210,10 +210,7 @@ pub async fn setup_env<'a>( } match account.provider().get_class_hash_at(BlockId::Tag(BlockTag::Pending), address).await { - Ok(_) => { - trace!(target: LOG_TARGET, "Account is valid and exists."); - Ok((account, chain_id, rpc_url)) - } + Ok(_) => Ok((account, chain_id, rpc_url)), Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { Err(anyhow!("Account with address {:#x} doesn't exist.", account.address())) } diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index 8486815947..7bd859a8a5 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -43,16 +43,16 @@ impl AccountOptions { where P: Provider + Send + Sync, { - trace!(target: LOG_TARGET, "Creating account with options: {:?}", self); + trace!(target: LOG_TARGET, account_options=?self, "Creating account.", ); let account_address = self.account_address(env_metadata)?; - trace!(target: LOG_TARGET, "Account address determined: {:?}", account_address); + trace!(target: LOG_TARGET, ?account_address, "Account address determined."); let signer = self.signer.signer(env_metadata, false)?; - trace!(target: LOG_TARGET, "Signer obtained: {:?}", signer); + trace!(target: LOG_TARGET, ?signer, "Signer obtained."); let chain_id = provider.chain_id().await.with_context(|| "Failed to retrieve network chain id.")?; - trace!(target: LOG_TARGET, "Chain ID obtained: {:?}", chain_id); + trace!(target: LOG_TARGET, ?chain_id, "Chain ID obtained."); let encoding = if self.legacy { trace!(target: LOG_TARGET, "Using legacy encoding."); ExecutionEncoding::Legacy @@ -61,17 +61,17 @@ impl AccountOptions { ExecutionEncoding::New }; - trace!(target: LOG_TARGET, "Creating SingleOwnerAccount with chain ID {:?} and encoding {:?}", chain_id, encoding); + trace!(target: LOG_TARGET, ?chain_id, ?encoding, "Creating SingleOwnerAccount."); Ok(SingleOwnerAccount::new(provider, signer, account_address, chain_id, encoding)) } fn account_address(&self, env_metadata: Option<&Environment>) -> Result { trace!(target: LOG_TARGET, "Determining account address."); if let Some(address) = self.account_address { - trace!(target: LOG_TARGET, "Account address: {:?}", address); + trace!(target: LOG_TARGET, ?address, "Account address found."); Ok(address) } else if let Some(address) = env_metadata.and_then(|env| env.account_address()) { - trace!(target: LOG_TARGET, "Account address found in environment metadata: {:?}", address); + trace!(target: LOG_TARGET, address, "Account address found in environment metadata."); Ok(FieldElement::from_str(address)?) } else { Err(anyhow!( diff --git a/bin/sozo/src/commands/options/fee.rs b/bin/sozo/src/commands/options/fee.rs index b7a8104204..6e96d56a91 100644 --- a/bin/sozo/src/commands/options/fee.rs +++ b/bin/sozo/src/commands/options/fee.rs @@ -26,22 +26,21 @@ impl FeeOptions { pub fn into_setting(self) -> Result { trace!( target: LOG_TARGET, - "FeeOptions: max_fee = {:?}, max_fee_raw = {:?}, estimate_only = {}", - self.max_fee, - self.max_fee_raw, - self.estimate_only + max_fee=?self.max_fee, + max_fee_raw=?self.max_fee_raw, + estimate_only=self.estimate_only, + "Converting FeeOptions into FeeSetting." ); match (self.max_fee, self.max_fee_raw, self.estimate_only) { (Some(max_fee), None, false) => { - trace!("Using max_fee: {:?}", max_fee); let max_fee_felt = bigdecimal_to_felt(&max_fee, 18)?; // The user is most likely making a mistake for using a max fee higher than 1 ETH if max_fee_felt > felt!("1000000000000000000") { trace!( target: LOG_TARGET, - "Max fee in Ether is higher than 1 ETH ({}), suggesting an error.", - max_fee_felt + ?max_fee_felt, + "Max fee in Ether is higher than 1 ETH." ); anyhow::bail!( "the --max-fee value is too large. --max-fee expects a value in Ether (18 \ @@ -52,15 +51,15 @@ impl FeeOptions { Ok(FeeSetting::Manual(max_fee_felt)) } (None, Some(max_fee_raw), false) => { - trace!(target: LOG_TARGET, "Using raw max_fee in Wei: {:?}", max_fee_raw); + trace!(target: LOG_TARGET, ?max_fee_raw, "Using raw max_fee in Wei."); Ok(FeeSetting::Manual(max_fee_raw)) } (None, None, true) => { - trace!(target: LOG_TARGET, "Only estimating the fee"); + trace!(target: LOG_TARGET, "Only estimating the fee."); Ok(FeeSetting::EstimateOnly) } (None, None, false) => { - trace!(target: LOG_TARGET, "No fee options specified"); + trace!(target: LOG_TARGET, "No fee options specified."); Ok(FeeSetting::None) } _ => Err(anyhow::anyhow!( @@ -81,26 +80,23 @@ where // Scale the bigint part up or down let (bigint, exponent) = dec.as_bigint_and_exponent(); - trace!(target: LOG_TARGET, "BigDecimal: bigint = {:?}, exponent = {}", bigint, exponent); let mut biguint = match bigint.to_biguint() { Some(value) => value, None => { - trace!(target: LOG_TARGET, "Could not convert bigint to biguint, too many decimal places"); + trace!(target: LOG_TARGET, "Could not convert bigint to biguint, too many decimal places."); anyhow::bail!("too many decimal places") } }; if exponent < decimals { - trace!(target: LOG_TARGET, "Scaling up bigint for conversion"); for _ in 0..(decimals - exponent) { biguint *= 10u32; } } else if exponent > decimals { - trace!(target: LOG_TARGET, "Scaling down bigint for conversion"); for _ in 0..(exponent - decimals) { let (quotient, remainder) = biguint.div_rem(&10u32.into()); if !remainder.is_zero() { - trace!(target: LOG_TARGET, "Found non-zero remainder during scaling down"); + trace!(target: LOG_TARGET, "Found non-zero remainder during scaling down."); anyhow::bail!("too many decimal places") } biguint = quotient; @@ -108,4 +104,4 @@ where } Ok(FieldElement::from_byte_slice_be(&biguint.to_bytes_be())?) -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index 59c2ce6431..46b5c7cddb 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -45,12 +45,8 @@ impl SignerOptions { { trace!( target: LOG_TARGET, - "Using private key from: {:?}", - if self.private_key.is_some() { - "command-line argument" - } else { - "environment metadata" - } + private_key, + "Signing using private key." ); return Ok(LocalWallet::from_signing_key(SigningKey::from_secret_scalar( FieldElement::from_str(private_key)?, @@ -68,12 +64,11 @@ impl SignerOptions { .as_deref() .or_else(|| env_metadata.and_then(|env| env.keystore_password())) { - trace!(target: LOG_TARGET, "Using keystore password from: {:?}", if self.keystore_password.is_some() { "command-line argument" } else { "environment metadata" }); password.to_owned() } else if no_wait { return Err(anyhow!("Could not find password. Please specify the password.")); } else { - trace!(target: LOG_TARGET, "Prompting user for keystore password"); + trace!(target: LOG_TARGET, "Prompting user for keystore password."); rpassword::prompt_password("Enter password: ")? } }; diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 547c2974fa..5fc4c03375 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -25,7 +25,7 @@ impl StarknetOptions { env_metadata: Option<&Environment>, ) -> Result> { let url = self.url(env_metadata)?; - trace!(target: LOG_TARGET, "Creating JsonRpcClient with given RPC URL: {}", url); + trace!(target: LOG_TARGET, ?url, "Creating JsonRpcClient with given RPC URL."); Ok(JsonRpcClient::new(HttpTransport::new(url))) } @@ -35,10 +35,10 @@ impl StarknetOptions { pub fn url(&self, env_metadata: Option<&Environment>) -> Result { trace!(target: LOG_TARGET, "Retrieving RPC URL for StarknetOptions."); if let Some(url) = self.rpc_url.as_ref() { - trace!(target: LOG_TARGET, "Using RPC URL from command line: {}", url); + trace!(target: LOG_TARGET, ?url, "Using RPC URL from command line."); Ok(url.clone()) } else if let Some(url) = env_metadata.and_then(|env| env.rpc_url()) { - trace!(target: LOG_TARGET, "Using RPC URL from environment metadata: {}", url); + trace!(target: LOG_TARGET, url, "Using RPC URL from environment metadata."); Ok(Url::parse(url)?) } else { trace!(target: LOG_TARGET, "Using default RPC URL: http://localhost:5050"); diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index 9e36de7ab7..0a9c21128c 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -36,10 +36,10 @@ impl From for TxnConfig { fn from(value: TransactionOptions) -> Self { trace!( target: LOG_TARGET, - "Converting TransactionOptions to TxnConfig. Multiplier: {:?}, Wait: {}, Receipt: {}", - value.fee_estimate_multiplier, - value.wait, - value.receipt, + fee_estimate_multiplier=value.fee_estimate_multiplier, + wait=value.wait, + receipt=value.receipt, + "Converting TransactionOptions to TxnConfig." ); Self { fee_estimate_multiplier: value.fee_estimate_multiplier, diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index d410317de8..bc5322c5c2 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -22,15 +22,15 @@ impl WorldOptions { pub fn address(&self, env_metadata: Option<&Environment>) -> Result { trace!( target: LOG_TARGET, - "Fetching World address. Given: {:?}, Env Metadata: {:?}", - self.world_address, - env_metadata + world_address=?self.world_address, + ?env_metadata, + "Fetching World address." ); if let Some(world_address) = self.world_address { - trace!(target: LOG_TARGET, "world_address: {:?}", world_address); + trace!(target: LOG_TARGET, ?world_address, "Fetched world_address."); Ok(world_address) } else if let Some(world_address) = env_metadata.and_then(|env| env.world_address()) { - trace!(target: LOG_TARGET, "world_address from env metadata: {}", world_address); + trace!(target: LOG_TARGET, world_address, "Fetched world_address from env metadata."); Ok(FieldElement::from_str(world_address)?) } else { Err(anyhow!( diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index ecf357bd53..0d62aa52a4 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -47,18 +47,18 @@ pub enum RegisterCommand { impl RegisterArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, "Executing command: {:?}", self.command); + trace!(target: LOG_TARGET, command=?self.command, "Executing command."); let env_metadata = utils::load_metadata_from_config(config)?; let (starknet, world, account, transaction, models) = match self.command { RegisterCommand::Model { starknet, world, account, transaction, models } => { - trace!(target: LOG_TARGET, "Registering models: {:?}", models); + trace!(target: LOG_TARGET, models=?models, "Registering models."); (starknet, world, account, transaction, models) } }; let world_address = world.world_address.unwrap_or_default(); - trace!(target: LOG_TARGET, "Using world address: {:?}", world_address); + trace!(target: LOG_TARGET, ?world_address, "Using world address"); config.tokio_handle().block_on(async { let world = diff --git a/examples/spawn-and-move/chess b/examples/spawn-and-move/chess deleted file mode 160000 index e8cc65b4f0..0000000000 --- a/examples/spawn-and-move/chess +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e8cc65b4f040409337e91124493df25c42f7211d diff --git a/examples/spawn-and-move/dojo-starter b/examples/spawn-and-move/dojo-starter deleted file mode 160000 index 85b45922af..0000000000 --- a/examples/spawn-and-move/dojo-starter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 85b45922afa2b60b05002c440bda57515e42c3d5 From 0229235445c62282ec23e86e2f003e84d74b5e96 Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Tue, 23 Apr 2024 03:11:50 -0300 Subject: [PATCH 04/16] Updated Sozo trace logs. --- bin/sozo/src/args.rs | 2 +- bin/sozo/src/commands/account.rs | 2 +- bin/sozo/src/commands/auth.rs | 2 +- bin/sozo/src/commands/build.rs | 2 +- bin/sozo/src/commands/call.rs | 2 +- bin/sozo/src/commands/clean.rs | 2 +- bin/sozo/src/commands/completions.rs | 2 +- bin/sozo/src/commands/dev.rs | 2 +- bin/sozo/src/commands/events.rs | 2 +- bin/sozo/src/commands/execute.rs | 2 +- bin/sozo/src/commands/init.rs | 2 +- bin/sozo/src/commands/keystore.rs | 2 +- bin/sozo/src/commands/migrate.rs | 2 +- bin/sozo/src/commands/mod.rs | 2 +- bin/sozo/src/commands/model.rs | 2 +- bin/sozo/src/commands/options/mod.rs | 2 +- bin/sozo/src/commands/options/signer.rs | 2 +- bin/sozo/src/commands/options/starknet.rs | 2 +- bin/sozo/src/commands/options/transaction.rs | 2 +- bin/sozo/src/commands/options/world.rs | 2 +- bin/sozo/src/commands/register.rs | 2 +- bin/sozo/src/commands/test.rs | 2 +- bin/sozo/src/main.rs | 6 +++--- 23 files changed, 25 insertions(+), 25 deletions(-) diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 8d730d1cf2..3b41ab6783 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -101,4 +101,4 @@ impl ProfileSpec { _ => Profile::default(), }) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/account.rs b/bin/sozo/src/commands/account.rs index ee402ae31c..524e7d0715 100644 --- a/bin/sozo/src/commands/account.rs +++ b/bin/sozo/src/commands/account.rs @@ -154,4 +154,4 @@ impl AccountArgs { } }) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/auth.rs b/bin/sozo/src/commands/auth.rs index 2ddc755286..f7a44f4783 100644 --- a/bin/sozo/src/commands/auth.rs +++ b/bin/sozo/src/commands/auth.rs @@ -213,4 +213,4 @@ mod tests { let result = auth::ModelContract::from_str(input); assert!(result.is_err()); } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 25473a78fd..1d18e6e80a 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -196,4 +196,4 @@ mod tests { // Assert assert_eq!(table, expected_table, "Tables mismatch") } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index 4b1e9d05fc..6a87b63003 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -59,4 +59,4 @@ impl CallArgs { .await }) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index 4b28d33f74..21c36a6255 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -143,4 +143,4 @@ mod tests { assert!(!manifest_toml.exists(), "Expected 'manifest.toml' to not exist"); assert!(!manifest_json.exists(), "Expected 'manifest.json' to not exist"); } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/completions.rs b/bin/sozo/src/commands/completions.rs index d07b989dc4..ad1afbd6e9 100644 --- a/bin/sozo/src/commands/completions.rs +++ b/bin/sozo/src/commands/completions.rs @@ -22,4 +22,4 @@ impl CompletionsArgs { generate(self.shell, &mut command, name, &mut io::stdout()); Ok(()) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index 291b1bb2ed..d826326c3c 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -302,4 +302,4 @@ fn handle_reload_action(context: &mut DevContext<'_>) { let new_context = load_context(config).expect("Failed to load context"); let _ = mem::replace(context, new_context); trace!(target: LOG_TARGET, "Context reloaded."); -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index 616fbca6f7..d978723f2c 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -89,4 +89,4 @@ impl EventsArgs { .await }) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index b7a444d926..7dc932ea6d 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -74,4 +74,4 @@ impl ExecuteArgs { .await }) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index c851e73b8e..9ab60ebffb 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -116,4 +116,4 @@ fn modify_git_history(url: &str) -> Result<()> { trace!(target: LOG_TARGET, "Git history modified."); Ok(()) -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/keystore.rs b/bin/sozo/src/commands/keystore.rs index ac5d567b53..5851403ce8 100644 --- a/bin/sozo/src/commands/keystore.rs +++ b/bin/sozo/src/commands/keystore.rs @@ -80,4 +80,4 @@ impl KeystoreArgs { } } } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index 3c4994d177..b61d18edcc 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -220,4 +220,4 @@ pub async fn setup_env<'a>( .with_context(|| "Problem initializing account for migration.")?; Ok((world_address, account, chain_id, rpc_url.to_string())) -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/mod.rs b/bin/sozo/src/commands/mod.rs index 1333afa558..181781977a 100644 --- a/bin/sozo/src/commands/mod.rs +++ b/bin/sozo/src/commands/mod.rs @@ -89,4 +89,4 @@ pub fn run(command: Commands, config: &Config) -> Result<()> { Commands::Events(args) => args.run(config), Commands::Completions(args) => args.run(), } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/model.rs b/bin/sozo/src/commands/model.rs index e5e0aae244..d92545c72c 100644 --- a/bin/sozo/src/commands/model.rs +++ b/bin/sozo/src/commands/model.rs @@ -103,4 +103,4 @@ impl ModelArgs { } }) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/options/mod.rs b/bin/sozo/src/commands/options/mod.rs index 9f817439fd..8614927877 100644 --- a/bin/sozo/src/commands/options/mod.rs +++ b/bin/sozo/src/commands/options/mod.rs @@ -10,4 +10,4 @@ const DOJO_PRIVATE_KEY_ENV_VAR: &str = "DOJO_PRIVATE_KEY"; const DOJO_KEYSTORE_PATH_ENV_VAR: &str = "DOJO_KEYSTORE_PATH"; const DOJO_KEYSTORE_PASSWORD_ENV_VAR: &str = "DOJO_KEYSTORE_PASSWORD"; const DOJO_ACCOUNT_ADDRESS_ENV_VAR: &str = "DOJO_ACCOUNT_ADDRESS"; -const DOJO_WORLD_ADDRESS_ENV_VAR: &str = "DOJO_WORLD_ADDRESS"; +const DOJO_WORLD_ADDRESS_ENV_VAR: &str = "DOJO_WORLD_ADDRESS"; \ No newline at end of file diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index 46b5c7cddb..f4d4aa47d4 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -247,4 +247,4 @@ mod tests { assert!(result.is_err()); } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 5fc4c03375..8e4376e930 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -108,4 +108,4 @@ mod tests { let cmd = Command::parse_from([""]); assert_eq!(cmd.options.url(Some(&env_metadata)).unwrap().as_str(), DEFAULT_RPC); } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index 0a9c21128c..648bed4207 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -47,4 +47,4 @@ impl From for TxnConfig { receipt: value.receipt, } } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index bc5322c5c2..9d40d1311e 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -102,4 +102,4 @@ mod tests { let cmd = Command::parse_from([""]); assert!(cmd.inner.address(None).is_err()); } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index 0d62aa52a4..053a6e2908 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -79,4 +79,4 @@ impl RegisterArgs { .await }) } -} +} \ No newline at end of file diff --git a/bin/sozo/src/commands/test.rs b/bin/sozo/src/commands/test.rs index 9ca645c72c..554aa4cc1c 100644 --- a/bin/sozo/src/commands/test.rs +++ b/bin/sozo/src/commands/test.rs @@ -121,4 +121,4 @@ fn build_project_config(unit: &CompilationUnit) -> Result { trace!(target: LOG_TARGET, ?project_config); Ok(project_config) -} +} \ No newline at end of file diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 9334e58d23..3c44eec84e 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -20,7 +20,7 @@ pub(crate) const LOG_TARGET: &str = "sozo::cli"; fn main() { let args = SozoArgs::parse(); - args.init_logging(); + let _ = args.init_logging(); trace!(target: LOG_TARGET, command = ?args.command, "Sozo CLI command started."); let ui = Ui::new(args.ui_verbosity(), OutputFormat::Text); @@ -59,9 +59,9 @@ fn cli_main(args: SozoArgs) -> Result<()> { trace!(target: LOG_TARGET, "Configuration built successfully"); - commands::run(args.command, &config); + let _ = commands::run(args.command, &config); trace!(target: LOG_TARGET, "Command execution completed"); Ok(()) -} +} \ No newline at end of file From 7b8a3fa60756b11081f0081b5ab4f7ea6c462d1a Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya <41485330+btirth@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:55:14 -0700 Subject: [PATCH 05/16] Updated Sozo trace logs Co-authored-by: glihm --- bin/sozo/src/args.rs | 4 +--- bin/sozo/src/commands/account.rs | 2 +- bin/sozo/src/commands/auth.rs | 12 ++++++------ bin/sozo/src/commands/build.rs | 1 - bin/sozo/src/commands/completions.rs | 1 - bin/sozo/src/commands/dev.rs | 2 +- bin/sozo/src/commands/events.rs | 8 ++++---- bin/sozo/src/commands/execute.rs | 2 +- bin/sozo/src/commands/init.rs | 1 - bin/sozo/src/commands/migrate.rs | 2 +- bin/sozo/src/commands/options/account.rs | 5 +---- bin/sozo/src/commands/options/starknet.rs | 2 +- bin/sozo/src/commands/register.rs | 2 +- bin/sozo/src/main.rs | 4 +--- 14 files changed, 19 insertions(+), 29 deletions(-) diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 3b41ab6783..4f48df5c18 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -57,9 +57,7 @@ impl SozoArgs { } pub fn init_logging(&self) -> Result<(), Box> { - const DEFAULT_LOG_FILTER: &str = "info,server=debug,\ - blockifier=off,jsonrpsee_server=off,\ - hyper=off,messaging=debug,node=error"; + const DEFAULT_LOG_FILTER: &str = "info,hyper=off,scarb=off"; let builder = fmt::Subscriber::builder().with_env_filter( EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?, diff --git a/bin/sozo/src/commands/account.rs b/bin/sozo/src/commands/account.rs index 524e7d0715..25977001ce 100644 --- a/bin/sozo/src/commands/account.rs +++ b/bin/sozo/src/commands/account.rs @@ -97,7 +97,7 @@ impl AccountArgs { ?signer, force, ?file, - "Executing New command" + "Executing New command." ); let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; account::new(signer, force, file).await diff --git a/bin/sozo/src/commands/auth.rs b/bin/sozo/src/commands/auth.rs index f7a44f4783..8b4f53ad3e 100644 --- a/bin/sozo/src/commands/auth.rs +++ b/bin/sozo/src/commands/auth.rs @@ -108,7 +108,7 @@ pub async fn grant( kind: AuthKind, transaction: TransactionOptions, ) -> Result<()> { - trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing 'Grant' command."); + trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing Grant command."); let world = utils::world_from_env_metadata(world, account, starknet, &env_metadata).await.unwrap(); @@ -117,7 +117,7 @@ pub async fn grant( trace!( target: LOG_TARGET, contracts=?models_contracts, - "Granting 'Writer' permissions." + "Granting Writer permissions." ); auth::grant_writer(&world, models_contracts, transaction.into()).await } @@ -125,7 +125,7 @@ pub async fn grant( trace!( target: LOG_TARGET, resources=?owners_resources, - "Granting 'Owner' permissions." + "Granting Owner permissions." ); auth::grant_owner(&world, owners_resources, transaction.into()).await } @@ -140,7 +140,7 @@ pub async fn revoke( kind: AuthKind, transaction: TransactionOptions, ) -> Result<()> { - trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing 'Revoke' command."); + trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing Revoke command."); let world = utils::world_from_env_metadata(world, account, starknet, &env_metadata).await.unwrap(); match kind { @@ -148,7 +148,7 @@ pub async fn revoke( trace!( target: LOG_TARGET, contracts=?models_contracts, - "Revoking 'Writer' permissions." + "Revoking Writer permissions." ); auth::revoke_writer(&world, models_contracts, transaction.into()).await } @@ -156,7 +156,7 @@ pub async fn revoke( trace!( target: LOG_TARGET, resources=?owners_resources, - "Revoking 'Owner' permissions." + "Revoking Owner permissions." ); auth::revoke_owner(&world, owners_resources, transaction.into()).await } diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 1d18e6e80a..11431f9915 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -81,7 +81,6 @@ impl BuildArgs { .unwrap() .block_on(bindgen.generate()) .expect("Error generating bindings"); - trace!(target: LOG_TARGET, "Completed generating bindings."); Ok(()) } diff --git a/bin/sozo/src/commands/completions.rs b/bin/sozo/src/commands/completions.rs index ad1afbd6e9..54642221bf 100644 --- a/bin/sozo/src/commands/completions.rs +++ b/bin/sozo/src/commands/completions.rs @@ -18,7 +18,6 @@ impl CompletionsArgs { pub fn run(self) -> Result<()> { let mut command = SozoArgs::command(); let name = command.get_name().to_string(); - trace!(target: LOG_TARGET, name, "Executing Command."); generate(self.shell, &mut command, name, &mut io::stdout()); Ok(()) } diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index d826326c3c..abe0e5ed9d 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -196,7 +196,7 @@ fn load_context(config: &Config) -> Result> { // we have only 1 unit in projects // TODO: double check if we always have one with the new version and the order if many. - trace!(target: LOG_TARGET, units=compilation_units.len(), "Generated compilation."); + trace!(target: LOG_TARGET, unit_count=compilation_units.len(), "Gathering compilation units."); let unit = compilation_units.first().unwrap(); let db = build_scarb_root_database(unit).unwrap(); Ok(DevContext { db, unit: unit.clone(), ws }) diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index d978723f2c..deaa7c5fb1 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -55,7 +55,7 @@ impl EventsArgs { trace!(target: LOG_TARGET, ?manifest_dir, "Fetched manifest directory."); let provider = self.starknet.provider(env_metadata.as_ref())?; - trace!(target: LOG_TARGET, ?provider, "Starknet RPC client provider"); + trace!(target: LOG_TARGET, ?provider, "Starknet RPC client provider."); let event_filter = events::get_event_filter( self.from_block, @@ -68,15 +68,15 @@ impl EventsArgs { from_block=self.from_block, to_block=self.to_block, chunk_size=self.chunk_size, - "Created event filter" + "Created event filter." ); let profile_name = ws.current_profile().expect("Scarb profile expected at this point.").to_string(); - trace!(target: LOG_TARGET, profile_name, "Fetched profile name"); + trace!(target: LOG_TARGET, profile_name, "Fetched profile name."); config.tokio_handle().block_on(async { - trace!(target: LOG_TARGET, "Starting async event parsing"); + trace!(target: LOG_TARGET, "Starting async event parsing."); events::parse( self.chunk_size, provider, diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index 7dc932ea6d..4bba06ae31 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -68,7 +68,7 @@ impl ExecuteArgs { contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, - "Executing command." + "Executing Execute command." ); execute::execute(self.contract, self.entrypoint, self.calldata, &world, &tx_config) .await diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index 9ab60ebffb..e5e44a3619 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -55,7 +55,6 @@ impl InitArgs { let template = self.template; let repo_url = if template.starts_with("https://") { - trace!(target: LOG_TARGET, template=%template); template } else { let url = "https://github.com/".to_string() + &template; diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index b61d18edcc..769f2cb931 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -70,7 +70,7 @@ pub enum MigrateCommand { impl MigrateArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, command=?self.command, "Executing command"); + trace!(target: LOG_TARGET, command=?self.command, "Executing Migrate command"); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; let env_metadata = if config.manifest_path().exists() { diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index 7bd859a8a5..9c549f0ed3 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -54,19 +54,16 @@ impl AccountOptions { provider.chain_id().await.with_context(|| "Failed to retrieve network chain id.")?; trace!(target: LOG_TARGET, ?chain_id, "Chain ID obtained."); let encoding = if self.legacy { - trace!(target: LOG_TARGET, "Using legacy encoding."); ExecutionEncoding::Legacy } else { - trace!(target: LOG_TARGET, "Using new encoding."); ExecutionEncoding::New }; - trace!(target: LOG_TARGET, ?chain_id, ?encoding, "Creating SingleOwnerAccount."); + trace!(target: LOG_TARGET, ?encoding, "Creating SingleOwnerAccount."); Ok(SingleOwnerAccount::new(provider, signer, account_address, chain_id, encoding)) } fn account_address(&self, env_metadata: Option<&Environment>) -> Result { - trace!(target: LOG_TARGET, "Determining account address."); if let Some(address) = self.account_address { trace!(target: LOG_TARGET, ?address, "Account address found."); Ok(address) diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 8e4376e930..355a8e6adb 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -41,7 +41,7 @@ impl StarknetOptions { trace!(target: LOG_TARGET, url, "Using RPC URL from environment metadata."); Ok(Url::parse(url)?) } else { - trace!(target: LOG_TARGET, "Using default RPC URL: http://localhost:5050"); + trace!(target: LOG_TARGET, "Using default RPC URL: http://localhost:5050."); Ok(Url::parse("http://localhost:5050").unwrap()) } } diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index 053a6e2908..5bfe2bf6ef 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -47,7 +47,7 @@ pub enum RegisterCommand { impl RegisterArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, command=?self.command, "Executing command."); + trace!(target: LOG_TARGET, command=?self.command, "Executing Register command."); let env_metadata = utils::load_metadata_from_config(config)?; let (starknet, world, account, transaction, models) = match self.command { diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 3c44eec84e..7e5d1330fa 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -40,7 +40,6 @@ fn cli_main(args: SozoArgs) -> Result<()> { compilers.add(Box::new(DojoCompiler)).unwrap() } _ => { - trace!(target: LOG_TARGET, "No additional compiler required"); } } @@ -57,11 +56,10 @@ fn cli_main(args: SozoArgs) -> Result<()> { .compilers(compilers) .build()?; - trace!(target: LOG_TARGET, "Configuration built successfully"); + trace!(target: LOG_TARGET, "Configuration built successfully."); let _ = commands::run(args.command, &config); - trace!(target: LOG_TARGET, "Command execution completed"); Ok(()) } \ No newline at end of file From ac24152d97182cb3892dcaefe216e81780228433 Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Wed, 24 Apr 2024 00:08:04 -0300 Subject: [PATCH 06/16] Updated Sozo trace logs. --- bin/sozo/src/args.rs | 2 +- bin/sozo/src/commands/account.rs | 2 +- bin/sozo/src/commands/auth.rs | 2 +- bin/sozo/src/commands/build.rs | 2 +- bin/sozo/src/commands/call.rs | 4 ++-- bin/sozo/src/commands/clean.rs | 2 +- bin/sozo/src/commands/completions.rs | 5 +---- bin/sozo/src/commands/dev.rs | 2 +- bin/sozo/src/commands/events.rs | 2 +- bin/sozo/src/commands/execute.rs | 2 +- bin/sozo/src/commands/init.rs | 13 ++++--------- bin/sozo/src/commands/keystore.rs | 2 +- bin/sozo/src/commands/migrate.rs | 2 +- bin/sozo/src/commands/mod.rs | 2 +- bin/sozo/src/commands/model.rs | 2 +- bin/sozo/src/commands/options/account.rs | 2 +- bin/sozo/src/commands/options/fee.rs | 2 +- bin/sozo/src/commands/options/mod.rs | 2 +- bin/sozo/src/commands/options/signer.rs | 2 +- bin/sozo/src/commands/options/starknet.rs | 2 +- bin/sozo/src/commands/options/transaction.rs | 2 +- bin/sozo/src/commands/options/world.rs | 2 +- bin/sozo/src/commands/register.rs | 6 +++--- bin/sozo/src/commands/test.rs | 2 +- bin/sozo/src/main.rs | 2 +- 25 files changed, 31 insertions(+), 39 deletions(-) diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 4f48df5c18..624d1ba784 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -99,4 +99,4 @@ impl ProfileSpec { _ => Profile::default(), }) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/account.rs b/bin/sozo/src/commands/account.rs index 25977001ce..ee18a2e1c4 100644 --- a/bin/sozo/src/commands/account.rs +++ b/bin/sozo/src/commands/account.rs @@ -154,4 +154,4 @@ impl AccountArgs { } }) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/auth.rs b/bin/sozo/src/commands/auth.rs index 8b4f53ad3e..754f02f400 100644 --- a/bin/sozo/src/commands/auth.rs +++ b/bin/sozo/src/commands/auth.rs @@ -213,4 +213,4 @@ mod tests { let result = auth::ModelContract::from_str(input); assert!(result.is_err()); } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 11431f9915..9182388596 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -195,4 +195,4 @@ mod tests { // Assert assert_eq!(table, expected_table, "Tables mismatch") } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index 6a87b63003..d33371092e 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -38,7 +38,7 @@ pub struct CallArgs { impl CallArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, block_id=self.block_id); + trace!(target: LOG_TARGET, contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, block_id=self.block_id, "Executing Call command."); let env_metadata = utils::load_metadata_from_config(config)?; trace!(target: LOG_TARGET, ?env_metadata, "Fetched environment metadata."); @@ -59,4 +59,4 @@ impl CallArgs { .await }) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index 21c36a6255..4b28d33f74 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -143,4 +143,4 @@ mod tests { assert!(!manifest_toml.exists(), "Expected 'manifest.toml' to not exist"); assert!(!manifest_json.exists(), "Expected 'manifest.json' to not exist"); } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/completions.rs b/bin/sozo/src/commands/completions.rs index 54642221bf..1f71098822 100644 --- a/bin/sozo/src/commands/completions.rs +++ b/bin/sozo/src/commands/completions.rs @@ -3,12 +3,9 @@ use std::io; use anyhow::Result; use clap::{Args, CommandFactory}; use clap_complete::{generate, Shell}; -use tracing::trace; use crate::args::SozoArgs; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::completions"; - #[derive(Debug, Args)] pub struct CompletionsArgs { shell: Shell, @@ -21,4 +18,4 @@ impl CompletionsArgs { generate(self.shell, &mut command, name, &mut io::stdout()); Ok(()) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index abe0e5ed9d..c403ec5af1 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -302,4 +302,4 @@ fn handle_reload_action(context: &mut DevContext<'_>) { let new_context = load_context(config).expect("Failed to load context"); let _ = mem::replace(context, new_context); trace!(target: LOG_TARGET, "Context reloaded."); -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index deaa7c5fb1..a3b7c31c79 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -89,4 +89,4 @@ impl EventsArgs { .await }) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index 4bba06ae31..7fadfb93cb 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -74,4 +74,4 @@ impl ExecuteArgs { .await }) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index e5e44a3619..38631eacda 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -24,21 +24,16 @@ impl InitArgs { let target_dir = match self.path { Some(path) => { if path.is_absolute() { - trace!(target: LOG_TARGET, ?path); path } else { let mut current_path = current_dir().unwrap(); current_path.push(path); - trace!(target: LOG_TARGET, ?current_path); current_path } } - None => { - let dir = current_dir().unwrap(); - trace!(target: LOG_TARGET, ?dir); - dir - } + None => current_dir().unwrap(), }; + trace!(target: LOG_TARGET, ?target_dir, "Executing Init command."); if target_dir.exists() { ensure!( @@ -67,7 +62,7 @@ impl InitArgs { // Navigate to the newly cloned repo. let initial_dir = current_dir()?; set_current_dir(&target_dir)?; - trace!(target: LOG_TARGET, ?target_dir); + trace!(target: LOG_TARGET, ?target_dir, "Navigating to newly cloned repo."); // Modify the git history. modify_git_history(&repo_url)?; @@ -115,4 +110,4 @@ fn modify_git_history(url: &str) -> Result<()> { trace!(target: LOG_TARGET, "Git history modified."); Ok(()) -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/keystore.rs b/bin/sozo/src/commands/keystore.rs index 5851403ce8..ac5d567b53 100644 --- a/bin/sozo/src/commands/keystore.rs +++ b/bin/sozo/src/commands/keystore.rs @@ -80,4 +80,4 @@ impl KeystoreArgs { } } } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index 769f2cb931..6d6eba0fc2 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -220,4 +220,4 @@ pub async fn setup_env<'a>( .with_context(|| "Problem initializing account for migration.")?; Ok((world_address, account, chain_id, rpc_url.to_string())) -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/mod.rs b/bin/sozo/src/commands/mod.rs index 181781977a..1333afa558 100644 --- a/bin/sozo/src/commands/mod.rs +++ b/bin/sozo/src/commands/mod.rs @@ -89,4 +89,4 @@ pub fn run(command: Commands, config: &Config) -> Result<()> { Commands::Events(args) => args.run(config), Commands::Completions(args) => args.run(), } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/model.rs b/bin/sozo/src/commands/model.rs index d92545c72c..e5e0aae244 100644 --- a/bin/sozo/src/commands/model.rs +++ b/bin/sozo/src/commands/model.rs @@ -103,4 +103,4 @@ impl ModelArgs { } }) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index 9c549f0ed3..ce792dab1c 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -190,4 +190,4 @@ mod tests { // 0x2 is the Calldata len. assert!(*result.get(3).unwrap() == FieldElement::from_hex_be("0x2").unwrap()); } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/options/fee.rs b/bin/sozo/src/commands/options/fee.rs index 6e96d56a91..4467d33b59 100644 --- a/bin/sozo/src/commands/options/fee.rs +++ b/bin/sozo/src/commands/options/fee.rs @@ -104,4 +104,4 @@ where } Ok(FieldElement::from_byte_slice_be(&biguint.to_bytes_be())?) -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/options/mod.rs b/bin/sozo/src/commands/options/mod.rs index 8614927877..9f817439fd 100644 --- a/bin/sozo/src/commands/options/mod.rs +++ b/bin/sozo/src/commands/options/mod.rs @@ -10,4 +10,4 @@ const DOJO_PRIVATE_KEY_ENV_VAR: &str = "DOJO_PRIVATE_KEY"; const DOJO_KEYSTORE_PATH_ENV_VAR: &str = "DOJO_KEYSTORE_PATH"; const DOJO_KEYSTORE_PASSWORD_ENV_VAR: &str = "DOJO_KEYSTORE_PASSWORD"; const DOJO_ACCOUNT_ADDRESS_ENV_VAR: &str = "DOJO_ACCOUNT_ADDRESS"; -const DOJO_WORLD_ADDRESS_ENV_VAR: &str = "DOJO_WORLD_ADDRESS"; \ No newline at end of file +const DOJO_WORLD_ADDRESS_ENV_VAR: &str = "DOJO_WORLD_ADDRESS"; diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index f4d4aa47d4..46b5c7cddb 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -247,4 +247,4 @@ mod tests { assert!(result.is_err()); } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 355a8e6adb..3cefc1a0d7 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -108,4 +108,4 @@ mod tests { let cmd = Command::parse_from([""]); assert_eq!(cmd.options.url(Some(&env_metadata)).unwrap().as_str(), DEFAULT_RPC); } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index db76ca3840..b45ac7ed79 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -55,4 +55,4 @@ impl From for TxnConfig { max_fee_raw: value.max_fee_raw, } } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index 9d40d1311e..bc5322c5c2 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -102,4 +102,4 @@ mod tests { let cmd = Command::parse_from([""]); assert!(cmd.inner.address(None).is_err()); } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index 5bfe2bf6ef..d95c462f72 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -52,7 +52,7 @@ impl RegisterArgs { let (starknet, world, account, transaction, models) = match self.command { RegisterCommand::Model { starknet, world, account, transaction, models } => { - trace!(target: LOG_TARGET, models=?models, "Registering models."); + trace!(target: LOG_TARGET, ?models, "Registering models."); (starknet, world, account, transaction, models) } }; @@ -66,7 +66,7 @@ impl RegisterArgs { let provider = world.account.provider(); let world_reader = WorldContractReader::new(world_address, &provider) .with_block(BlockId::Tag(BlockTag::Pending)); - trace!(target: LOG_TARGET, "WorldContractReader initialized with block tag Pending."); + trace!(target: LOG_TARGET, ?world_address, "WorldContractReader initialized with block tag Pending."); register::model_register( models, @@ -79,4 +79,4 @@ impl RegisterArgs { .await }) } -} \ No newline at end of file +} diff --git a/bin/sozo/src/commands/test.rs b/bin/sozo/src/commands/test.rs index 554aa4cc1c..9ca645c72c 100644 --- a/bin/sozo/src/commands/test.rs +++ b/bin/sozo/src/commands/test.rs @@ -121,4 +121,4 @@ fn build_project_config(unit: &CompilationUnit) -> Result { trace!(target: LOG_TARGET, ?project_config); Ok(project_config) -} \ No newline at end of file +} diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 7e5d1330fa..9be3185a28 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -62,4 +62,4 @@ fn cli_main(args: SozoArgs) -> Result<()> { Ok(()) -} \ No newline at end of file +} From 066dcaaa7f5c2379d8a221e7db88012916f195e6 Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya <41485330+btirth@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:16:36 -0700 Subject: [PATCH 07/16] Updated Sozo trace logs Co-authored-by: Ammar Arif --- bin/sozo/src/commands/build.rs | 9 --------- bin/sozo/src/commands/clean.rs | 4 ---- bin/sozo/src/commands/execute.rs | 6 ------ bin/sozo/src/commands/init.rs | 5 ----- bin/sozo/src/commands/mod.rs | 2 +- bin/sozo/src/commands/register.rs | 1 - bin/sozo/src/main.rs | 1 - 7 files changed, 1 insertion(+), 27 deletions(-) diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 9182388596..82295a3a21 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -96,20 +96,12 @@ fn create_stats_table(contracts_statistics: Vec) -> Table { Cell::new_align("Bytecode size (felts)", format::Alignment::CENTER), Cell::new_align("Class size (bytes)", format::Alignment::CENTER), ])); - trace!(target: LOG_TARGET, "Creating table for contract statistics."); for contract_stats in contracts_statistics { // Add table rows let contract_name = contract_stats.contract_name; let number_felts = contract_stats.number_felts; let file_size = contract_stats.file_size; - trace!( - target: LOG_TARGET, - contract_name, - number_felts, - file_size, - "Adding row to table." - ); table.add_row(Row::new(vec![ Cell::new_align(&contract_name, format::Alignment::LEFT), Cell::new_align(format!("{}", number_felts).as_str(), format::Alignment::RIGHT), @@ -117,7 +109,6 @@ fn create_stats_table(contracts_statistics: Vec) -> Table { ])); } - trace!(target: LOG_TARGET, "Completed creating stats table."); table } diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index 4b28d33f74..82f81794f8 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -31,8 +31,6 @@ impl CleanArgs { if d.exists() { trace!(target: LOG_TARGET, directory=?d, "Removing directory."); fs::remove_dir_all(d)?; - } else { - trace!(target: LOG_TARGET, directory=?d, "Directory does not exist."); } } @@ -60,8 +58,6 @@ impl CleanArgs { if self.all && profile_dir.exists() { trace!(target: LOG_TARGET, ?profile_dir, "Removing entire profile directory."); fs::remove_dir_all(profile_dir)?; - } else { - trace!(target: LOG_TARGET, ?profile_dir, "Profile directory does not exist."); } Ok(()) diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index 7fadfb93cb..48f08cf63b 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -56,12 +56,6 @@ impl ExecuteArgs { .await .unwrap(); let tx_config = self.transaction.into(); - trace!( - target: LOG_TARGET, - ?tx_config, - "Transaction configuration initialized.", - - ); trace!( target: LOG_TARGET, diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index 38631eacda..59ae5d8fae 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -40,9 +40,6 @@ impl InitArgs { fs::read_dir(&target_dir)?.next().is_none(), io::Error::new(io::ErrorKind::Other, "Target directory is not empty",) ); - trace!(target: LOG_TARGET, "Target directory is empty."); - } else { - trace!(target: LOG_TARGET, "Target directory does not exist."); } config.ui().print("\n\n ā›©ļø ====== STARTING ====== ā›©ļø \n"); @@ -62,7 +59,6 @@ impl InitArgs { // Navigate to the newly cloned repo. let initial_dir = current_dir()?; set_current_dir(&target_dir)?; - trace!(target: LOG_TARGET, ?target_dir, "Navigating to newly cloned repo."); // Modify the git history. modify_git_history(&repo_url)?; @@ -70,7 +66,6 @@ impl InitArgs { config.ui().print("\nšŸŽ‰ Successfully created a new ā›©ļø Dojo project!"); // Navigate back. - trace!(target: LOG_TARGET, ?initial_dir, "Returned to initial directory."); set_current_dir(initial_dir)?; config.ui().print( diff --git a/bin/sozo/src/commands/mod.rs b/bin/sozo/src/commands/mod.rs index 1333afa558..26521819a4 100644 --- a/bin/sozo/src/commands/mod.rs +++ b/bin/sozo/src/commands/mod.rs @@ -36,7 +36,7 @@ use register::RegisterArgs; use test::TestArgs; #[derive(Subcommand)] -#[derive(Debug)] +#[derive(Debug, Subcommand)] pub enum Commands { #[command(about = "Manage accounts")] Account(AccountArgs), diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index d95c462f72..2ff10277e2 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -66,7 +66,6 @@ impl RegisterArgs { let provider = world.account.provider(); let world_reader = WorldContractReader::new(world_address, &provider) .with_block(BlockId::Tag(BlockTag::Pending)); - trace!(target: LOG_TARGET, ?world_address, "WorldContractReader initialized with block tag Pending."); register::model_register( models, diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 9be3185a28..05ff0f394f 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -21,7 +21,6 @@ fn main() { let args = SozoArgs::parse(); let _ = args.init_logging(); - trace!(target: LOG_TARGET, command = ?args.command, "Sozo CLI command started."); let ui = Ui::new(args.ui_verbosity(), OutputFormat::Text); if let Err(err) = cli_main(args) { From 2c4124dde42bbeb83c5d188c68cc5c05fab6776d Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya <41485330+btirth@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:21:22 -0700 Subject: [PATCH 08/16] Updated Sozo trace logs. --- bin/sozo/src/commands/init.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index 59ae5d8fae..0f4e1befb5 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -49,9 +49,7 @@ impl InitArgs { let repo_url = if template.starts_with("https://") { template } else { - let url = "https://github.com/".to_string() + &template; - trace!(target: LOG_TARGET, url, "Constructed Git URL."); - url + "https://github.com/".to_string() + &template }; clone_repo(&repo_url, &target_dir, config)?; From 5bb716a7ea3c5946cf1c74d84feb9ff0307e4736 Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Thu, 25 Apr 2024 00:46:52 -0300 Subject: [PATCH 09/16] Removed json for Sozo log. --- bin/sozo/src/args.rs | 10 +--------- bin/sozo/src/commands/mod.rs | 1 - 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 624d1ba784..3ae22c7ab5 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -36,10 +36,6 @@ pub struct SozoArgs { #[arg(help = "Run without accessing the network.")] pub offline: bool, - #[arg(long)] - #[arg(help = "Output logs in JSON format.")] - pub json_log: bool, - #[command(subcommand)] pub command: Commands, } @@ -63,11 +59,7 @@ impl SozoArgs { EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?, ); - let subscriber: Box = if self.json_log { - Box::new(builder.json().finish()) - } else { - Box::new(builder.finish()) - }; + let subscriber: Box = Box::new(builder.finish()); Ok(tracing::subscriber::set_global_default(subscriber)?) } diff --git a/bin/sozo/src/commands/mod.rs b/bin/sozo/src/commands/mod.rs index 26521819a4..6c8b876b01 100644 --- a/bin/sozo/src/commands/mod.rs +++ b/bin/sozo/src/commands/mod.rs @@ -35,7 +35,6 @@ use model::ModelArgs; use register::RegisterArgs; use test::TestArgs; -#[derive(Subcommand)] #[derive(Debug, Subcommand)] pub enum Commands { #[command(about = "Manage accounts")] From 1d666803d716601bf64516609fb20b92b2cb58cb Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Fri, 26 Apr 2024 20:33:19 -0300 Subject: [PATCH 10/16] Removed LOG_TARGET for Sozo trace logs. --- bin/sozo/src/commands/account.rs | 21 ++++++++--------- bin/sozo/src/commands/auth.rs | 14 ++++-------- bin/sozo/src/commands/build.rs | 8 +++---- bin/sozo/src/commands/call.rs | 6 ++--- bin/sozo/src/commands/clean.rs | 12 ++++------ bin/sozo/src/commands/dev.rs | 24 +++++++++----------- bin/sozo/src/commands/events.rs | 17 ++++++-------- bin/sozo/src/commands/execute.rs | 3 --- bin/sozo/src/commands/init.rs | 17 +++++--------- bin/sozo/src/commands/migrate.rs | 20 ++++++++-------- bin/sozo/src/commands/options/account.rs | 16 ++++++------- bin/sozo/src/commands/options/fee.rs | 14 ++++-------- bin/sozo/src/commands/options/signer.rs | 5 +--- bin/sozo/src/commands/options/starknet.rs | 12 ++++------ bin/sozo/src/commands/options/transaction.rs | 3 --- bin/sozo/src/commands/options/world.rs | 8 ++----- bin/sozo/src/commands/register.rs | 8 +++---- 17 files changed, 79 insertions(+), 129 deletions(-) diff --git a/bin/sozo/src/commands/account.rs b/bin/sozo/src/commands/account.rs index ee18a2e1c4..d244a1ab1a 100644 --- a/bin/sozo/src/commands/account.rs +++ b/bin/sozo/src/commands/account.rs @@ -13,8 +13,6 @@ use super::options::starknet::StarknetOptions; use crate::utils; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::account"; - #[derive(Debug, Args)] pub struct AccountArgs { #[clap(subcommand)] @@ -86,20 +84,20 @@ pub enum AccountCommand { impl AccountArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, command=?self.command, "Executing command."); + trace!(command=?self.command, "Executing command."); let env_metadata = utils::load_metadata_from_config(config)?; config.tokio_handle().block_on(async { match self.command { AccountCommand::New { signer, force, file } => { - trace!( - target: LOG_TARGET, + + let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; + trace!( ?signer, force, ?file, "Executing New command." ); - let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; account::new(signer, force, file).await } AccountCommand::Deploy { @@ -112,11 +110,14 @@ impl AccountArgs { file, no_confirmation, } => { + + let provider = starknet.provider(env_metadata.as_ref())?; + let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; + let fee_setting = fee.into_setting()?; trace!( - target: LOG_TARGET, ?starknet, ?signer, - ?fee, + ?fee_setting, simulate, ?nonce, poll_interval, @@ -124,9 +125,6 @@ impl AccountArgs { no_confirmation, "Executing Deploy command." ); - let provider = starknet.provider(env_metadata.as_ref())?; - let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; - let fee_setting = fee.into_setting()?; account::deploy( provider, signer, @@ -141,7 +139,6 @@ impl AccountArgs { } AccountCommand::Fetch { starknet, force, output, address } => { trace!( - target: LOG_TARGET, ?starknet, force, ?output, diff --git a/bin/sozo/src/commands/auth.rs b/bin/sozo/src/commands/auth.rs index 754f02f400..6b662ad8e6 100644 --- a/bin/sozo/src/commands/auth.rs +++ b/bin/sozo/src/commands/auth.rs @@ -11,8 +11,6 @@ use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; use crate::utils; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::auth"; - #[derive(Debug, Args)] pub struct AuthArgs { #[command(subcommand)] @@ -59,10 +57,10 @@ pub enum AuthCommand { impl AuthArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, command=?self.command, "Executing Auth command.", ); + trace!(command=?self.command, "Executing Auth command.", ); let env_metadata = utils::load_metadata_from_config(config)?; - trace!(target: LOG_TARGET, metadata=?env_metadata, "Loaded environment."); + trace!(metadata=?env_metadata, "Loaded environment."); match self.command { AuthCommand::Grant { kind, world, starknet, account, transaction } => config @@ -108,14 +106,13 @@ pub async fn grant( kind: AuthKind, transaction: TransactionOptions, ) -> Result<()> { - trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing Grant command."); + trace!(?kind, ?world, ?starknet, ?account, ?transaction, "Executing Grant command."); let world = utils::world_from_env_metadata(world, account, starknet, &env_metadata).await.unwrap(); match kind { AuthKind::Writer { models_contracts } => { trace!( - target: LOG_TARGET, contracts=?models_contracts, "Granting Writer permissions." ); @@ -123,7 +120,6 @@ pub async fn grant( } AuthKind::Owner { owners_resources } => { trace!( - target: LOG_TARGET, resources=?owners_resources, "Granting Owner permissions." ); @@ -140,13 +136,12 @@ pub async fn revoke( kind: AuthKind, transaction: TransactionOptions, ) -> Result<()> { - trace!(target: LOG_TARGET, ?kind, ?world, ?starknet, ?account, ?transaction, "Executing Revoke command."); + trace!(?kind, ?world, ?starknet, ?account, ?transaction, "Executing Revoke command."); let world = utils::world_from_env_metadata(world, account, starknet, &env_metadata).await.unwrap(); match kind { AuthKind::Writer { models_contracts } => { trace!( - target: LOG_TARGET, contracts=?models_contracts, "Revoking Writer permissions." ); @@ -154,7 +149,6 @@ pub async fn revoke( } AuthKind::Owner { owners_resources } => { trace!( - target: LOG_TARGET, resources=?owners_resources, "Revoking Owner permissions." ); diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 82295a3a21..53ab54867d 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -9,8 +9,6 @@ use scarb::ops::CompileOpts; use sozo_ops::statistics::{get_contract_statistics_for_dir, ContractStatistics}; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::build"; - #[derive(Debug, Args)] pub struct BuildArgs { #[arg(long)] @@ -39,7 +37,7 @@ impl BuildArgs { config, CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, )?; - trace!(target: LOG_TARGET, ?compile_info, "Compiled workspace."); + trace!(?compile_info, "Compiled workspace."); let mut builtin_plugins = vec![]; if self.typescript { @@ -58,7 +56,7 @@ impl BuildArgs { let target_dir = &compile_info.target_dir; let contracts_statistics = get_contract_statistics_for_dir(target_dir) .context("Error getting contracts stats")?; - trace!(target: LOG_TARGET, ?contracts_statistics, ?target_dir, "Fetched contract statistics for target directory."); + trace!(?contracts_statistics, ?target_dir, "Fetched contract statistics for target directory."); let table = create_stats_table(contracts_statistics); table.printstd() @@ -75,7 +73,7 @@ impl BuildArgs { plugins: vec![], builtin_plugins, }; - trace!(target: LOG_TARGET, pluginManager=?bindgen, "Generating bindings."); + trace!(pluginManager=?bindgen, "Generating bindings."); tokio::runtime::Runtime::new() .unwrap() diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index d33371092e..64d82a80b7 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -8,8 +8,6 @@ use super::options::world::WorldOptions; use crate::utils; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::call"; - #[derive(Debug, Args)] #[command(about = "Call a system with the given calldata.")] pub struct CallArgs { @@ -38,10 +36,10 @@ pub struct CallArgs { impl CallArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, block_id=self.block_id, "Executing Call command."); + trace!(contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, block_id=self.block_id, "Executing Call command."); let env_metadata = utils::load_metadata_from_config(config)?; - trace!(target: LOG_TARGET, ?env_metadata, "Fetched environment metadata."); + trace!(?env_metadata, "Fetched environment metadata."); config.tokio_handle().block_on(async { let world_reader = diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index 038cd20ef7..6ae1b12271 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -7,8 +7,6 @@ use dojo_lang::compiler::{ABIS_DIR, BASE_DIR, MANIFESTS_DIR}; use scarb::core::Config; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::clean"; - #[derive(Debug, Args)] pub struct CleanArgs { #[arg(short, long)] @@ -24,12 +22,12 @@ impl CleanArgs { /// /// * `profile_dir` - The directory where the profile files are located. pub fn clean_manifests(&self, profile_dir: &Utf8PathBuf) -> Result<()> { - trace!(target: LOG_TARGET, ?profile_dir, "Cleaning manifests."); + trace!(?profile_dir, "Cleaning manifests."); let dirs = vec![profile_dir.join(BASE_DIR), profile_dir.join(ABIS_DIR).join(BASE_DIR)]; for d in dirs { if d.exists() { - trace!(target: LOG_TARGET, directory=?d, "Removing directory."); + trace!(directory=?d, "Removing directory."); fs::remove_dir_all(d)?; } } @@ -39,7 +37,7 @@ impl CleanArgs { pub fn run(self, config: &Config) -> Result<()> { let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - trace!(target: LOG_TARGET, ws=?ws, "Workspace read successfully."); + trace!(ws=?ws, "Workspace read successfully."); let profile_name = ws.current_profile().expect("Scarb profile is expected at this point.").to_string(); @@ -51,12 +49,12 @@ impl CleanArgs { let profile_dir = manifest_dir.join(MANIFESTS_DIR).join(profile_name); // By default, this command cleans the build manifests and scarb artifacts. - trace!(target: LOG_TARGET, "Cleaning Scarb artifacts and build manifests."); + trace!("Cleaning Scarb artifacts and build manifests."); scarb::ops::clean(config)?; self.clean_manifests(&profile_dir)?; if self.all && profile_dir.exists() { - trace!(target: LOG_TARGET, ?profile_dir, "Removing entire profile directory."); + trace!(?profile_dir, "Removing entire profile directory."); fs::remove_dir_all(profile_dir)?; } diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index 535f9e6ccb..1e1c3460b2 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -29,8 +29,6 @@ use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::dev"; - #[derive(Debug, Args)] pub struct DevArgs { #[arg(long)] @@ -56,7 +54,7 @@ impl DevArgs { let env_metadata = if config.manifest_path().exists() { dojo_metadata_from_workspace(&ws).env().cloned() } else { - trace!(target: LOG_TARGET, "Manifest path does not exist."); + trace!("Manifest path does not exist."); None }; @@ -105,7 +103,7 @@ impl DevArgs { } Err(error) => { error!( - target: LOG_TARGET, + error = ?error, address = ?world_address, "Migrating world." @@ -121,7 +119,7 @@ impl DevArgs { .unwrap_or(DevAction::None), Ok(Err(_)) => DevAction::None, Err(error) => { - error!(target: LOG_TARGET, error = ?error, "Receiving dev action."); + error!( error = ?error, "Receiving dev action."); break; } }; @@ -140,7 +138,7 @@ impl DevArgs { } Err(error) => { error!( - target: LOG_TARGET, + error = ?error, address = ?world_address, "Migrating world.", @@ -178,7 +176,7 @@ fn handle_event(event: &DebouncedEvent) -> DevAction { _ => DevAction::None, }; - trace!(target: LOG_TARGET, ?action, "Determined action."); + trace!(?action, "Determined action."); action } @@ -199,7 +197,7 @@ fn load_context(config: &Config) -> Result> { // we have only 1 unit in projects // TODO: double check if we always have one with the new version and the order if many. - trace!(target: LOG_TARGET, unit_count=compilation_units.len(), "Gathering compilation units."); + trace!(unit_count=compilation_units.len(), "Gathering compilation units."); let unit = compilation_units.first().unwrap(); let db = build_scarb_root_database(unit).unwrap(); Ok(DevContext { db, unit: unit.clone(), ws }) @@ -215,7 +213,7 @@ fn build(context: &mut DevContext<'_>) -> Result<()> { anyhow!("could not compile `{package_name}` due to previous error") })?; ws.config().ui().print("šŸ“¦ Rebuild done"); - trace!(target: LOG_TARGET, ?package_name, "Build completed."); + trace!(?package_name, "Build completed."); Ok(()) } @@ -272,7 +270,7 @@ where } fn process_event(event: &DebouncedEvent, context: &mut DevContext<'_>) -> DevAction { - trace!(target: LOG_TARGET, event=?event, "Processing event."); + trace!(event=?event, "Processing event."); let action = handle_event(event); match &action { DevAction::None => {} @@ -282,7 +280,7 @@ fn process_event(event: &DebouncedEvent, context: &mut DevContext<'_>) -> DevAct } } - trace!(target: LOG_TARGET, action=?action, "Processed action."); + trace!(action=?action, "Processed action."); action } @@ -299,10 +297,10 @@ fn handle_build_action(path: &Path, context: &mut DevContext<'_>) { } fn handle_reload_action(context: &mut DevContext<'_>) { - trace!(target: LOG_TARGET, "Reloading context."); + trace!("Reloading context."); let config = context.ws.config(); config.ui().print("Reloading project"); let new_context = load_context(config).expect("Failed to load context"); let _ = mem::replace(context, new_context); - trace!(target: LOG_TARGET, "Context reloaded."); + trace!("Context reloaded."); } diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index a3b7c31c79..5db43af9f9 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -8,8 +8,6 @@ use super::options::world::WorldOptions; use crate::utils; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::events"; - #[derive(Debug, Args)] pub struct EventsArgs { #[arg(help = "List of specific events to be filtered")] @@ -46,16 +44,16 @@ pub struct EventsArgs { impl EventsArgs { pub fn run(self, config: &Config) -> Result<()> { let env_metadata = utils::load_metadata_from_config(config)?; - trace!(target: LOG_TARGET, "Fetched metadata from config."); + trace!("Fetched metadata from config."); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - trace!(target: LOG_TARGET, ws_members_count=ws.members().count(), "Fetched workspace."); + trace!(ws_members_count=ws.members().count(), "Fetched workspace."); let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - trace!(target: LOG_TARGET, ?manifest_dir, "Fetched manifest directory."); + trace!(?manifest_dir, "Fetched manifest directory."); let provider = self.starknet.provider(env_metadata.as_ref())?; - trace!(target: LOG_TARGET, ?provider, "Starknet RPC client provider."); + trace!(?provider, "Starknet RPC client provider."); let event_filter = events::get_event_filter( self.from_block, @@ -63,8 +61,7 @@ impl EventsArgs { self.events, self.world.world_address, ); - trace!( - target: LOG_TARGET, + trace!( from_block=self.from_block, to_block=self.to_block, chunk_size=self.chunk_size, @@ -73,10 +70,10 @@ impl EventsArgs { let profile_name = ws.current_profile().expect("Scarb profile expected at this point.").to_string(); - trace!(target: LOG_TARGET, profile_name, "Fetched profile name."); + trace!(profile_name, "Fetched profile name."); config.tokio_handle().block_on(async { - trace!(target: LOG_TARGET, "Starting async event parsing."); + trace!("Starting async event parsing."); events::parse( self.chunk_size, provider, diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index 48f08cf63b..8fdb0e11f3 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -11,8 +11,6 @@ use super::options::world::WorldOptions; use crate::utils; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::execute"; - #[derive(Debug, Args)] #[command(about = "Execute a system with the given calldata.")] pub struct ExecuteArgs { @@ -58,7 +56,6 @@ impl ExecuteArgs { let tx_config = self.transaction.into(); trace!( - target: LOG_TARGET, contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index 0f4e1befb5..09035f1493 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -8,8 +8,6 @@ use clap::Args; use scarb::core::Config; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::init"; - #[derive(Debug, Args)] pub struct InitArgs { #[arg(help = "Target directory")] @@ -33,7 +31,7 @@ impl InitArgs { } None => current_dir().unwrap(), }; - trace!(target: LOG_TARGET, ?target_dir, "Executing Init command."); + trace!(?target_dir, "Executing Init command."); if target_dir.exists() { ensure!( @@ -71,7 +69,7 @@ impl InitArgs { `sozo build`", ); - trace!(target: LOG_TARGET, "Project initialization completed."); + trace!("Project initialization completed."); Ok(()) } @@ -80,18 +78,15 @@ impl InitArgs { fn clone_repo(url: &str, path: &Path, config: &Config) -> Result<()> { config.ui().print(format!("Cloning project template from {}...", url)); Command::new("git").args(["clone", "--recursive", url, path.to_str().unwrap()]).output()?; - trace!(target: LOG_TARGET, "Repository cloned successfully."); + trace!("Repository cloned successfully."); Ok(()) } fn modify_git_history(url: &str) -> Result<()> { - trace!(target: LOG_TARGET, "Modifying Git history."); + trace!("Modifying Git history."); let git_output = Command::new("git").args(["rev-parse", "--short", "HEAD"]).output()?.stdout; let commit_hash = String::from_utf8(git_output)?; - trace!( - target: LOG_TARGET, - commit_hash=commit_hash.trim() - ); + trace!(commit_hash=commit_hash.trim()); fs::remove_dir_all(".git")?; @@ -101,6 +96,6 @@ fn modify_git_history(url: &str) -> Result<()> { let commit_msg = format!("chore: init from {} at {}", url, commit_hash.trim()); Command::new("git").args(["commit", "-m", &commit_msg]).output()?; - trace!(target: LOG_TARGET, "Git history modified."); + trace!("Git history modified."); Ok(()) } diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index bce8145bd1..466c67844c 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -19,8 +19,6 @@ use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::migrate"; - #[derive(Debug, Args)] pub struct MigrateArgs { #[command(subcommand)] @@ -56,13 +54,13 @@ pub enum MigrateCommand { impl MigrateArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, command=?self.command, "Executing Migrate command"); + trace!(command=?self.command, "Executing Migrate command"); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; let env_metadata = if config.manifest_path().exists() { dojo_metadata_from_workspace(&ws).env().cloned() } else { - trace!(target: LOG_TARGET, "Manifest path does not exist."); + trace!("Manifest path does not exist."); None }; @@ -95,7 +93,7 @@ impl MigrateArgs { .await }), MigrateCommand::Apply { transaction } => config.tokio_handle().block_on(async { - trace!(target: LOG_TARGET, name, "Applying migration."); + trace!(name, "Applying migration."); let txn_config: TxnConfig = transaction.into(); migration::migrate(&ws, world_address, rpc_url, &account, &name, false, txn_config) @@ -117,18 +115,18 @@ pub async fn setup_env<'a>( SingleOwnerAccount, LocalWallet>, String, )> { - trace!(target: LOG_TARGET, "Setting up environment."); + trace!("Setting up environment."); let ui = ws.config().ui(); let world_address = world.address(env).ok(); - trace!(target: LOG_TARGET, ?world_address); + trace!(?world_address); let (account, rpc_url) = { let provider = starknet.provider(env)?; - trace!(target: LOG_TARGET, "Provider initialized."); + trace!("Provider initialized."); let spec_version = provider.spec_version().await?; - trace!(target: LOG_TARGET, spec_version); + trace!(spec_version); if spec_version != RPC_SPEC_VERSION { return Err(anyhow!( @@ -139,12 +137,12 @@ pub async fn setup_env<'a>( } let rpc_url = starknet.url(env)?; - trace!(target: LOG_TARGET, ?rpc_url); + trace!(?rpc_url); let chain_id = provider.chain_id().await?; let chain_id = parse_cairo_short_string(&chain_id) .with_context(|| "Cannot parse chain_id as string")?; - trace!(target: LOG_TARGET, chain_id); + trace!(chain_id); let mut account = account.account(provider, env).await?; account.set_block_id(BlockId::Tag(BlockTag::Pending)); diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index ece2e412ec..4b46e14973 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -12,8 +12,6 @@ use super::signer::SignerOptions; use super::DOJO_ACCOUNT_ADDRESS_ENV_VAR; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::account"; - // INVARIANT: // - For commandline: we can either specify `private_key` or `keystore_path` along with // `keystore_password`. This is enforced by Clap. @@ -45,32 +43,32 @@ impl AccountOptions { where P: Provider + Send + Sync, { - trace!(target: LOG_TARGET, account_options=?self, "Creating account.", ); + trace!(account_options=?self, "Creating account."); let account_address = self.account_address(env_metadata)?; - trace!(target: LOG_TARGET, ?account_address, "Account address determined."); + trace!(?account_address, "Account address determined."); let signer = self.signer.signer(env_metadata, false)?; - trace!(target: LOG_TARGET, ?signer, "Signer obtained."); + trace!(?signer, "Signer obtained."); let chain_id = provider.chain_id().await.with_context(|| "Failed to retrieve network chain id.")?; - trace!(target: LOG_TARGET, ?chain_id, "Chain ID obtained."); + trace!(?chain_id, "Chain ID obtained."); let encoding = if self.legacy { ExecutionEncoding::Legacy } else { ExecutionEncoding::New }; - trace!(target: LOG_TARGET, ?encoding, "Creating SingleOwnerAccount."); + trace!(?encoding, "Creating SingleOwnerAccount."); Ok(SingleOwnerAccount::new(provider, signer, account_address, chain_id, encoding)) } fn account_address(&self, env_metadata: Option<&Environment>) -> Result { if let Some(address) = self.account_address { - trace!(target: LOG_TARGET, ?address, "Account address found."); + trace!(?address, "Account address found."); Ok(address) } else if let Some(address) = env_metadata.and_then(|env| env.account_address()) { - trace!(target: LOG_TARGET, address, "Account address found in environment metadata."); + trace!(address, "Account address found in environment metadata."); Ok(FieldElement::from_str(address)?) } else { Err(anyhow!( diff --git a/bin/sozo/src/commands/options/fee.rs b/bin/sozo/src/commands/options/fee.rs index ed7c03fd95..5edd6d3ac0 100644 --- a/bin/sozo/src/commands/options/fee.rs +++ b/bin/sozo/src/commands/options/fee.rs @@ -7,8 +7,6 @@ use starknet::macros::felt; use starknet_crypto::FieldElement; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::fee"; - #[derive(Debug, Args, Clone)] #[command(next_help_heading = "Fee options")] pub struct FeeOptions { @@ -28,7 +26,6 @@ pub struct FeeOptions { impl FeeOptions { pub fn into_setting(self) -> Result { trace!( - target: LOG_TARGET, max_fee=?self.max_fee, max_fee_raw=?self.max_fee_raw, estimate_only=self.estimate_only, @@ -41,7 +38,6 @@ impl FeeOptions { // The user is most likely making a mistake for using a max fee higher than 1 ETH if max_fee_felt > felt!("1000000000000000000") { trace!( - target: LOG_TARGET, ?max_fee_felt, "Max fee in Ether is higher than 1 ETH." ); @@ -54,15 +50,15 @@ impl FeeOptions { Ok(FeeSetting::Manual(max_fee_felt)) } (None, Some(max_fee_raw), false) => { - trace!(target: LOG_TARGET, ?max_fee_raw, "Using raw max_fee in Wei."); + trace!(?max_fee_raw, "Using raw max_fee in Wei."); Ok(FeeSetting::Manual(max_fee_raw)) } (None, None, true) => { - trace!(target: LOG_TARGET, "Only estimating the fee."); + trace!("Only estimating the fee."); Ok(FeeSetting::EstimateOnly) } (None, None, false) => { - trace!(target: LOG_TARGET, "No fee options specified."); + trace!("No fee options specified."); Ok(FeeSetting::None) } _ => Err(anyhow::anyhow!( @@ -86,7 +82,7 @@ where let mut biguint = match bigint.to_biguint() { Some(value) => value, None => { - trace!(target: LOG_TARGET, "Could not convert bigint to biguint, too many decimal places."); + trace!("Could not convert bigint to biguint, too many decimal places."); anyhow::bail!("too many decimal places") } }; @@ -99,7 +95,7 @@ where for _ in 0..(exponent - decimals) { let (quotient, remainder) = biguint.div_rem(&10u32.into()); if !remainder.is_zero() { - trace!(target: LOG_TARGET, "Found non-zero remainder during scaling down."); + trace!("Found non-zero remainder during scaling down."); anyhow::bail!("too many decimal places") } biguint = quotient; diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index 097665d275..6910a50d45 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -9,8 +9,6 @@ use tracing::trace; use super::{DOJO_KEYSTORE_PASSWORD_ENV_VAR, DOJO_KEYSTORE_PATH_ENV_VAR, DOJO_PRIVATE_KEY_ENV_VAR}; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::signer"; - #[derive(Debug, Args)] #[command(next_help_heading = "Signer options")] // INVARIANT: @@ -47,7 +45,6 @@ impl SignerOptions { self.private_key.as_deref().or_else(|| env_metadata.and_then(|env| env.private_key())) { trace!( - target: LOG_TARGET, private_key, "Signing using private key." ); @@ -71,7 +68,7 @@ impl SignerOptions { } else if no_wait { return Err(anyhow!("Could not find password. Please specify the password.")); } else { - trace!(target: LOG_TARGET, "Prompting user for keystore password."); + trace!("Prompting user for keystore password."); rpassword::prompt_password("Enter password: ")? } }; diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 4091a5073a..f386b8b827 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -8,8 +8,6 @@ use tracing::trace; use super::STARKNET_RPC_URL_ENV_VAR; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::starknet"; - #[derive(Debug, Args)] #[command(next_help_heading = "Starknet options")] pub struct StarknetOptions { @@ -26,7 +24,7 @@ impl StarknetOptions { env_metadata: Option<&Environment>, ) -> Result> { let url = self.url(env_metadata)?; - trace!(target: LOG_TARGET, ?url, "Creating JsonRpcClient with given RPC URL."); + trace!(?url, "Creating JsonRpcClient with given RPC URL."); Ok(JsonRpcClient::new(HttpTransport::new(url))) } @@ -34,15 +32,15 @@ impl StarknetOptions { // This function is made public because [`JsonRpcClient`] does not expose // the raw rpc url. pub fn url(&self, env_metadata: Option<&Environment>) -> Result { - trace!(target: LOG_TARGET, "Retrieving RPC URL for StarknetOptions."); + trace!("Retrieving RPC URL for StarknetOptions."); if let Some(url) = self.rpc_url.as_ref() { - trace!(target: LOG_TARGET, ?url, "Using RPC URL from command line."); + trace!(?url, "Using RPC URL from command line."); Ok(url.clone()) } else if let Some(url) = env_metadata.and_then(|env| env.rpc_url()) { - trace!(target: LOG_TARGET, url, "Using RPC URL from environment metadata."); + trace!(url, "Using RPC URL from environment metadata."); Ok(Url::parse(url)?) } else { - trace!(target: LOG_TARGET, "Using default RPC URL: http://localhost:5050."); + trace!("Using default RPC URL: http://localhost:5050."); Ok(Url::parse("http://localhost:5050").unwrap()) } } diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index c3ba59bc65..0b78dcf06d 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -3,8 +3,6 @@ use dojo_world::migration::TxnConfig; use tracing::trace; use starknet::core::types::FieldElement; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::transaction"; - #[derive(Debug, Args)] #[command(next_help_heading = "Transaction options")] pub struct TransactionOptions { @@ -43,7 +41,6 @@ pub struct TransactionOptions { impl From for TxnConfig { fn from(value: TransactionOptions) -> Self { trace!( - target: LOG_TARGET, fee_estimate_multiplier=value.fee_estimate_multiplier, wait=value.wait, receipt=value.receipt, diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index ee4a39bf24..a6ab10daa3 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -8,8 +8,6 @@ use tracing::trace; use super::DOJO_WORLD_ADDRESS_ENV_VAR; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::options::world"; - #[derive(Debug, Args)] #[command(next_help_heading = "World options")] pub struct WorldOptions { @@ -22,16 +20,14 @@ pub struct WorldOptions { impl WorldOptions { pub fn address(&self, env_metadata: Option<&Environment>) -> Result { trace!( - target: LOG_TARGET, - world_address=?self.world_address, ?env_metadata, "Fetching World address." ); if let Some(world_address) = self.world_address { - trace!(target: LOG_TARGET, ?world_address, "Fetched world_address."); + trace!(?world_address, "Fetched world_address."); Ok(world_address) } else if let Some(world_address) = env_metadata.and_then(|env| env.world_address()) { - trace!(target: LOG_TARGET, world_address, "Fetched world_address from env metadata."); + trace!(world_address, "Fetched world_address from env metadata."); Ok(FieldElement::from_str(world_address)?) } else { Err(anyhow!( diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index 2ff10277e2..64b4a85061 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -13,8 +13,6 @@ use super::options::world::WorldOptions; use crate::utils; use tracing::trace; -pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::register"; - #[derive(Debug, Args)] pub struct RegisterArgs { #[command(subcommand)] @@ -47,18 +45,18 @@ pub enum RegisterCommand { impl RegisterArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(target: LOG_TARGET, command=?self.command, "Executing Register command."); + trace!(command=?self.command, "Executing Register command."); let env_metadata = utils::load_metadata_from_config(config)?; let (starknet, world, account, transaction, models) = match self.command { RegisterCommand::Model { starknet, world, account, transaction, models } => { - trace!(target: LOG_TARGET, ?models, "Registering models."); + trace!(?models, "Registering models."); (starknet, world, account, transaction, models) } }; let world_address = world.world_address.unwrap_or_default(); - trace!(target: LOG_TARGET, ?world_address, "Using world address"); + trace!(?world_address, "Using world address"); config.tokio_handle().block_on(async { let world = From d8ee5ecf380910c79e1d50113419530863ff16dd Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya <41485330+btirth@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:15:02 -0700 Subject: [PATCH 11/16] Updated Sozo trace logs Co-authored-by: glihm --- bin/sozo/src/commands/build.rs | 2 +- bin/sozo/src/commands/call.rs | 2 +- bin/sozo/src/commands/events.rs | 8 ++++---- bin/sozo/src/commands/migrate.rs | 2 +- bin/sozo/src/commands/options/world.rs | 4 ---- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 53ab54867d..5b1898bb51 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -56,7 +56,7 @@ impl BuildArgs { let target_dir = &compile_info.target_dir; let contracts_statistics = get_contract_statistics_for_dir(target_dir) .context("Error getting contracts stats")?; - trace!(?contracts_statistics, ?target_dir, "Fetched contract statistics for target directory."); + trace!(?contracts_statistics, ?target_dir, "Read contract statistics for target directory."); let table = create_stats_table(contracts_statistics); table.printstd() diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index 64d82a80b7..3a646eb370 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -39,7 +39,7 @@ impl CallArgs { trace!(contract=?self.contract, entrypoint=self.entrypoint, calldata=?self.calldata, block_id=self.block_id, "Executing Call command."); let env_metadata = utils::load_metadata_from_config(config)?; - trace!(?env_metadata, "Fetched environment metadata."); + trace!(?env_metadata, "Loaded metadata from config."); config.tokio_handle().block_on(async { let world_reader = diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index 5db43af9f9..a9c8ba2807 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -44,13 +44,13 @@ pub struct EventsArgs { impl EventsArgs { pub fn run(self, config: &Config) -> Result<()> { let env_metadata = utils::load_metadata_from_config(config)?; - trace!("Fetched metadata from config."); + trace!(?env_metadata, "Metadata loaded from config."); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - trace!(ws_members_count=ws.members().count(), "Fetched workspace."); + trace!(ws_members_count=ws.members().count(), "Read workspace."); let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); - trace!(?manifest_dir, "Fetched manifest directory."); + trace!(?manifest_dir, "Manifest directory defined from workspace."); let provider = self.starknet.provider(env_metadata.as_ref())?; trace!(?provider, "Starknet RPC client provider."); @@ -70,7 +70,7 @@ impl EventsArgs { let profile_name = ws.current_profile().expect("Scarb profile expected at this point.").to_string(); - trace!(profile_name, "Fetched profile name."); + trace!(profile_name, "Current profile."); config.tokio_handle().block_on(async { trace!("Starting async event parsing."); diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index 466c67844c..d567d567ad 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -54,7 +54,7 @@ pub enum MigrateCommand { impl MigrateArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(command=?self.command, "Executing Migrate command"); + trace!(command=?self.command, "Executing Migrate command."); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; let env_metadata = if config.manifest_path().exists() { diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index a6ab10daa3..6d55dd9458 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -19,10 +19,6 @@ pub struct WorldOptions { impl WorldOptions { pub fn address(&self, env_metadata: Option<&Environment>) -> Result { - trace!( - ?env_metadata, - "Fetching World address." - ); if let Some(world_address) = self.world_address { trace!(?world_address, "Fetched world_address."); Ok(world_address) From fc2b5c07fb969a62224f9bf6dc8c7d4d08308b29 Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Sat, 27 Apr 2024 00:34:10 -0300 Subject: [PATCH 12/16] Updated Sozo trace logs - removed fetch keyword. --- bin/sozo/src/commands/options/world.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index 6d55dd9458..7cd4584355 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -20,10 +20,10 @@ pub struct WorldOptions { impl WorldOptions { pub fn address(&self, env_metadata: Option<&Environment>) -> Result { if let Some(world_address) = self.world_address { - trace!(?world_address, "Fetched world_address."); + trace!(?world_address, "Loaded world_address."); Ok(world_address) } else if let Some(world_address) = env_metadata.and_then(|env| env.world_address()) { - trace!(world_address, "Fetched world_address from env metadata."); + trace!(world_address, "Loaded world_address from env metadata."); Ok(FieldElement::from_str(world_address)?) } else { Err(anyhow!( From e1b71a03554cee57540f702ede79dda6dcd0ac0a Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Mon, 29 Apr 2024 19:45:13 -0300 Subject: [PATCH 13/16] Resolved failing checks. --- bin/sozo/src/args.rs | 3 ++- bin/sozo/src/commands/account.rs | 21 ++++---------------- bin/sozo/src/commands/build.rs | 6 +++++- bin/sozo/src/commands/call.rs | 3 +-- bin/sozo/src/commands/dev.rs | 5 ++--- bin/sozo/src/commands/events.rs | 13 ++++++------ bin/sozo/src/commands/execute.rs | 2 +- bin/sozo/src/commands/init.rs | 2 +- bin/sozo/src/commands/migrate.rs | 2 +- bin/sozo/src/commands/options/account.rs | 8 +------- bin/sozo/src/commands/options/fee.rs | 7 ++----- bin/sozo/src/commands/options/signer.rs | 5 +---- bin/sozo/src/commands/options/starknet.rs | 2 +- bin/sozo/src/commands/options/transaction.rs | 8 ++++---- bin/sozo/src/commands/register.rs | 3 +-- bin/sozo/src/main.rs | 6 ++---- 16 files changed, 35 insertions(+), 61 deletions(-) diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 3ae22c7ab5..ba11d6a5b1 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -5,9 +5,10 @@ use scarb::compiler::Profile; use scarb_ui::Verbosity; use smol_str::SmolStr; use tracing::level_filters::LevelFilter; -use tracing_log::AsTrace; use tracing::Subscriber; +use tracing_log::AsTrace; use tracing_subscriber::{fmt, EnvFilter}; + use crate::commands::Commands; use crate::utils::generate_version; diff --git a/bin/sozo/src/commands/account.rs b/bin/sozo/src/commands/account.rs index d244a1ab1a..892b9dd818 100644 --- a/bin/sozo/src/commands/account.rs +++ b/bin/sozo/src/commands/account.rs @@ -6,12 +6,12 @@ use scarb::core::Config; use sozo_ops::account; use starknet::signers::LocalWallet; use starknet_crypto::FieldElement; +use tracing::trace; use super::options::fee::FeeOptions; use super::options::signer::SignerOptions; use super::options::starknet::StarknetOptions; use crate::utils; -use tracing::trace; #[derive(Debug, Args)] pub struct AccountArgs { @@ -84,20 +84,14 @@ pub enum AccountCommand { impl AccountArgs { pub fn run(self, config: &Config) -> Result<()> { - trace!(command=?self.command, "Executing command."); + trace!(command = ?self.command, "Executing command."); let env_metadata = utils::load_metadata_from_config(config)?; config.tokio_handle().block_on(async { match self.command { AccountCommand::New { signer, force, file } => { - let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; - trace!( - ?signer, - force, - ?file, - "Executing New command." - ); + trace!(?signer, force, ?file, "Executing New command."); account::new(signer, force, file).await } AccountCommand::Deploy { @@ -110,7 +104,6 @@ impl AccountArgs { file, no_confirmation, } => { - let provider = starknet.provider(env_metadata.as_ref())?; let signer: LocalWallet = signer.signer(env_metadata.as_ref(), false)?; let fee_setting = fee.into_setting()?; @@ -138,13 +131,7 @@ impl AccountArgs { .await } AccountCommand::Fetch { starknet, force, output, address } => { - trace!( - ?starknet, - force, - ?output, - ?address, - "Executing Fetch command." - ); + trace!(?starknet, force, ?output, ?address, "Executing Fetch command."); let provider = starknet.provider(env_metadata.as_ref())?; account::fetch(provider, force, output, address).await } diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 5b1898bb51..84201833ba 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -56,7 +56,11 @@ impl BuildArgs { let target_dir = &compile_info.target_dir; let contracts_statistics = get_contract_statistics_for_dir(target_dir) .context("Error getting contracts stats")?; - trace!(?contracts_statistics, ?target_dir, "Read contract statistics for target directory."); + trace!( + ?contracts_statistics, + ?target_dir, + "Read contract statistics for target directory." + ); let table = create_stats_table(contracts_statistics); table.printstd() diff --git a/bin/sozo/src/commands/call.rs b/bin/sozo/src/commands/call.rs index 3a646eb370..5037950e47 100644 --- a/bin/sozo/src/commands/call.rs +++ b/bin/sozo/src/commands/call.rs @@ -2,11 +2,11 @@ use anyhow::Result; use clap::Args; use scarb::core::Config; use starknet::core::types::FieldElement; +use tracing::trace; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; use crate::utils; -use tracing::trace; #[derive(Debug, Args)] #[command(about = "Call a system with the given calldata.")] @@ -41,7 +41,6 @@ impl CallArgs { let env_metadata = utils::load_metadata_from_config(config)?; trace!(?env_metadata, "Loaded metadata from config."); config.tokio_handle().block_on(async { - let world_reader = utils::world_reader_from_env_metadata(self.world, self.starknet, &env_metadata) .await diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index 1e1c3460b2..1e753e26b7 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -24,6 +24,7 @@ use starknet::core::types::FieldElement; use starknet::providers::Provider; use starknet::signers::Signer; use tracing::{error, trace}; + use super::migrate::setup_env; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; @@ -103,7 +104,6 @@ impl DevArgs { } Err(error) => { error!( - error = ?error, address = ?world_address, "Migrating world." @@ -138,7 +138,6 @@ impl DevArgs { } Err(error) => { error!( - error = ?error, address = ?world_address, "Migrating world.", @@ -197,7 +196,7 @@ fn load_context(config: &Config) -> Result> { // we have only 1 unit in projects // TODO: double check if we always have one with the new version and the order if many. - trace!(unit_count=compilation_units.len(), "Gathering compilation units."); + trace!(unit_count = compilation_units.len(), "Gathering compilation units."); let unit = compilation_units.first().unwrap(); let db = build_scarb_root_database(unit).unwrap(); Ok(DevContext { db, unit: unit.clone(), ws }) diff --git a/bin/sozo/src/commands/events.rs b/bin/sozo/src/commands/events.rs index a9c8ba2807..c0766d8566 100644 --- a/bin/sozo/src/commands/events.rs +++ b/bin/sozo/src/commands/events.rs @@ -2,11 +2,11 @@ use anyhow::Result; use clap::Args; use scarb::core::Config; use sozo_ops::events; +use tracing::trace; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; use crate::utils; -use tracing::trace; #[derive(Debug, Args)] pub struct EventsArgs { @@ -47,7 +47,7 @@ impl EventsArgs { trace!(?env_metadata, "Metadata loaded from config."); let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; - trace!(ws_members_count=ws.members().count(), "Read workspace."); + trace!(ws_members_count = ws.members().count(), "Read workspace."); let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf(); trace!(?manifest_dir, "Manifest directory defined from workspace."); @@ -61,13 +61,12 @@ impl EventsArgs { self.events, self.world.world_address, ); - trace!( - from_block=self.from_block, - to_block=self.to_block, - chunk_size=self.chunk_size, + trace!( + from_block = self.from_block, + to_block = self.to_block, + chunk_size = self.chunk_size, "Created event filter." ); - let profile_name = ws.current_profile().expect("Scarb profile expected at this point.").to_string(); trace!(profile_name, "Current profile."); diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index 8fdb0e11f3..bc39c2d285 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -3,13 +3,13 @@ use clap::Args; use scarb::core::Config; use sozo_ops::execute; use starknet::core::types::FieldElement; +use tracing::trace; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; use crate::utils; -use tracing::trace; #[derive(Debug, Args)] #[command(about = "Execute a system with the given calldata.")] diff --git a/bin/sozo/src/commands/init.rs b/bin/sozo/src/commands/init.rs index 09035f1493..a9fa4e0255 100644 --- a/bin/sozo/src/commands/init.rs +++ b/bin/sozo/src/commands/init.rs @@ -86,7 +86,7 @@ fn modify_git_history(url: &str) -> Result<()> { trace!("Modifying Git history."); let git_output = Command::new("git").args(["rev-parse", "--short", "HEAD"]).output()?.stdout; let commit_hash = String::from_utf8(git_output)?; - trace!(commit_hash=commit_hash.trim()); + trace!(commit_hash = commit_hash.trim()); fs::remove_dir_all(".git")?; diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index d567d567ad..e46e6d78d7 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -12,12 +12,12 @@ use starknet::core::utils::parse_cairo_short_string; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::{JsonRpcClient, Provider, ProviderError}; use starknet::signers::LocalWallet; +use tracing::trace; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; -use tracing::trace; #[derive(Debug, Args)] pub struct MigrateArgs { diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index 5e16c5cbd3..8b6d08b29a 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -7,10 +7,10 @@ use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount}; use starknet::core::types::{BlockId, BlockTag, FieldElement}; use starknet::providers::Provider; use starknet::signers::LocalWallet; +use tracing::trace; use super::signer::SignerOptions; use super::DOJO_ACCOUNT_ADDRESS_ENV_VAR; -use tracing::trace; // INVARIANT: // - For commandline: we can either specify `private_key` or `keystore_path` along with @@ -53,12 +53,6 @@ impl AccountOptions { let chain_id = provider.chain_id().await.with_context(|| "Failed to retrieve network chain id.")?; trace!(?chain_id, "Chain ID obtained."); - let encoding = if self.legacy { - ExecutionEncoding::Legacy - } else { - ExecutionEncoding::New - }; - let encoding = if self.legacy { ExecutionEncoding::Legacy } else { ExecutionEncoding::New }; trace!(?encoding, "Creating SingleOwnerAccount."); let mut account = diff --git a/bin/sozo/src/commands/options/fee.rs b/bin/sozo/src/commands/options/fee.rs index 5edd6d3ac0..941671f167 100644 --- a/bin/sozo/src/commands/options/fee.rs +++ b/bin/sozo/src/commands/options/fee.rs @@ -37,10 +37,7 @@ impl FeeOptions { // The user is most likely making a mistake for using a max fee higher than 1 ETH if max_fee_felt > felt!("1000000000000000000") { - trace!( - ?max_fee_felt, - "Max fee in Ether is higher than 1 ETH." - ); + trace!(?max_fee_felt, "Max fee in Ether is higher than 1 ETH."); anyhow::bail!( "the --max-fee value is too large. --max-fee expects a value in Ether (18 \ decimals). Use --max-fee-raw instead to use a raw max_fee amount in Wei." @@ -101,6 +98,6 @@ where biguint = quotient; } } - + Ok(FieldElement::from_byte_slice_be(&biguint.to_bytes_be())?) } diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index 6910a50d45..a8a102d35f 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -44,10 +44,7 @@ impl SignerOptions { if let Some(private_key) = self.private_key.as_deref().or_else(|| env_metadata.and_then(|env| env.private_key())) { - trace!( - private_key, - "Signing using private key." - ); + trace!(private_key, "Signing using private key."); return Ok(LocalWallet::from_signing_key(SigningKey::from_secret_scalar( FieldElement::from_str(private_key)?, ))); diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index f386b8b827..5b14de281d 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -3,8 +3,8 @@ use clap::Args; use dojo_world::metadata::Environment; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::JsonRpcClient; -use url::Url; use tracing::trace; +use url::Url; use super::STARKNET_RPC_URL_ENV_VAR; diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index 0b78dcf06d..5b63f63c7e 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -1,7 +1,7 @@ use clap::Args; use dojo_world::migration::TxnConfig; -use tracing::trace; use starknet::core::types::FieldElement; +use tracing::trace; #[derive(Debug, Args)] #[command(next_help_heading = "Transaction options")] @@ -41,9 +41,9 @@ pub struct TransactionOptions { impl From for TxnConfig { fn from(value: TransactionOptions) -> Self { trace!( - fee_estimate_multiplier=value.fee_estimate_multiplier, - wait=value.wait, - receipt=value.receipt, + fee_estimate_multiplier = value.fee_estimate_multiplier, + wait = value.wait, + receipt = value.receipt, "Converting TransactionOptions to TxnConfig." ); Self { diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index 64b4a85061..58c417dc90 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -5,13 +5,13 @@ use scarb::core::Config; use sozo_ops::register; use starknet::accounts::ConnectedAccount; use starknet::core::types::{BlockId, BlockTag, FieldElement}; +use tracing::trace; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; use crate::utils; -use tracing::trace; #[derive(Debug, Args)] pub struct RegisterArgs { @@ -64,7 +64,6 @@ impl RegisterArgs { let provider = world.account.provider(); let world_reader = WorldContractReader::new(world_address, &provider) .with_block(BlockId::Tag(BlockTag::Pending)); - register::model_register( models, &world, diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 05ff0f394f..8e9841cb33 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -10,6 +10,7 @@ use scarb::compiler::CompilerRepository; use scarb::core::Config; use scarb_ui::{OutputFormat, Ui}; use tracing::trace; + use crate::commands::Commands; mod args; @@ -18,7 +19,6 @@ mod utils; pub(crate) const LOG_TARGET: &str = "sozo::cli"; fn main() { - let args = SozoArgs::parse(); let _ = args.init_logging(); let ui = Ui::new(args.ui_verbosity(), OutputFormat::Text); @@ -38,8 +38,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { trace!(target: LOG_TARGET, "Adding DojoCompiler to compiler repository"); compilers.add(Box::new(DojoCompiler)).unwrap() } - _ => { - } + _ => {} } let manifest_path = scarb::ops::find_manifest_path(args.manifest_path.as_deref())?; @@ -59,6 +58,5 @@ fn cli_main(args: SozoArgs) -> Result<()> { let _ = commands::run(args.command, &config); - Ok(()) } From 182ee2e3418e9a69cb604b393641b46a41d3bedb Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya <41485330+btirth@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:36:32 -0700 Subject: [PATCH 14/16] Updated Sozo trace logs. Co-authored-by: glihm --- bin/sozo/src/commands/dev.rs | 3 +-- bin/sozo/src/commands/execute.rs | 1 + bin/sozo/src/commands/options/account.rs | 2 +- bin/sozo/src/commands/register.rs | 2 +- bin/sozo/src/main.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index 1e753e26b7..e7707b1496 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -119,7 +119,7 @@ impl DevArgs { .unwrap_or(DevAction::None), Ok(Err(_)) => DevAction::None, Err(error) => { - error!( error = ?error, "Receiving dev action."); + error!(error = ?error, "Receiving dev action."); break; } }; @@ -212,7 +212,6 @@ fn build(context: &mut DevContext<'_>) -> Result<()> { anyhow!("could not compile `{package_name}` due to previous error") })?; ws.config().ui().print("šŸ“¦ Rebuild done"); - trace!(?package_name, "Build completed."); Ok(()) } diff --git a/bin/sozo/src/commands/execute.rs b/bin/sozo/src/commands/execute.rs index bc39c2d285..afd1e8371f 100644 --- a/bin/sozo/src/commands/execute.rs +++ b/bin/sozo/src/commands/execute.rs @@ -61,6 +61,7 @@ impl ExecuteArgs { calldata=?self.calldata, "Executing Execute command." ); + execute::execute(self.contract, self.entrypoint, self.calldata, &world, &tx_config) .await }) diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index 8b6d08b29a..f8a534c657 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -52,7 +52,7 @@ impl AccountOptions { let chain_id = provider.chain_id().await.with_context(|| "Failed to retrieve network chain id.")?; - trace!(?chain_id, "Chain ID obtained."); + trace!(?chain_id); let encoding = if self.legacy { ExecutionEncoding::Legacy } else { ExecutionEncoding::New }; trace!(?encoding, "Creating SingleOwnerAccount."); let mut account = diff --git a/bin/sozo/src/commands/register.rs b/bin/sozo/src/commands/register.rs index 58c417dc90..865cc04526 100644 --- a/bin/sozo/src/commands/register.rs +++ b/bin/sozo/src/commands/register.rs @@ -56,7 +56,7 @@ impl RegisterArgs { }; let world_address = world.world_address.unwrap_or_default(); - trace!(?world_address, "Using world address"); + trace!(?world_address, "Using world address."); config.tokio_handle().block_on(async { let world = diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 8e9841cb33..0979eec695 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -35,7 +35,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { match &args.command { Commands::Build(_) | Commands::Dev(_) | Commands::Migrate(_) => { - trace!(target: LOG_TARGET, "Adding DojoCompiler to compiler repository"); + trace!(target: LOG_TARGET, "Adding DojoCompiler to compiler repository."); compilers.add(Box::new(DojoCompiler)).unwrap() } _ => {} From f68986f612facef6eb50b6f7fa235755febea21e Mon Sep 17 00:00:00 2001 From: Tirth Bharatiya Date: Tue, 30 Apr 2024 17:40:54 -0300 Subject: [PATCH 15/16] Updated Sozo trace logs. --- bin/sozo/src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index 0979eec695..e5c6878148 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -17,7 +17,6 @@ mod args; mod commands; mod utils; -pub(crate) const LOG_TARGET: &str = "sozo::cli"; fn main() { let args = SozoArgs::parse(); let _ = args.init_logging(); @@ -35,7 +34,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { match &args.command { Commands::Build(_) | Commands::Dev(_) | Commands::Migrate(_) => { - trace!(target: LOG_TARGET, "Adding DojoCompiler to compiler repository."); + trace!("Adding DojoCompiler to compiler repository."); compilers.add(Box::new(DojoCompiler)).unwrap() } _ => {} @@ -45,7 +44,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { utils::verify_cairo_version_compatibility(&manifest_path)?; - let config = Config::builder(manifest_path) + let config = Config::builder(manifest_path.clone()) .log_filter_directive(env::var_os("SCARB_LOG")) .profile(args.profile_spec.determine()?) .offline(args.offline) @@ -54,7 +53,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { .compilers(compilers) .build()?; - trace!(target: LOG_TARGET, "Configuration built successfully."); + trace!(%manifest_path, "Configuration built successfully."); let _ = commands::run(args.command, &config); From a741fa93fb18d7077f56f18f814765f88b0ee358 Mon Sep 17 00:00:00 2001 From: glihm Date: Tue, 30 Apr 2024 16:28:53 -0600 Subject: [PATCH 16/16] fix: ensure sozo commands return expected Result --- bin/sozo/src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index e5c6878148..eea47706c5 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -55,7 +55,5 @@ fn cli_main(args: SozoArgs) -> Result<()> { trace!(%manifest_path, "Configuration built successfully."); - let _ = commands::run(args.command, &config); - - Ok(()) + commands::run(args.command, &config) }