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

Replace PaymentAddress with MASP when transferring to a shielded address #3626

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

yito88
Copy link
Member

@yito88 yito88 commented Aug 13, 2024

Describe your changes

Checklist before merging

  • If this PR has some consensus breaking changes, I added the corresponding breaking:: labels
    • This will require 2 reviewers to approve the changes

Copy link

codecov bot commented Aug 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.27%. Comparing base (8e04d45) to head (b82d487).
Report is 226 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3626      +/-   ##
==========================================
- Coverage   61.27%   61.27%   -0.01%     
==========================================
  Files         312      312              
  Lines      101338   101338              
==========================================
- Hits        62092    62090       -2     
- Misses      39246    39248       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM at least, @grarco should review as well

@yito88
Copy link
Member Author

yito88 commented Aug 13, 2024

The test of an IBC shielding transfer failed when --disposable-gas-payer. I'm investigating it.

@yito88
Copy link
Member Author

yito88 commented Aug 13, 2024

The test failed because the MASP VP rejected the transaction.
It seems that we can't replace it because the MASP VP checks the receiver address in the IBC packet for replay protection.

@grarco
Copy link
Contributor

grarco commented Aug 14, 2024

I've reverted the previous changes that were wrong because they were modifying the ibc receiver when Namada is the source chain when instead we want to do that only when we receive an ibc packet. At the moment though, we can't achieve this for Namada2Namada IBC shielded transfers cause the memo can be used only for either the shielding or the refund and in this case we'd need both. We could update build_ibc_transfer after we've changed the refunding to a transparent trasfer.

For now the only thing I did was updating the gaia e2e tests to use the MASP internal address instead of the payment address as the receiver in the IBC packet.

We should also update the docs somewhere to instruct users of other IBC chains to follow this practice when they submit a shielding ibc transaction to Namada (this is probably something for @brentstone)

@yito88

@grarco
Copy link
Contributor

grarco commented Aug 14, 2024

@cwgoes I ran the test locally with a wrong hardcoded address and the test failed. I can confirm that we convert the string that we get in the ibc packet into an Address using this function, which indeed casts all payment addresses to the internal MASP address:

impl TryFrom<Signer> for Address {
type Error = DecodeError;
fn try_from(signer: Signer) -> Result<Self> {
// The given address should be an address or payment address. When
// sending a token from a spending key, it has been already
// replaced with the MASP address.
Address::decode(signer.as_ref()).or(
match crate::masp::PaymentAddress::from_str(signer.as_ref()) {
Ok(_) => Ok(MASP),
Err(_) => Err(DecodeError::InvalidInnerEncoding(format!(
"Invalid address for IBC transfer: {signer}"
))),
},
)
}
}

@grarco grarco added the merge Ready to merge - mergifyio bot will add the PR to merge queue when all checks pass label Aug 23, 2024
mergify bot added a commit that referenced this pull request Aug 23, 2024
@mergify mergify bot merged commit c61f09e into main Aug 23, 2024
21 checks passed
@mergify mergify bot deleted the yuji/ibc-replace-payment-address branch August 23, 2024 09:10
Fraccaman added a commit that referenced this pull request Aug 26, 2024
…dump

* origin/main: (191 commits)
  ci: use custom runner for docs step
  fix: better checkout settings, fix sccache wrapper
  changelog: add #3694
  fix wasm dir during join-network
  Changelog #3689
  Minor fixes to governance cli/msgs
  fix: use current epoch
  Changelog
  Add script boot localnet with two genesis validators
  Updates expected msg in wallet e2e test
  Changelog #3681
  Two attempts for decryption password
  Removes comments
  Prompts the key that we are trying to decrypt
  Terminates client if decryption of signing key fails
  Propagates error in sdk if decryption of signing key fails
  Removes FIXME comment
  Add fullnode support
  added changelog
  token: fix transfer to self
  make build: exclude fuzz targets
  replace context with client
  Changelog #3676
  Removes test step from wasm for test Makefile
  Removes dev dependencies from wasm tests
  Amend comment in genesis sign txs
  Changelog #3669
  Updates help message of `--gas-limit`
  Refactors `dispatch_inner_txs`
  Adds masp fee payment integration test
  Improves safety of masp txs events
  fix for clippy
  is_apple_silicon
  fixup! ci: add job checking for cargo docs
  README: update docs section
  fix rustdoc issues
  ci: do not run changelog check on rc branches
  ci: increase integration tests timeout
  ci: add job checking for cargo docs
  Namada 0.43.0
  generate key
  changelog: add #3445
  fuzz: add txs_wasm_run
  fuzz: add txs_finalize_block target
  add conditional fuzzing sig acceptance at lower level
  fuzz: add txs_process_proposal
  fuzz: add README.md
  token: avoid trying to read denom when fuzzing
  prepare_proposal: make tx fee checks pass for fuzzing
  fuzz: add txs_prepare_proposal
  fuzz: use a shorter target name
  fix clippy
  tx: prevent overflow in arbitrary masp builder
  fuzz_txs_mempool: rm unused import
  impl Arbitrary for MaspBuilder to derive tx sections
  use updated jubjub that prevents invalid arb ExtendedPoint
  fuzz_txs_mempool: catch panics in serialization
  fuzz_txs_mempool: use non-panicking tx serialization method
  tx: add non-panicking serialization method
  tx: add arbitrary masp tx section
  make/fuzz-txs-mempool: run with `--dev` to avoid OOM
  shell/mempool: skip chain ID check for fuzzing
  tx: fix manual impl Arbitrary for Section
  core/key: fix arbitrary impls
  fuzz_txs_mempool: re-use TestShell between runs
  fuzz: set dev opt-level = 3
  node/init_chain: no wasm pre-compile for fuzzing
  Makefile: add `cargo-fuzz` dep and `fuzz-txs-mempool` recipe
  fuzz mempool with arb txs
  tx: impl Arbitrary for Tx
  init a fuzz target with cargo-fuzz
  fixup! test/e2e/ledger: add test-genesis `--check-can-sign` args
  Improves failures handling in `try_masp_fee_payment`
  Matches masp ref order in protocol with that of the masp vp
  changelog: add #3660
  test/e2e/ledger: add test-genesis `--check-can-sign` args
  cli: added `--check-can-sign` arg to `namadan utils test-genesis`
  add changelog
  rm accidentally revived files
  test/e2e/ledger_tests: add localnet genesis test using `utils test-genesis`
  fix to check the existing addr
  fix default refund target
  fix tests
  add shielded mode to transfer context
  change to transparent addr
  Added changelog
  Fixed bug in creating BenchShieldedContext
  Changelog for #3655
  Optimize building chain ctx
  node/utils/test-genesis: remove unnecessary broadcaster task
  Added tests that birthdays work correctly with shielded sync
  changelog: add #3652
  cli/client: fix clippy
  cli/node: don't load ctx for node utils
  Added dated keys to shielded sync args
  Removed birthday logic from payment address generation
  Moved type alias to a more logical location
  Changelog #3626
  Changes gaia e2e tests to use masp internal address instead of payment addresses for ibc-shielding
  Reverts previous changes
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IBC MASP merge Ready to merge - mergifyio bot will add the PR to merge queue when all checks pass testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants