Skip to content

Commit

Permalink
chore: reverting renaming of Misbehaviour (cosmos#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored and seunlanlege committed Aug 9, 2022
1 parent 831c92c commit e7e4df1
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 174 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (channel) [\#644](https://github.com/cosmos/ibc-go/pull/644) Removes `CounterpartyHops` function from the ChannelKeeper.
* (testing) [\#776](https://github.com/cosmos/ibc-go/pull/776) Adding helper fn to generate capability name for testing callbacks
* (channel) [\#882](https://github.com/cosmos/ibc-go/pull/882) The `WriteAcknowledgement` API now takes `exported.Acknowledgement` instead of a byte array
* (06-solomachine) [\#1093](https://github.com/cosmos/ibc-go/pull/1093) Renaming `06-solomachine` type `Misbehaviour` to `DuplicateSignatures`

### State Machine Breaking

Expand Down
40 changes: 20 additions & 20 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@
- [ConnectionStateData](#ibc.lightclients.solomachine.v2.ConnectionStateData)
- [ConsensusState](#ibc.lightclients.solomachine.v2.ConsensusState)
- [ConsensusStateData](#ibc.lightclients.solomachine.v2.ConsensusStateData)
- [DuplicateSignatures](#ibc.lightclients.solomachine.v2.DuplicateSignatures)
- [Header](#ibc.lightclients.solomachine.v2.Header)
- [HeaderData](#ibc.lightclients.solomachine.v2.HeaderData)
- [Misbehaviour](#ibc.lightclients.solomachine.v2.Misbehaviour)
- [NextSequenceRecvData](#ibc.lightclients.solomachine.v2.NextSequenceRecvData)
- [PacketAcknowledgementData](#ibc.lightclients.solomachine.v2.PacketAcknowledgementData)
- [PacketCommitmentData](#ibc.lightclients.solomachine.v2.PacketCommitmentData)
Expand Down Expand Up @@ -4764,25 +4764,6 @@ verification.



<a name="ibc.lightclients.solomachine.v2.DuplicateSignatures"></a>

### DuplicateSignatures
DuplicateSignatures defines misbehaviour for a solo machine which consists
of a sequence and two signatures over different messages at that sequence.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `sequence` | [uint64](#uint64) | | |
| `signature_one` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |
| `signature_two` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |






<a name="ibc.lightclients.solomachine.v2.Header"></a>

### Header
Expand Down Expand Up @@ -4818,6 +4799,25 @@ HeaderData returns the SignBytes data for update verification.



<a name="ibc.lightclients.solomachine.v2.Misbehaviour"></a>

### Misbehaviour
Misbehaviour defines misbehaviour for a solo machine which consists
of a sequence and two signatures over different messages at that sequence.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `sequence` | [uint64](#uint64) | | |
| `signature_one` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |
| `signature_two` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |






<a name="ibc.lightclients.solomachine.v2.NextSequenceRecvData"></a>

### NextSequenceRecvData
Expand Down
220 changes: 110 additions & 110 deletions modules/core/02-client/migrations/v6/solomachine.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/core/02-client/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
{
"invalid solomachine misbehaviour",
func() {
msg, err = types.NewMsgSubmitMisbehaviour("solomachine", &solomachinetypes.DuplicateSignatures{}, suite.chainA.SenderAccount.GetAddress().String())
msg, err = types.NewMsgSubmitMisbehaviour("solomachine", &solomachinetypes.Misbehaviour{}, suite.chainA.SenderAccount.GetAddress().String())
suite.Require().NoError(err)
},
false,
Expand Down
24 changes: 12 additions & 12 deletions modules/light-clients/06-solomachine/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,48 @@ import (
"github.com/cosmos/ibc-go/v3/modules/core/exported"
)

var _ exported.Misbehaviour = &DuplicateSignatures{}
var _ exported.Misbehaviour = &Misbehaviour{}

// ClientType is a Solo Machine light client.
func (ds DuplicateSignatures) ClientType() string {
func (misbehaviour Misbehaviour) ClientType() string {
return exported.Solomachine
}

// GetClientID returns the ID of the client that committed a misbehaviour.
func (ds DuplicateSignatures) GetClientID() string {
return ds.ClientId
func (misbehaviour Misbehaviour) GetClientID() string {
return misbehaviour.ClientId
}

// Type implements Misbehaviour interface.
func (ds DuplicateSignatures) Type() string {
func (misbehaviour Misbehaviour) Type() string {
return exported.TypeClientMisbehaviour
}

// ValidateBasic implements Misbehaviour interface.
func (ds DuplicateSignatures) ValidateBasic() error {
if err := host.ClientIdentifierValidator(ds.ClientId); err != nil {
func (misbehaviour Misbehaviour) ValidateBasic() error {
if err := host.ClientIdentifierValidator(misbehaviour.ClientId); err != nil {
return sdkerrors.Wrap(err, "invalid client identifier for solo machine")
}

if ds.Sequence == 0 {
if misbehaviour.Sequence == 0 {
return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "sequence cannot be 0")
}

if err := ds.SignatureOne.ValidateBasic(); err != nil {
if err := misbehaviour.SignatureOne.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "signature one failed basic validation")
}

if err := ds.SignatureTwo.ValidateBasic(); err != nil {
if err := misbehaviour.SignatureTwo.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "signature two failed basic validation")
}

// misbehaviour signatures cannot be identical
if bytes.Equal(ds.SignatureOne.Signature, ds.SignatureTwo.Signature) {
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(ds.SignatureOne.Data, ds.SignatureTwo.Data) {
if bytes.Equal(misbehaviour.SignatureOne.Data, misbehaviour.SignatureTwo.Data) {
return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "misbehaviour signature data must be signed over different messages")
}

Expand Down
44 changes: 22 additions & 22 deletions modules/light-clients/06-solomachine/misbehaviour_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,91 +19,91 @@ func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() {

testCases := []struct {
name string
malleateMisbehaviour func(duplicateSigHeader *types.DuplicateSignatures)
malleateMisbehaviour func(misbehaviour *types.Misbehaviour)
expPass bool
}{
{
"valid misbehaviour",
func(*types.DuplicateSignatures) {},
func(*types.Misbehaviour) {},
true,
},
{
"invalid client ID",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.ClientId = "(badclientid)"
func(misbehaviour *types.Misbehaviour) {
misbehaviour.ClientId = "(badclientid)"
},
false,
},
{
"sequence is zero",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.Sequence = 0
func(misbehaviour *types.Misbehaviour) {
misbehaviour.Sequence = 0
},
false,
},
{
"signature one sig is empty",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.SignatureOne.Signature = []byte{}
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureOne.Signature = []byte{}
},
false,
},
{
"signature two sig is empty",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.SignatureTwo.Signature = []byte{}
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureTwo.Signature = []byte{}
},
false,
},
{
"signature one data is empty",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.SignatureOne.Data = nil
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureOne.Data = nil
},
false,
},
{
"signature two data is empty",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.SignatureTwo.Data = []byte{}
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureTwo.Data = []byte{}
},
false,
},
{
"signatures are identical",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.SignatureTwo.Signature = duplicateSigHeader.SignatureOne.Signature
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureTwo.Signature = misbehaviour.SignatureOne.Signature
},
false,
},
{
"data signed is identical",
func(duplicateSigHeader *types.DuplicateSignatures) {
duplicateSigHeader.SignatureTwo.Data = duplicateSigHeader.SignatureOne.Data
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureTwo.Data = misbehaviour.SignatureOne.Data
},
false,
},
{
"data type for SignatureOne is unspecified",
func(misbehaviour *types.DuplicateSignatures) {
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureOne.DataType = types.UNSPECIFIED
}, false,
},
{
"data type for SignatureTwo is unspecified",
func(misbehaviour *types.DuplicateSignatures) {
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureTwo.DataType = types.UNSPECIFIED
}, false,
},
{
"timestamp for SignatureOne is zero",
func(misbehaviour *types.DuplicateSignatures) {
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureOne.Timestamp = 0
}, false,
},
{
"timestamp for SignatureTwo is zero",
func(misbehaviour *types.DuplicateSignatures) {
func(misbehaviour *types.Misbehaviour) {
misbehaviour.SignatureTwo.Timestamp = 0
}, false,
},
Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/06-solomachine/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
)
registry.RegisterImplementations(
(*exported.Misbehaviour)(nil),
&DuplicateSignatures{},
&Misbehaviour{},
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState(
misbehaviour exported.Misbehaviour,
) (exported.ClientState, error) {

soloMisbehaviour, ok := misbehaviour.(*DuplicateSignatures)
soloMisbehaviour, ok := misbehaviour.(*Misbehaviour)
if !ok {
return nil, sdkerrors.Wrapf(
clienttypes.ErrInvalidClientType,
"misbehaviour type %T, expected %T", misbehaviour, &DuplicateSignatures{},
"misbehaviour type %T, expected %T", misbehaviour, &Misbehaviour{},
)
}

Expand All @@ -50,7 +50,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState(
// verifySignatureAndData verifies that the currently registered public key has signed
// over the provided data and that the data is valid. The data is valid if it can be
// unmarshaled into the specified data type.
func verifySignatureAndData(cdc codec.BinaryCodec, clientState ClientState, misbehaviour *DuplicateSignatures, sigAndData *SignatureAndData) error {
func verifySignatureAndData(cdc codec.BinaryCodec, clientState ClientState, misbehaviour *Misbehaviour, sigAndData *SignatureAndData) error {

// do not check misbehaviour timestamp since we want to allow processing of past misbehaviour

Expand Down
4 changes: 2 additions & 2 deletions proto/ibc/lightclients/solomachine/v2/solomachine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ message Header {
string new_diversifier = 5 [(gogoproto.moretags) = "yaml:\"new_diversifier\""];
}

// DuplicateSignatures defines misbehaviour for a solo machine which consists
// Misbehaviour defines misbehaviour for a solo machine which consists
// of a sequence and two signatures over different messages at that sequence.
message DuplicateSignatures {
message Misbehaviour {
option (gogoproto.goproto_getters) = false;
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
uint64 sequence = 2;
Expand Down
4 changes: 2 additions & 2 deletions testing/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (solo *Solomachine) CreateHeader() *solomachinetypes.Header {

// CreateMisbehaviour constructs testing misbehaviour for the solo machine client
// by signing over two different data bytes at the same sequence.
func (solo *Solomachine) CreateMisbehaviour() *solomachinetypes.DuplicateSignatures {
func (solo *Solomachine) CreateMisbehaviour() *solomachinetypes.Misbehaviour {
path := solo.GetClientStatePath("counterparty")
dataOne, err := solomachinetypes.ClientStateDataBytes(solo.cdc, path, solo.ClientState())
require.NoError(solo.t, err)
Expand Down Expand Up @@ -204,7 +204,7 @@ func (solo *Solomachine) CreateMisbehaviour() *solomachinetypes.DuplicateSignatu
Timestamp: solo.Time,
}

return &solomachinetypes.DuplicateSignatures{
return &solomachinetypes.Misbehaviour{
ClientId: solo.ClientID,
Sequence: solo.Sequence,
SignatureOne: &signatureOne,
Expand Down

0 comments on commit e7e4df1

Please sign in to comment.