Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare signature data in misbehaviours only if path differs #2744

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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