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

Add codec borsh feature #273

Merged
merged 20 commits into from
Dec 16, 2022
Merged

Conversation

DaviRain-Su
Copy link
Contributor

Closes: #259

Description


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

crates/ibc/src/core/ics02_client/client_type.rs Outdated Show resolved Hide resolved
crates/ibc/Cargo.toml Outdated Show resolved Hide resolved
crates/ibc/Cargo.toml Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Base: 67.46% // Head: 66.14% // Decreases project coverage by -1.31% ⚠️

Coverage data is based on head (362cb6c) compared to base (edb9d7c).
Patch coverage: 0.40% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #273      +/-   ##
==========================================
- Coverage   67.46%   66.14%   -1.32%     
==========================================
  Files         125      125              
  Lines       12796    13051     +255     
==========================================
  Hits         8633     8633              
- Misses       4163     4418     +255     
Impacted Files Coverage Δ
crates/ibc/src/core/ics02_client/client_type.rs 43.75% <0.00%> (-26.25%) ⬇️
crates/ibc/src/core/ics02_client/height.rs 59.81% <0.00%> (-3.56%) ⬇️
...rates/ibc/src/core/ics02_client/trust_threshold.rs 60.34% <0.00%> (-6.97%) ⬇️
crates/ibc/src/core/ics03_connection/connection.rs 29.61% <0.00%> (-9.46%) ⬇️
crates/ibc/src/core/ics03_connection/version.rs 90.25% <0.00%> (-3.66%) ⬇️
crates/ibc/src/core/ics04_channel/channel.rs 54.01% <0.00%> (-5.77%) ⬇️
crates/ibc/src/core/ics04_channel/commitment.rs 21.87% <0.00%> (-13.13%) ⬇️
crates/ibc/src/core/ics04_channel/packet.rs 51.25% <0.00%> (-3.42%) ⬇️
crates/ibc/src/core/ics04_channel/timeout.rs 39.04% <0.00%> (-2.37%) ⬇️
crates/ibc/src/core/ics04_channel/version.rs 64.70% <0.00%> (-13.87%) ⬇️
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@plafer
Copy link
Contributor

plafer commented Dec 7, 2022

@DaviRain-Su is this ready to be reviewed? Whenever you're ready, please mark the PR as "ready for review" and I'll review it!

@DaviRain-Su
Copy link
Contributor Author

@DaviRain-Su is this ready to be reviewed? Whenever you're ready, please mark the PR as "ready for review" and I'll review it!

yet, it can review

@DaviRain-Su DaviRain-Su marked this pull request as ready for review December 8, 2022 01:48
Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

Once again, great work here.

This is just a preliminary review, will finish it later!

crates/ibc/Cargo.toml Outdated Show resolved Hide resolved
crates/ibc/Cargo.toml Outdated Show resolved Hide resolved
@plafer
Copy link
Contributor

plafer commented Dec 9, 2022

I notice that a subset of the types were tagged as serializable/deserializable by borsh and parity-scale-codec. What is the reasoning behind the choice of which type should be serializable/deserializable?

@DaviRain-Su
Copy link
Contributor Author

DaviRain-Su commented Dec 12, 2022

I notice that a subset of the types were tagged as serializable/deserializable by borsh and parity-scale-codec. What is the reasoning behind the choice of which type should be serializable/deserializable?

In the substrate pallet we use the scale-codec encoding, while using borsh is the next contract we have to use

Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

almost there 😃

crates/ibc/Cargo.toml Outdated Show resolved Hide resolved
crates/ibc/Cargo.toml Outdated Show resolved Hide resolved
crates/ibc/src/core/ics04_channel/packet.rs Show resolved Hide resolved
- Add parity-scale-codec and Borsh below type
- core::ics02_client::trust_threshold
- core::ics03_connection::connection
- core::ics03_connection::version
- core::ics04_channel::channel
- core::ics04_channel::commitment
- core::ics04_channel::version
- core::ics26_routing (ModuleId)
- crate::Signer type
Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

Left a few improvements!

crates/ibc/src/core/ics02_client/client_type.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics02_client/client_type.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics03_connection/version.rs Outdated Show resolved Hide resolved
crates/ibc/src/timestamp.rs Outdated Show resolved Hide resolved
crates/ibc/src/timestamp.rs Show resolved Hide resolved
Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

A few uses of the derive macros were forgotten, and left a few nits!

crates/ibc/src/core/ics24_host/identifier.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics24_host/identifier.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics24_host/identifier.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics24_host/identifier.rs Outdated Show resolved Hide resolved
crates/ibc/src/timestamp.rs Outdated Show resolved Hide resolved
crates/ibc/src/timestamp.rs Outdated Show resolved Hide resolved
crates/ibc/src/timestamp.rs Outdated Show resolved Hide resolved
@DaviRain-Su
Copy link
Contributor Author

this is error, I change they suggest but have also error.

error: `Box::new(_)` of default value
    --> crates/ibc/src/mock/context.rs:1882:21
     |
1882 |                     Box::new(MockAck::default()),
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#box_default
note: the lint level is defined here
    --> crates/ibc/src/lib.rs:8:5
     |
8    |     warnings,
     |     ^^^^^^^^
     = note: `#[deny(clippy::box_default)]` implied by `#[deny(warnings)]`

@plafer
Copy link
Contributor

plafer commented Dec 16, 2022

The CI fails because Rust 1.66 was just released. This fixes it:

diff --git a/crates/ibc/src/mock/context.rs b/crates/ibc/src/mock/context.rs
index 05b48096..6ffffae1 100644
--- a/crates/ibc/src/mock/context.rs
+++ b/crates/ibc/src/mock/context.rs
@@ -1879,7 +1879,7 @@ mod tests {
                 _relayer: &Signer,
             ) -> OnRecvPacketAck {
                 OnRecvPacketAck::Successful(
-                    Box::new(MockAck::default()),
+                    Box::<MockAck>::default(),
                     Box::new(|module| {
                         let module = module.downcast_mut::<FooModule>().unwrap();
                         module.counter += 1;

Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

Thank you @DaviRain-Su! I very much appreciate your contributions 😄

@plafer plafer merged commit cec7c31 into cosmos:main Dec 16, 2022
@DaviRain-Su DaviRain-Su deleted the add-codec-borsh-feature branch December 17, 2022 02:15
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 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.

Add serialization and deserialization features for codec and borsh to the host type in ics24
2 participants