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

Murisi/borsh ibc msg transfer #3527

Closed
wants to merge 16 commits into from
Closed

Conversation

murisi
Copy link
Contributor

@murisi murisi commented Jul 18, 2024

Describe your changes

Attempt to close #3501 and hence simplify the (de)serialization of IBC transactions for third parties. More specifically, the following changes have been made:

  • IBC transaction data is now always a tagged serialization of the IbcMessage enumeration instead of being an untagged serialization of a MsgTransfer, MsgNftTransfer or Any structure.
  • IBC transaction data is now encoded using Borsh serialization instead of Protobufs. This is more consistent with how all the other parts of a Tx are serialized using Borsh, and will ease schema generation.
  • Updated the test vector generation code (i.e. the generator and the vector printer) to produce transactions in accordance with the above two changes.

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

Namada 0.40.0

Checklist before merging to draft

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

@murisi murisi marked this pull request as ready for review July 18, 2024 13:04
@murisi murisi requested a review from yito88 July 18, 2024 13:05
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 11.15422% with 916 lines in your changes missing coverage. Please review.

Project coverage is 53.08%. Comparing base (8479d38) to head (3c2ad18).
Report is 4 commits behind head on main.

Files Patch % Lines
crates/ibc/src/msg.rs 4.37% 547 Missing ⚠️
crates/sdk/src/signing.rs 0.00% 293 Missing ⚠️
crates/ibc/src/lib.rs 33.33% 18 Missing ⚠️
crates/token/src/lib.rs 0.00% 14 Missing ⚠️
crates/sdk/src/tx.rs 0.00% 9 Missing ⚠️
crates/governance/src/storage/proposal.rs 0.00% 7 Missing ⚠️
crates/node/src/bench_utils.rs 0.00% 6 Missing ⚠️
crates/sdk/src/lib.rs 0.00% 6 Missing ⚠️
crates/ibc/src/actions.rs 0.00% 5 Missing ⚠️
crates/light_sdk/src/transaction/ibc.rs 0.00% 3 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3527      +/-   ##
==========================================
- Coverage   53.48%   53.08%   -0.40%     
==========================================
  Files         320      320              
  Lines      110000   110794     +794     
==========================================
- Hits        58832    58815      -17     
- Misses      51168    51979     +811     

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

Copy link
Member

@yito88 yito88 left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you! I left comments for minor stuff.

let mut data = vec![];
prost::Message::encode(&msg.to_any(), &mut data).unwrap();
let data = IbcMessage::Envelope(Box::new(
MsgEnvelope::from(ConnectionMsg::from(msg)).into(),
Copy link
Member

@yito88 yito88 Jul 18, 2024

Choose a reason for hiding this comment

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

It's OK. MsgEnvelope::Connection(msg.into()) can be simple because we don't need to import ConnectionMsg explicitly ?

@@ -104,11 +105,16 @@ where
let tx_data =
batched_tx.tx.data(batched_tx.cmt).ok_or(Error::NoTxData)?;

// Message body must be an IbcMessage
let tx_data = IbcMessage::try_from_slice(&tx_data)
Copy link
Member

Choose a reason for hiding this comment

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

I prefer using message instead of tx_data for the following functions.

Suggested change
let tx_data = IbcMessage::try_from_slice(&tx_data)
let message = IbcMessage::try_from_slice(&tx_data)

@@ -184,7 +190,7 @@ where
Ok(())
}

fn validate_with_msg(&self, tx_data: &[u8]) -> VpResult<()> {
fn validate_with_msg(&self, tx_data: IbcMessage) -> VpResult<()> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fn validate_with_msg(&self, tx_data: IbcMessage) -> VpResult<()> {
fn validate_with_msg(&self, message: IbcMessage) -> VpResult<()> {

@murisi murisi force-pushed the murisi/borsh-ibc-msg-transfer branch from 474fb23 to 3c2ad18 Compare July 19, 2024 13:05
@murisi murisi marked this pull request as draft July 19, 2024 21:40
@murisi
Copy link
Contributor Author

murisi commented Jul 29, 2024

Closed in favour of the rebase in #3560 .

@murisi murisi closed this Jul 29, 2024
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.

Use a tag/discriminant to distinguish between IBC NFT transfers and fungible token transfers
2 participants