From 4bf87379e9173ef31ba87d030dfe25bcc0702369 Mon Sep 17 00:00:00 2001 From: qima Date: Wed, 4 Dec 2024 22:20:44 +0800 Subject: [PATCH 1/6] fix(test): early bail out to avoid test timed out --- ant-node/tests/verify_data_location.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ant-node/tests/verify_data_location.rs b/ant-node/tests/verify_data_location.rs index db934a4c67..efdd848df8 100644 --- a/ant-node/tests/verify_data_location.rs +++ b/ant-node/tests/verify_data_location.rs @@ -263,7 +263,11 @@ async fn verify_location(all_peers: &Vec, node_rpc_addresses: &[SocketAd } } - if !failed.is_empty() { + // The retry will take long time, result in the overall test failed due to timedout. + // Hence need an early bail out here. + let just_missed_one = failed.values().all(|failed_peers| failed_peers.len() <= 1); + + if !(failed.is_empty() || just_missed_one) { error!("Verification failed for {:?} entries", failed.len()); println!("Verification failed for {:?} entries", failed.len()); From db222e573798a0026c68bf331363dc482d1da722 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Wed, 4 Dec 2024 19:12:25 +0000 Subject: [PATCH 2/6] fix: use `ant_networking` for metrics prefix The `ant-networking` prefix was incompatible with the new version of Telegraf because it doesn't allow hyphens in the metric name; however, in any case, this shouldn't have had the hyphen, and should actually have remained as `sn_networking`. It was mistakenly renamed, because we wanted to keep the `sn_` prefix in the metric names so that we could change them more gradually. Now we've decided to just go with the `ant_` prefix, so we are also changing the `sn_node` prefix to `ant_node` as part of this commit. --- ant-networking/src/metrics/mod.rs | 2 +- ant-node/src/metrics.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ant-networking/src/metrics/mod.rs b/ant-networking/src/metrics/mod.rs index 03d2b9a9e9..cb0081d963 100644 --- a/ant-networking/src/metrics/mod.rs +++ b/ant-networking/src/metrics/mod.rs @@ -77,7 +77,7 @@ impl NetworkMetricsRecorder { let libp2p_metrics = Libp2pMetrics::new(&mut registries.standard_metrics); let sub_registry = registries .standard_metrics - .sub_registry_with_prefix("ant-networking"); + .sub_registry_with_prefix("ant_networking"); let records_stored = Gauge::default(); sub_registry.register( diff --git a/ant-node/src/metrics.rs b/ant-node/src/metrics.rs index fcd230276f..667b299826 100644 --- a/ant-node/src/metrics.rs +++ b/ant-node/src/metrics.rs @@ -71,7 +71,7 @@ impl NodeMetricsRecorder { let sub_registry = registries .standard_metrics - .sub_registry_with_prefix("sn_node"); + .sub_registry_with_prefix("ant_node"); let put_record_ok = Family::default(); sub_registry.register( From 845dad389f349387d8eafabe00162437f8a06951 Mon Sep 17 00:00:00 2001 From: grumbach Date: Thu, 5 Dec 2024 13:31:47 +0900 Subject: [PATCH 3/6] feat: improve parents naming --- ant-protocol/src/storage/transaction.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ant-protocol/src/storage/transaction.rs b/ant-protocol/src/storage/transaction.rs index 4732ef1f2d..0045f9e746 100644 --- a/ant-protocol/src/storage/transaction.rs +++ b/ant-protocol/src/storage/transaction.rs @@ -19,7 +19,7 @@ pub type TransactionContent = [u8; 32]; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash, Ord, PartialOrd)] pub struct Transaction { pub owner: PublicKey, - pub parent: Vec, + pub parents: Vec, pub content: TransactionContent, pub outputs: Vec<(PublicKey, TransactionContent)>, /// signs the above 4 fields with the owners key @@ -29,14 +29,14 @@ pub struct Transaction { impl Transaction { pub fn new( owner: PublicKey, - parent: Vec, + parents: Vec, content: TransactionContent, outputs: Vec<(PublicKey, TransactionContent)>, signature: Signature, ) -> Self { Self { owner, - parent, + parents, content, outputs, signature, @@ -53,7 +53,7 @@ impl Transaction { bytes.extend_from_slice("parent".as_bytes()); bytes.extend_from_slice( &self - .parent + .parents .iter() .map(|p| p.to_bytes()) .collect::>() From f170c914003ebca64f07ec70da4f2fa8340267b9 Mon Sep 17 00:00:00 2001 From: Roland Sherwin Date: Thu, 5 Dec 2024 15:09:31 +0530 Subject: [PATCH 4/6] fix(metrics): use the newer crate name for all the metrics --- .gitignore | 2 +- ant-networking/src/cmd.rs | 2 +- ant-networking/src/driver.rs | 2 +- ant-networking/src/metrics/mod.rs | 2 +- ant-node/README.md | 2 +- ant-node/src/event.rs | 2 +- ant-node/src/metrics.rs | 6 +++--- node-launchpad/src/node_stats.rs | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index bf0d0deed0..ef12210b4e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,7 @@ metrics/prometheus/prometheus.yml .DS_Store *.dot -sn_node_manager/.vagrant +ant-node-manager/.vagrant # Python .venv/ diff --git a/ant-networking/src/cmd.rs b/ant-networking/src/cmd.rs index cba58c1f3b..f64fcdf236 100644 --- a/ant-networking/src/cmd.rs +++ b/ant-networking/src/cmd.rs @@ -38,7 +38,7 @@ use crate::target_arch::Instant; const MAX_CONTINUOUS_HDD_WRITE_ERROR: usize = 5; -// Shall be synced with `sn_node::PERIODIC_REPLICATION_INTERVAL_MAX_S` +// Shall be synced with `ant_node::PERIODIC_REPLICATION_INTERVAL_MAX_S` const REPLICATION_TIMEOUT: Duration = Duration::from_secs(45); // Throttles replication to at most once every 30 seconds diff --git a/ant-networking/src/driver.rs b/ant-networking/src/driver.rs index a9792700da..7ab95144f4 100644 --- a/ant-networking/src/driver.rs +++ b/ant-networking/src/driver.rs @@ -545,7 +545,7 @@ impl NetworkBuilder { let metrics_recorder = NetworkMetricsRecorder::new(&mut metrics_registries); let metadata_sub_reg = metrics_registries .metadata - .sub_registry_with_prefix("ant-networking"); + .sub_registry_with_prefix("ant_networking"); metadata_sub_reg.register( "peer_id", diff --git a/ant-networking/src/metrics/mod.rs b/ant-networking/src/metrics/mod.rs index cb0081d963..43a5b73f16 100644 --- a/ant-networking/src/metrics/mod.rs +++ b/ant-networking/src/metrics/mod.rs @@ -199,7 +199,7 @@ impl NetworkMetricsRecorder { let extended_metrics_sub_registry = registries .extended_metrics - .sub_registry_with_prefix("ant-networking"); + .sub_registry_with_prefix("ant_networking"); let shunned_count_across_time_frames = Family::default(); extended_metrics_sub_registry.register( "shunned_count_across_time_frames", diff --git a/ant-node/README.md b/ant-node/README.md index 1f4c0692ca..e95385f2e8 100644 --- a/ant-node/README.md +++ b/ant-node/README.md @@ -130,7 +130,7 @@ default_dir = AntNode.get_default_root_dir(peer_id) ## Testing -To run tests, navigate to the `sn_node` directory and execute: +To run tests, navigate to the `ant-node` directory and execute: ```bash cargo test diff --git a/ant-node/src/event.rs b/ant-node/src/event.rs index eab7c651bb..d8b508ec74 100644 --- a/ant-node/src/event.rs +++ b/ant-node/src/event.rs @@ -38,7 +38,7 @@ impl NodeEventsChannel { self.0.subscribe() } - // Broadcast a new event, meant to be a helper only used by the sn_node's internals. + // Broadcast a new event, meant to be a helper only used by the ant-node's internals. pub(crate) fn broadcast(&self, event: NodeEvent) { let event_string = format!("{event:?}"); if let Err(err) = self.0.send(event) { diff --git a/ant-node/src/metrics.rs b/ant-node/src/metrics.rs index 667b299826..43bad46639 100644 --- a/ant-node/src/metrics.rs +++ b/ant-node/src/metrics.rs @@ -59,12 +59,12 @@ enum RecordType { impl NodeMetricsRecorder { pub(crate) fn new(registries: &mut MetricsRegistries) -> Self { - let node_metadata_sub_registry = registries.metadata.sub_registry_with_prefix("sn_node"); + let node_metadata_sub_registry = registries.metadata.sub_registry_with_prefix("ant_node"); node_metadata_sub_registry.register( - "safenode_version", + "antnode_version", "The version of the safe node", Info::new(vec![( - "safenode_version".to_string(), + "antnode_version".to_string(), env!("CARGO_PKG_VERSION").to_string(), )]), ); diff --git a/node-launchpad/src/node_stats.rs b/node-launchpad/src/node_stats.rs index 9c726ec4c5..892dd8cbda 100644 --- a/node-launchpad/src/node_stats.rs +++ b/node-launchpad/src/node_stats.rs @@ -179,7 +179,7 @@ impl NodeStats { let mut stats = IndividualNodeStats::default(); for sample in all_metrics.samples.iter() { - if sample.metric == "sn_node_total_forwarded_rewards" { + if sample.metric == "ant_node_total_forwarded_rewards" { // Nanos match sample.value { prometheus_parse::Value::Counter(val) @@ -189,7 +189,7 @@ impl NodeStats { } _ => {} } - } else if sample.metric == "sn_node_current_reward_wallet_balance" { + } else if sample.metric == "ant_node_current_reward_wallet_balance" { // Attos match sample.value { prometheus_parse::Value::Counter(val) From 5a137c3dbbb18a6b90d68d6fb411560d26c17132 Mon Sep 17 00:00:00 2001 From: Ermine Jose Date: Tue, 3 Dec 2024 16:20:32 +0530 Subject: [PATCH 5/6] feat: add more debug logs to client API --- autonomi/src/client/archive.rs | 12 +++++++++--- autonomi/src/client/archive_private.rs | 8 ++++++-- autonomi/src/client/data.rs | 8 +++++++- autonomi/src/client/data_private.rs | 1 + autonomi/src/client/external_signer.rs | 4 ++++ autonomi/src/client/fs.rs | 15 +++++++++++++-- autonomi/src/client/fs_private.rs | 6 +++++- autonomi/src/client/mod.rs | 4 ++++ autonomi/src/client/payment.rs | 4 ++++ autonomi/src/client/registers.rs | 20 +++++++++++++++----- autonomi/src/client/utils.rs | 9 ++++++--- autonomi/src/client/vault.rs | 3 ++- evmlib/src/contract/data_payments/mod.rs | 2 +- 13 files changed, 77 insertions(+), 19 deletions(-) diff --git a/autonomi/src/client/archive.rs b/autonomi/src/client/archive.rs index 8eb23bb686..bb0d530417 100644 --- a/autonomi/src/client/archive.rs +++ b/autonomi/src/client/archive.rs @@ -93,13 +93,15 @@ impl Archive { .as_secs(); meta.modified = now; self.map.insert(new_path.to_path_buf(), (data_addr, meta)); + debug!("Renamed file successfully in the archive, old path: {old_path:?} new_path: {new_path:?}"); Ok(()) } /// Add a file to a local archive /// Note that this does not upload the archive to the network pub fn add_file(&mut self, path: PathBuf, data_addr: DataAddr, meta: Metadata) { - self.map.insert(path, (data_addr, meta)); + self.map.insert(path.clone(), (data_addr, meta)); + debug!("Added a new file to the archive, path: {:?}", path); } /// List all files in the archive @@ -160,7 +162,9 @@ impl Client { let bytes = archive .into_bytes() .map_err(|e| PutError::Serialization(format!("Failed to serialize archive: {e:?}")))?; - self.data_put(bytes, wallet.into()).await + let result = self.data_put(bytes, wallet.into()).await; + debug!("Uploaded archive {archive:?} to the network and the address is {result:?}"); + result } /// Get the cost to upload an archive @@ -168,6 +172,8 @@ impl Client { let bytes = archive .into_bytes() .map_err(|e| CostError::Serialization(format!("Failed to serialize archive: {e:?}")))?; - self.data_cost(bytes).await + let result = self.data_cost(bytes).await; + debug!("Calculated the cost to upload archive {archive:?} is {result:?}"); + result } } diff --git a/autonomi/src/client/archive_private.rs b/autonomi/src/client/archive_private.rs index 84927c977c..ee8705be2a 100644 --- a/autonomi/src/client/archive_private.rs +++ b/autonomi/src/client/archive_private.rs @@ -56,13 +56,15 @@ impl PrivateArchive { .as_secs(); meta.modified = now; self.map.insert(new_path.to_path_buf(), (data_addr, meta)); + debug!("Renamed file successfully in the private archive, old path: {old_path:?} new_path: {new_path:?}"); Ok(()) } /// Add a file to a local archive /// Note that this does not upload the archive to the network pub fn add_file(&mut self, path: PathBuf, data_map: PrivateDataAccess, meta: Metadata) { - self.map.insert(path, (data_map, meta)); + self.map.insert(path.clone(), (data_map, meta)); + debug!("Added a new file to the archive, path: {:?}", path); } /// List all files in the archive @@ -129,6 +131,8 @@ impl Client { let bytes = archive .into_bytes() .map_err(|e| PutError::Serialization(format!("Failed to serialize archive: {e:?}")))?; - self.private_data_put(bytes, payment_option).await + let result = self.private_data_put(bytes, payment_option).await; + debug!("Uploaded private archive {archive:?} to the network and address is {result:?}"); + result } } diff --git a/autonomi/src/client/data.rs b/autonomi/src/client/data.rs index 113e0511a5..e7f5d80a8e 100644 --- a/autonomi/src/client/data.rs +++ b/autonomi/src/client/data.rs @@ -134,6 +134,7 @@ impl Client { .fetch_from_data_map_chunk(data_map_chunk.value()) .await?; + debug!("Successfully fetched a blob of data from the network"); Ok(data) } @@ -214,7 +215,7 @@ impl Client { info!("Getting chunk: {addr:?}"); let key = NetworkAddress::from_chunk_address(ChunkAddress::new(addr)).to_record_key(); - + debug!("Fetching chunk from network at: {key:?}"); let get_cfg = GetRecordCfg { get_quorum: Quorum::One, retry_strategy: None, @@ -234,6 +235,10 @@ impl Client { let chunk: Chunk = try_deserialize_record(&record)?; Ok(chunk) } else { + error!( + "Record kind mismatch: expected Chunk, got {:?}", + header.kind + ); Err(NetworkError::RecordKindMismatch(RecordKind::Chunk).into()) } } @@ -267,6 +272,7 @@ impl Client { .map(|quote| quote.2.cost.as_atto()) .sum::(), ); + debug!("Total cost calculated: {total_cost:?}"); Ok(total_cost) } diff --git a/autonomi/src/client/data_private.rs b/autonomi/src/client/data_private.rs index 5f2dd1793c..d31a13f437 100644 --- a/autonomi/src/client/data_private.rs +++ b/autonomi/src/client/data_private.rs @@ -54,6 +54,7 @@ impl Client { ); let data = self.fetch_from_data_map_chunk(data_map.0.value()).await?; + debug!("Successfully fetched a blob of private data from the network"); Ok(data) } diff --git a/autonomi/src/client/external_signer.rs b/autonomi/src/client/external_signer.rs index 6a4e46d524..d3b7ede67d 100644 --- a/autonomi/src/client/external_signer.rs +++ b/autonomi/src/client/external_signer.rs @@ -30,6 +30,10 @@ impl Client { let (quote_payments, free_chunks) = extract_quote_payments(&cost_map); let quotes = cost_map_to_quotes(cost_map); + debug!( + "Got the quotes , quote_payments and freechunks from the network {:?}", + (quotes.clone(), quote_payments.clone(), free_chunks.clone()) + ); Ok((quotes, quote_payments, free_chunks)) } } diff --git a/autonomi/src/client/fs.rs b/autonomi/src/client/fs.rs index 15e32d1bf5..44bb7017dd 100644 --- a/autonomi/src/client/fs.rs +++ b/autonomi/src/client/fs.rs @@ -89,8 +89,10 @@ impl Client { let data = self.data_get(data_addr).await?; if let Some(parent) = to_dest.parent() { tokio::fs::create_dir_all(parent).await?; + debug!("Created parent directories {parent:?} for {to_dest:?}"); } - tokio::fs::write(to_dest, data).await?; + tokio::fs::write(to_dest.clone(), data).await?; + debug!("Downloaded file to {to_dest:?} from the network address {data_addr:?}"); Ok(()) } @@ -101,9 +103,15 @@ impl Client { to_dest: PathBuf, ) -> Result<(), DownloadError> { let archive = self.archive_get(archive_addr).await?; + debug!("Downloaded archive for the directory from the network at {archive_addr:?}"); for (path, addr, _meta) in archive.iter() { self.file_download(*addr, to_dest.join(path)).await?; } + debug!( + "All files in the directory downloaded to {:?} from the network address {:?}", + to_dest.parent(), + archive_addr + ); Ok(()) } @@ -159,6 +167,7 @@ impl Client { info!("Complete archive upload completed in {:?}", start.elapsed()); #[cfg(feature = "loud")] println!("Upload completed in {:?}", start.elapsed()); + debug!("Directory uploaded to the network at {arch_addr:?}"); Ok(arch_addr) } @@ -173,9 +182,10 @@ impl Client { #[cfg(feature = "loud")] println!("Uploading file: {path:?}"); - let data = tokio::fs::read(path).await?; + let data = tokio::fs::read(path.clone()).await?; let data = Bytes::from(data); let addr = self.data_put(data, wallet.into()).await?; + debug!("File {path:?} uploaded to the network at {addr:?}"); Ok(addr) } @@ -217,6 +227,7 @@ impl Client { let archive_cost = self.data_cost(Bytes::from(root_serialized)).await?; total_cost += archive_cost.as_atto(); + debug!("Total cost for the directory: {total_cost:?}"); Ok(total_cost.into()) } } diff --git a/autonomi/src/client/fs_private.rs b/autonomi/src/client/fs_private.rs index 9a49cbd2c1..654fd4cef3 100644 --- a/autonomi/src/client/fs_private.rs +++ b/autonomi/src/client/fs_private.rs @@ -36,8 +36,10 @@ impl Client { let data = self.private_data_get(data_access).await?; if let Some(parent) = to_dest.parent() { tokio::fs::create_dir_all(parent).await?; + debug!("Created parent directories for {to_dest:?}"); } - tokio::fs::write(to_dest, data).await?; + tokio::fs::write(to_dest.clone(), data).await?; + debug!("Downloaded file to {to_dest:?}"); Ok(()) } @@ -52,6 +54,7 @@ impl Client { self.private_file_download(addr.clone(), to_dest.join(path)) .await?; } + debug!("Downloaded directory to {to_dest:?}"); Ok(()) } @@ -129,6 +132,7 @@ impl Client { let data = tokio::fs::read(path).await?; let data = Bytes::from(data); let addr = self.private_data_put(data, wallet.into()).await?; + debug!("Uploaded file successfully in the privateAchive: {addr:?}"); Ok(addr) } } diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index f039d097a0..dc408e51c1 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -115,6 +115,7 @@ impl Client { ant_networking::target_arch::spawn(handle_event_receiver(event_receiver, sender)); receiver.await.expect("sender should not close")?; + debug!("Client is connected to the network"); Ok(Self { network, @@ -127,6 +128,8 @@ impl Client { let (client_event_sender, client_event_receiver) = tokio::sync::mpsc::channel(CLIENT_EVENT_CHANNEL_SIZE); self.client_event_sender = Arc::new(Some(client_event_sender)); + debug!("All events to the clients are enabled"); + client_event_receiver } } @@ -140,6 +143,7 @@ fn build_client_and_run_swarm(local: bool) -> (Network, mpsc::Receiver { let (receipt, _) = self.pay(content_addrs, &wallet).await?; + debug!( + "Paid for content addresses with wallet and the receipt is {:?}", + receipt + ); Ok(receipt) } PaymentOption::Receipt(receipt) => Ok(receipt), diff --git a/autonomi/src/client/registers.rs b/autonomi/src/client/registers.rs index c405fd6cf7..8a032399a5 100644 --- a/autonomi/src/client/registers.rs +++ b/autonomi/src/client/registers.rs @@ -96,7 +96,11 @@ impl Register { if let Some(value) = initial_value { register.write_atop(&value, &owner)?; } - + debug!( + "Created register {:?} with address: {:?}", + register, + register.address() + ); Ok(register) } @@ -166,10 +170,12 @@ impl Client { } } - Ok(Register { + let register = Register { signed_reg, crdt_reg, - }) + }; + debug!("Fetched register {register:?} from the address: {address} in the network"); + Ok(register) } /// Updates a Register on the network with a new value. This will overwrite existing value(s). @@ -217,7 +223,11 @@ impl Client { register.address() ) })?; - + debug!( + "Updated register {:?} with new value {:?}", + register.address(), + new_value + ); Ok(()) } @@ -244,7 +254,7 @@ impl Client { .map(|quote| quote.2.cost.as_atto()) .sum::(), ); - + debug!("Calculated the cost to create register with name: {name} is {total_cost}"); Ok(total_cost) } diff --git a/autonomi/src/client/utils.rs b/autonomi/src/client/utils.rs index 4962b400eb..9207b035c2 100644 --- a/autonomi/src/client/utils.rs +++ b/autonomi/src/client/utils.rs @@ -34,6 +34,7 @@ use crate::self_encryption::DataMapLevel; impl Client { /// Fetch and decrypt all chunks in the data map. pub(crate) async fn fetch_from_data_map(&self, data_map: &DataMap) -> Result { + debug!("Fetching encrypted data chunks from data map {data_map:?}"); let mut download_tasks = vec![]; for info in data_map.infos() { download_tasks.push(async move { @@ -53,7 +54,7 @@ impl Client { } }); } - + debug!("Successfully fetched all the encrypted chunks"); let encrypted_chunks = process_tasks_with_max_concurrency(download_tasks, *CHUNK_DOWNLOAD_BATCH_SIZE) .await @@ -64,7 +65,7 @@ impl Client { error!("Error decrypting encrypted_chunks: {e:?}"); GetError::Decryption(crate::self_encryption::Error::SelfEncryption(e)) })?; - + debug!("Successfully decrypted all the chunks"); Ok(data) } @@ -153,7 +154,9 @@ impl Client { use_put_record_to: Some(vec![storing_node]), verification, }; - Ok(self.network.put_record(record, &put_cfg).await?) + let payment_upload = Ok(self.network.put_record(record, &put_cfg).await?); + debug!("Successfully stored chunk: {chunk:?} to {storing_node:?}"); + payment_upload } /// Pay for the chunks and get the proof of payment. diff --git a/autonomi/src/client/vault.rs b/autonomi/src/client/vault.rs index baa86ed120..83553e3e16 100644 --- a/autonomi/src/client/vault.rs +++ b/autonomi/src/client/vault.rs @@ -63,10 +63,11 @@ impl Client { &self, secret_key: &VaultSecretKey, ) -> Result<(Bytes, VaultContentType), VaultError> { - info!("Fetching and decrypting vault"); + info!("Fetching and decrypting vault..."); let pad = self.get_vault_from_network(secret_key).await?; let data = pad.decrypt_data(secret_key)?; + debug!("vault data is successfully fetched and decrypted"); Ok((data, pad.data_encoding())) } diff --git a/evmlib/src/contract/data_payments/mod.rs b/evmlib/src/contract/data_payments/mod.rs index 79f90f9b04..ce633fb269 100644 --- a/evmlib/src/contract/data_payments/mod.rs +++ b/evmlib/src/contract/data_payments/mod.rs @@ -81,7 +81,7 @@ where .await? .watch() .await?; - + debug!("Data payments transaction hash: {:?}", tx_hash); Ok(tx_hash) } From 07c7ec28764077347d2a45614c11bdc8783ba4bc Mon Sep 17 00:00:00 2001 From: Ermine Jose Date: Thu, 5 Dec 2024 21:30:55 +0530 Subject: [PATCH 6/6] feat: add debug prints to evmlib --- evmlib/src/contract/data_payments/mod.rs | 5 +++++ evmlib/src/cryptography.rs | 2 ++ evmlib/src/transaction.rs | 1 + 3 files changed, 8 insertions(+) diff --git a/evmlib/src/contract/data_payments/mod.rs b/evmlib/src/contract/data_payments/mod.rs index ce633fb269..45a4f981a3 100644 --- a/evmlib/src/contract/data_payments/mod.rs +++ b/evmlib/src/contract/data_payments/mod.rs @@ -50,6 +50,10 @@ where let contract = DataPaymentsContract::deploy(provider, payment_token_address) .await .expect("Could not deploy contract"); + debug!( + "DataPayments contract deployed at: {:?}", + contract.address() + ); DataPaymentsHandler { contract } } @@ -66,6 +70,7 @@ where data_payments: I, ) -> Result { let (calldata, to) = self.pay_for_quotes_calldata(data_payments)?; + debug!("Data payments calldata is processed to the address {to:?}"); let transaction_request = self .contract diff --git a/evmlib/src/cryptography.rs b/evmlib/src/cryptography.rs index 02870942d9..84ad2b31d3 100644 --- a/evmlib/src/cryptography.rs +++ b/evmlib/src/cryptography.rs @@ -37,6 +37,8 @@ pub fn sign_message(evm_secret_key_str: &str, message: &[u8]) -> Result, let message_hash = to_eth_signed_message_hash(message); let (signature, _) = sign_message_recoverable(&signer.into_credential(), message_hash)?; + debug!("Message signed successfully with {message_hash:?} and {signature:?}"); + Ok(signature.to_vec()) } diff --git a/evmlib/src/transaction.rs b/evmlib/src/transaction.rs index dc8609a4d5..7e09e4495f 100644 --- a/evmlib/src/transaction.rs +++ b/evmlib/src/transaction.rs @@ -45,6 +45,7 @@ pub async fn get_transaction_receipt_by_hash( .get_transaction_receipt(transaction_hash) .await .inspect_err(|err| error!("Error getting transaction receipt for transaction_hash: {transaction_hash:?} : {err:?}", ))?; + debug!("Transaction receipt for {transaction_hash:?}: {maybe_receipt:?}"); Ok(maybe_receipt) }