-
Notifications
You must be signed in to change notification settings - Fork 225
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
Refactor Light Client verification predicates interface for use from IBC #960
Conversation
Signed-off-by: Thane Thomson <[email protected]>
…eters Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #960 +/- ##
=======================================
Coverage 72.0% 72.1%
=======================================
Files 203 203
Lines 16522 16632 +110
=======================================
+ Hits 11912 12005 +93
- Misses 4610 4627 +17
Continue to review full report at Codecov.
|
Signed-off-by: Thane Thomson <[email protected]>
…peer ID Signed-off-by: Thane Thomson <[email protected]>
…verification Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
This commit refactors the light client verifier to require the minimum possible amount of detail in its parameters to perform verification. (The LightBlock structure provides far more data than is actually necessary) This refactor makes it much easier to reuse the verification code from ibc-rs. Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
This commit makes use of the latest code from informalsystems/tendermint-rs#960 in order to reuse the light client's verification predicates instead of reimplementing them in the `ibc` crate. Signed-off-by: Thane Thomson <[email protected]>
The rustdoc error seems to only pop up with Rust nightly 1.57.0, whereas it compiles just fine with 1.56.0. It's a problem in
|
Signed-off-by: Thane Thomson <[email protected]>
&self.hasher, | ||
)); | ||
|
||
// TODO(thane): Is this check necessary for IBC? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josef-widder We may need your help here.
It seems the IBC handler (ICS 07) has no access to the set of next_validators
for the untrusted header. For this reason, this field is an Option
here. When the IBC handler calls into verify
it does so with this field to None
(cf. https://github.com/informalsystems/ibc-rs/pull/1321/files#diff-9a833365bf13b4ff1ce2cc757bf18ebabea582b2b97774040e0b7be03fcacbf4R93-R95). This check will effectively be disabled in the context of the IBC handler. This is probably a problem and we need to sort it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this concern need not block the PR. (Josef will only return from holidays after Sept 27). Maybe @ancazamfir could help us sort out the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Structurally the refactoring makes sense to me, can't comment much on the internals of the verification.
} | ||
} | ||
|
||
/// The default production implementation of the [`PredicateVerifier`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implies that there is a common understanding what a "production" environment constitutes. More qualification would aid in contextualised this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is something we've been talking/thinking about for a year now 😄 We're definitely open to suggestions on the naming front.
The original purpose, afaik, was to disambiguate mock versions from non-mock versions of the types, but I think @romac can elaborate on this better than I can?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I am not super happy with the current terminology (that I came up with). I guess we need to differentiate between:
a) the trait (previously Predicates
, now Verifier
)
b) the "production" implementation (previously ProdPredicates
, now ProdVerifier
)
c) the potential mock implementations of the trait (no use for that yet)
I agree that the Prod
prefix is subpar, maybe Default
or Standard
would be a better fit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🛀 😷 🌽 💐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job, @thanethomson! Very much an improvement over the previous API 💯
} | ||
} | ||
|
||
/// The default production implementation of the [`PredicateVerifier`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I am not super happy with the current terminology (that I came up with). I guess we need to differentiate between:
a) the trait (previously Predicates
, now Verifier
)
b) the "production" implementation (previously ProdPredicates
, now ProdVerifier
)
c) the potential mock implementations of the trait (no use for that yet)
I agree that the Prod
prefix is subpar, maybe Default
or Standard
would be a better fit?
@@ -77,6 +77,28 @@ impl Status { | |||
} | |||
} | |||
|
|||
/// Trusted block parameters needed for light client verification. | |||
pub struct TrustedBlockState<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
* bla * on going * ongoing * on going * on going * timestamp default changed from none to now * failed ping pong - signs * Update context.rs * bla * blabla * fixed test client_update_ping_pong * fmt + clippy * Update context.rs * Update context.rs * remove comments * Update host.rs * Update to tendermint-rs v0.20.0 * Update changelog * Fix tendermint-rs version in changelog * Update predicates.rs * Update context.rs * tests * tendermint stuff in * Update Cargo.toml * clippy + fmt * moved predicates into ics07 header.rs * Adapted to latest TM changes * Fixed MockHeader test * Fmt & clippy * Removed irrelevant file * Bit more cleanup * fixed tests * upgraded to new error model * fmt * errors and timestamp changes * Fix error notation and formatting Signed-off-by: Thane Thomson <[email protected]> * Upgrade to tendermint-rs master Signed-off-by: Thane Thomson <[email protected]> * Use tendermint-rs from branch thane/ibc-1252 Signed-off-by: Thane Thomson <[email protected]> * Refactor ICS07 update handler to reuse light client verifier This commit makes use of the latest code from informalsystems/tendermint-rs#960 in order to reuse the light client's verification predicates instead of reimplementing them in the `ibc` crate. Signed-off-by: Thane Thomson <[email protected]> * Update Cargo.lock to address zeroize issue Signed-off-by: Thane Thomson <[email protected]> * Bump tendermint-light-client dep to v0.22.0 for ibc module Signed-off-by: Thane Thomson <[email protected]> * Refactor to accommodate new context API Signed-off-by: Thane Thomson <[email protected]> * Fix missing import Signed-off-by: Thane Thomson <[email protected]> * Fix imports Signed-off-by: Thane Thomson <[email protected]> * Fix error check in test Signed-off-by: Thane Thomson <[email protected]> * Output debug version of error Signed-off-by: Thane Thomson <[email protected]> * Remove test as per #1321 (comment) Signed-off-by: Thane Thomson <[email protected]> * Address comments from Adi Signed-off-by: Thane Thomson <[email protected]> * Cosmetic tweaks Signed-off-by: Thane Thomson <[email protected]> * Add revision number check Signed-off-by: Thane Thomson <[email protected]> * Fix broken test Signed-off-by: Thane Thomson <[email protected]> * Check incoming header height against chain ID version from client state Signed-off-by: Thane Thomson <[email protected]> * Add revision_number consistency check when deserializing header Signed-off-by: Thane Thomson <[email protected]> * Clarify MismatchedRevisions error message Signed-off-by: Thane Thomson <[email protected]> * Add changelog entries Signed-off-by: Thane Thomson <[email protected]> * Commented import no longer necessary Signed-off-by: Thane Thomson <[email protected]> * Add in-the-middle monotonicity checks Signed-off-by: Thane Thomson <[email protected]> * Fix broken dep tree relating to Prometheus Signed-off-by: Thane Thomson <[email protected]> * Move next/prev consensus state search functionality to ClientReader trait Signed-off-by: Thane Thomson <[email protected]> * Move impl of prev/next to the specific implementation and simplify signatures * Disable `tendermint-light-client` default features, ie. RPC client, std and color-eyre * Apply suggestions from code review * Fix compilation * Cleanup BTreeMap import * Always show underlying reason in ics07_tendermint errors * Update modules/src/ics02_client/handler/update_client.rs * Fix compilation Co-authored-by: cezarad <[email protected]> Co-authored-by: Romain Ruetschi <[email protected]> Co-authored-by: cezarad <[email protected]> Co-authored-by: Adi Seredinschi <[email protected]> Co-authored-by: Anca Zamfir <[email protected]>
…tems#1321) * bla * on going * ongoing * on going * on going * timestamp default changed from none to now * failed ping pong - signs * Update context.rs * bla * blabla * fixed test client_update_ping_pong * fmt + clippy * Update context.rs * Update context.rs * remove comments * Update host.rs * Update to tendermint-rs v0.20.0 * Update changelog * Fix tendermint-rs version in changelog * Update predicates.rs * Update context.rs * tests * tendermint stuff in * Update Cargo.toml * clippy + fmt * moved predicates into ics07 header.rs * Adapted to latest TM changes * Fixed MockHeader test * Fmt & clippy * Removed irrelevant file * Bit more cleanup * fixed tests * upgraded to new error model * fmt * errors and timestamp changes * Fix error notation and formatting Signed-off-by: Thane Thomson <[email protected]> * Upgrade to tendermint-rs master Signed-off-by: Thane Thomson <[email protected]> * Use tendermint-rs from branch thane/ibc-1252 Signed-off-by: Thane Thomson <[email protected]> * Refactor ICS07 update handler to reuse light client verifier This commit makes use of the latest code from informalsystems/tendermint-rs#960 in order to reuse the light client's verification predicates instead of reimplementing them in the `ibc` crate. Signed-off-by: Thane Thomson <[email protected]> * Update Cargo.lock to address zeroize issue Signed-off-by: Thane Thomson <[email protected]> * Bump tendermint-light-client dep to v0.22.0 for ibc module Signed-off-by: Thane Thomson <[email protected]> * Refactor to accommodate new context API Signed-off-by: Thane Thomson <[email protected]> * Fix missing import Signed-off-by: Thane Thomson <[email protected]> * Fix imports Signed-off-by: Thane Thomson <[email protected]> * Fix error check in test Signed-off-by: Thane Thomson <[email protected]> * Output debug version of error Signed-off-by: Thane Thomson <[email protected]> * Remove test as per informalsystems#1321 (comment) Signed-off-by: Thane Thomson <[email protected]> * Address comments from Adi Signed-off-by: Thane Thomson <[email protected]> * Cosmetic tweaks Signed-off-by: Thane Thomson <[email protected]> * Add revision number check Signed-off-by: Thane Thomson <[email protected]> * Fix broken test Signed-off-by: Thane Thomson <[email protected]> * Check incoming header height against chain ID version from client state Signed-off-by: Thane Thomson <[email protected]> * Add revision_number consistency check when deserializing header Signed-off-by: Thane Thomson <[email protected]> * Clarify MismatchedRevisions error message Signed-off-by: Thane Thomson <[email protected]> * Add changelog entries Signed-off-by: Thane Thomson <[email protected]> * Commented import no longer necessary Signed-off-by: Thane Thomson <[email protected]> * Add in-the-middle monotonicity checks Signed-off-by: Thane Thomson <[email protected]> * Fix broken dep tree relating to Prometheus Signed-off-by: Thane Thomson <[email protected]> * Move next/prev consensus state search functionality to ClientReader trait Signed-off-by: Thane Thomson <[email protected]> * Move impl of prev/next to the specific implementation and simplify signatures * Disable `tendermint-light-client` default features, ie. RPC client, std and color-eyre * Apply suggestions from code review * Fix compilation * Cleanup BTreeMap import * Always show underlying reason in ics07_tendermint errors * Update modules/src/ics02_client/handler/update_client.rs * Fix compilation Co-authored-by: cezarad <[email protected]> Co-authored-by: Romain Ruetschi <[email protected]> Co-authored-by: cezarad <[email protected]> Co-authored-by: Adi Seredinschi <[email protected]> Co-authored-by: Anca Zamfir <[email protected]>
* bla * on going * ongoing * on going * on going * timestamp default changed from none to now * failed ping pong - signs * Update context.rs * bla * blabla * fixed test client_update_ping_pong * fmt + clippy * Update context.rs * Update context.rs * remove comments * Update host.rs * Update to tendermint-rs v0.20.0 * Update changelog * Fix tendermint-rs version in changelog * Update predicates.rs * Update context.rs * tests * tendermint stuff in * Update Cargo.toml * clippy + fmt * moved predicates into ics07 header.rs * Adapted to latest TM changes * Fixed MockHeader test * Fmt & clippy * Removed irrelevant file * Bit more cleanup * fixed tests * upgraded to new error model * fmt * errors and timestamp changes * Fix error notation and formatting Signed-off-by: Thane Thomson <[email protected]> * Upgrade to tendermint-rs master Signed-off-by: Thane Thomson <[email protected]> * Use tendermint-rs from branch thane/ibc-1252 Signed-off-by: Thane Thomson <[email protected]> * Refactor ICS07 update handler to reuse light client verifier This commit makes use of the latest code from informalsystems/tendermint-rs#960 in order to reuse the light client's verification predicates instead of reimplementing them in the `ibc` crate. Signed-off-by: Thane Thomson <[email protected]> * Update Cargo.lock to address zeroize issue Signed-off-by: Thane Thomson <[email protected]> * Bump tendermint-light-client dep to v0.22.0 for ibc module Signed-off-by: Thane Thomson <[email protected]> * Refactor to accommodate new context API Signed-off-by: Thane Thomson <[email protected]> * Fix missing import Signed-off-by: Thane Thomson <[email protected]> * Fix imports Signed-off-by: Thane Thomson <[email protected]> * Fix error check in test Signed-off-by: Thane Thomson <[email protected]> * Output debug version of error Signed-off-by: Thane Thomson <[email protected]> * Remove test as per informalsystems/hermes#1321 (comment) Signed-off-by: Thane Thomson <[email protected]> * Address comments from Adi Signed-off-by: Thane Thomson <[email protected]> * Cosmetic tweaks Signed-off-by: Thane Thomson <[email protected]> * Add revision number check Signed-off-by: Thane Thomson <[email protected]> * Fix broken test Signed-off-by: Thane Thomson <[email protected]> * Check incoming header height against chain ID version from client state Signed-off-by: Thane Thomson <[email protected]> * Add revision_number consistency check when deserializing header Signed-off-by: Thane Thomson <[email protected]> * Clarify MismatchedRevisions error message Signed-off-by: Thane Thomson <[email protected]> * Add changelog entries Signed-off-by: Thane Thomson <[email protected]> * Commented import no longer necessary Signed-off-by: Thane Thomson <[email protected]> * Add in-the-middle monotonicity checks Signed-off-by: Thane Thomson <[email protected]> * Fix broken dep tree relating to Prometheus Signed-off-by: Thane Thomson <[email protected]> * Move next/prev consensus state search functionality to ClientReader trait Signed-off-by: Thane Thomson <[email protected]> * Move impl of prev/next to the specific implementation and simplify signatures * Disable `tendermint-light-client` default features, ie. RPC client, std and color-eyre * Apply suggestions from code review * Fix compilation * Cleanup BTreeMap import * Always show underlying reason in ics07_tendermint errors * Update modules/src/ics02_client/handler/update_client.rs * Fix compilation Co-authored-by: cezarad <[email protected]> Co-authored-by: Romain Ruetschi <[email protected]> Co-authored-by: cezarad <[email protected]> Co-authored-by: Adi Seredinschi <[email protected]> Co-authored-by: Anca Zamfir <[email protected]>
Closes #956
The main aim of this PR is to remove references to the
LightBlock
type from the verification predicates, as theLightBlock
type isn't used in informalsystems/hermes#1252Tomorrow I'll try working on refactoring that PR to make use of this code to see if it will work.
.changelog/