Skip to content

Commit

Permalink
Compare signature data in misbehaviours only if path differs (#2744)
Browse files Browse the repository at this point in the history
fix(statemachine)!: (06-solomachine) [#2744] Misbehaviour.ValidateBasic() now only enforces that signature data does not match when the signature paths are different.
  • Loading branch information
chatton authored Nov 14, 2022
1 parent 2dfd275 commit d46f59b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### State Machine Breaking

* (light-clients/07-tendermint) [\#2554](https://github.com/cosmos/ibc-go/pull/2554) Forbid negative values for `TrustingPeriod`, `UnbondingPeriod` and `MaxClockDrift` (as specified in ICS-07).
* (06-solomachine) [\#2744](https://github.com/cosmos/ibc-go/pull/2744) `Misbehaviour.ValidateBasic()` now only enforces that signature data does not match when the signature paths are different.

### Improvements

Expand Down
7 changes: 4 additions & 3 deletions modules/light-clients/06-solomachine/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ func (misbehaviour Misbehaviour) ValidateBasic() error {
return sdkerrors.Wrap(err, "signature two failed basic validation")
}

// misbehaviour signatures cannot be identical
// misbehaviour signatures cannot be identical.
if bytes.Equal(misbehaviour.SignatureOne.Signature, misbehaviour.SignatureTwo.Signature) {
return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "misbehaviour signatures cannot be equal")
}

// message data signed cannot be identical
if bytes.Equal(misbehaviour.SignatureOne.Data, misbehaviour.SignatureTwo.Data) {
// message data signed cannot be identical if both paths are the same.
if bytes.Equal(misbehaviour.SignatureOne.Path, misbehaviour.SignatureTwo.Path) &&
bytes.Equal(misbehaviour.SignatureOne.Data, misbehaviour.SignatureTwo.Data) {
return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "misbehaviour signature data must be signed over different messages")
}

Expand Down
10 changes: 9 additions & 1 deletion modules/light-clients/06-solomachine/misbehaviour_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() {
false,
},
{
"data signed is identical",
"data signed is identical but path differs",
func(misbehaviour *solomachine.Misbehaviour) {
misbehaviour.SignatureTwo.Data = misbehaviour.SignatureOne.Data
},
true,
},
{
"data signed and path are identical",
func(misbehaviour *solomachine.Misbehaviour) {
misbehaviour.SignatureTwo.Path = misbehaviour.SignatureOne.Path
misbehaviour.SignatureTwo.Data = misbehaviour.SignatureOne.Data
},
false,
},
{
Expand Down

0 comments on commit d46f59b

Please sign in to comment.