Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better conversions debugging #3805

Merged
merged 3 commits into from
Sep 11, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improve the logging options for querying MASP conversions.
([\#3805](https://github.com/anoma/namada/pull/3805))
21 changes: 15 additions & 6 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,7 @@ pub mod args {
pub const DRY_RUN_TX: ArgFlag = flag("dry-run");
pub const DRY_RUN_WRAPPER_TX: ArgFlag = flag("dry-run-wrapper");
pub const DUMP_TX: ArgFlag = flag("dump-tx");
pub const DUMP_CONVERSION_TREE: ArgFlag = flag("dump-conversion-tree");
pub const EPOCH: ArgOpt<Epoch> = arg_opt("epoch");
pub const ERC20: Arg<EthAddress> = arg("erc20");
pub const ETH_CONFIRMATIONS: Arg<u64> = arg("confirmations");
Expand Down Expand Up @@ -4960,7 +4961,8 @@ pub mod args {
produce the signature."
)))
.arg(RECEIVER.def().help(wrap!(
"The receiver address on the destination chain as string."
"The receiver address on the destination chain as a \
string."
)))
.arg(TOKEN.def().help(wrap!("The transfer token.")))
.arg(
Expand All @@ -4979,13 +4981,14 @@ pub mod args {
.help(wrap!("The timeout as seconds.")),
)
.arg(REFUND_TARGET.def().help(wrap!(
"The refund target address when IBC shielded transfer \
failure."
"The refund target address to use if the IBC shielded \
transfer fails."
)))
.arg(IBC_SHIELDING_DATA_PATH.def().help(wrap!(
"The file path of the IBC shielding data for the \
destination Namada. This can't be set with --ibc-memo at \
the same time."
"Used only when shielding over IBC from one instance of \
the Namada blockchain to another. The file path of the \
IBC shielding data for the destination Namada chain. \
This can't be set with --ibc-memo at the same time."
)))
.arg(
IBC_MEMO
Expand Down Expand Up @@ -6135,6 +6138,7 @@ pub mod args {
query: self.query.to_sdk(ctx)?,
token: self.token.map(|x| ctx.borrow_chain_or_exit().get(&x)),
epoch: self.epoch,
dump_tree: self.dump_tree,
})
}
}
Expand All @@ -6144,10 +6148,12 @@ pub mod args {
let query = Query::parse(matches);
let token = TOKEN_OPT.parse(matches);
let epoch = MASP_EPOCH.parse(matches);
let dump_tree = DUMP_CONVERSION_TREE.parse(matches);
Self {
query,
epoch,
token,
dump_tree,
}
}

Expand All @@ -6159,6 +6165,9 @@ pub mod args {
.arg(TOKEN_OPT.def().help(wrap!(
"The token address for which to query conversions."
)))
.arg(DUMP_CONVERSION_TREE.def().help(wrap!(
"Dumps the full conversion tree if the flag is set."
)))
}
}

Expand Down
9 changes: 7 additions & 2 deletions crates/apps_lib/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ pub async fn query_conversions(
let total_rewards = rpc::query_masp_total_rewards(context.client())
.await
.expect("MASP total rewards should be present");
display!(
display_line!(
context.io(),
"Total rewards of native token minted for shielded pool: {}",
total_rewards.to_string_native()
Expand All @@ -1900,6 +1900,11 @@ pub async fn query_conversions(
let conversions = rpc::query_conversions(context.client())
.await
.expect("Conversions should be defined");

if args.dump_tree {
display_line!(context.io(), "Conversions: {conversions:?}");
}

// Track whether any non-sentinel conversions are found
let mut conversions_found = false;
for (addr, _denom, digit, epoch, amt) in conversions.values() {
Expand Down Expand Up @@ -1945,7 +1950,7 @@ pub async fn query_conversions(
if !conversions_found {
display_line!(
context.io(),
"No conversions found satisfying specified criteria."
"\nNo conversions found satisfying specified criteria."
);
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,8 @@ pub struct QueryConversions<C: NamadaTypes = SdkTypes> {
pub token: Option<C::Address>,
/// Epoch of the asset
pub epoch: Option<MaspEpoch>,
/// Flag to dump the conversion tree
pub dump_tree: bool,
}

/// Query token balance(s)
Expand Down
Loading