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:
parent
6344d626db
commit
966e26d23d
@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user