From cb5373ed03b7dbd059ffe34525e830f5e2193733 Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 13 Aug 2024 13:18:53 +0200 Subject: [PATCH 1/4] replace PaymentAddress with MASP --- crates/sdk/src/tx.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/sdk/src/tx.rs b/crates/sdk/src/tx.rs index 9c52c05624..f6b242807c 100644 --- a/crates/sdk/src/tx.rs +++ b/crates/sdk/src/tx.rs @@ -4,6 +4,7 @@ use std::borrow::Cow; use std::collections::BTreeMap; use std::fs::File; use std::path::{Path, PathBuf}; +use std::str::FromStr; use std::time::Duration; use borsh::BorshSerialize; @@ -2521,7 +2522,13 @@ pub async fn build_ibc_transfer( // Check that the source address exists on chain let source = source_exists_or_err(source.clone(), args.tx.force, context).await?; - // We cannot check the receiver + // If the receiver is a payment address, replace it with MASP internal + // address + let receiver = match PaymentAddress::from_str(&args.receiver) { + Ok(_) => MASP.to_string(), + Err(_) => args.receiver.clone(), + } + .into(); // validate the amount given let validated_amount = @@ -2708,7 +2715,7 @@ pub async fn build_ibc_transfer( let packet_data = PacketData { token, sender, - receiver: args.receiver.clone().into(), + receiver, memo: memo.unwrap_or_default().into(), }; let message = IbcMsgTransfer { @@ -2739,7 +2746,7 @@ pub async fn build_ibc_transfer( token_uris: None, token_data: None, sender, - receiver: args.receiver.clone().into(), + receiver, memo: memo.map(|s| s.into()), }; let message = IbcMsgNftTransfer { From 3a33e60f8b76b02841d40956f92d7fd67ff4909d Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Wed, 14 Aug 2024 17:27:38 +0200 Subject: [PATCH 2/4] Reverts previous changes --- crates/sdk/src/tx.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/crates/sdk/src/tx.rs b/crates/sdk/src/tx.rs index f6b242807c..9c52c05624 100644 --- a/crates/sdk/src/tx.rs +++ b/crates/sdk/src/tx.rs @@ -4,7 +4,6 @@ use std::borrow::Cow; use std::collections::BTreeMap; use std::fs::File; use std::path::{Path, PathBuf}; -use std::str::FromStr; use std::time::Duration; use borsh::BorshSerialize; @@ -2522,13 +2521,7 @@ pub async fn build_ibc_transfer( // Check that the source address exists on chain let source = source_exists_or_err(source.clone(), args.tx.force, context).await?; - // If the receiver is a payment address, replace it with MASP internal - // address - let receiver = match PaymentAddress::from_str(&args.receiver) { - Ok(_) => MASP.to_string(), - Err(_) => args.receiver.clone(), - } - .into(); + // We cannot check the receiver // validate the amount given let validated_amount = @@ -2715,7 +2708,7 @@ pub async fn build_ibc_transfer( let packet_data = PacketData { token, sender, - receiver, + receiver: args.receiver.clone().into(), memo: memo.unwrap_or_default().into(), }; let message = IbcMsgTransfer { @@ -2746,7 +2739,7 @@ pub async fn build_ibc_transfer( token_uris: None, token_data: None, sender, - receiver, + receiver: args.receiver.clone().into(), memo: memo.map(|s| s.into()), }; let message = IbcMsgNftTransfer { From bf15563cea0780a012ef26c1e612d44de0a19640 Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Wed, 14 Aug 2024 17:28:13 +0200 Subject: [PATCH 3/4] Changes gaia e2e tests to use masp internal address instead of payment addresses for ibc-shielding --- crates/tests/src/e2e/ibc_tests.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index aa11f8565f..4bcae75f8c 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -28,7 +28,7 @@ use namada_apps_lib::facade::tendermint::block::Header as TmHeader; use namada_apps_lib::facade::tendermint::merkle::proof::ProofOps as TmProof; use namada_apps_lib::facade::tendermint_rpc::{Client, HttpClient, Url}; use namada_core::string_encoding::StringEncoded; -use namada_sdk::address::{Address, InternalAddress}; +use namada_sdk::address::{Address, InternalAddress, MASP}; use namada_sdk::events::extend::ReadFromEventAttributes; use namada_sdk::governance::cli::onchain::PgfFunding; use namada_sdk::governance::pgf::ADDRESS as PGF_ADDRESS; @@ -73,6 +73,7 @@ use namada_sdk::ibc::primitives::{Signer, ToProto}; use namada_sdk::ibc::storage::*; use namada_sdk::key::PublicKey; use namada_sdk::masp::fs::FsShieldedUtils; +use namada_sdk::masp::PaymentAddress; use namada_sdk::parameters::{storage as param_storage, EpochDuration}; use namada_sdk::queries::RPC; use namada_sdk::state::ics23_specs::ibc_proof_specs; @@ -2234,6 +2235,12 @@ fn transfer_from_gaia( let channel_id = channel_id.to_string(); let amount = format!("{}{}", amount, token.as_ref()); let rpc = format!("tcp://{GAIA_RPC}"); + // If the receiver is a pyament address we want to mask it to the more + // general MASP internal address to improve on privacy + let receiver = match PaymentAddress::from_str(receiver.as_ref()) { + Ok(_) => MASP.to_string(), + Err(_) => receiver.as_ref().to_string(), + }; let mut args = vec![ "tx", "ibc-transfer", From b82d487185c8a567d7ddd4b2d387792e8372710b Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Wed, 14 Aug 2024 17:30:39 +0200 Subject: [PATCH 4/4] Changelog #3626 --- .../unreleased/testing/3626-ibc-replace-payment-address.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/unreleased/testing/3626-ibc-replace-payment-address.md diff --git a/.changelog/unreleased/testing/3626-ibc-replace-payment-address.md b/.changelog/unreleased/testing/3626-ibc-replace-payment-address.md new file mode 100644 index 0000000000..ac5782198f --- /dev/null +++ b/.changelog/unreleased/testing/3626-ibc-replace-payment-address.md @@ -0,0 +1,3 @@ +- Updated the gaia e2e tests to use the MASP internal address instead of + the payment address as the receiver of an IBC shielding transaction. + ([\#3626](https://github.com/anoma/namada/pull/3626)) \ No newline at end of file