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

chore: revert renaming of 06-solomachine type Misbehaviour #1099

Merged
merged 1 commit into from
Mar 11, 2022
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: 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 @@ -245,9 +245,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 @@ -3680,25 +3680,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 @@ -3734,6 +3715,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
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 @@ -591,7 +591,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
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
24 changes: 12 additions & 12 deletions modules/light-clients/06-solomachine/types/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
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
44 changes: 22 additions & 22 deletions modules/light-clients/06-solomachine/types/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
Loading