From 15df9d165ea74b1c2a29fb51799bcbf864896ff3 Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Fri, 22 Nov 2024 19:25:12 +0100 Subject: [PATCH 1/4] Log the implicit vp in `query-protocol-parameters` --- crates/apps_lib/src/client/rpc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/apps_lib/src/client/rpc.rs b/crates/apps_lib/src/client/rpc.rs index 17087858f5..ad4e6f16c6 100644 --- a/crates/apps_lib/src/client/rpc.rs +++ b/crates/apps_lib/src/client/rpc.rs @@ -773,6 +773,12 @@ pub async fn query_protocol_parameters( masp_epoch_multiplier ); + let key = param_storage::get_implicit_vp_key(); + let implicit_vp: Hash = query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + display_line!(context.io(), "{:4}Implicit VP: {}", "", implicit_vp); + let key = param_storage::get_vp_allowlist_storage_key(); let vp_allowlist: Vec = query_storage_value(context.client(), &key) .await From 735a76924c3ab35683adeb9492571d898592d8cc Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Fri, 22 Nov 2024 22:33:00 +0100 Subject: [PATCH 2/4] Adds missing protocol params in logs --- crates/apps_lib/src/client/rpc.rs | 158 +++++++++++++++++++----------- 1 file changed, 102 insertions(+), 56 deletions(-) diff --git a/crates/apps_lib/src/client/rpc.rs b/crates/apps_lib/src/client/rpc.rs index ad4e6f16c6..3879670349 100644 --- a/crates/apps_lib/src/client/rpc.rs +++ b/crates/apps_lib/src/client/rpc.rs @@ -748,102 +748,147 @@ pub async fn query_protocol_parameters( query_storage_value(context.client(), &key) .await .expect("Parameter should be defined."); + let key = param_storage::get_masp_epoch_multiplier_key(); + let masp_epoch_multiplier: u64 = + query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_implicit_vp_key(); + let implicit_vp_code_hash: Hash = + query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_vp_allowlist_storage_key(); + let vp_allowlist: Vec = query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_tx_allowlist_storage_key(); + let tx_allowlist: Vec = query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_max_proposal_bytes_key(); + let max_proposal_bytes: ProposalBytes = + query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_max_tx_bytes_key(); + let max_tx_bytes: u32 = query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_max_block_gas_key(); + let max_block_gas: u64 = query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_masp_fee_payment_gas_limit_key(); + let masp_fee_payment_gas_limit: u64 = + query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_gas_cost_key(); + let minimum_gas_price: BTreeMap = + query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_gas_scale_key(); + let gas_scale: u64 = query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_native_token_transferable_key(); + let is_native_token_transferable: bool = + query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + let key = param_storage::get_epochs_per_year_key(); + let epochs_per_year: u64 = query_storage_value(context.client(), &key) + .await + .expect("Parameter should be defined."); + + // Reconstruct the Parameters type to ensure we retrieved all of them + let parameters = namada_core::parameters::Parameters { + max_tx_bytes, + epoch_duration, + max_proposal_bytes, + max_block_gas, + vp_allowlist, + tx_allowlist, + implicit_vp_code_hash: Some(implicit_vp_code_hash), + epochs_per_year, + masp_epoch_multiplier, + masp_fee_payment_gas_limit, + gas_scale, + minimum_gas_price, + is_native_token_transferable, + }; + // Deconstruct the type to ensure we display all the fields + let namada_core::parameters::Parameters { + max_tx_bytes, + epoch_duration, + max_proposal_bytes, + max_block_gas, + vp_allowlist, + tx_allowlist, + implicit_vp_code_hash, + epochs_per_year, + masp_epoch_multiplier, + masp_fee_payment_gas_limit, + gas_scale, + minimum_gas_price, + is_native_token_transferable, + } = parameters; + display_line!( context.io(), "{:4}Min. epoch duration: {} seconds", "", epoch_duration.min_duration ); + display_line!(context.io(), "{:4}Epochs per year: {}", "", epochs_per_year); display_line!( context.io(), "{:4}Min. number of blocks: {}", "", epoch_duration.min_num_of_blocks ); - - let key = param_storage::get_masp_epoch_multiplier_key(); - let masp_epoch_multiplier: u64 = - query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!( context.io(), "{:4}Masp epoch multiplier: {:?}", "", masp_epoch_multiplier ); - - let key = param_storage::get_implicit_vp_key(); - let implicit_vp: Hash = query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); - display_line!(context.io(), "{:4}Implicit VP: {}", "", implicit_vp); - - let key = param_storage::get_vp_allowlist_storage_key(); - let vp_allowlist: Vec = query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); + display_line!( + context.io(), + "{:4}Implicit VP: {}", + "", + implicit_vp_code_hash.expect("The implicit vp should be set") + ); display_line!(context.io(), "{:4}VP allowlist: {:?}", "", vp_allowlist); - - let key = param_storage::get_tx_allowlist_storage_key(); - let tx_allowlist: Vec = query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!( context.io(), "{:4}Transactions allowlist: {:?}", "", tx_allowlist ); - - let key = param_storage::get_max_proposal_bytes_key(); - let max_proposal_bytes: ProposalBytes = - query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!( context.io(), "{:4}Max. proposal bytes: {:?}", "", max_proposal_bytes.get() ); - - let key = param_storage::get_max_tx_bytes_key(); - let max_tx_bytes: u32 = query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!(context.io(), "{:4}Max tx bytes: {:?}", "", max_tx_bytes); - - let key = param_storage::get_max_block_gas_key(); - let max_block_gas: u64 = query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!( context.io(), "{:4}Max. block gas: {:?} gas units", "", max_block_gas ); - - let key = param_storage::get_masp_fee_payment_gas_limit_key(); - let masp_fee_payment_gas_limit: u64 = - query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!( context.io(), "{:4}Masp fee payment gas limit: {:?} gas units", "", masp_fee_payment_gas_limit ); - - let key = param_storage::get_gas_cost_key(); - let gas_cost_table: BTreeMap = - query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!(context.io(), "{:4}Minimum gas costs:", ""); - for (token, gas_cost) in gas_cost_table { + for (token, gas_cost) in minimum_gas_price { let denom = rpc::query_denom(context.client(), &token) .await .expect("Token should have denom"); @@ -856,12 +901,13 @@ pub async fn query_protocol_parameters( den_amt ); } - - let key = param_storage::get_gas_scale_key(); - let gas_scale: u64 = query_storage_value(context.client(), &key) - .await - .expect("Parameter should be defined."); display_line!(context.io(), "{:4}Gas scale: {:?}", "", gas_scale); + display_line!( + context.io(), + "{:4}Is native token transferable: {:?}", + "", + is_native_token_transferable + ); display_line!(context.io(), "\nProof of Stake parameters"); let PosParams { From 8d279e10c778bd17d464ac649b8f0b6de0de1077 Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Fri, 22 Nov 2024 22:36:07 +0100 Subject: [PATCH 3/4] Changelog #4083 --- .changelog/unreleased/improvements/4083-log-implicit-vp.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/4083-log-implicit-vp.md diff --git a/.changelog/unreleased/improvements/4083-log-implicit-vp.md b/.changelog/unreleased/improvements/4083-log-implicit-vp.md new file mode 100644 index 0000000000..b2e35b986a --- /dev/null +++ b/.changelog/unreleased/improvements/4083-log-implicit-vp.md @@ -0,0 +1,2 @@ +- Updated the `query-protocol-parameters` command to display some missing + parameters. ([\#4083](https://github.com/anoma/namada/pull/4083)) \ No newline at end of file From bfc7c63f7d6f4256f3b4580966eec345b3ff7135 Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Fri, 22 Nov 2024 22:53:41 +0100 Subject: [PATCH 4/4] Improves implicit vp display --- crates/apps_lib/src/client/rpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/apps_lib/src/client/rpc.rs b/crates/apps_lib/src/client/rpc.rs index 3879670349..447dffdecc 100644 --- a/crates/apps_lib/src/client/rpc.rs +++ b/crates/apps_lib/src/client/rpc.rs @@ -857,7 +857,7 @@ pub async fn query_protocol_parameters( ); display_line!( context.io(), - "{:4}Implicit VP: {}", + "{:4}Implicit VP hash: {}", "", implicit_vp_code_hash.expect("The implicit vp should be set") );