Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cw-orch-daemon/src/channel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmrs::proto::cosmos::base::tendermint::v1beta1::{
service_client::ServiceClient, GetNodeInfoRequest,
};
use cw_orch_core::log::CONNECTIVITY_LOGS;
use cw_orch_core::log::connectivity_target;
use ibc_chain_registry::chain::Grpc;
use ibc_relayer_types::core::ics24_host::identifier::ChainId;
use tonic::transport::{Channel, ClientTlsConfig};
Expand All @@ -17,7 +17,7 @@ impl GrpcChannel {
let mut successful_connections = vec![];

for Grpc { address, .. } in grpc.iter() {
log::debug!(target: CONNECTIVITY_LOGS, "Trying to connect to endpoint: {}", address);
log::debug!(target: &connectivity_target(), "Trying to connect to endpoint: {}", address);

// get grpc endpoint
let endpoint = Channel::builder(address.clone().try_into().unwrap());
Expand All @@ -41,7 +41,7 @@ impl GrpcChannel {
continue;
};

log::debug!(target: CONNECTIVITY_LOGS, "Attempting to connect with TLS");
log::debug!(target: &connectivity_target(), "Attempting to connect with TLS");

// re attempt to connect
let endpoint = endpoint.clone().tls_config(ClientTlsConfig::new())?;
Expand Down
10 changes: 5 additions & 5 deletions cw-orch-daemon/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use cosmwasm_std::{Addr, Coin};
use cw_orch_core::{
contract::interface_traits::Uploadable,
environment::{ChainState, IndexResponse},
log::TRANSACTION_LOGS,
log::transaction_target,
};
use flate2::{write, Compression};
use serde::{de::DeserializeOwned, Serialize};
Expand Down Expand Up @@ -112,7 +112,7 @@ impl DaemonAsync {
funds: parse_cw_coins(coins)?,
};
let result = self.sender.commit_tx(vec![exec_msg], None).await?;
log::info!(target: TRANSACTION_LOGS, "Execution done: {:?}", result.txhash);
log::info!(target: &transaction_target(), "Execution done: {:?}", result.txhash);

Ok(result)
}
Expand All @@ -139,7 +139,7 @@ impl DaemonAsync {

let result = sender.commit_tx(vec![init_msg], None).await?;

log::info!(target: TRANSACTION_LOGS, "Instantiation done: {:?}", result.txhash);
log::info!(target: &transaction_target(), "Instantiation done: {:?}", result.txhash);

Ok(result)
}
Expand Down Expand Up @@ -236,7 +236,7 @@ impl DaemonAsync {
let sender = &self.sender;
let wasm_path = uploadable.wasm();

log::debug!(target: TRANSACTION_LOGS, "Uploading file at {:?}", wasm_path);
log::debug!(target: &transaction_target(), "Uploading file at {:?}", wasm_path);

let file_contents = std::fs::read(wasm_path.path())?;
let mut e = write::GzEncoder::new(Vec::new(), Compression::default());
Expand All @@ -250,7 +250,7 @@ impl DaemonAsync {

let result = sender.commit_tx(vec![store_msg], None).await?;

log::info!(target: TRANSACTION_LOGS, "Uploading done: {:?}", result.txhash);
log::info!(target: &transaction_target(), "Uploading done: {:?}", result.txhash);

let code_id = result.uploaded_code_id().unwrap();

Expand Down
4 changes: 2 additions & 2 deletions cw-orch-daemon/src/keys/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bitcoin::{
Network,
};
use cosmrs::tx::SignerPublicKey;
use cw_orch_core::log::LOCAL_LOGS;
use cw_orch_core::log::local_target;
use hkd32::mnemonic::{Phrase, Seed};
use prost_types::Any;
use rand_core::OsRng;
Expand Down Expand Up @@ -123,7 +123,7 @@ impl PrivateKey {

let vec_pk = public_key.serialize();

log::debug!(target: LOCAL_LOGS, "{:?}, public key", general_purpose::STANDARD.encode(vec_pk));
log::debug!(target: &local_target(), "{:?}, public key", general_purpose::STANDARD.encode(vec_pk));

let inj_key = InjectivePubKey { key: vec_pk.into() };

Expand Down
8 changes: 4 additions & 4 deletions cw-orch-daemon/src/keys/public.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::DaemonError;
use bitcoin::bech32::{decode, encode, u5, FromBase32, ToBase32, Variant};
use cw_orch_core::log::LOCAL_LOGS;
use cw_orch_core::log::local_target;
pub use ed25519_dalek::VerifyingKey as Ed25519;
use ring::digest::{Context, SHA256};
use ripemd::{Digest as _, Ripemd160};
Expand Down Expand Up @@ -72,7 +72,7 @@ impl PublicKey {
source,
}
})?;
log::debug!(target: LOCAL_LOGS, "{:#?}", hex::encode(&vu8));
log::debug!(target: &local_target(), "{:#?}", hex::encode(&vu8));
if vu8.starts_with(&BECH32_PUBKEY_DATA_PREFIX_SECP256K1) {
let public_key = PublicKey::public_key_from_pubkey(&vu8)?;
let raw = PublicKey::address_from_public_key(&public_key);
Expand Down Expand Up @@ -261,7 +261,7 @@ impl PublicKey {
} else {
// eprintln!("a_pub_ed_key {}", hex::encode(public_key));
log::debug!(
target: LOCAL_LOGS,
target: &local_target(),
"address_from_public_ed25519_key public key - {}",
hex::encode(public_key)
);
Expand All @@ -283,7 +283,7 @@ impl PublicKey {
// let address: Vec<u8> = ripe_result.to_vec();
// eprintln!("address_from_public_ed_key {}", hex::encode(&address));
log::debug!(
target: LOCAL_LOGS,
target: &local_target(),
"address_from_public_ed25519_key sha result - {}",
hex::encode(&address)
);
Expand Down
9 changes: 1 addition & 8 deletions cw-orch-daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ pub(crate) mod cosmos_modules {
pub use cosmrs::proto::{
cosmos::{
auth::v1beta1 as auth,
authz::v1beta1 as authz,
bank::v1beta1 as bank,
base::{abci::v1beta1 as abci, tendermint::v1beta1 as tendermint, v1beta1 as base},
crisis::v1beta1 as crisis,
distribution::v1beta1 as distribution,
evidence::v1beta1 as evidence,
base::{abci::v1beta1 as abci, tendermint::v1beta1 as tendermint},
feegrant::v1beta1 as feegrant,
gov::v1beta1 as gov,
mint::v1beta1 as mint,
params::v1beta1 as params,
slashing::v1beta1 as slashing,
staking::v1beta1 as staking,
tx::v1beta1 as tx,
vesting::v1beta1 as vesting,
Expand Down
19 changes: 9 additions & 10 deletions cw-orch-daemon/src/queriers/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use cosmrs::{
},
tendermint::{Block, Time},
};
use cw_orch_core::log::QUERY_LOGS;
use cw_orch_core::CwOrchEnvVars;
use cw_orch_core::{log::query_target, CwOrchEnvVars};
use tonic::transport::Channel;

use super::DaemonQuerier;
Expand Down Expand Up @@ -222,14 +221,14 @@ impl Node {
match client.get_tx(request.clone()).await {
Ok(tx) => {
let resp = tx.into_inner().tx_response.unwrap();
log::debug!(target: QUERY_LOGS, "TX found: {:?}", resp);
log::debug!(target: &query_target(), "TX found: {:?}", resp);
return Ok(resp.into());
}
Err(err) => {
// increase wait time
block_speed = (block_speed as f64 * 1.6) as u64;
log::debug!(target: QUERY_LOGS, "TX not found with error: {:?}", err);
log::debug!(target: QUERY_LOGS, "Waiting {block_speed} seconds");
log::debug!(target: &query_target(), "TX not found with error: {:?}", err);
log::debug!(target: &query_target(), "Waiting {block_speed} seconds");
tokio::time::sleep(Duration::from_secs(block_speed)).await;
}
}
Expand Down Expand Up @@ -303,21 +302,21 @@ impl Node {
Ok(tx) => {
let resp = tx.into_inner().tx_responses;
if retry_on_empty && resp.is_empty() {
log::debug!(target: QUERY_LOGS, "No TX found with events {:?}", events);
log::debug!(target: QUERY_LOGS, "Waiting 10s");
log::debug!(target: &query_target(), "No TX found with events {:?}", events);
log::debug!(target: &query_target(), "Waiting 10s");
tokio::time::sleep(Duration::from_secs(10)).await;
} else {
log::debug!(
target: QUERY_LOGS,
target: &query_target(),
"TX found by events: {:?}",
resp.iter().map(|t| t.txhash.clone())
);
return Ok(resp.iter().map(|r| r.clone().into()).collect());
}
}
Err(err) => {
log::debug!(target: QUERY_LOGS, "TX not found with error: {:?}", err);
log::debug!(target: QUERY_LOGS, "Waiting 10s");
log::debug!(target: &query_target(), "TX not found with error: {:?}", err);
log::debug!(target: &query_target(), "Waiting 10s");
tokio::time::sleep(Duration::from_secs(10)).await;
}
}
Expand Down
4 changes: 2 additions & 2 deletions cw-orch-daemon/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use cosmrs::{
AccountId, Any,
};
use cosmwasm_std::{coin, Addr, Coin};
use cw_orch_core::{log::LOCAL_LOGS, CwOrchEnvVars};
use cw_orch_core::{log::local_target, CwOrchEnvVars};

use secp256k1::{All, Context, Secp256k1, Signing};
use std::{convert::TryFrom, rc::Rc, str::FromStr};
Expand Down Expand Up @@ -84,7 +84,7 @@ impl Sender<All> {
secp,
};
log::info!(
target: LOCAL_LOGS,
target: &local_target(),
"Interacting with {} using address: {}",
daemon_state.chain_data.chain_id,
sender.pub_addr_str()?
Expand Down
8 changes: 4 additions & 4 deletions cw-orch-daemon/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cosmwasm_std::Addr;
use cw_orch_core::{
env::STATE_FOLDER_ENV_NAME,
environment::{DeployDetails, StateInterface},
log::{CONNECTIVITY_LOGS, LOCAL_LOGS},
log::{connectivity_target, local_target},
CwEnvError, CwOrchEnvVars,
};
use ibc_chain_registry::chain::ChainData;
Expand Down Expand Up @@ -46,7 +46,7 @@ impl DaemonState {
return Err(DaemonError::GRPCListIsEmpty);
}

log::debug!(target: CONNECTIVITY_LOGS, "Found {} gRPC endpoints", chain_data.apis.grpc.len());
log::debug!(target: &connectivity_target(), "Found {} gRPC endpoints", chain_data.apis.grpc.len());

// find working grpc channel
let grpc_channel =
Expand All @@ -70,7 +70,7 @@ impl DaemonState {
.into_string()
.unwrap();

log::debug!(target: LOCAL_LOGS, "Using state file : {}", json_file_path);
log::debug!(target: &local_target(), "Using state file : {}", json_file_path);

// if the network we are connecting is a local kind, add it to the fn
if chain_data.network_type == ChainKind::Local.to_string() {
Expand Down Expand Up @@ -113,7 +113,7 @@ impl DaemonState {

if !read_only {
log::info!(
target: LOCAL_LOGS,
target: &local_target(),
"Writing daemon state JSON file: {:#?}",
state.json_file_path
);
Expand Down
8 changes: 4 additions & 4 deletions cw-orch-daemon/src/tx_broadcaster.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cw_orch_core::log::{TRANSACTION_LOGS, TX_RETRY_LOGS};
use cw_orch_core::log::transaction_target;
use secp256k1::All;

use crate::{
Expand Down Expand Up @@ -81,7 +81,7 @@ impl TxBroadcaster {
// We try and broadcast once
let mut tx_response = broadcast_helper(&mut tx_builder, wallet).await;
log::info!(
target: TX_RETRY_LOGS,
target: &transaction_target(),
"Awaiting TX inclusion in block..."
);
while tx_retry {
Expand All @@ -101,7 +101,7 @@ impl TxBroadcaster {
.average_block_speed(None)
.await?;
log::warn!(
target: TX_RETRY_LOGS,
target: &transaction_target(),
"Retrying broadcasting TX in {} seconds because of {}",
block_speed,
s.reason
Expand Down Expand Up @@ -133,7 +133,7 @@ async fn broadcast_helper(
) -> Result<TxResponse, DaemonError> {
let tx = tx_builder.build(wallet).await?;
let tx_response = wallet.broadcast_tx(tx).await?;
log::debug!(target: TRANSACTION_LOGS, "TX broadcast response: {:?}", tx_response);
log::debug!(target: &transaction_target(), "TX broadcast response: {:?}", tx_response);

assert_broadcast_code_response(tx_response)
}
Expand Down
53 changes: 27 additions & 26 deletions cw-orch-daemon/src/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cosmrs::{
tx::{self, Body, Fee, Raw, SequenceNumber, SignDoc, SignerInfo},
Any, Coin,
};
use cw_orch_core::log::TRANSACTION_LOGS;
use cw_orch_core::log::transaction_target;
use cw_orch_core::CwOrchEnvVars;
use secp256k1::All;

Expand Down Expand Up @@ -106,35 +106,36 @@ impl TxBuilder {
let sequence = self.sequence.unwrap_or(sequence);

//
let (tx_fee, gas_limit) =
if let (Some(fee), Some(gas_limit)) = (self.fee_amount, self.gas_limit) {
log::debug!(
target: TRANSACTION_LOGS,
"Using pre-defined fee and gas limits: {}, {}",
fee,
gas_limit
);
(fee, gas_limit)
} else {
let sim_gas_used = wallet
.calculate_gas(&self.body, sequence, account_number)
.await?;
log::debug!(target: TRANSACTION_LOGS, "Simulated gas needed {:?}", sim_gas_used);

let (gas_expected, fee_amount) = wallet.get_fee_from_gas(sim_gas_used)?;

log::debug!(target: TRANSACTION_LOGS, "Calculated fee needed: {:?}", fee_amount);
// set the gas limit of self for future txs
// there's no way to change the tx_builder body so simulation gas should remain the same as well
self.gas_limit = Some(gas_expected);

(fee_amount, gas_expected)
};
let (tx_fee, gas_limit) = if let (Some(fee), Some(gas_limit)) =
(self.fee_amount, self.gas_limit)
{
log::debug!(
target: &transaction_target(),
"Using pre-defined fee and gas limits: {}, {}",
fee,
gas_limit
);
(fee, gas_limit)
} else {
let sim_gas_used = wallet
.calculate_gas(&self.body, sequence, account_number)
.await?;
log::debug!(target: &transaction_target(), "Simulated gas needed {:?}", sim_gas_used);

let (gas_expected, fee_amount) = wallet.get_fee_from_gas(sim_gas_used)?;

log::debug!(target: &transaction_target(), "Calculated fee needed: {:?}", fee_amount);
// set the gas limit of self for future txs
// there's no way to change the tx_builder body so simulation gas should remain the same as well
self.gas_limit = Some(gas_expected);

(fee_amount, gas_expected)
};

let fee = Self::build_fee(tx_fee, &wallet.get_fee_token(), gas_limit)?;

log::debug!(
target: TRANSACTION_LOGS,
target: &transaction_target(),
"submitting TX: \n fee: {:?}\naccount_nr: {:?}\nsequence: {:?}",
fee,
account_number,
Expand Down
31 changes: 0 additions & 31 deletions cw-orch/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,3 @@

pub use cw_orch_daemon::sender::Wallet;
pub use cw_orch_daemon::*;

pub(crate) mod cosmos_modules {
pub use cosmrs::proto::{
cosmos::{
auth::v1beta1 as auth,
authz::v1beta1 as authz,
bank::v1beta1 as bank,
base::{abci::v1beta1 as abci, tendermint::v1beta1 as tendermint, v1beta1 as base},
crisis::v1beta1 as crisis,
distribution::v1beta1 as distribution,
evidence::v1beta1 as evidence,
feegrant::v1beta1 as feegrant,
gov::v1beta1 as gov,
mint::v1beta1 as mint,
params::v1beta1 as params,
slashing::v1beta1 as slashing,
staking::v1beta1 as staking,
tx::v1beta1 as tx,
vesting::v1beta1 as vesting,
},
cosmwasm::wasm::v1 as cosmwasm,
ibc::{
applications::transfer::v1 as ibc_transfer,
core::{
channel::v1 as ibc_channel, client::v1 as ibc_client,
connection::v1 as ibc_connection,
},
},
tendermint::abci as tendermint_abci,
};
}
Loading