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

Make the sender set MASP transaction to IBC memo #3444

Merged
merged 40 commits into from
Jul 5, 2024

Conversation

yito88
Copy link
Member

@yito88 yito88 commented Jun 26, 2024

Describe your changes

closes #3438

WARNING: don't merge this PR for now because tx_ibc.wasm failed to be compiled on my Apple silicon machine.

Transaction runner error: Wasm compilation error: Compilation error: Assembler failed finalization with: ImpossibleRelocation(Dynamic(DynamicLabel(0)))

We could workaround this error.

Indicate on which release or other PRs this topic is based on

#3422
Diff: 5c3b3ab...ca79554

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

murisi and others added 30 commits May 28, 2024 12:29
@brentstone brentstone mentioned this pull request Jul 1, 2024
@yito88 yito88 requested review from sug0 and grarco July 3, 2024 07:41
@yito88 yito88 marked this pull request as ready for review July 3, 2024 07:41
crates/ibc/src/msg.rs Outdated Show resolved Hide resolved
crates/ibc/src/msg.rs Outdated Show resolved Hide resolved
@yito88 yito88 requested a review from cwgoes July 3, 2024 08:58
@@ -6498,7 +6526,7 @@ pub mod args {
"The channel ID via which the token is received."
)))
.arg(REFUND.def().help(wrap!(
"Generate the shielded transfer for refunding."
"Generate the shielding transfer for refunding."
Copy link
Contributor

Choose a reason for hiding this comment

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

This is used to generate both the refunding tx and the actual shielding transfer on the destination chain, correct? If that's the case maybe we can change the message here

Copy link
Member Author

@yito88 yito88 Jul 4, 2024

Choose a reason for hiding this comment

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

Thanks, Hermes used the argument. Now build_ibc_transfer generates the masp tx for the refunding.
Users don't have to generate it with this command anymore.
I'll remove this argument.

@@ -2662,6 +2662,6 @@ pub struct GenIbcShieldedTransfer<C: NamadaTypes = SdkTypes> {
pub port_id: PortId,
/// Channel ID via which the token is received
pub channel_id: ChannelId,
/// Generate the shielded transfer for refunding
/// Generate the shielding transfer for refunding
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here as in the client

let mut masp_txs = Vec::new();
for cmt in &tx.header.batch {
let tx_data = tx.data(cmt).ok_or_else(|| {
Error::Other("Missing expected masp transaction".to_string())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Error::Other("Missing expected masp transaction".to_string())
Error::Other("Missing transaction data".to_string())

Ok(masp_txs)
} else {
Err(Error::Other(
"IBC meesage doesn't have masp transaction".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"IBC meesage doesn't have masp transaction".to_string(),
"IBC message doesn't have masp transaction".to_string(),

@@ -27,6 +27,7 @@ pub enum Action {
Gov(GovAction),
Pgf(PgfAction),
Masp(MaspAction),
IbcShielding,
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking that instead of IbcShielding perhaps we could just expand the MaspAction to be an enum like:

enum MaspAction {
    TxSection(Hash),
    InnerTxCmt(Hash)
}

The first case is the one we already have and its hash is the hash of the tx's Masp section. The second case is an alternative to IbcShielding and its hash is that of the TxCommitments (i.e. the inner tx hash). The ibc transaction could write the second variant when the tx is an incoming one. In the SDK then, we can look at the specific inner txs of the batch that contain a masp ibc tx and extract only their memos without looking at all of them.

This is a minor suggestion, feel free to ignore it

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, it looks better. However, the change for setting Hash into the action caused wasm compilation error on arm mac. Let's leave it as it is.

grarco
grarco previously approved these changes Jul 3, 2024
Copy link
Contributor

@grarco grarco left a comment

Choose a reason for hiding this comment

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

Minor comments but looks good to me, thanks!

@grarco
Copy link
Contributor

grarco commented Jul 4, 2024

Actually, I believe there's an issue, my bad for not spotting it earlier. In the sdk we use extract_masp_tx_from_ibc_message when we have a valid masp tx which is missing the masp ref event. In this case we iterate over all the inner txs of the batch and try to extract the ibc message from the tx data and if we can we push the masp Transaction to the result.

The issue is that we don't know if that specific inner tx was successful: if it wasn't, the client (or indexer) extracts information from a wrong source and spoils the internal state of the ShieldedContext, which might prevent it from constructing valid transactions in the future.

We need a way to tell, in the events we emit, which transactions of the batch are actually valid and filter only these ones in extract_masp_tx_from_ibc_message

@grarco grarco mentioned this pull request Jul 5, 2024
@grarco
Copy link
Contributor

grarco commented Jul 5, 2024

Actually, I believe there's an issue, my bad for not spotting it earlier. In the sdk we use extract_masp_tx_from_ibc_message when we have a valid masp tx which is missing the masp ref event. In this case we iterate over all the inner txs of the batch and try to extract the ibc message from the tx data and if we can we push the masp Transaction to the result.

The issue is that we don't know if that specific inner tx was successful: if it wasn't, the client (or indexer) extracts information from a wrong source and spoils the internal state of the ShieldedContext, which might prevent it from constructing valid transactions in the future.

We need a way to tell, in the events we emit, which transactions of the batch are actually valid and filter only these ones in extract_masp_tx_from_ibc_message

Opened #3488 to track this separately

@brentstone brentstone merged commit fecfaee into main Jul 5, 2024
15 of 19 checks passed
@brentstone brentstone deleted the yuji/fix-ibc-shielding-transfer branch July 5, 2024 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Another receiver can get tokens in IBC shielding transfer with an evil IBC relayer
5 participants