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 Verifier::verify_misbehaviour_header for verifying headers coming from a misbehaviour evidence #1300

Merged
merged 6 commits into from
Apr 20, 2023

Conversation

romac
Copy link
Member

@romac romac commented Apr 17, 2023

Closes: #1294

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Added entry in .changelog/

@romac romac requested review from plafer and ancazamfir April 17, 2023 10:43
@codecov-commenter
Copy link

Codecov Report

Merging #1300 (81adaff) into main (adf235f) will decrease coverage by 0.1%.
The diff coverage is 38.4%.

❗ Current head 81adaff differs from pull request most recent head eedb4df. Consider uploading reports for the commit eedb4df to get more accurate results

@@           Coverage Diff           @@
##            main   #1300     +/-   ##
=======================================
- Coverage   64.3%   64.2%   -0.1%     
=======================================
  Files        271     271             
  Lines      24450   24484     +34     
=======================================
+ Hits       15723   15725      +2     
- Misses      8727    8759     +32     
Impacted Files Coverage Δ
light-client-verifier/src/verifier.rs 82.1% <38.4%> (-11.1%) ⬇️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

) -> Verdict {
ensure_verdict_success!(self.verify_validator_sets(&untrusted));
ensure_verdict_success!(
self.validate_misbehaviour_against_trusted(&untrusted, &trusted, options, now)
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 it would be clearer to use self.validate_against_trusted() directly to see the correspondence with the verify() implementation

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -51,32 +51,44 @@ impl From<Result<(), VerificationError>> for Verdict {
/// - [TMBC-VAL-CONTAINS-CORR.1]
/// - [TMBC-VAL-COMMIT.1]
pub trait Verifier: Send + Sync {
/// Perform the verification.
/// Verify a header received in a `MsgUpdateClient`.
fn verify(
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps verify_update_header() would be a more descriptive name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 300 to 304
ensure_verdict_success!(self.verify_validator_sets(&untrusted));
ensure_verdict_success!(self.validate_against_trusted(&untrusted, &trusted, options, now));
ensure_verdict_success!(self.check_header_is_from_past(&untrusted, options, now));
ensure_verdict_success!(self.verify_commit_against_trusted(&untrusted, &trusted, options));
ensure_verdict_success!(self.verify_commit(&untrusted));
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this implementation is a subset of verify_misbehaviour_header(), maybe we could call verify_misbehaviour_header(), and then check_header_is_from_past()? This would make it clear that there's only one additional check between an update and a misbehaviour header.

Although then it might be confusing to call a "misbehaviour" in an "update" verification? Or maybe we do some renaming? Not sure...

Copy link
Member Author

Choose a reason for hiding this comment

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

I would rather keep it as is, since it's only a few lines of code and the one check that is omitted is clearly documented in the doc comment.

Copy link
Contributor

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

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

LGTM!

@romac romac merged commit 9e48f17 into main Apr 20, 2023
@romac romac deleted the romac/verify-misbehavior-header branch April 20, 2023 08:45
@romac romac mentioned this pull request May 2, 2023
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.

light-client: new lib API for misbehaviour header verification
4 participants