Fix tendermint misbehaviour trusted consensus state age check (#8006)

* use TrustingPeriod instead of UnbondingPeriod when verifying the age of the trusted consensus state

* update comment
This commit is contained in:
colin axnér 2020-11-23 16:10:25 +01:00 committed by GitHub
parent 6344d626db
commit 966e26d23d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -92,12 +92,12 @@ func checkMisbehaviourHeader(
return err
}
// assert that the timestamp is not from more than an unbonding period ago
if currentTimestamp.Sub(consState.Timestamp) >= clientState.UnbondingPeriod {
// assert that the age of the trusted consensus state is not older than the trusting period
if currentTimestamp.Sub(consState.Timestamp) >= clientState.TrustingPeriod {
return sdkerrors.Wrapf(
ErrUnbondingPeriodExpired,
"current timestamp minus the latest consensus state timestamp is greater than or equal to the unbonding period (%d >= %d)",
currentTimestamp.Sub(consState.Timestamp), clientState.UnbondingPeriod,
ErrTrustingPeriodExpired,
"current timestamp minus the latest consensus state timestamp is greater than or equal to the trusting period (%d >= %d)",
currentTimestamp.Sub(consState.Timestamp), clientState.TrustingPeriod,
)
}

View File

@ -256,7 +256,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
false,
},
{
"unbonding period expired",
"trusting period expired",
types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false),
types.NewConsensusState(time.Time{}, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash),
heightMinus1,
@ -267,7 +267,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() {
Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners),
ClientId: chainID,
},
suite.now.Add(ubdPeriod),
suite.now.Add(trustingPeriod),
false,
},
{