informalsystems/tendermint-rs

light-client: new lib API for misbehaviour header verification

ancazamfir opened this issue · 0 comments

Description

Currently ibc-rs uses the verify() function to verify headers received in MsgUpdateClient

fn verify(
&self,
untrusted: UntrustedBlockState<'_>,
trusted: TrustedBlockState<'_>,
options: &Options,
now: Time,
) -> 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_against_trusted(&untrusted, &trusted, options));
ensure_verdict_success!(self.verify_commit(&untrusted));
Verdict::Success
}
}

There is a need to verify headers received in MsgSubmitMisbehaviour. The verification for these headers is a bit more relaxed in order to catch FLA attacks. In particular the "header in the future" check for the header should be skipped from validate_against_trusted().
// Ensure the header isn't from a future time
verdict!(self.predicates.is_header_from_past(
untrusted.signed_header.header.time,
options.clock_drift,
now,
));

Currently the ibc-rs makes explicitly these calls from verify():

        ...verify_validator_sets(&untrusted);
        ...verify_commit_against_trusted(&untrusted, &trusted, options));
        ...verify_commit(&untrusted));

and also does all the checks from validate_against_trusted() except the header in the future one. Code is hard to follow as the checks are spread across multiple functions and also one needs to dive into the library to understand what it is being checked and where.

This PR reorganizes the code around client update/ misbehaviour. New code will temporarily call the same verify() API for both update and misbehaviour headers but we need to eventually provide the new API.
Intuitively this should also be needed for the light client detector in tendermint-rs for header verification from witnesses.

Definition of "done"

  • new verify_misbehaviour_header API implementation and documentation available