diff --git a/Cargo.lock b/Cargo.lock index f877a5028..3491b6193 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5060,7 +5060,6 @@ dependencies = [ "ipc-types", "ipc-wallet", "ipc_actors_abis", - "log", "num-derive 0.3.3", "num-traits", "reqwest", @@ -5075,6 +5074,7 @@ dependencies = [ "tokio", "tokio-tungstenite 0.18.0", "toml 0.8.10", + "tracing", "url", "zeroize", ] diff --git a/fendermint/app/options/src/debug.rs b/fendermint/app/options/src/debug.rs new file mode 100644 index 000000000..c6a95f817 --- /dev/null +++ b/fendermint/app/options/src/debug.rs @@ -0,0 +1,67 @@ +// Copyright 2022-2024 Protocol Labs +// SPDX-License-Identifier: Apache-2.0, MIT + +use std::path::PathBuf; + +use crate::parse::parse_eth_address; +use clap::{Args, Subcommand}; +use fvm_shared::address::Address; +use ipc_api::subnet_id::SubnetID; + +#[derive(Args, Debug)] +pub struct DebugArgs { + #[command(subcommand)] + pub command: DebugCommands, +} + +#[derive(Subcommand, Debug)] +pub enum DebugCommands { + /// IPC commands. + Ipc { + #[command(subcommand)] + command: DebugIpcCommands, + }, +} + +#[derive(Subcommand, Debug, Clone)] +pub enum DebugIpcCommands { + /// Fetch topdown events from the parent and export them to JSON. + /// + /// This can be used to construct an upgrade to impute missing events. + ExportTopDownEvents(Box), +} + +#[derive(Args, Debug, Clone)] +pub struct DebugExportTopDownEventsArgs { + /// Child subnet for with the events will be fetched + #[arg(long, short)] + pub subnet_id: SubnetID, + + /// Endpoint to the RPC of the child subnet's parent + #[arg(long, short)] + pub parent_endpoint: url::Url, + + /// HTTP basic authentication token. + #[arg(long)] + pub parent_auth_token: Option, + + /// IPC gateway of the parent; 20 byte Ethereum address in 0x prefixed hex format + #[arg(long, value_parser = parse_eth_address)] + pub parent_gateway: Address, + + /// IPC registry of the parent; 20 byte Ethereum address in 0x prefixed hex format + #[arg(long, value_parser = parse_eth_address)] + pub parent_registry: Address, + + /// The first block to query for events. + #[arg(long)] + pub start_block_height: u64, + + /// The last block to query for events. + #[arg(long)] + pub end_block_height: u64, + + /// Location of the JSON file to write events to. + #[arg(long)] + pub events_file: PathBuf, +} diff --git a/fendermint/app/options/src/genesis.rs b/fendermint/app/options/src/genesis.rs index 2dc3c15ed..3da1794bc 100644 --- a/fendermint/app/options/src/genesis.rs +++ b/fendermint/app/options/src/genesis.rs @@ -145,6 +145,7 @@ pub struct GenesisIntoTendermintArgs { pub enum GenesisIpcCommands { /// Set all gateway parameters. Gateway(GenesisIpcGatewayArgs), + /// Fetch the genesis parameters of a subnet from the parent. FromParent(Box), } @@ -180,11 +181,15 @@ pub struct GenesisFromParentArgs { #[arg(long, short)] pub parent_endpoint: url::Url, + /// HTTP basic authentication token. + #[arg(long)] + pub parent_auth_token: Option, + /// IPC gateway of the parent; 20 byte Ethereum address in 0x prefixed hex format #[arg(long, value_parser = parse_eth_address, default_value = "0xff00000000000000000000000000000000000064")] pub parent_gateway: Address, - /// IPC registry of the parent; 20 byte Ethereum address in 0x prefixed hex format + /// IPC registry of the parent; 20 byte Ethereum address in 0x prefixed hex format #[arg(long, value_parser = parse_eth_address, default_value = "0xff00000000000000000000000000000000000065")] pub parent_registry: Address, diff --git a/fendermint/app/options/src/lib.rs b/fendermint/app/options/src/lib.rs index 86ca68af6..ea317efba 100644 --- a/fendermint/app/options/src/lib.rs +++ b/fendermint/app/options/src/lib.rs @@ -5,6 +5,7 @@ use std::path::PathBuf; use clap::{Args, Parser, Subcommand}; use config::ConfigArgs; +use debug::DebugArgs; use fvm_shared::address::Network; use lazy_static::lazy_static; use tracing_subscriber::EnvFilter; @@ -15,6 +16,7 @@ use self::{ }; pub mod config; +pub mod debug; pub mod eth; pub mod genesis; pub mod key; @@ -181,6 +183,8 @@ impl Options { pub enum Commands { /// Parse the configuration file and print it to the console. Config(ConfigArgs), + /// Arbitrary commands that aid in debugging. + Debug(DebugArgs), /// Run the `App`, listening to ABCI requests from Tendermint. Run(RunArgs), /// Subcommands related to the construction of signing keys. diff --git a/fendermint/app/src/cmd/debug.rs b/fendermint/app/src/cmd/debug.rs new file mode 100644 index 000000000..364fd36c1 --- /dev/null +++ b/fendermint/app/src/cmd/debug.rs @@ -0,0 +1,68 @@ +// Copyright 2022-2024 Protocol Labs +// SPDX-License-Identifier: Apache-2.0, MIT + +use anyhow::{anyhow, Context}; +use fendermint_app_options::debug::{ + DebugArgs, DebugCommands, DebugExportTopDownEventsArgs, DebugIpcCommands, +}; +use fendermint_vm_topdown::proxy::IPCProviderProxy; +use ipc_provider::{ + config::subnet::{EVMSubnet, SubnetConfig}, + IpcProvider, +}; + +use crate::cmd; + +cmd! { + DebugArgs(self) { + match &self.command { + DebugCommands::Ipc { command } => command.exec(()).await, + } + } +} + +cmd! { + DebugIpcCommands(self) { + match self { + DebugIpcCommands::ExportTopDownEvents(args) => + export_topdown_events(args).await + } + } +} + +async fn export_topdown_events(args: &DebugExportTopDownEventsArgs) -> anyhow::Result<()> { + // Configuration for the child subnet on the parent network, + // based on how it's done in `run.rs` and the `genesis ipc from-parent` command. + let parent_provider = IpcProvider::new_with_subnet( + None, + ipc_provider::config::Subnet { + id: args + .subnet_id + .parent() + .ok_or_else(|| anyhow!("subnet is not a child"))?, + config: SubnetConfig::Fevm(EVMSubnet { + provider_http: args.parent_endpoint.clone(), + provider_timeout: None, + auth_token: args.parent_auth_token.clone(), + registry_addr: args.parent_registry, + gateway_addr: args.parent_gateway, + }), + }, + )?; + + let parent_proxy = IPCProviderProxy::new(parent_provider, args.subnet_id.clone()) + .context("failed to create provider proxy")?; + + let events = fendermint_vm_topdown::sync::fetch_topdown_events( + &parent_proxy, + args.start_block_height, + args.end_block_height, + ) + .await + .context("failed to fetch topdown events")?; + + let json = serde_json::to_string_pretty(&events)?; + std::fs::write(&args.events_file, json)?; + + Ok(()) +} diff --git a/fendermint/app/src/cmd/genesis.rs b/fendermint/app/src/cmd/genesis.rs index 10cdf1d13..183a89cb7 100644 --- a/fendermint/app/src/cmd/genesis.rs +++ b/fendermint/app/src/cmd/genesis.rs @@ -92,7 +92,7 @@ cmd! { GenesisIpcCommands::Gateway(args) => set_ipc_gateway(&genesis_file, args), GenesisIpcCommands::FromParent(args) => - new_genesis_from_parent(&genesis_file, args).await + new_genesis_from_parent(&genesis_file, args).await, } } } @@ -294,7 +294,7 @@ async fn new_genesis_from_parent( config: SubnetConfig::Fevm(EVMSubnet { provider_http: args.parent_endpoint.clone(), provider_timeout: None, - auth_token: None, + auth_token: args.parent_auth_token.clone(), registry_addr: args.parent_registry, gateway_addr: args.parent_gateway, }), diff --git a/fendermint/app/src/cmd/mod.rs b/fendermint/app/src/cmd/mod.rs index f24c42ba9..e32592459 100644 --- a/fendermint/app/src/cmd/mod.rs +++ b/fendermint/app/src/cmd/mod.rs @@ -11,6 +11,7 @@ use anyhow::{anyhow, Context}; use async_trait::async_trait; pub mod config; +pub mod debug; pub mod eth; pub mod genesis; pub mod key; @@ -62,6 +63,7 @@ macro_rules! cmd { pub async fn exec(opts: &Options) -> anyhow::Result<()> { match &opts.command { Commands::Config(args) => args.exec(settings(opts)?).await, + Commands::Debug(args) => args.exec(()).await, Commands::Run(args) => args.exec(settings(opts)?).await, Commands::Key(args) => args.exec(()).await, Commands::Genesis(args) => args.exec(()).await, diff --git a/fendermint/vm/topdown/src/sync/mod.rs b/fendermint/vm/topdown/src/sync/mod.rs index 2ac1128d2..03d98f129 100644 --- a/fendermint/vm/topdown/src/sync/mod.rs +++ b/fendermint/vm/topdown/src/sync/mod.rs @@ -19,6 +19,8 @@ use std::time::Duration; use fendermint_vm_genesis::{Power, Validator}; +pub use syncer::fetch_topdown_events; + /// Query the parent finality from the block chain state. /// /// It returns `None` from queries until the ledger has been initialized. diff --git a/fendermint/vm/topdown/src/sync/syncer.rs b/fendermint/vm/topdown/src/sync/syncer.rs index dff206fb0..675d4e4c6 100644 --- a/fendermint/vm/topdown/src/sync/syncer.rs +++ b/fendermint/vm/topdown/src/sync/syncer.rs @@ -12,6 +12,7 @@ use crate::{ use anyhow::anyhow; use async_stm::{atomically, atomically_or_err, StmError}; use ethers::utils::hex; +use libp2p::futures::TryFutureExt; use std::sync::Arc; use tracing::instrument; @@ -266,45 +267,12 @@ where Ok(data.0) } - #[instrument(skip(self))] async fn fetch_data( &self, height: BlockHeight, block_hash: BlockHash, ) -> Result { - let changes_res = self - .parent_proxy - .get_validator_changes(height) - .await - .map_err(|e| Error::CannotQueryParent(format!("get_validator_changes: {e}"), height))?; - - if changes_res.block_hash != block_hash { - tracing::warn!( - height, - change_set_hash = hex::encode(&changes_res.block_hash), - block_hash = hex::encode(&block_hash), - "change set block hash does not equal block hash", - ); - return Err(Error::ParentChainReorgDetected); - } - - let topdown_msgs_res = self - .parent_proxy - .get_top_down_msgs(height) - .await - .map_err(|e| Error::CannotQueryParent(format!("get_top_down_msgs: {e}"), height))?; - - if topdown_msgs_res.block_hash != block_hash { - tracing::warn!( - height, - topdown_msgs_hash = hex::encode(&topdown_msgs_res.block_hash), - block_hash = hex::encode(&block_hash), - "topdown messages block hash does not equal block hash", - ); - return Err(Error::ParentChainReorgDetected); - } - - Ok((block_hash, changes_res.value, topdown_msgs_res.value)) + fetch_data(self.parent_proxy.as_ref(), height, block_hash).await } async fn finalized_chain_head(&self) -> anyhow::Result> { @@ -342,6 +310,83 @@ fn map_voting_err(e: StmError) -> StmError { } } +#[instrument(skip(parent_proxy))] +async fn fetch_data

( + parent_proxy: &P, + height: BlockHeight, + block_hash: BlockHash, +) -> Result +where + P: ParentQueryProxy + Send + Sync + 'static, +{ + let changes_res = parent_proxy + .get_validator_changes(height) + .map_err(|e| Error::CannotQueryParent(format!("get_validator_changes: {e}"), height)); + + let topdown_msgs_res = parent_proxy + .get_top_down_msgs(height) + .map_err(|e| Error::CannotQueryParent(format!("get_top_down_msgs: {e}"), height)); + + let (changes_res, topdown_msgs_res) = tokio::join!(changes_res, topdown_msgs_res); + let (changes_res, topdown_msgs_res) = (changes_res?, topdown_msgs_res?); + + if changes_res.block_hash != block_hash { + tracing::warn!( + height, + change_set_hash = hex::encode(&changes_res.block_hash), + block_hash = hex::encode(&block_hash), + "change set block hash does not equal block hash", + ); + return Err(Error::ParentChainReorgDetected); + } + + if topdown_msgs_res.block_hash != block_hash { + tracing::warn!( + height, + topdown_msgs_hash = hex::encode(&topdown_msgs_res.block_hash), + block_hash = hex::encode(&block_hash), + "topdown messages block hash does not equal block hash", + ); + return Err(Error::ParentChainReorgDetected); + } + + Ok((block_hash, changes_res.value, topdown_msgs_res.value)) +} + +pub async fn fetch_topdown_events

( + parent_proxy: &P, + start_height: BlockHeight, + end_height: BlockHeight, +) -> Result, Error> +where + P: ParentQueryProxy + Send + Sync + 'static, +{ + let mut events = Vec::new(); + for height in start_height..=end_height { + match parent_proxy.get_block_hash(height).await { + Ok(res) => { + let (block_hash, changes, msgs) = + fetch_data(parent_proxy, height, res.block_hash).await?; + + if !(changes.is_empty() && msgs.is_empty()) { + events.push((height, (block_hash, changes, msgs))); + } + } + Err(e) => { + if is_null_round_str(&e.to_string()) { + continue; + } else { + return Err(Error::CannotQueryParent( + format!("get_block_hash: {e}"), + height, + )); + } + } + } + } + Ok(events) +} + #[cfg(test)] mod tests { use crate::proxy::ParentQueryProxy; diff --git a/ipc/api/src/staking.rs b/ipc/api/src/staking.rs index e49f1e2ab..723a10a76 100644 --- a/ipc/api/src/staking.rs +++ b/ipc/api/src/staking.rs @@ -8,11 +8,12 @@ use ethers::utils::hex; use fvm_shared::address::Address; use fvm_shared::econ::TokenAmount; use ipc_actors_abis::{lib_staking_change_log, subnet_actor_getter_facet}; +use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; pub type ConfigurationNumber = u64; -#[derive(Clone, Debug, num_enum::TryFromPrimitive)] +#[derive(Clone, Debug, num_enum::TryFromPrimitive, Deserialize, Serialize)] #[non_exhaustive] #[repr(u8)] pub enum StakingOperation { @@ -22,14 +23,14 @@ pub enum StakingOperation { SetFederatedPower = 3, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct StakingChangeRequest { pub configuration_number: ConfigurationNumber, pub change: StakingChange, } /// The change request to validator staking -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct StakingChange { pub op: StakingOperation, pub payload: Vec, diff --git a/ipc/provider/Cargo.toml b/ipc/provider/Cargo.toml index 658276550..58d9c0ea4 100644 --- a/ipc/provider/Cargo.toml +++ b/ipc/provider/Cargo.toml @@ -14,7 +14,7 @@ async-trait = { workspace = true } futures-util = { workspace = true } reqwest = { workspace = true } -log = { workspace = true } +tracing = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } cid = { workspace = true } diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index 7066844c9..fd9281126 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -117,11 +117,11 @@ impl BottomUpCheckpointMan /// Run the bottom up checkpoint submission daemon in the foreground pub async fn run(self, submitter: Address, submission_interval: Duration) { - log::info!("launching {self} for {submitter}"); + tracing::info!("launching {self} for {submitter}"); loop { if let Err(e) = self.submit_next_epoch(submitter).await { - log::error!("cannot submit checkpoint for submitter: {submitter} due to {e}"); + tracing::error!("cannot submit checkpoint for submitter: {submitter} due to {e}"); } tokio::time::sleep(submission_interval).await; } @@ -136,19 +136,21 @@ impl BottomUpCheckpointMan .map_err(|e| { anyhow!("cannot obtain the last bottom up checkpoint height due to: {e:}") })?; - log::info!("last submission height: {last_checkpoint_epoch}"); + tracing::info!("last submission height: {last_checkpoint_epoch}"); let current_height = self.child_handler.current_epoch().await?; let finalized_height = max(1, current_height - self.finalization_blocks); - log::debug!("last submission height: {last_checkpoint_epoch}, current height: {current_height}, finalized_height: {finalized_height}"); + tracing::debug!("last submission height: {last_checkpoint_epoch}, current height: {current_height}, finalized_height: {finalized_height}"); if finalized_height <= last_checkpoint_epoch { return Ok(()); } let start = last_checkpoint_epoch + 1; - log::debug!("start querying quorum reached events from : {start} to {finalized_height}"); + tracing::debug!( + "start querying quorum reached events from : {start} to {finalized_height}" + ); let mut count = 0; let mut all_submit_tasks = vec![]; @@ -156,11 +158,11 @@ impl BottomUpCheckpointMan for h in start..=finalized_height { let events = self.child_handler.quorum_reached_events(h).await?; if events.is_empty() { - log::debug!("no reached events at height : {h}"); + tracing::debug!("no reached events at height : {h}"); continue; } - log::debug!("found reached events at height : {h}"); + tracing::debug!("found reached events at height : {h}"); for event in events { // Note that the event will be emitted later than the checkpoint height. @@ -168,7 +170,7 @@ impl BottomUpCheckpointMan // in fendermint at height 403. This means the event.height == 400 which is // already committed. if event.height <= last_checkpoint_epoch { - log::debug!("event height already committed: {}", event.height); + tracing::debug!("event height already committed: {}", event.height); continue; } @@ -176,7 +178,7 @@ impl BottomUpCheckpointMan .child_handler .checkpoint_bundle_at(event.height) .await?; - log::debug!("bottom up bundle: {bundle:?}"); + tracing::debug!("bottom up bundle: {bundle:?}"); // We support parallel checkpoint submission using FIFO order with a limited parallelism (controlled by // the size of submission_semaphore). @@ -195,18 +197,20 @@ impl BottomUpCheckpointMan Self::submit_checkpoint(parent_handler_clone, submitter, bundle, event) .await .inspect_err(|err| { - log::error!("Fail to submit checkpoint at height {height}: {err}"); + tracing::error!( + "Fail to submit checkpoint at height {height}: {err}" + ); }); drop(submission_permit); result })); count += 1; - log::debug!("This round has asynchronously submitted {count} checkpoints",); + tracing::debug!("This round has asynchronously submitted {count} checkpoints",); } } - log::debug!("Waiting for all submissions to finish"); + tracing::debug!("Waiting for all submissions to finish"); // Return error if any of the submit task failed. try_join_all(all_submit_tasks).await?; @@ -234,7 +238,7 @@ impl BottomUpCheckpointMan ) })?; - log::info!( + tracing::info!( "submitted bottom up checkpoint({}) in parent at height {}", event.height, epoch diff --git a/ipc/provider/src/jsonrpc/mod.rs b/ipc/provider/src/jsonrpc/mod.rs index 7dbcf39ca..ea294fe21 100644 --- a/ipc/provider/src/jsonrpc/mod.rs +++ b/ipc/provider/src/jsonrpc/mod.rs @@ -78,11 +78,11 @@ impl JsonRpcClient for JsonRpcClientImpl { let response = builder.send().await?; let response_body = response.text().await?; - log::debug!("received raw response body: {:?}", response_body); + tracing::debug!("received raw response body: {:?}", response_body); let value = serde_json::from_str::>(response_body.as_ref()).map_err(|e| { - log::error!("cannot parse json rpc client response: {:?}", response_body); + tracing::error!("cannot parse json rpc client response: {:?}", response_body); anyhow!( "cannot parse json rpc response: {:} due to {:}", response_body, @@ -157,18 +157,18 @@ async fn handle_stream( loop { match ws_stream.next().await { None => { - log::trace!("No message in websocket stream. The stream was closed."); + tracing::trace!("No message in websocket stream. The stream was closed."); break; } Some(result) => match result { Ok(msg) => { println!("{}", msg); - log::trace!("Read message from websocket stream: {}", msg); + tracing::trace!("Read message from websocket stream: {}", msg); let value = serde_json::from_str(msg.to_text().unwrap()).unwrap(); chan.send(value).await.unwrap(); } Err(err) => { - log::error!("Error reading message from websocket stream: {:?}", err); + tracing::error!("Error reading message from websocket stream: {:?}", err); break; } }, diff --git a/ipc/provider/src/lib.rs b/ipc/provider/src/lib.rs index 735e7a07b..d507e0b98 100644 --- a/ipc/provider/src/lib.rs +++ b/ipc/provider/src/lib.rs @@ -126,21 +126,16 @@ impl IpcProvider { /// Get the connection instance for the subnet. pub fn connection(&self, subnet: &SubnetID) -> Option { let subnets = &self.config.subnets; + match subnets.get(subnet) { Some(subnet) => match &subnet.config { config::subnet::SubnetConfig::Fevm(_) => { - let wallet = match self.evm_wallet() { - Ok(w) => Some(w), - Err(e) => { - log::warn!("error initializing evm wallet: {e}"); - None - } - }; + let wallet = self.evm_keystore.clone(); let manager = match EthSubnetManager::from_subnet_with_wallet_store(subnet, wallet) { Ok(w) => Some(w), Err(e) => { - log::warn!("error initializing evm wallet: {e}"); + tracing::warn!("error initializing evm manager: {e}"); return None; } }; @@ -154,6 +149,21 @@ impl IpcProvider { } } + /// Get the connection of a subnet, or return an error. + fn get_connection(&self, subnet: &SubnetID) -> anyhow::Result { + match self.connection(subnet) { + None => Err(anyhow!( + "subnet not found: {subnet}; known subnets: {:?}", + self.config + .subnets + .keys() + .map(|id| id.to_string()) + .collect::>() + )), + Some(conn) => Ok(conn), + } + } + /// Set the default account for the provider pub fn with_sender(&mut self, from: Address) { self.sender = Some(from); @@ -243,10 +253,7 @@ impl IpcProvider { permission_mode: PermissionMode, supply_source: SupplySource, ) -> anyhow::Result

{ - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -277,10 +284,7 @@ impl IpcProvider { public_key: Vec, ) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -297,11 +301,7 @@ impl IpcProvider { balance: TokenAmount, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; - + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -315,10 +315,7 @@ impl IpcProvider { amount: TokenAmount, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -333,10 +330,7 @@ impl IpcProvider { collateral: TokenAmount, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -351,10 +345,7 @@ impl IpcProvider { collateral: TokenAmount, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -368,10 +359,7 @@ impl IpcProvider { from: Option
, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -385,10 +373,7 @@ impl IpcProvider { from: Option
, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -402,10 +387,7 @@ impl IpcProvider { from: Option
, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -418,10 +400,7 @@ impl IpcProvider { gateway_addr: Option
, subnet: &SubnetID, ) -> anyhow::Result> { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; let subnet_config = conn.subnet(); @@ -444,10 +423,7 @@ impl IpcProvider { amount: TokenAmount, ) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -473,10 +449,7 @@ impl IpcProvider { amount: TokenAmount, ) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -497,7 +470,7 @@ impl IpcProvider { amount: TokenAmount, ) -> anyhow::Result { let conn = match self.connection(&subnet) { - None => return Err(anyhow!("target subnet not found")), + None => return Err(anyhow!("target subnet not found: {subnet}")), Some(conn) => conn, }; @@ -535,10 +508,7 @@ impl IpcProvider { to: Address, amount: TokenAmount, ) -> anyhow::Result<()> { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -565,19 +535,13 @@ impl IpcProvider { subnet: &SubnetID, address: &Address, ) -> anyhow::Result { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().wallet_balance(address).await } pub async fn chain_head(&self, subnet: &SubnetID) -> anyhow::Result { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().chain_head_height().await } @@ -585,10 +549,7 @@ impl IpcProvider { /// Obtain the genesis epoch of the input subnet. pub async fn genesis_epoch(&self, subnet: &SubnetID) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("parent subnet config not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager().genesis_epoch(subnet).await } @@ -599,10 +560,7 @@ impl IpcProvider { validator: &Address, ) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target subnet parent not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager().get_validator_info(subnet, validator).await } @@ -614,10 +572,7 @@ impl IpcProvider { epoch: ChainEpoch, ) -> anyhow::Result>> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target subnet parent not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager().get_validator_changeset(subnet, epoch).await } @@ -626,10 +581,7 @@ impl IpcProvider { /// generate the genesis of the subnet pub async fn get_genesis_info(&self, subnet: &SubnetID) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("parent subnet config not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager().get_genesis_info(subnet).await } @@ -639,10 +591,7 @@ impl IpcProvider { epoch: ChainEpoch, ) -> anyhow::Result>> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager().get_top_down_msgs(subnet, epoch).await } @@ -652,37 +601,25 @@ impl IpcProvider { subnet: &SubnetID, height: ChainEpoch, ) -> anyhow::Result { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().get_block_hash(height).await } pub async fn get_chain_id(&self, subnet: &SubnetID) -> anyhow::Result { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().get_chain_id().await } pub async fn get_commit_sha(&self, subnet: &SubnetID) -> anyhow::Result<[u8; 32]> { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().get_commit_sha().await } pub async fn get_chain_head_height(&self, subnet: &SubnetID) -> anyhow::Result { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().chain_head_height().await } @@ -692,10 +629,7 @@ impl IpcProvider { subnet: &SubnetID, height: ChainEpoch, ) -> anyhow::Result { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().checkpoint_bundle_at(height).await } @@ -705,10 +639,7 @@ impl IpcProvider { subnet: &SubnetID, ) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager() .last_bottom_up_checkpoint_height(subnet) @@ -720,10 +651,7 @@ impl IpcProvider { subnet: &SubnetID, height: ChainEpoch, ) -> anyhow::Result> { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().quorum_reached_events(height).await } @@ -736,10 +664,7 @@ impl IpcProvider { endpoint: String, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; let subnet_config = conn.subnet(); let sender = self.check_sender(subnet_config, from)?; @@ -752,20 +677,14 @@ impl IpcProvider { /// Lists the bootstrap nodes of a subnet pub async fn list_bootstrap_nodes(&self, subnet: &SubnetID) -> anyhow::Result> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager().list_bootstrap_nodes(subnet).await } /// Returns the latest finality from the parent committed in a child subnet. pub async fn latest_parent_finality(&self, subnet: &SubnetID) -> anyhow::Result { - let conn = match self.connection(subnet) { - None => return Err(anyhow!("target subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(subnet)?; conn.manager().latest_parent_finality().await } @@ -779,10 +698,7 @@ impl IpcProvider { federated_power: &[u128], ) -> anyhow::Result { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; - let conn = match self.connection(&parent) { - None => return Err(anyhow!("target parent subnet not found")), - Some(conn) => conn, - }; + let conn = self.get_connection(&parent)?; conn.manager() .set_federated_power(from, subnet, validators, public_keys, federated_power) .await diff --git a/ipc/provider/src/lotus/client.rs b/ipc/provider/src/lotus/client.rs index 3ee32f9f3..d1ce5b072 100644 --- a/ipc/provider/src/lotus/client.rs +++ b/ipc/provider/src/lotus/client.rs @@ -157,7 +157,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::MPOOL_PUSH_MESSAGE, params) .await?; - log::debug!("received mpool_push_message response: {r:?}"); + tracing::debug!("received mpool_push_message response: {r:?}"); Ok(r.message) } @@ -165,7 +165,7 @@ impl LotusClient for LotusJsonRPCClient { async fn mpool_push(&self, mut msg: MpoolPushMessage) -> Result { if msg.nonce.is_none() { let nonce = self.mpool_nonce(&msg.from).await?; - log::info!( + tracing::info!( "sender: {:} with nonce: {nonce:} in subnet: {:}", msg.from, self.subnet @@ -178,12 +178,12 @@ impl LotusClient for LotusJsonRPCClient { } self.estimate_message_gas(&mut msg).await?; - log::debug!("estimated gas for message: {msg:?}"); + tracing::debug!("estimated gas for message: {msg:?}"); let signature = self.sign_mpool_message(&msg)?; let params = create_signed_message_params(msg, signature); - log::debug!( + tracing::debug!( "message to push to mpool: {params:?} in subnet: {:?}", self.subnet ); @@ -192,7 +192,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::MPOOL_PUSH, params) .await?; - log::debug!("received mpool_push_message response: {r:?}"); + tracing::debug!("received mpool_push_message response: {r:?}"); Cid::try_from(r) } @@ -210,7 +210,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::STATE_WAIT_MSG, params) .await?; - log::debug!("received state_wait_msg response: {r:?}"); + tracing::debug!("received state_wait_msg response: {r:?}"); Ok(r) } @@ -220,7 +220,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::STATE_NETWORK_NAME, serde_json::Value::Null) .await?; - log::debug!("received state_network_name response: {r:?}"); + tracing::debug!("received state_network_name response: {r:?}"); Ok(r) } @@ -233,7 +233,7 @@ impl LotusClient for LotusJsonRPCClient { .request::(methods::STATE_NETWORK_VERSION, params) .await?; - log::debug!("received state_network_version response: {r:?}"); + tracing::debug!("received state_network_version response: {r:?}"); Ok(r) } @@ -254,7 +254,7 @@ impl LotusClient for LotusJsonRPCClient { cids.insert(key, Cid::try_from(cid_map)?); } - log::debug!("received state_actor_manifest_cid response: {cids:?}"); + tracing::debug!("received state_actor_manifest_cid response: {cids:?}"); Ok(cids) } @@ -264,7 +264,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::WALLET_DEFAULT_ADDRESS, json!({})) .await?; - log::debug!("received wallet_default response: {r:?}"); + tracing::debug!("received wallet_default response: {r:?}"); let addr = Address::from_str(&r)?; Ok(addr) @@ -276,7 +276,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::WALLET_LIST, json!({})) .await?; - log::debug!("received wallet_list response: {r:?}"); + tracing::debug!("received wallet_list response: {r:?}"); Ok(r) } @@ -287,7 +287,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::WALLET_NEW, json!([key_type_str])) .await?; - log::debug!("received wallet_new response: {r:?}"); + tracing::debug!("received wallet_new response: {r:?}"); Ok(r) } @@ -297,7 +297,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::WALLET_BALANCE, json!([address.to_string()])) .await?; - log::debug!("received wallet_balance response: {r:?}"); + tracing::debug!("received wallet_balance response: {r:?}"); let v = BigInt::from_str(&r)?; Ok(TokenAmount::from_atto(v)) @@ -316,7 +316,7 @@ impl LotusClient for LotusJsonRPCClient { json!([address.to_string(), [CIDMap::from(tipset)]]), ) .await?; - log::debug!("received read_state response: {r:?}"); + tracing::debug!("received read_state response: {r:?}"); Ok(r) } @@ -325,7 +325,7 @@ impl LotusClient for LotusJsonRPCClient { .client .request::(methods::CHAIN_HEAD, NO_PARAMS) .await?; - log::debug!("received chain_head response: {r:?}"); + tracing::debug!("received chain_head response: {r:?}"); Ok(r) } @@ -345,7 +345,7 @@ impl LotusClient for LotusJsonRPCClient { json!([epoch, [CIDMap::from(tip_set)]]), ) .await?; - log::debug!("received get_tipset_by_height response: {r:?}"); + tracing::debug!("received get_tipset_by_height response: {r:?}"); Ok(r) } } diff --git a/ipc/provider/src/lotus/message/state.rs b/ipc/provider/src/lotus/message/state.rs index 4749cee42..19ced4908 100644 --- a/ipc/provider/src/lotus/message/state.rs +++ b/ipc/provider/src/lotus/message/state.rs @@ -52,7 +52,7 @@ impl Receipt { let r = base64::engine::general_purpose::STANDARD .decode(self.result.unwrap()) .map_err(|e| { - log::error!("cannot base64 decode due to {e:?}"); + tracing::error!("cannot base64 decode due to {e:?}"); anyhow!("cannot decode return string") })?; @@ -61,7 +61,7 @@ impl Receipt { "deserialize create subnet return response", ) .map_err(|e| { - log::error!("cannot decode bytes due to {e:?}"); + tracing::error!("cannot decode bytes due to {e:?}"); anyhow!("cannot cbor deserialize return data") }) } diff --git a/ipc/provider/src/manager/evm/manager.rs b/ipc/provider/src/manager/evm/manager.rs index a8cfd004b..cfeeb09ae 100644 --- a/ipc/provider/src/manager/evm/manager.rs +++ b/ipc/provider/src/manager/evm/manager.rs @@ -86,7 +86,7 @@ struct IPCContractInfo { impl TopDownFinalityQuery for EthSubnetManager { async fn genesis_epoch(&self, subnet_id: &SubnetID) -> Result { let address = contract_address_from_subnet(subnet_id)?; - log::info!("querying genesis epoch in evm subnet contract: {address:}"); + tracing::info!("querying genesis epoch in evm subnet contract: {address:}"); let evm_subnet_id = gateway_getter_facet::SubnetID::try_from(subnet_id)?; @@ -122,7 +122,7 @@ impl TopDownFinalityQuery for EthSubnetManager { ); let topic1 = contract_address_from_subnet(subnet_id)?; - log::debug!( + tracing::debug!( "getting top down messages for subnet: {:?} with topic 1: {}", subnet_id, topic1, @@ -184,7 +184,7 @@ impl TopDownFinalityQuery for EthSubnetManager { epoch: ChainEpoch, ) -> Result>> { let address = contract_address_from_subnet(subnet_id)?; - log::info!("querying validator changes in evm subnet contract: {address:}"); + tracing::info!("querying validator changes in evm subnet contract: {address:}"); let contract = subnet_actor_manager_facet::SubnetActorManagerFacet::new( address, @@ -222,7 +222,7 @@ impl TopDownFinalityQuery for EthSubnetManager { } async fn latest_parent_finality(&self) -> Result { - log::info!("querying latest parent finality "); + tracing::info!("querying latest parent finality "); let contract = gateway_getter_facet::GatewayGetterFacet::new( self.ipc_contract_info.gateway_addr, @@ -244,10 +244,10 @@ impl SubnetManager for EthSubnetManager { .to_u128() .ok_or_else(|| anyhow!("invalid min validator stake"))?; - log::debug!("calling create subnet for EVM manager"); + tracing::debug!("calling create subnet for EVM manager"); let route = subnet_id_to_evm_addresses(¶ms.parent)?; - log::debug!("root SubnetID as Ethereum type: {route:?}"); + tracing::debug!("root SubnetID as Ethereum type: {route:?}"); let params = register_subnet_facet::ConstructorParams { parent_id: register_subnet_facet::SubnetID { @@ -266,7 +266,7 @@ impl SubnetManager for EthSubnetManager { supply_source: register_subnet_facet::SupplySource::try_from(params.supply_source)?, }; - log::info!("creating subnet on evm with params: {params:?}"); + tracing::info!("creating subnet on evm with params: {params:?}"); let signer = self.get_signer(&from)?; let signer = Arc::new(signer); @@ -286,7 +286,7 @@ impl SubnetManager for EthSubnetManager { match receipt { Some(r) => { for log in r.logs { - log::debug!("log: {log:?}"); + tracing::debug!("log: {log:?}"); match ethers_contract::parse_log::( log, @@ -295,11 +295,11 @@ impl SubnetManager for EthSubnetManager { let register_subnet_facet::SubnetDeployedFilter { subnet_addr } = subnet_deploy; - log::debug!("subnet deployed at {subnet_addr:?}"); + tracing::debug!("subnet deployed at {subnet_addr:?}"); return ethers_address_to_fil_address(&subnet_addr); } Err(_) => { - log::debug!("no event for subnet actor published yet, continue"); + tracing::debug!("no event for subnet actor published yet, continue"); continue; } } @@ -323,7 +323,7 @@ impl SubnetManager for EthSubnetManager { .ok_or_else(|| anyhow!("invalid min validator stake"))?; let address = contract_address_from_subnet(&subnet)?; - log::info!( + tracing::info!( "interacting with evm subnet contract: {address:} with collateral: {collateral:}" ); @@ -350,7 +350,7 @@ impl SubnetManager for EthSubnetManager { .ok_or_else(|| anyhow!("invalid initial balance"))?; let address = contract_address_from_subnet(&subnet)?; - log::info!("interacting with evm subnet contract: {address:} with balance: {balance:}"); + tracing::info!("interacting with evm subnet contract: {address:} with balance: {balance:}"); let signer = Arc::new(self.get_signer(&from)?); let contract = @@ -371,7 +371,7 @@ impl SubnetManager for EthSubnetManager { amount: TokenAmount, ) -> Result<()> { let address = contract_address_from_subnet(&subnet)?; - log::info!("pre-release funds from {subnet:} at contract: {address:}"); + tracing::info!("pre-release funds from {subnet:} at contract: {address:}"); let amount = amount .atto() @@ -398,7 +398,7 @@ impl SubnetManager for EthSubnetManager { .ok_or_else(|| anyhow!("invalid collateral amount"))?; let address = contract_address_from_subnet(&subnet)?; - log::info!( + tracing::info!( "interacting with evm subnet contract: {address:} with collateral: {collateral:}" ); @@ -427,7 +427,7 @@ impl SubnetManager for EthSubnetManager { .ok_or_else(|| anyhow!("invalid collateral amount"))?; let address = contract_address_from_subnet(&subnet)?; - log::info!( + tracing::info!( "interacting with evm subnet contract: {address:} with collateral: {collateral:}" ); @@ -443,7 +443,7 @@ impl SubnetManager for EthSubnetManager { async fn leave_subnet(&self, subnet: SubnetID, from: Address) -> Result<()> { let address = contract_address_from_subnet(&subnet)?; - log::info!("leaving evm subnet: {subnet:} at contract: {address:}"); + tracing::info!("leaving evm subnet: {subnet:} at contract: {address:}"); let signer = Arc::new(self.get_signer(&from)?); let contract = @@ -460,7 +460,7 @@ impl SubnetManager for EthSubnetManager { async fn kill_subnet(&self, subnet: SubnetID, from: Address) -> Result<()> { let address = contract_address_from_subnet(&subnet)?; - log::info!("kill evm subnet: {subnet:} at contract: {address:}"); + tracing::info!("kill evm subnet: {subnet:} at contract: {address:}"); let signer = Arc::new(self.get_signer(&from)?); let contract = @@ -489,7 +489,7 @@ impl SubnetManager for EthSubnetManager { let mut s = HashMap::new(); let evm_subnets = gateway_contract.list_subnets().call().await?; - log::debug!("raw subnet: {evm_subnets:?}"); + tracing::debug!("raw subnet: {evm_subnets:?}"); for subnet in evm_subnets { let info = SubnetInfo::try_from(subnet)?; @@ -501,7 +501,7 @@ impl SubnetManager for EthSubnetManager { async fn claim_collateral(&self, subnet: SubnetID, from: Address) -> Result<()> { let address = contract_address_from_subnet(&subnet)?; - log::info!("claim collateral evm subnet: {subnet:} at contract: {address:}"); + tracing::info!("claim collateral evm subnet: {subnet:} at contract: {address:}"); let signer = Arc::new(self.get_signer(&from)?); let contract = @@ -531,10 +531,10 @@ impl SubnetManager for EthSubnetManager { .to_u128() .ok_or_else(|| anyhow!("invalid value to fund"))?; - log::info!("fund with evm gateway contract: {gateway_addr:} with value: {value:}, original: {amount:?}"); + tracing::info!("fund with evm gateway contract: {gateway_addr:} with value: {value:}, original: {amount:?}"); let evm_subnet_id = gateway_manager_facet::SubnetID::try_from(&subnet)?; - log::debug!("evm subnet id to fund: {evm_subnet_id:?}"); + tracing::debug!("evm subnet id to fund: {evm_subnet_id:?}"); let signer = Arc::new(self.get_signer(&from)?); let gateway_contract = gateway_manager_facet::GatewayManagerFacet::new( @@ -561,7 +561,9 @@ impl SubnetManager for EthSubnetManager { to: Address, amount: TokenAmount, ) -> Result { - log::debug!("fund with token, subnet: {subnet}, amount: {amount}, from: {from}, to: {to}"); + tracing::debug!( + "fund with token, subnet: {subnet}, amount: {amount}, from: {from}, to: {to}" + ); let value = fil_amount_to_eth_amount(&amount)?; let evm_subnet_id = gateway_manager_facet::SubnetID::try_from(&subnet)?; @@ -598,7 +600,7 @@ impl SubnetManager for EthSubnetManager { .to_u128() .ok_or_else(|| anyhow!("invalid value to fund"))?; - log::info!("release with evm gateway contract: {gateway_addr:} with value: {value:}"); + tracing::info!("release with evm gateway contract: {gateway_addr:} with value: {value:}"); let signer = Arc::new(self.get_signer(&from)?); let gateway_contract = gateway_manager_facet::GatewayManagerFacet::new( @@ -631,7 +633,7 @@ impl SubnetManager for EthSubnetManager { self.ensure_same_gateway(&gateway_addr)?; - log::info!("propagate postbox evm gateway contract: {gateway_addr:} with message key: {postbox_msg_key:?}"); + tracing::info!("propagate postbox evm gateway contract: {gateway_addr:} with message key: {postbox_msg_key:?}"); let signer = Arc::new(self.get_signer(&from)?); let gateway_contract = gateway_messenger_facet::GatewayMessengerFacet::new( @@ -662,7 +664,7 @@ impl SubnetManager for EthSubnetManager { let tx_pending = signer.send_transaction(tx, None).await?; - log::info!( + tracing::info!( "sending FIL from {from:} to {to:} in tx {:?}", tx_pending.tx_hash() ); @@ -694,11 +696,11 @@ impl SubnetManager for EthSubnetManager { self.ipc_contract_info.gateway_addr, Arc::new(self.ipc_contract_info.provider.clone()), ); - log::debug!( + tracing::debug!( "gateway_contract address : {:?}", self.ipc_contract_info.gateway_addr ); - log::debug!( + tracing::debug!( "gateway_contract_getter_facet address : {:?}", gateway_contract.address() ); @@ -811,7 +813,7 @@ impl SubnetManager for EthSubnetManager { federated_power: &[u128], ) -> Result { let address = contract_address_from_subnet(subnet)?; - log::info!("interacting with evm subnet contract: {address:}"); + tracing::info!("interacting with evm subnet contract: {address:}"); let signer = Arc::new(self.get_signer(from)?); let contract = @@ -821,21 +823,21 @@ impl SubnetManager for EthSubnetManager { .iter() .map(|validator_address| payload_to_evm_address(validator_address.payload()).unwrap()) .collect(); - log::debug!("converted addresses: {:?}", addresses); + tracing::debug!("converted addresses: {:?}", addresses); let pubkeys: Vec = public_keys .iter() .map(|key| ethers::core::types::Bytes::from(key.clone())) .collect(); - log::debug!("converted pubkeys: {:?}", pubkeys); + tracing::debug!("converted pubkeys: {:?}", pubkeys); let power_u256: Vec = federated_power .iter() .map(|power| ethers::core::types::U256::from(*power)) .collect(); - log::debug!("converted power: {:?}", power_u256); + tracing::debug!("converted power: {:?}", power_u256); - log::debug!("from address: {:?}", from); + tracing::debug!("from address: {:?}", from); let call = contract.set_federated_power(addresses, pubkeys, power_u256); let txn = call_with_premium_estimation(signer, call).await?; @@ -869,7 +871,7 @@ impl EthManager for EthSubnetManager { .bottom_up_checkpoint(ethers::types::U256::from(epoch as u64)) .call() .await?; - log::debug!("raw bottom up checkpoint from gateway: {checkpoint:?}"); + tracing::debug!("raw bottom up checkpoint from gateway: {checkpoint:?}"); let token = checkpoint.into_token(); let c = subnet_actor_checkpointing_facet::BottomUpCheckpoint::from_token(token)?; Ok(c) @@ -877,7 +879,7 @@ impl EthManager for EthSubnetManager { async fn get_applied_top_down_nonce(&self, subnet_id: &SubnetID) -> Result { let route = subnet_id_to_evm_addresses(subnet_id)?; - log::debug!("getting applied top down nonce for route: {route:?}"); + tracing::debug!("getting applied top down nonce for route: {route:?}"); let evm_subnet_id = gateway_getter_facet::SubnetID { root: subnet_id.root_id(), @@ -1058,7 +1060,7 @@ impl BottomUpCheckpointRelayer for EthSubnetManager { signatories: Vec
, ) -> anyhow::Result { let address = contract_address_from_subnet(&checkpoint.subnet_id)?; - log::debug!( + tracing::debug!( "submit bottom up checkpoint: {checkpoint:?} in evm subnet contract: {address:}" );