Skip to content

Commit

Permalink
Fix tendermint misbehaviour trusted consensus state age check (#8006)
Browse files Browse the repository at this point in the history
* use TrustingPeriod instead of UnbondingPeriod when verifying the age of the trusted consensus state

* update comment
  • Loading branch information
colin-axner authored Nov 23, 2020
1 parent 6344d62 commit 966e26d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions x/ibc/light-clients/07-tendermint/types/misbehaviour_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
{
Expand Down

0 comments on commit 966e26d

Please sign in to comment.