diff --git a/.changelog/unreleased/testing/3982-test-unshields-multiple-digits.md b/.changelog/unreleased/testing/3982-test-unshields-multiple-digits.md new file mode 100644 index 0000000000..8f7a13cca3 --- /dev/null +++ b/.changelog/unreleased/testing/3982-test-unshields-multiple-digits.md @@ -0,0 +1,3 @@ +- Increase the default masp fee payment gas limit to 65000 in genesis + localnet files. Moreover, add additional test cases for MASP fee unshields. + ([\#3982](https://github.com/anoma/namada/pull/3982)) \ No newline at end of file diff --git a/crates/tests/src/integration/masp.rs b/crates/tests/src/integration/masp.rs index 790756a6bd..9cd8aaf07f 100644 --- a/crates/tests/src/integration/masp.rs +++ b/crates/tests/src/integration/masp.rs @@ -28,7 +28,7 @@ use crate::e2e::setup::constants::{ AA_PAYMENT_ADDRESS, AA_VIEWING_KEY, AB_PAYMENT_ADDRESS, AB_VIEWING_KEY, AC_PAYMENT_ADDRESS, AC_VIEWING_KEY, ALBERT, ALBERT_KEY, A_SPENDING_KEY, BB_PAYMENT_ADDRESS, BERTHA, BERTHA_KEY, BTC, B_SPENDING_KEY, CHRISTEL, - CHRISTEL_KEY, ETH, MASP, NAM, + CHRISTEL_KEY, C_SPENDING_KEY, ETH, MASP, NAM, }; use crate::strings::TX_APPLIED_SUCCESS; @@ -696,6 +696,8 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { // Assert that we have minted NAM rewards const EXPECTED_REWARDS: u128 = 6427858447239330; + const UNSHIELD_REWARDS_AMT: u128 = EXPECTED_REWARDS / 2; + const REMAINING_REWARDS_AMT: u128 = EXPECTED_REWARDS - UNSHIELD_REWARDS_AMT; let captured = CapturedOutput::of(|| { run( @@ -715,6 +717,185 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { assert!(captured.result.is_ok(), "{:?}", captured.result); assert!(captured.contains(&format!("nam: {EXPECTED_REWARDS}"))); + // Unshield half of the rewards. Pay for gas transparently + let captured = CapturedOutput::of(|| { + run( + &node, + Bin::Client, + vec![ + "unshield", + "--source", + A_SPENDING_KEY, + "--target", + BERTHA, + "--token", + NAM, + "--amount", + &UNSHIELD_REWARDS_AMT.to_string(), + "--signing-keys", + BERTHA_KEY, + "--node", + RPC, + "--gas-limit", + "65000", + ], + ) + }); + assert!(captured.result.is_ok(), "{:?}", captured.result); + assert!(captured.contains(TX_APPLIED_SUCCESS)); + + // Fetch latest shielded state + run( + &node, + Bin::Client, + vec![ + "shielded-sync", + "--viewing-keys", + AA_VIEWING_KEY, + "--node", + RPC, + ], + )?; + + // Check that we now have half of the rewards + let captured = CapturedOutput::of(|| { + run( + &node, + Bin::Client, + vec![ + "balance", + "--owner", + AA_VIEWING_KEY, + "--token", + NAM, + "--node", + RPC, + ], + ) + }); + assert!(captured.result.is_ok(), "{:?}", captured.result); + assert!(captured.contains(&format!("nam: {REMAINING_REWARDS_AMT}"))); + + // Shield 1 NAM to cover fees + let captured = CapturedOutput::of(|| { + run( + &node, + Bin::Client, + vec![ + "shield", + "--source", + BERTHA_KEY, + "--target", + AC_PAYMENT_ADDRESS, + "--token", + NAM, + "--amount", + "1", + "--gas-payer", + BERTHA_KEY, + "--node", + RPC, + ], + ) + }); + assert!(captured.result.is_ok(), "{:?}", captured.result); + assert!(captured.contains(TX_APPLIED_SUCCESS)); + + // Fetch latest shielded state + run( + &node, + Bin::Client, + vec![ + "shielded-sync", + "--viewing-keys", + AA_VIEWING_KEY, + AC_VIEWING_KEY, + "--node", + RPC, + ], + )?; + + // Check the shielded NAM balance + let captured = CapturedOutput::of(|| { + run( + &node, + Bin::Client, + vec![ + "balance", + "--owner", + AC_VIEWING_KEY, + "--token", + NAM, + "--node", + RPC, + ], + ) + }); + assert!(captured.result.is_ok(), "{:?}", captured.result); + assert!(captured.contains("nam: 1")); + + // Unshield the other half of the rewards. Pay for gas using + // a spending key + let captured = CapturedOutput::of(|| { + run( + &node, + Bin::Client, + vec![ + "unshield", + "--source", + A_SPENDING_KEY, + "--target", + BERTHA, + "--token", + NAM, + "--amount", + &REMAINING_REWARDS_AMT.to_string(), + "--node", + RPC, + "--disposable-gas-payer", + "--gas-spending-key", + C_SPENDING_KEY, + "--gas-limit", + "65000", + ], + ) + }); + assert!(captured.result.is_ok(), "{:?}", captured.result); + assert!(captured.contains(TX_APPLIED_SUCCESS)); + + // Fetch latest shielded state + run( + &node, + Bin::Client, + vec![ + "shielded-sync", + "--viewing-keys", + AA_VIEWING_KEY, + AC_VIEWING_KEY, + "--node", + RPC, + ], + )?; + + // Check that we now have a null NAM balance + let captured = CapturedOutput::of(|| { + run( + &node, + Bin::Client, + vec![ + "balance", + "--owner", + AA_VIEWING_KEY, + "--token", + NAM, + "--node", + RPC, + ], + ) + }); + assert!(captured.result.is_ok(), "{:?}", captured.result); + assert!(captured.contains("nam: 0")); + Ok(()) } diff --git a/genesis/hardware/parameters.toml b/genesis/hardware/parameters.toml index 1bf0dfd65a..5b9caade99 100644 --- a/genesis/hardware/parameters.toml +++ b/genesis/hardware/parameters.toml @@ -21,7 +21,7 @@ masp_epoch_multiplier = 2 # Max gas for block max_block_gas = 3_000_000 # Masp fee payment gas limit -masp_fee_payment_gas_limit = 50_000 +masp_fee_payment_gas_limit = 65_000 # Gas scale gas_scale = 50_000 diff --git a/genesis/localnet/parameters.toml b/genesis/localnet/parameters.toml index cb07d138b1..0d9db2961a 100644 --- a/genesis/localnet/parameters.toml +++ b/genesis/localnet/parameters.toml @@ -21,7 +21,7 @@ masp_epoch_multiplier = 2 # Max gas for block max_block_gas = 3_000_000 # Masp fee payment gas limit -masp_fee_payment_gas_limit = 50_000 +masp_fee_payment_gas_limit = 65_000 # Gas scale gas_scale = 50_000 diff --git a/genesis/starter/parameters.toml b/genesis/starter/parameters.toml index a034213be4..2336ea9304 100644 --- a/genesis/starter/parameters.toml +++ b/genesis/starter/parameters.toml @@ -21,7 +21,7 @@ masp_epoch_multiplier = 2 # Max gas for block max_block_gas = 3_000_000 # Masp fee payment gas limit -masp_fee_payment_gas_limit = 50_000 +masp_fee_payment_gas_limit = 65_000 # Gas scale gas_scale = 50_000