Skip to content

lite: clarify behaviour in DynamicVerifier #3174

@ebuchman

Description

@ebuchman

The DynamicVerifier verifies a SignedHeader by first updating to a FullCommit for SignedHeader.Height - 1. Then it should have FullCommit.NextValidatorSet.Hash() == SignedHeader.ValidatorsHash and can verify the signatures.

It verifies this using a BaseVerifier once it has all the data.

Then, to update to a FullCommit for height SignedHeader.Height, it needs the validator set for SignedHeader.Height + 1.

The current behaviour is as follow:

  • if it can't get this validator set, return no error
  • if it can get this validator set, check that it matches the SignedHeader.NextValidatorsHash, and if not, return an error
  • if it can get this val set, it matches, and it verifies, then save the new full commit and return no error

First, why do we ignore the error if we can't get the validator set? If it's because Tendermint doesn't expose the next validator set for the latest block over /validators, then maybe we can fix that.

Second, it seems we're doing a full verification of the commit twice: once with the BaseVerifier, and once with the FullCommit:

// Verify the signed header using the matching valset.
cert := NewBaseVerifier(ic.chainID, trustedFC.Height()+1, trustedFC.NextValidators)
err = cert.Verify(shdr)

and

// Create filled FullCommit.
nfc := FullCommit{
SignedHeader: shdr,
Validators: trustedFC.NextValidators,
NextValidators: nextValset,
}
// Validate the full commit. This checks the cryptographic
// signatures of Commit against Validators.
if err := nfc.ValidateFull(ic.chainID); err != nil {

It seems the latter verification is mostly redundant. The only part that's needed from it is checking the NextValidatorSet matches up.

We should investigate and clean this up if it's indeed true.

Related: #3173

Metadata

Metadata

Assignees

No one assigned

    Labels

    C:lightComponent: Light

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions