From afb901b13449aaec1f58e6783a04e480864c3c84 Mon Sep 17 00:00:00 2001 From: zhengpeng <847850277@qq.com> Date: Fri, 20 Dec 2024 15:17:42 +0800 Subject: [PATCH] [ISSUES#2829] Optimize trace!. --- crates/dojo/utils/src/tx/declarer.rs | 7 ++++--- crates/dojo/utils/src/tx/deployer.rs | 2 +- crates/dojo/world/src/diff/mod.rs | 3 ++- crates/dojo/world/src/remote/events_to_remote.rs | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/dojo/utils/src/tx/declarer.rs b/crates/dojo/utils/src/tx/declarer.rs index e1b5b0f48c..62519e6f41 100644 --- a/crates/dojo/utils/src/tx/declarer.rs +++ b/crates/dojo/utils/src/tx/declarer.rs @@ -14,6 +14,7 @@ use starknet::core::types::{ BlockId, BlockTag, DeclareTransactionResult, Felt, FlattenedSierraClass, StarknetError, }; use starknet::providers::{Provider, ProviderError}; +use tracing::trace; use crate::{ FeeConfig, TransactionError, TransactionExt, TransactionResult, TransactionWaiter, TxnConfig, @@ -92,7 +93,7 @@ where match account.provider().get_class(BlockId::Tag(BlockTag::Pending), class_hash).await { Err(ProviderError::StarknetError(StarknetError::ClassHashNotFound)) => {} Ok(_) => { - tracing::trace!( + trace!( label = labeled_class.label, class_hash = format!("{:#066x}", class_hash), "Class already declared." @@ -104,7 +105,7 @@ where let casm_class_hash = labeled_class.casm_class_hash; - tracing::trace!( + trace!( label = labeled_class.label, class_hash = format!("{:#066x}", class_hash), casm_class_hash = format!("{:#066x}", casm_class_hash), @@ -127,7 +128,7 @@ where } }; - tracing::trace!( + trace!( label = labeled_class.label, transaction_hash = format!("{:#066x}", transaction_hash), class_hash = format!("{:#066x}", class_hash), diff --git a/crates/dojo/utils/src/tx/deployer.rs b/crates/dojo/utils/src/tx/deployer.rs index f449a17fc8..da15d1a5c9 100644 --- a/crates/dojo/utils/src/tx/deployer.rs +++ b/crates/dojo/utils/src/tx/deployer.rs @@ -98,7 +98,7 @@ where match provider.get_class_hash_at(BlockId::Tag(BlockTag::Pending), contract_address).await { Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => Ok(false), Ok(_) => { - tracing::trace!( + trace!( contract_address = format!("{:#066x}", contract_address), "Contract already deployed." ); diff --git a/crates/dojo/world/src/diff/mod.rs b/crates/dojo/world/src/diff/mod.rs index 0bf084255e..c32ef25503 100644 --- a/crates/dojo/world/src/diff/mod.rs +++ b/crates/dojo/world/src/diff/mod.rs @@ -12,6 +12,7 @@ use starknet::core::types::contract::SierraClass; use starknet::core::types::{BlockId, BlockTag, StarknetError}; use starknet::providers::{Provider, ProviderError}; use starknet_crypto::Felt; +use tracing::trace; use super::local::{ResourceLocal, WorldLocal}; use super::remote::{ResourceRemote, WorldRemote}; @@ -171,7 +172,7 @@ impl WorldDiff { { Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => Ok(false), Ok(_) => { - tracing::trace!( + trace!( contract_address = format!("{:#066x}", world_address), "World already deployed." ); diff --git a/crates/dojo/world/src/remote/events_to_remote.rs b/crates/dojo/world/src/remote/events_to_remote.rs index 38ca1143f5..38837b5feb 100644 --- a/crates/dojo/world/src/remote/events_to_remote.rs +++ b/crates/dojo/world/src/remote/events_to_remote.rs @@ -36,7 +36,7 @@ impl WorldRemote { // The world contract exists, we can continue and fetch the events. } Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { - tracing::trace!(%world_address, "No remote world contract found."); + trace!(%world_address, "No remote world contract found."); return Ok(world); } Err(e) => return Err(e.into()), @@ -70,7 +70,7 @@ impl WorldRemote { let chunk_size = 500; - tracing::trace!( + trace!( world_address = format!("{:#066x}", world_address), chunk_size, ?filter, @@ -106,7 +106,7 @@ impl WorldRemote { for event in &events { match world::Event::try_from(event) { Ok(ev) => { - tracing::trace!(?ev, "Processing world event."); + trace!(?ev, "Processing world event."); world.match_event(ev)?; } Err(e) => {