Skip to content

Commit

Permalink
remove misbehaviour GetHeight (#166)
Browse files Browse the repository at this point in the history
* remove misbehaviour GetHeight

* add changelog

* remove unused misbehaviour event attribute
  • Loading branch information
colin-axner authored May 11, 2021
1 parent 5991e86 commit 4007cfa
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking

* (modules) [\#166](https://github.com/cosmos/ibc-go/pull/166) Remove GetHeight from the misbehaviour interface. The `consensus_height` attribute has been removed from Misbehaviour events.
* (modules) [\#162](https://github.com/cosmos/ibc-go/pull/162) Remove deprecated Handler types in core IBC and the ICS 20 transfer module.
* (modules/core) [\#161](https://github.com/cosmos/ibc-go/pull/161) Remove Type(), Route(), GetSignBytes() from 02-client, 03-connection, and 04-channel messages.
* (modules) [\#140](https://github.com/cosmos/ibc-go/pull/140) IsFrozen() client state interface changed to Status(). gRPC `ClientStatus` route added.
Expand Down
2 changes: 2 additions & 0 deletions docs/migrations/ibc-migration-043.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ The `OnRecvPacket` callback has been modified to only return the acknowledgement

The `packet_data` attribute has been deprecated in favor of `packet_data_hex`, in order to provide standardized encoding/decoding of packet data in events. While the `packet_data` event still exists, all relayers and IBC Event consumers are strongly encouraged to switch over to using `packet_data_hex` as soon as possible.

The `consensus_height` attribute has been removed in the Misbehaviour event emitted. IBC clients no longer have a frozen height and misbehaviour does not necessarily have an associated height.

## Relevant SDK changes

* (codec) [\#9226](https://github.com/cosmos/cosmos-sdk/pull/9226) Rename codec interfaces and methods, to follow a general Go interfaces:
Expand Down
4 changes: 2 additions & 2 deletions modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
// set eventType to SubmitMisbehaviour
eventType = types.EventTypeSubmitMisbehaviour

k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", clientID, "height", header.GetHeight().String())
k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", clientID)

defer func() {
telemetry.IncrCounterWithLabels(
Expand Down Expand Up @@ -224,7 +224,7 @@ func (k Keeper) CheckMisbehaviourAndUpdateState(ctx sdk.Context, misbehaviour ex
}

k.SetClientState(ctx, misbehaviour.GetClientID(), clientState)
k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", misbehaviour.GetClientID(), "height", misbehaviour.GetHeight().String())
k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", misbehaviour.GetClientID())

defer func() {
telemetry.IncrCounterWithLabels(
Expand Down
3 changes: 0 additions & 3 deletions modules/core/exported/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ type Misbehaviour interface {
ClientType() string
GetClientID() string
ValidateBasic() error

// Height at which the infraction occurred
GetHeight() Height
}

// Header is the consensus state update information
Expand Down
1 change: 0 additions & 1 deletion modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (k Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSu
clienttypes.EventTypeSubmitMisbehaviour,
sdk.NewAttribute(clienttypes.AttributeKeyClientID, msg.ClientId),
sdk.NewAttribute(clienttypes.AttributeKeyClientType, misbehaviour.ClientType()),
sdk.NewAttribute(clienttypes.AttributeKeyConsensusHeight, misbehaviour.GetHeight().String()),
),
)

Expand Down
7 changes: 0 additions & 7 deletions modules/light-clients/06-solomachine/types/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ func (misbehaviour Misbehaviour) Type() string {
return exported.TypeClientMisbehaviour
}

// GetHeight returns the sequence at which misbehaviour occurred.
// Return exported.Height to satisfy interface
// Revision number is always 0 for a solo-machine
func (misbehaviour Misbehaviour) GetHeight() exported.Height {
return clienttypes.NewHeight(0, misbehaviour.Sequence)
}

// ValidateBasic implements Evidence interface.
func (misbehaviour Misbehaviour) ValidateBasic() error {
if err := host.ClientIdentifierValidator(misbehaviour.ClientId); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ func (suite *SoloMachineTestSuite) TestMisbehaviour() {

suite.Require().Equal(exported.Solomachine, misbehaviour.ClientType())
suite.Require().Equal(suite.solomachine.ClientID, misbehaviour.GetClientID())
suite.Require().Equal(uint64(0), misbehaviour.GetHeight().GetRevisionNumber())
suite.Require().Equal(suite.solomachine.Sequence, misbehaviour.GetHeight().GetRevisionHeight())
}

func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() {
Expand Down
5 changes: 0 additions & 5 deletions modules/light-clients/07-tendermint/types/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ func (misbehaviour Misbehaviour) GetClientID() string {
return misbehaviour.ClientId
}

// GetHeight returns the height at which misbehaviour occurred
func (misbehaviour Misbehaviour) GetHeight() exported.Height {
return misbehaviour.Header1.GetHeight()
}

// GetTime returns the timestamp at which misbehaviour occurred. It uses the
// maximum value from both headers to prevent producing an invalid header outside
// of the misbehaviour age range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func (suite *TendermintTestSuite) TestMisbehaviour() {

suite.Require().Equal(exported.Tendermint, misbehaviour.ClientType())
suite.Require().Equal(clientID, misbehaviour.GetClientID())
suite.Require().Equal(height, misbehaviour.GetHeight())
}

func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() {
Expand Down

0 comments on commit 4007cfa

Please sign in to comment.