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

Export standalone commitment creators for PacketCommitment & AcknowledgementCommitment #492

Merged
merged 3 commits into from
Mar 6, 2023

Conversation

Farhad-Shabani
Copy link
Member

Closes: #470, #375


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).

@Farhad-Shabani Farhad-Shabani added the A: breaking Admin: breaking change that may impact operators label Mar 2, 2023
@Farhad-Shabani Farhad-Shabani self-assigned this Mar 2, 2023
@Farhad-Shabani Farhad-Shabani marked this pull request as ready for review March 2, 2023 02:49
@codecov
Copy link

codecov bot commented Mar 2, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.04 ⚠️

Comparison is base (61c33db) 71.52% compared to head (2e859ee) 71.48%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #492      +/-   ##
==========================================
- Coverage   71.52%   71.48%   -0.04%     
==========================================
  Files         125      125              
  Lines       15890    15858      -32     
==========================================
- Hits        11365    11336      -29     
+ Misses       4525     4522       -3     
Impacted Files Coverage Δ
crates/ibc/src/core/context.rs 82.38% <ø> (-1.96%) ⬇️
crates/ibc/src/core/ics04_channel/context.rs 78.84% <ø> (+1.06%) ⬆️
crates/ibc/src/mock/context.rs 74.16% <ø> (-0.07%) ⬇️
crates/ibc/src/test_utils.rs 77.89% <ø> (-1.77%) ⬇️
crates/ibc/src/core/context/acknowledgement.rs 97.32% <100.00%> (ø)
crates/ibc/src/core/context/recv_packet.rs 96.25% <100.00%> (+0.04%) ⬆️
crates/ibc/src/core/context/timeout.rs 95.83% <100.00%> (ø)
crates/ibc/src/core/ics04_channel/commitment.rs 55.00% <100.00%> (+34.41%) ⬆️
.../src/core/ics04_channel/handler/acknowledgement.rs 84.34% <100.00%> (ø)
.../ibc/src/core/ics04_channel/handler/recv_packet.rs 85.22% <100.00%> (ø)
... and 3 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.

@Farhad-Shabani Farhad-Shabani requested a review from plafer March 2, 2023 15:58
@@ -69,3 +69,52 @@ impl From<Vec<u8>> for AcknowledgementCommitment {
Self(bytes)
}
}

pub use compute::{compute_ack_commitment, compute_packet_commitment};
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just remove the compute module altogether?

Copy link
Member Author

@Farhad-Shabani Farhad-Shabani Mar 2, 2023

Choose a reason for hiding this comment

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

To keep it modular (achieves a different goal than the code above), better-organized import calls.
It's okay if we keep this, I'll also put pub(crate) before mod compute ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like that there are now 2 paths to the same items, and both are used internally (e.g from commitment, and from compute).

achieves a different goal than the code above

I think they do achieve the same goal: the commitment module holds structs and free functions related to packet commitments. I think this is also why you think it makes sense to expose it as such to the users ;).

I guess the TLDR of my opinion is that separating free functions from struct definitions is not sufficient to justify a new submodule. However this is subject to endless debate and is more a matter of preference anyways, so I'll let you make the final decision as to whether we keep the module or not!

Copy link
Member Author

Choose a reason for hiding this comment

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

That's fine 😄
587fa8b

/// `{revision_number: 0, revision_height: 0}` to be consistent with ibc-go,
/// where this value is used to mean "no timeout height":
/// <https://github.com/cosmos/ibc-go/blob/04791984b3d6c83f704c4f058e6ca0038d155d91/modules/core/04-channel/keeper/packet.go#L206>
pub fn compute_packet_commitment(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can make this pub(crate) since it is only meant to be used internally by ibc-core.

Copy link
Member Author

Choose a reason for hiding this comment

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

}

/// Compute the commitment for an acknowledgement.
pub fn compute_ack_commitment(ack: &Acknowledgement) -> AcknowledgementCommitment {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, this can be pub(crate)

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,3 @@
- Export standalone commitment computations for `PacketCommitment` and
Copy link
Contributor

Choose a reason for hiding this comment

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

We would change this to something more along the lines of "made packet/ack commitment methods private"

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

👌

@plafer plafer merged commit 116638e into main Mar 6, 2023
@plafer plafer deleted the farhad/compute-commitments branch March 6, 2023 12:09
@Farhad-Shabani Farhad-Shabani linked an issue Mar 6, 2023 that may be closed by this pull request
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
…wledgementCommitment` (#492)

* Export standalone commitment creators for Ack & Packet

* Remove compute mod + make compute functions private

* Fix clippy catch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: breaking Admin: breaking change that may impact operators
Projects
Status: Done
2 participants