From 79ae26f181a2e752a3c8c241be26d27fb03341a8 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Tue, 21 May 2024 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?light-client-verifier:=20=F0=9F=8C=B1=20restore?= =?UTF-8?q?=20`verify=5Fcommit()`=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in #1410, alterations were made to the `PredicateVerifier` to improve performance when verifying commits. specifically, a call to `verify_commit_against_trusted(untrusted, trusted, options)` will now make use of new internal interfaces that check validator signatures and signer overlap at the same time. this is a worthwhile performance improvement, but in the process, it made changes to the public interface of `PredicateVerifier` that break some use cases. as i understand it, there is no strict need to remove the other public interface from the verifier. those that call `verify_commit_against_trusted` can still receive a performance boost, but calling `verify_commit` on just the untrusted state should still work after those changes. so, this commit restores `verify_commit(untrusted)`, and keeps `verify_commit_against_trusted(untrusted, trusted, options)` under its previous name. --- light-client-verifier/src/verifier.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/light-client-verifier/src/verifier.rs b/light-client-verifier/src/verifier.rs index caec451ef..d26eb2c34 100644 --- a/light-client-verifier/src/verifier.rs +++ b/light-client-verifier/src/verifier.rs @@ -209,10 +209,24 @@ where Verdict::Success } + /// Verify that more than 2/3 of the validators correctly committed the block. + /// + /// Use [`PredicateVerifier::verify_commit_against_trusted()`] to also verify that there is + /// enough overlap between validator sets. + pub fn verify_commit(&self, untrusted: &UntrustedBlockState<'_>) -> Verdict { + verdict!(self.predicates.has_sufficient_signers_overlap( + untrusted.signed_header, + untrusted.validators, + &self.voting_power_calculator, + )); + + Verdict::Success + } + /// Verify that a) there is enough overlap between the validator sets of the /// trusted and untrusted blocks and b) more than 2/3 of the validators /// correctly committed the block. - pub fn verify_commit( + pub fn verify_commit_against_trusted( &self, untrusted: &UntrustedBlockState<'_>, trusted: &TrustedBlockState<'_>, @@ -288,7 +302,7 @@ where 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(&untrusted, &trusted, options)); + ensure_verdict_success!(self.verify_commit_against_trusted(&untrusted, &trusted, options)); Verdict::Success } @@ -305,7 +319,7 @@ where ) -> Verdict { ensure_verdict_success!(self.verify_validator_sets(&untrusted)); ensure_verdict_success!(self.validate_against_trusted(&untrusted, &trusted, options, now)); - ensure_verdict_success!(self.verify_commit(&untrusted, &trusted, options)); + ensure_verdict_success!(self.verify_commit_against_trusted(&untrusted, &trusted, options)); Verdict::Success } }