Skip to content

Commit

Permalink
shielded-pool(ics20): process truncated addresses in packet data (#4962)
Browse files Browse the repository at this point in the history
## Describe your changes

This PR makes sure that truncated addresses are encoded correctly when
ICS20 withdrawals are marshaled into fungible packet data.

In addition to that, it modifies pcli to (hazardously?) handcraft a
return `Address` with an identity clue key and zero diversifier.

To test this PR, one can performa IBC roundtrip against a testnet chain
with broken bech32m handling (e.g, `grand-1`).

## Issue ticket number and link

#4950 

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > CB release branch.
  • Loading branch information
erwanor authored and conorsch committed Dec 17, 2024
1 parent ff94498 commit c4ab7d7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
16 changes: 12 additions & 4 deletions crates/bin/pcli/src/command/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,18 @@ impl TxCmd {
} => {
let destination_chain_address = to;

let (ephemeral_return_address, _) = app
.config
.full_viewing_key
.ephemeral_address(OsRng, AddressIndex::from(*source));
let ephemeral_return_address = if *use_transparent_address {
let ivk = app.config.full_viewing_key.incoming();

ivk.transparent_address()
.parse::<Address>()
.expect("we round-trip from a valid transparent address")
} else {
app.config
.full_viewing_key
.ephemeral_address(OsRng, AddressIndex::from(*source))
.0
};

let timeout_height = match timeout_height {
Some(h) => h.clone(),
Expand Down
11 changes: 8 additions & 3 deletions crates/core/component/shielded-pool/src/ics20_withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,14 @@ impl TryFrom<pb::Ics20Withdrawal> for Ics20Withdrawal {

impl From<Ics20Withdrawal> for pb::FungibleTokenPacketData {
fn from(w: Ics20Withdrawal) -> Self {
let return_address = match w.use_compat_address {
true => w.return_address.compat_encoding(),
false => w.return_address.to_string(),
let ordinary_return_address = w.return_address.to_string();

let return_address = if w.use_transparent_address {
w.return_address
.encode_as_transparent_address()
.unwrap_or_else(|| ordinary_return_address)
} else {
ordinary_return_address
};

pb::FungibleTokenPacketData {
Expand Down
3 changes: 3 additions & 0 deletions crates/core/transaction/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,14 @@ mod test {

#[cfg(test)]
fn dummy_spend() -> spend::Spend {
use penumbra_shielded_pool::EncryptedBackref;

spend::Spend {
body: spend::Body {
balance_commitment: dummy_commitment(),
nullifier: Nullifier(Fq::default()),
rk: dummy_pk(),
encrypted_backref: EncryptedBackref::dummy(),
},
auth_sig: dummy_sig(),
proof: dummy_proof_spend(),
Expand Down

0 comments on commit c4ab7d7

Please sign in to comment.