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

imp: make it easier to use custom verifiers for Tendermint clients #1168

Merged
merged 9 commits into from
Apr 17, 2024

Conversation

Farhad-Shabani
Copy link
Member

@Farhad-Shabani Farhad-Shabani commented Apr 15, 2024

Relevant context: #1166 (comment)


PR author checklist:

  • Added changelog entry, using unclog.
  • 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).

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.72%. Comparing base (68513d8) to head (8fe4460).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1168      +/-   ##
==========================================
- Coverage   63.79%   63.72%   -0.08%     
==========================================
  Files         219      218       -1     
  Lines       21389    21394       +5     
==========================================
- Hits        13646    13633      -13     
- Misses       7743     7761      +18     

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

@Farhad-Shabani Farhad-Shabani marked this pull request as ready for review April 15, 2024 19:23
Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

Left some comments.

@@ -38,7 +42,7 @@ where
ctx,
client_id,
client_message,
&DefaultVerifier,
&ProdVerifier::default(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am a bit confused about how I would reuse this interface for a custom verifier. After I implement Verifier trait for my custom logic, how do I pass it here instead of ProdVerifier::default()?

Copy link
Member Author

Choose a reason for hiding this comment

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

See if this works. b8244a5

Copy link
Collaborator

@rnbguy rnbguy Apr 17, 2024

Choose a reason for hiding this comment

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

Am I correct to conclude that someone has to create a wrapper struct:

struct CustomClientState(ClientState);

and delegate all calls except this one? If I am correct, can we add a generic to the current ClientState?

struct ClientState<V: Verifier + Default> { ... }

type DefaultClientState = ClientState<ProdVerifier>;
type SovClientState = ClientState<SovVerifier>;

I am just confirming my understanding. If you already plan for this in future PRs, go ahead with this current merge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Am I correct to conclude that someone has to create a wrapper struct

That's right

Can we add a generic to the current ClientState

Our plan was to do this, but adding a generic introduces complications that eventually lead to refactoring some of the APIs as well. Aside from that, we didn't want to introduce complexity to normal users.
We can consider the generic or even writing macros in the future if there be a serious need.

Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

LGTM ✨ Thanks !

@Farhad-Shabani Farhad-Shabani added this pull request to the merge queue Apr 17, 2024
Merged via the queue into main with commit 2eecb5f Apr 17, 2024
18 checks passed
@Farhad-Shabani Farhad-Shabani deleted the farhad/discard-TmVerifier branch April 17, 2024 13:43
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
…1168)

* imp: simplify introducing custom verifier object

* chore: add changelog

* Update .changelog/unreleased/breaking-changes/1168-discard-TmVerifier.md

Co-authored-by: Rano | Ranadeep <[email protected]>
Signed-off-by: Sean Chen <[email protected]>

* Update ibc-clients/ics07-tendermint/src/client_state/validation.rs

Co-authored-by: Rano | Ranadeep <[email protected]>
Signed-off-by: Sean Chen <[email protected]>

* Update .changelog/unreleased/breaking-changes/1168-discard-TmVerifier.md

Co-authored-by: Rano | Ranadeep <[email protected]>
Signed-off-by: Sean Chen <[email protected]>

* Update ibc-clients/ics07-tendermint/src/client_state/validation.rs

Co-authored-by: Rano | Ranadeep <[email protected]>
Signed-off-by: Sean Chen <[email protected]>

* Update ibc-clients/ics07-tendermint/src/client_state/validation.rs

Co-authored-by: Rano | Ranadeep <[email protected]>
Signed-off-by: Sean Chen <[email protected]>

* docs: nudge toward implementing a newtype wrapper

* nit

---------

Signed-off-by: Sean Chen <[email protected]>
Co-authored-by: Sean Chen <[email protected]>
Co-authored-by: Rano | Ranadeep <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants