From 1f7a2787aa43f8e45da09440917096a2bc1637e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Tue, 25 Aug 2020 16:17:38 +0200 Subject: [PATCH] Final IBC migration and Amino removal (#7157) * migrate tm messages and change header/evidence to pointers * remove amino * add nil checks and test for pointer changes * fix format --- .../solomachine/v1/solomachine.proto | 4 +- proto/ibc/tendermint/tendermint.proto | 55 +- x/ibc/02-client/client/utils/utils.go | 21 +- x/ibc/02-client/keeper/client_test.go | 6 +- x/ibc/02-client/keeper/keeper_test.go | 2 +- x/ibc/02-client/types/codec.go | 20 +- x/ibc/03-connection/client/utils/utils.go | 10 +- x/ibc/04-channel/client/utils/utils.go | 15 +- x/ibc/07-tendermint/client/cli/tx.go | 59 +- x/ibc/07-tendermint/types/codec.go | 24 +- x/ibc/07-tendermint/types/evidence.go | 8 +- x/ibc/07-tendermint/types/evidence_test.go | 106 +- x/ibc/07-tendermint/types/header.go | 5 +- x/ibc/07-tendermint/types/header_test.go | 9 +- x/ibc/07-tendermint/types/misbehaviour.go | 2 +- x/ibc/07-tendermint/types/msgs.go | 80 +- x/ibc/07-tendermint/types/msgs_test.go | 16 +- x/ibc/07-tendermint/types/tendermint.pb.go | 1530 ++++++++++++++--- x/ibc/07-tendermint/types/tendermint_test.go | 4 +- x/ibc/07-tendermint/types/test_utils.go | 6 +- x/ibc/07-tendermint/types/update.go | 12 +- x/ibc/07-tendermint/types/update_test.go | 2 +- x/ibc/09-localhost/types/codec.go | 5 - x/ibc/23-commitment/types/codec.go | 24 +- x/ibc/ibc_test.go | 5 +- x/ibc/keeper/keeper_test.go | 34 - .../solomachine/client/cli/tx.go | 4 +- .../solomachine/types/evidence_test.go | 4 +- .../solomachine/types/header_test.go | 8 +- .../solomachine/types/misbehaviour.go | 6 +- x/ibc/light-clients/solomachine/types/msgs.go | 13 +- .../solomachine/types/msgs_test.go | 8 +- .../light-clients/solomachine/types/proof.go | 2 +- .../solomachine/types/solomachine.pb.go | 152 +- .../light-clients/solomachine/types/update.go | 8 +- .../solomachine/types/update_test.go | 6 +- x/ibc/module.go | 11 +- x/ibc/simulation/genesis_test.go | 4 - x/ibc/testing/chain.go | 10 +- x/ibc/testing/solomachine.go | 8 +- x/ibc/types/codec.go | 10 - 41 files changed, 1654 insertions(+), 664 deletions(-) delete mode 100644 x/ibc/keeper/keeper_test.go diff --git a/proto/ibc/lightclients/solomachine/v1/solomachine.proto b/proto/ibc/lightclients/solomachine/v1/solomachine.proto index 23c654263d6a..be46ebc0e6e7 100644 --- a/proto/ibc/lightclients/solomachine/v1/solomachine.proto +++ b/proto/ibc/lightclients/solomachine/v1/solomachine.proto @@ -78,7 +78,7 @@ message MsgCreateClient { message MsgUpdateClient { option (gogoproto.goproto_getters) = false; string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - Header header = 2 [(gogoproto.nullable) = false]; + Header header = 2; } // MsgSubmitClientMisbehaviour defines an sdk.Msg type that supports submitting @@ -87,6 +87,6 @@ message MsgSubmitClientMisbehaviour { option (gogoproto.goproto_getters) = false; bytes submitter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - Evidence evidence = 2 [(gogoproto.nullable) = false]; + Evidence evidence = 2; } diff --git a/proto/ibc/tendermint/tendermint.proto b/proto/ibc/tendermint/tendermint.proto index 129d293f8279..18b1cbaf5ed4 100644 --- a/proto/ibc/tendermint/tendermint.proto +++ b/proto/ibc/tendermint/tendermint.proto @@ -78,12 +78,10 @@ message Evidence { string chain_id = 2 [(gogoproto.moretags) = "yaml:\"chain_id\""]; Header header_1 = 3 [ (gogoproto.customname) = "Header1", - (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"header_1\"" ]; Header header_2 = 4 [ (gogoproto.customname) = "Header2", - (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"header_2\"" ]; } @@ -103,7 +101,6 @@ message Evidence { message Header { .tendermint.types.SignedHeader signed_header = 1 [ (gogoproto.embed) = true, - (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"signed_header\"" ]; @@ -119,3 +116,55 @@ message Fraction { int64 numerator = 1; int64 denominator = 2; } + +// MsgCreateClient defines a message to create a tendermint client. +message MsgCreateClient { + option (gogoproto.goproto_getters) = false; + + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + Header header = 2; + Fraction trust_level = 3 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"trust_level\"" + ]; + google.protobuf.Duration trusting_period = 4 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"trusting_period\"" + ]; + google.protobuf.Duration unbonding_period = 5 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"unbonding_period\"" + ]; + google.protobuf.Duration max_clock_drift = 6 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"max_clock_drift\"" + ]; + repeated ics23.ProofSpec proof_specs = 8 + [(gogoproto.moretags) = "yaml:\"proof_specs\""]; + bytes signer = 7 + [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgCreateClient defines an sdk.Msg to update a tendermint client state to +// the given header. +message MsgUpdateClient { + option (gogoproto.goproto_getters) = false; + + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + Header header = 2; + bytes signer = 3 + [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgSubmitClientMisbehaviour defines an sdk.Msg type that submits Evidence for +// light client misbehaviour. +message MsgSubmitClientMisbehaviour { + option (gogoproto.goproto_getters) = false; + + Evidence evidence = 1; + bytes submitter = 2 + [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} diff --git a/x/ibc/02-client/client/utils/utils.go b/x/ibc/02-client/client/utils/utils.go index 2e1f9cec90c7..7df4a1ea6e19 100644 --- a/x/ibc/02-client/client/utils/utils.go +++ b/x/ibc/02-client/client/utils/utils.go @@ -7,7 +7,8 @@ import ( tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" + + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" @@ -47,8 +48,10 @@ func QueryClientStateABCI( return nil, err } - var clientState exported.ClientState - if err := clientCtx.LegacyAmino.UnmarshalBinaryBare(res.Value, &clientState); err != nil { + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + clientState, err := types.UnmarshalClientState(cdc, res.Value) + if err != nil { return nil, err } @@ -57,7 +60,7 @@ func QueryClientStateABCI( return nil, err } - proofBz, err := clientCtx.LegacyAmino.MarshalBinaryBare(res.ProofOps) + proofBz, err := cdc.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -102,8 +105,10 @@ func QueryConsensusStateABCI( return nil, err } - var cs exported.ConsensusState - if err := clientCtx.LegacyAmino.UnmarshalBinaryBare(res.Value, &cs); err != nil { + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + cs, err := types.UnmarshalConsensusState(cdc, res.Value) + if err != nil { return nil, err } @@ -112,7 +117,7 @@ func QueryConsensusStateABCI( return nil, err } - proofBz, err := clientCtx.LegacyAmino.MarshalBinaryBare(res.ProofOps) + proofBz, err := cdc.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -155,7 +160,7 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctmtypes.Header, int64, } header := ibctmtypes.Header{ - SignedHeader: *protoCommit, + SignedHeader: protoCommit, ValidatorSet: protoValset, } diff --git a/x/ibc/02-client/keeper/client_test.go b/x/ibc/02-client/keeper/client_test.go index d7eecd0aee84..364e64be6449 100644 --- a/x/ibc/02-client/keeper/client_test.go +++ b/x/ibc/02-client/keeper/client_test.go @@ -57,16 +57,16 @@ func (suite *KeeperTestSuite) TestCreateClient() { func (suite *KeeperTestSuite) TestUpdateClientTendermint() { // Must create header creation functions since suite.header gets recreated on each test case - createFutureUpdateFn := func(s *KeeperTestSuite) ibctmtypes.Header { + createFutureUpdateFn := func(s *KeeperTestSuite) *ibctmtypes.Header { return ibctmtypes.CreateTestHeader(testChainID, int64(suite.header.GetHeight()+3), int64(suite.header.GetHeight()), suite.header.Header.Time.Add(time.Hour), suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) } - createPastUpdateFn := func(s *KeeperTestSuite) ibctmtypes.Header { + createPastUpdateFn := func(s *KeeperTestSuite) *ibctmtypes.Header { return ibctmtypes.CreateTestHeader(testChainID, int64(suite.header.GetHeight()-2), int64(suite.header.GetHeight())-4, suite.header.Header.Time, suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) } var ( - updateHeader ibctmtypes.Header + updateHeader *ibctmtypes.Header clientState *ibctmtypes.ClientState ) diff --git a/x/ibc/02-client/keeper/keeper_test.go b/x/ibc/02-client/keeper/keeper_test.go index 2e277b3fa2ea..423fb3136356 100644 --- a/x/ibc/02-client/keeper/keeper_test.go +++ b/x/ibc/02-client/keeper/keeper_test.go @@ -51,7 +51,7 @@ type KeeperTestSuite struct { ctx sdk.Context keeper *keeper.Keeper consensusState *ibctmtypes.ConsensusState - header ibctmtypes.Header + header *ibctmtypes.Header valSet *tmtypes.ValidatorSet valSetHash tmbytes.HexBytes privVal tmtypes.PrivValidator diff --git a/x/ibc/02-client/types/codec.go b/x/ibc/02-client/types/codec.go index 8990b2ffcb25..671be5445ea4 100644 --- a/x/ibc/02-client/types/codec.go +++ b/x/ibc/02-client/types/codec.go @@ -10,16 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" ) -// RegisterCodec registers the IBC client interfaces and types -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterInterface((*exported.ClientState)(nil), nil) // remove after genesis migration - cdc.RegisterInterface((*exported.MsgCreateClient)(nil), nil) - cdc.RegisterInterface((*exported.MsgUpdateClient)(nil), nil) - cdc.RegisterInterface((*exported.ConsensusState)(nil), nil) - cdc.RegisterInterface((*exported.Header)(nil), nil) - cdc.RegisterInterface((*exported.Misbehaviour)(nil), nil) -} - // RegisterInterfaces registers the client interfaces to protobuf Any. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterInterface( @@ -37,22 +27,14 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { } var ( - amino = codec.New() - // SubModuleCdc references the global x/ibc/02-client module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. + // ONLY be used in certain instances of tests and for JSON encoding. // // The actual codec used for serialization should be provided to x/ibc/02-client and // defined at the application level. SubModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) ) -func init() { - RegisterCodec(amino) - amino.Seal() -} - // PackClientState constructs a new Any packed with the given client state value. It returns // an error if the client state can't be casted to a protobuf message or if the concrete // implemention is not registered to the protobuf codec. diff --git a/x/ibc/03-connection/client/utils/utils.go b/x/ibc/03-connection/client/utils/utils.go index 2b13f2c6c834..d22bb03f19fa 100644 --- a/x/ibc/03-connection/client/utils/utils.go +++ b/x/ibc/03-connection/client/utils/utils.go @@ -49,12 +49,14 @@ func queryConnectionABCI(clientCtx client.Context, connectionID string) (*types. return nil, err } + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + var connection types.ConnectionEnd - if err := clientCtx.LegacyAmino.UnmarshalBinaryBare(res.Value, &connection); err != nil { + if err := cdc.UnmarshalBinaryBare(res.Value, &connection); err != nil { return nil, err } - proofBz, err := clientCtx.LegacyAmino.MarshalBinaryBare(res.ProofOps) + proofBz, err := cdc.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -92,12 +94,14 @@ func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*typ return nil, err } + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + var paths []string if err := clientCtx.LegacyAmino.UnmarshalBinaryBare(res.Value, &paths); err != nil { return nil, err } - proofBz, err := clientCtx.LegacyAmino.MarshalBinaryBare(res.ProofOps) + proofBz, err := cdc.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } diff --git a/x/ibc/04-channel/client/utils/utils.go b/x/ibc/04-channel/client/utils/utils.go index 17a1f74b9d05..856173639db8 100644 --- a/x/ibc/04-channel/client/utils/utils.go +++ b/x/ibc/04-channel/client/utils/utils.go @@ -7,6 +7,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" clientutils "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" @@ -49,7 +50,9 @@ func queryPacketCommitmentABCI( return nil, err } - proofBz, err := clientCtx.LegacyAmino.MarshalBinaryBare(res.ProofOps) + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + proofBz, err := cdc.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -90,12 +93,14 @@ func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*type return nil, err } + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + var channel types.Channel - if err := clientCtx.LegacyAmino.UnmarshalBinaryBare(res.Value, &channel); err != nil { + if err := cdc.UnmarshalBinaryBare(res.Value, &channel); err != nil { return nil, err } - proofBz, err := clientCtx.LegacyAmino.MarshalBinaryBare(res.ProofOps) + proofBz, err := cdc.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -229,7 +234,9 @@ func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID strin return nil, err } - proofBz, err := clientCtx.LegacyAmino.MarshalBinaryBare(res.ProofOps) + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + proofBz, err := cdc.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } diff --git a/x/ibc/07-tendermint/client/cli/tx.go b/x/ibc/07-tendermint/client/cli/tx.go index 75b6e0c81447..a8fbe0c98f12 100644 --- a/x/ibc/07-tendermint/client/cli/tx.go +++ b/x/ibc/07-tendermint/client/cli/tx.go @@ -15,9 +15,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/version" - evidenceexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" - ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) @@ -35,7 +35,7 @@ func NewCreateClientCmd() *cobra.Command { Long: `Create a new tendermint IBC client. - 'trust-level' flag can be a fraction (eg: '1/3') or 'default' - 'proof-specs' flag can be JSON input, a path to a .json file or 'default'`, - Example: fmt.Sprintf("%s tx ibc %s create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift] --trust-level default --proof-specs [path/to/proof-specs.json] --from node0 --home ../node0/cli --chain-id $CID", version.AppName, ibctmtypes.SubModuleName), + Example: fmt.Sprintf("%s tx ibc %s create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift] --trust-level default --proof-specs [path/to/proof-specs.json] --from node0 --home ../node0/cli --chain-id $CID", version.AppName, types.SubModuleName), Args: cobra.ExactArgs(5), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -46,27 +46,29 @@ func NewCreateClientCmd() *cobra.Command { clientID := args[0] - var header ibctmtypes.Header - if err := clientCtx.LegacyAmino.UnmarshalJSON([]byte(args[1]), &header); err != nil { + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + var header *types.Header + if err := cdc.UnmarshalJSON([]byte(args[1]), &header); err != nil { // check for file path if JSON input is not provided contents, err := ioutil.ReadFile(args[1]) if err != nil { return errors.New("neither JSON input nor path to .json file were provided for consensus header") } - if err := clientCtx.LegacyAmino.UnmarshalJSON(contents, &header); err != nil { + if err := cdc.UnmarshalJSON(contents, &header); err != nil { return errors.Wrap(err, "error unmarshalling consensus header file") } } var ( - trustLevel ibctmtypes.Fraction + trustLevel types.Fraction specs []*ics23.ProofSpec ) lvl, _ := cmd.Flags().GetString(flagTrustLevel) if lvl == "default" { - trustLevel = ibctmtypes.NewFractionFromTm(light.DefaultTrustLevel) + trustLevel = types.NewFractionFromTm(light.DefaultTrustLevel) } else { trustLevel, err = parseFraction(lvl) if err != nil { @@ -92,18 +94,18 @@ func NewCreateClientCmd() *cobra.Command { spc, _ := cmd.Flags().GetString(flagProofSpecs) if spc == "default" { specs = commitmenttypes.GetSDKSpecs() - } else if err := clientCtx.LegacyAmino.UnmarshalJSON([]byte(spc), &specs); err != nil { + } else if err := cdc.UnmarshalJSON([]byte(spc), &specs); err != nil { // check for file path if JSON input not provided contents, err := ioutil.ReadFile(spc) if err != nil { return errors.New("neither JSON input nor path to .json file was provided for proof specs flag") } - if err := clientCtx.LegacyAmino.UnmarshalJSON(contents, &specs); err != nil { + if err := cdc.UnmarshalJSON(contents, &specs); err != nil { return errors.Wrap(err, "error unmarshalling proof specs file") } } - msg := ibctmtypes.NewMsgCreateClient( + msg := types.NewMsgCreateClient( clientID, header, trustLevel, trustingPeriod, ubdPeriod, maxClockDrift, specs, clientCtx.GetFromAddress(), ) @@ -131,7 +133,7 @@ func NewUpdateClientCmd() *cobra.Command { Long: "update existing tendermint client with a tendermint header", Example: fmt.Sprintf( "$ %s tx ibc %s update [client-id] [path/to/header.json] --from node0 --home ../node0/cli --chain-id $CID", - version.AppName, ibctmtypes.SubModuleName, + version.AppName, types.SubModuleName, ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -143,19 +145,21 @@ func NewUpdateClientCmd() *cobra.Command { clientID := args[0] - var header ibctmtypes.Header - if err := clientCtx.LegacyAmino.UnmarshalJSON([]byte(args[1]), &header); err != nil { + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + var header *types.Header + if err := cdc.UnmarshalJSON([]byte(args[1]), &header); err != nil { // check for file path if JSON input is not provided contents, err := ioutil.ReadFile(args[1]) if err != nil { return errors.New("neither JSON input nor path to .json file were provided") } - if err := clientCtx.LegacyAmino.UnmarshalJSON(contents, &header); err != nil { + if err := cdc.UnmarshalJSON(contents, &header); err != nil { return errors.Wrap(err, "error unmarshalling header file") } } - msg := ibctmtypes.NewMsgUpdateClient(clientID, header, clientCtx.GetFromAddress()) + msg := types.NewMsgUpdateClient(clientID, header, clientCtx.GetFromAddress()) if err := msg.ValidateBasic(); err != nil { return err } @@ -179,7 +183,7 @@ func NewSubmitMisbehaviourCmd() *cobra.Command { Long: "submit a client misbehaviour to invalidate to invalidate previous state roots and prevent future updates", Example: fmt.Sprintf( "$ %s tx ibc %s misbehaviour [path/to/evidence.json] --from node0 --home ../node0/cli --chain-id $CID", - version.AppName, ibctmtypes.SubModuleName, + version.AppName, types.SubModuleName, ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -189,19 +193,21 @@ func NewSubmitMisbehaviourCmd() *cobra.Command { return err } - var ev evidenceexported.Evidence - if err := clientCtx.LegacyAmino.UnmarshalJSON([]byte(args[0]), &ev); err != nil { + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + var ev *types.Evidence + if err := cdc.UnmarshalJSON([]byte(args[0]), &ev); err != nil { // check for file path if JSON input is not provided contents, err := ioutil.ReadFile(args[0]) if err != nil { return errors.New("neither JSON input nor path to .json file were provided") } - if err := clientCtx.LegacyAmino.UnmarshalJSON(contents, &ev); err != nil { + if err := cdc.UnmarshalJSON(contents, &ev); err != nil { return errors.Wrap(err, "error unmarshalling evidence file") } } - msg := ibctmtypes.NewMsgSubmitClientMisbehaviour(ev, clientCtx.GetFromAddress()) + msg := types.NewMsgSubmitClientMisbehaviour(ev, clientCtx.GetFromAddress()) if err := msg.ValidateBasic(); err != nil { return err } @@ -215,24 +221,25 @@ func NewSubmitMisbehaviourCmd() *cobra.Command { return cmd } -func parseFraction(fraction string) (ibctmtypes.Fraction, error) { +func parseFraction(fraction string) (types.Fraction, error) { fr := strings.Split(fraction, "/") if len(fr) != 2 || fr[0] == fraction { - return ibctmtypes.Fraction{}, fmt.Errorf("fraction must have format 'numerator/denominator' got %s", fraction) + return types.Fraction{}, fmt.Errorf("fraction must have format 'numerator/denominator' got %s", fraction) } numerator, err := strconv.ParseInt(fr[0], 10, 64) if err != nil { - return ibctmtypes.Fraction{}, fmt.Errorf("invalid trust-level numerator: %w", err) + return types.Fraction{}, fmt.Errorf("invalid trust-level numerator: %w", err) } denominator, err := strconv.ParseInt(fr[1], 10, 64) if err != nil { - return ibctmtypes.Fraction{}, fmt.Errorf("invalid trust-level denominator: %w", err) + return types.Fraction{}, fmt.Errorf("invalid trust-level denominator: %w", err) } - return ibctmtypes.Fraction{ + return types.Fraction{ Numerator: numerator, Denominator: denominator, }, nil + } diff --git a/x/ibc/07-tendermint/types/codec.go b/x/ibc/07-tendermint/types/codec.go index 1daacf1dfba0..c10bc49dff9f 100644 --- a/x/ibc/07-tendermint/types/codec.go +++ b/x/ibc/07-tendermint/types/codec.go @@ -3,23 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" evidenceexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" ) -// RegisterCodec registers the necessary x/ibc/07-tendermint interfaces and conrete types -// on the provided Amino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(ClientState{}, "ibc/client/tendermint/ClientState", nil) - cdc.RegisterConcrete(ConsensusState{}, "ibc/client/tendermint/ConsensusState", nil) - cdc.RegisterConcrete(Header{}, "ibc/client/tendermint/Header", nil) - cdc.RegisterConcrete(Evidence{}, "ibc/client/tendermint/Evidence", nil) - cdc.RegisterConcrete(&MsgCreateClient{}, "ibc/client/tendermint/MsgCreateClient", nil) - cdc.RegisterConcrete(&MsgUpdateClient{}, "ibc/client/tendermint/MsgUpdateClient", nil) - cdc.RegisterConcrete(&MsgSubmitClientMisbehaviour{}, "ibc/client/tendermint/MsgSubmitClientMisbehaviour", nil) -} - // RegisterInterfaces registers the tendermint concrete evidence and client-related // implementations and interfaces. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { @@ -38,19 +25,10 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { } var ( - amino = codec.New() - // SubModuleCdc references the global x/ibc/07-tendermint module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. + // ONLY be used in certain instances of tests and for JSON encoding. // // The actual codec used for serialization should be provided to x/ibc/07-tendermint and // defined at the application level. SubModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) ) - -func init() { - cryptocodec.RegisterCrypto(amino) - RegisterCodec(amino) - amino.Seal() -} diff --git a/x/ibc/07-tendermint/types/evidence.go b/x/ibc/07-tendermint/types/evidence.go index c69be74237e7..ddcadf35d65a 100644 --- a/x/ibc/07-tendermint/types/evidence.go +++ b/x/ibc/07-tendermint/types/evidence.go @@ -24,7 +24,7 @@ var ( ) // NewEvidence creates a new Evidence instance. -func NewEvidence(clientID, chainID string, header1, header2 Header) *Evidence { +func NewEvidence(clientID, chainID string, header1, header2 *Header) *Evidence { return &Evidence{ ClientId: clientID, ChainId: chainID, @@ -87,6 +87,12 @@ func (ev Evidence) GetTime() time.Time { // ValidateBasic implements Evidence interface func (ev Evidence) ValidateBasic() error { + if ev.Header1 == nil { + return sdkerrors.Wrap(ErrInvalidHeader, "evidence Header1 cannot be nil") + } + if ev.Header2 == nil { + return sdkerrors.Wrap(ErrInvalidHeader, "evidence Header2 cannot be nil") + } if ev.Header1.TrustedHeight == 0 { return sdkerrors.Wrap(ErrInvalidHeaderHeight, "evidence Header1 must have non-zero trusted height") } diff --git a/x/ibc/07-tendermint/types/evidence_test.go b/x/ibc/07-tendermint/types/evidence_test.go index 465e90928e4a..3d0fa44832d7 100644 --- a/x/ibc/07-tendermint/types/evidence_test.go +++ b/x/ibc/07-tendermint/types/evidence_test.go @@ -10,15 +10,14 @@ import ( clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" ) func (suite *TendermintTestSuite) TestEvidence() { signers := []tmtypes.PrivValidator{suite.privVal} - ev := &ibctmtypes.Evidence{ + ev := &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now, suite.valSet, suite.valSet, signers), + Header2: types.CreateTestHeader(chainID, height, height-1, suite.now, suite.valSet, suite.valSet, signers), ChainId: chainID, ClientId: clientID, } @@ -53,140 +52,153 @@ func (suite *TendermintTestSuite) TestEvidenceValidateBasic() { testCases := []struct { name string - evidence *ibctmtypes.Evidence - malleateEvidence func(ev *ibctmtypes.Evidence) error + evidence *types.Evidence + malleateEvidence func(ev *types.Evidence) error expPass bool }{ { "valid evidence", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), + Header2: types.CreateTestHeader(chainID, height, height-1, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, true, }, + { + "evidence Header1 is nil", + types.NewEvidence(clientID, chainID, nil, suite.header), + func(ev *types.Evidence) error { return nil }, + false, + }, + { + "evidence Header2 is nil", + types.NewEvidence(clientID, chainID, suite.header, nil), + func(ev *types.Evidence) error { return nil }, + false, + }, + { "valid evidence with different trusted headers", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, height-3, suite.now.Add(time.Minute), suite.valSet, bothValSet, signers), + Header2: types.CreateTestHeader(chainID, height, height-3, suite.now.Add(time.Minute), suite.valSet, bothValSet, signers), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, true, }, { "trusted height is 0 in Header1", - &ibctmtypes.Evidence{ - Header1: ibctmtypes.CreateTestHeader(chainID, height, 0, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), + &types.Evidence{ + Header1: types.CreateTestHeader(chainID, height, 0, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), Header2: suite.header, ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "trusted height is 0 in Header2", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, 0, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), + Header2: types.CreateTestHeader(chainID, height, 0, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "trusted valset is nil in Header1", - &ibctmtypes.Evidence{ - Header1: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now.Add(time.Minute), suite.valSet, nil, signers), + &types.Evidence{ + Header1: types.CreateTestHeader(chainID, height, height-1, suite.now.Add(time.Minute), suite.valSet, nil, signers), Header2: suite.header, ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "trusted valset is nil in Header2", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now.Add(time.Minute), suite.valSet, nil, signers), + Header2: types.CreateTestHeader(chainID, height, height-1, suite.now.Add(time.Minute), suite.valSet, nil, signers), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "invalid client ID ", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now, suite.valSet, suite.valSet, signers), + Header2: types.CreateTestHeader(chainID, height, height-1, suite.now, suite.valSet, suite.valSet, signers), ChainId: chainID, ClientId: "GAIA", }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "wrong chainID on header1", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader("ethermint", height, height-1, suite.now, suite.valSet, suite.valSet, signers), + Header2: types.CreateTestHeader("ethermint", height, height-1, suite.now, suite.valSet, suite.valSet, signers), ChainId: "ethermint", ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "wrong chainID on header2", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader("ethermint", height, height-1, suite.now, suite.valSet, suite.valSet, signers), + Header2: types.CreateTestHeader("ethermint", height, height-1, suite.now, suite.valSet, suite.valSet, signers), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "mismatched heights", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, 6, 4, suite.now, suite.valSet, suite.valSet, signers), + Header2: types.CreateTestHeader(chainID, 6, 4, suite.now, suite.valSet, suite.valSet, signers), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "same block id", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, Header2: suite.header, ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { return nil }, + func(ev *types.Evidence) error { return nil }, false, }, { "header 1 doesn't have 2/3 majority", - &ibctmtypes.Evidence{ - Header1: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now, bothValSet, suite.valSet, bothSigners), + &types.Evidence{ + Header1: types.CreateTestHeader(chainID, height, height-1, suite.now, bothValSet, suite.valSet, bothSigners), Header2: suite.header, ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { + func(ev *types.Evidence) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(ev.Header1.GetHeight()), 1, tmproto.PrecommitType, altValSet) blockID, err := tmtypes.BlockIDFromProto(&ev.Header1.Commit.BlockID) @@ -202,13 +214,13 @@ func (suite *TendermintTestSuite) TestEvidenceValidateBasic() { }, { "header 2 doesn't have 2/3 majority", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now, bothValSet, suite.valSet, bothSigners), + Header2: types.CreateTestHeader(chainID, height, height-1, suite.now, bothValSet, suite.valSet, bothSigners), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { + func(ev *types.Evidence) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(ev.Header2.GetHeight()), 1, tmproto.PrecommitType, altValSet) blockID, err := tmtypes.BlockIDFromProto(&ev.Header2.Commit.BlockID) @@ -224,14 +236,14 @@ func (suite *TendermintTestSuite) TestEvidenceValidateBasic() { }, { "validators sign off on wrong commit", - &ibctmtypes.Evidence{ + &types.Evidence{ Header1: suite.header, - Header2: ibctmtypes.CreateTestHeader(chainID, height, height-1, suite.now, bothValSet, suite.valSet, bothSigners), + Header2: types.CreateTestHeader(chainID, height, height-1, suite.now, bothValSet, suite.valSet, bothSigners), ChainId: chainID, ClientId: clientID, }, - func(ev *ibctmtypes.Evidence) error { - tmBlockID := ibctmtypes.MakeBlockID(tmhash.Sum([]byte("other_hash")), 3, tmhash.Sum([]byte("other_partset"))) + func(ev *types.Evidence) error { + tmBlockID := types.MakeBlockID(tmhash.Sum([]byte("other_hash")), 3, tmhash.Sum([]byte("other_partset"))) ev.Header2.Commit.BlockID = tmBlockID.ToProto() return nil }, diff --git a/x/ibc/07-tendermint/types/header.go b/x/ibc/07-tendermint/types/header.go index aa732e9d697f..d69361edaa26 100644 --- a/x/ibc/07-tendermint/types/header.go +++ b/x/ibc/07-tendermint/types/header.go @@ -55,10 +55,13 @@ func (h Header) GetTime() time.Time { // NOTE: TrustedHeight and TrustedValidators may be empty when creating client // with MsgCreateClient func (h Header) ValidateBasic(chainID string) error { + if h.SignedHeader == nil { + return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "tendermint signed header cannot be nil") + } if h.Header == nil { return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "tendermint header cannot be nil") } - tmSignedHeader, err := tmtypes.SignedHeaderFromProto(&h.SignedHeader) + tmSignedHeader, err := tmtypes.SignedHeaderFromProto(h.SignedHeader) if err != nil { return sdkerrors.Wrap(err, "header is not a tendermint header") } diff --git a/x/ibc/07-tendermint/types/header_test.go b/x/ibc/07-tendermint/types/header_test.go index 3b3176a56289..bd8dd2221bfc 100644 --- a/x/ibc/07-tendermint/types/header_test.go +++ b/x/ibc/07-tendermint/types/header_test.go @@ -25,7 +25,7 @@ func (suite *TendermintTestSuite) TestGetTime() { func (suite *TendermintTestSuite) TestHeaderValidateBasic() { var ( - header types.Header + header *types.Header chainID string ) testCases := []struct { @@ -34,9 +34,12 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { expPass bool }{ {"valid header", func() {}, true}, - {"signed header is nil", func() { + {"header is nil", func() { header.Header = nil }, false}, + {"signed header is nil", func() { + header.SignedHeader = nil + }, false}, {"signed header failed tendermint ValidateBasic", func() { header = suite.chainA.LastHeader chainID = "chainid" @@ -59,6 +62,8 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { tc := tc suite.Run(tc.name, func() { + suite.SetupTest() + chainID = suite.chainA.ChainID // must be explicitly changed in malleate header = suite.chainA.LastHeader // must be explicitly changed in malleate diff --git a/x/ibc/07-tendermint/types/misbehaviour.go b/x/ibc/07-tendermint/types/misbehaviour.go index 4f18b3842d8c..3f5957cb01c5 100644 --- a/x/ibc/07-tendermint/types/misbehaviour.go +++ b/x/ibc/07-tendermint/types/misbehaviour.go @@ -103,7 +103,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( // checkMisbehaviourHeader checks that a Header in Misbehaviour is valid evidence given // a trusted ConsensusState func checkMisbehaviourHeader( - clientState *ClientState, consState *ConsensusState, header Header, currentTimestamp time.Time, + clientState *ClientState, consState *ConsensusState, header *Header, currentTimestamp time.Time, ) error { tmTrustedValset, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) diff --git a/x/ibc/07-tendermint/types/msgs.go b/x/ibc/07-tendermint/types/msgs.go index c6b32e598364..44cd756f2ea0 100644 --- a/x/ibc/07-tendermint/types/msgs.go +++ b/x/ibc/07-tendermint/types/msgs.go @@ -21,35 +21,15 @@ var ( _ evidenceexported.MsgSubmitEvidence = (*MsgSubmitClientMisbehaviour)(nil) ) -// MsgCreateClient defines a message to create an IBC client -type MsgCreateClient struct { - ClientID string `json:"client_id" yaml:"client_id"` - Header Header `json:"header" yaml:"header"` - TrustLevel Fraction `json:"trust_level" yaml:"trust_level"` - TrustingPeriod time.Duration `json:"trusting_period" yaml:"trusting_period"` - UnbondingPeriod time.Duration `json:"unbonding_period" yaml:"unbonding_period"` - MaxClockDrift time.Duration `json:"max_clock_drift" yaml:"max_clock_drift"` - ProofSpecs []*ics23.ProofSpec `json:"proof_specs" yaml:"proof_specs"` - Signer sdk.AccAddress `json:"address" yaml:"address"` -} - -// this is a constant to satisfy the linter -const TODO = "TODO" - -// dummy implementation of proto.Message -func (msg *MsgCreateClient) Reset() {} -func (msg *MsgCreateClient) String() string { return TODO } -func (msg *MsgCreateClient) ProtoMessage() {} - // NewMsgCreateClient creates a new MsgCreateClient instance func NewMsgCreateClient( - id string, header Header, trustLevel Fraction, + id string, header *Header, trustLevel Fraction, trustingPeriod, unbondingPeriod, maxClockDrift time.Duration, specs []*ics23.ProofSpec, signer sdk.AccAddress, ) *MsgCreateClient { return &MsgCreateClient{ - ClientID: id, + ClientId: id, Header: header, TrustLevel: trustLevel, TrustingPeriod: trustingPeriod, @@ -84,7 +64,8 @@ func (msg MsgCreateClient) ValidateBasic() error { if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress } - if msg.Header.SignedHeader.Header == nil { + + if msg.Header == nil || msg.Header.SignedHeader == nil || msg.Header.SignedHeader.Header == nil { return sdkerrors.Wrap(ErrInvalidHeader, "header cannot be nil") } // ValidateBasic of provided header with self-attested chain-id @@ -106,12 +87,12 @@ func (msg MsgCreateClient) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidProofSpecs, "proof spec cannot be nil") } } - return host.ClientIdentifierValidator(msg.ClientID) + return host.ClientIdentifierValidator(msg.ClientId) } // GetSignBytes implements sdk.Msg func (msg MsgCreateClient) GetSignBytes() []byte { - return sdk.MustSortJSON(SubModuleCdc.MustMarshalJSON(msg)) + return sdk.MustSortJSON(SubModuleCdc.MustMarshalJSON(&msg)) } // GetSigners implements sdk.Msg @@ -121,7 +102,7 @@ func (msg MsgCreateClient) GetSigners() []sdk.AccAddress { // GetClientID implements clientexported.MsgCreateClient func (msg MsgCreateClient) GetClientID() string { - return msg.ClientID + return msg.ClientId } // GetClientType implements clientexported.MsgCreateClient @@ -149,22 +130,10 @@ func (msg MsgCreateClient) InitializeClientState() clientexported.ClientState { ) } -// MsgUpdateClient defines a message to update an IBC client -type MsgUpdateClient struct { - ClientID string `json:"client_id" yaml:"client_id"` - Header Header `json:"header" yaml:"header"` - Signer sdk.AccAddress `json:"address" yaml:"address"` -} - -// dummy implementation of proto.Message -func (msg *MsgUpdateClient) Reset() {} -func (msg *MsgUpdateClient) String() string { return TODO } -func (msg *MsgUpdateClient) ProtoMessage() {} - // NewMsgUpdateClient creates a new MsgUpdateClient instance -func NewMsgUpdateClient(id string, header Header, signer sdk.AccAddress) *MsgUpdateClient { +func NewMsgUpdateClient(id string, header *Header, signer sdk.AccAddress) *MsgUpdateClient { return &MsgUpdateClient{ - ClientID: id, + ClientId: id, Header: header, Signer: signer, } @@ -185,12 +154,19 @@ func (msg MsgUpdateClient) ValidateBasic() error { if msg.Signer.Empty() { return sdkerrors.ErrInvalidAddress } - return host.ClientIdentifierValidator(msg.ClientID) + if msg.Header == nil || msg.Header.SignedHeader == nil || msg.Header.Header == nil { + return sdkerrors.Wrap(ErrInvalidHeader, "header cannot be nil") + } + // ValidateBasic of provided header with self-attested chain-id + if err := msg.Header.ValidateBasic(msg.Header.Header.GetChainID()); err != nil { + return err + } + return host.ClientIdentifierValidator(msg.ClientId) } // GetSignBytes implements sdk.Msg func (msg MsgUpdateClient) GetSignBytes() []byte { - return sdk.MustSortJSON(SubModuleCdc.MustMarshalJSON(msg)) + return sdk.MustSortJSON(SubModuleCdc.MustMarshalJSON(&msg)) } // GetSigners implements sdk.Msg @@ -200,7 +176,7 @@ func (msg MsgUpdateClient) GetSigners() []sdk.AccAddress { // GetClientID implements clientexported.MsgUpdateClient func (msg MsgUpdateClient) GetClientID() string { - return msg.ClientID + return msg.ClientId } // GetHeader implements clientexported.MsgUpdateClient @@ -208,22 +184,10 @@ func (msg MsgUpdateClient) GetHeader() clientexported.Header { return msg.Header } -// MsgSubmitClientMisbehaviour defines an sdk.Msg type that supports submitting -// Evidence for client misbehaviour. -type MsgSubmitClientMisbehaviour struct { - Evidence evidenceexported.Evidence `json:"evidence" yaml:"evidence"` - Submitter sdk.AccAddress `json:"submitter" yaml:"submitter"` -} - -// dummy implementation of proto.Message -func (msg MsgSubmitClientMisbehaviour) Reset() {} -func (msg MsgSubmitClientMisbehaviour) String() string { return TODO } -func (msg MsgSubmitClientMisbehaviour) ProtoMessage() {} - // NewMsgSubmitClientMisbehaviour creates a new MsgSubmitClientMisbehaviour // instance. -func NewMsgSubmitClientMisbehaviour(e evidenceexported.Evidence, s sdk.AccAddress) MsgSubmitClientMisbehaviour { - return MsgSubmitClientMisbehaviour{Evidence: e, Submitter: s} +func NewMsgSubmitClientMisbehaviour(e *Evidence, s sdk.AccAddress) *MsgSubmitClientMisbehaviour { + return &MsgSubmitClientMisbehaviour{Evidence: e, Submitter: s} } // Route returns the MsgSubmitClientMisbehaviour's route. @@ -252,7 +216,7 @@ func (msg MsgSubmitClientMisbehaviour) ValidateBasic() error { // GetSignBytes returns the raw bytes a signer is expected to sign when submitting // a MsgSubmitClientMisbehaviour message. func (msg MsgSubmitClientMisbehaviour) GetSignBytes() []byte { - return sdk.MustSortJSON(SubModuleCdc.MustMarshalJSON(msg)) + return sdk.MustSortJSON(SubModuleCdc.MustMarshalJSON(&msg)) } // GetSigners returns the single expected signer for a MsgSubmitClientMisbehaviour. diff --git a/x/ibc/07-tendermint/types/msgs_test.go b/x/ibc/07-tendermint/types/msgs_test.go index 3322aa906c2e..0cab73d33751 100644 --- a/x/ibc/07-tendermint/types/msgs_test.go +++ b/x/ibc/07-tendermint/types/msgs_test.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" types "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func (suite *TendermintTestSuite) TestMsgCreateClientValidateBasic() { @@ -28,7 +29,10 @@ func (suite *TendermintTestSuite) TestMsgCreateClientValidateBasic() { {types.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, types.DefaultTrustLevel, 0, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "zero trusting period passed"}, {types.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, types.DefaultTrustLevel, trustingPeriod, 0, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "zero unbonding period passed"}, {types.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), nil), false, "Empty address passed"}, - {types.NewMsgCreateClient(exported.ClientTypeTendermint, types.Header{}, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "nil header"}, + {types.NewMsgCreateClient(exported.ClientTypeTendermint, &types.Header{}, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "empty header"}, + {types.NewMsgCreateClient(exported.ClientTypeTendermint, nil, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "nil header"}, + {types.NewMsgCreateClient(exported.ClientTypeTendermint, &types.Header{SignedHeader: nil}, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "nil header"}, + {types.NewMsgCreateClient(exported.ClientTypeTendermint, &types.Header{SignedHeader: &tmproto.SignedHeader{Header: nil}}, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "nil header"}, {types.NewMsgCreateClient(exported.ClientTypeTendermint, invalidHeader, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, commitmenttypes.GetSDKSpecs(), signer), false, "invalid header"}, {types.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, []*ics23.ProofSpec{nil}, signer), false, "invalid proof specs"}, {types.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, nil, signer), false, "nil proof specs"}, @@ -54,9 +58,13 @@ func (suite *TendermintTestSuite) TestMsgUpdateClient() { expPass bool errMsg string }{ - {types.NewMsgUpdateClient(exported.ClientTypeTendermint, types.Header{}, signer), true, "success msg should pass"}, - {types.NewMsgUpdateClient("(badClient)", types.Header{}, signer), false, "invalid client id passed"}, - {types.NewMsgUpdateClient(exported.ClientTypeTendermint, types.Header{}, nil), false, "Empty address passed"}, + {types.NewMsgUpdateClient(exported.ClientTypeTendermint, suite.header, signer), true, "success msg should pass"}, + {types.NewMsgUpdateClient("(badClient)", &types.Header{}, signer), false, "invalid client id passed"}, + {types.NewMsgUpdateClient(exported.ClientTypeTendermint, suite.header, nil), false, "Empty address passed"}, + {types.NewMsgUpdateClient(exported.ClientTypeTendermint, &types.Header{}, nil), false, "empty Header"}, + {types.NewMsgUpdateClient(exported.ClientTypeTendermint, nil, nil), false, "nil header"}, + {types.NewMsgUpdateClient(exported.ClientTypeTendermint, &types.Header{SignedHeader: nil}, nil), false, "nil signed header"}, + {types.NewMsgUpdateClient(exported.ClientTypeTendermint, &types.Header{SignedHeader: &tmproto.SignedHeader{Header: nil}}, nil), false, "nil tendermint header"}, } for i, tc := range cases { diff --git a/x/ibc/07-tendermint/types/tendermint.pb.go b/x/ibc/07-tendermint/types/tendermint.pb.go index d46ac1dd004e..cb10f0a822ab 100644 --- a/x/ibc/07-tendermint/types/tendermint.pb.go +++ b/x/ibc/07-tendermint/types/tendermint.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" _go "github.com/confio/ics23/go" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -130,13 +131,13 @@ func (m *ConsensusState) XXX_DiscardUnknown() { var xxx_messageInfo_ConsensusState proto.InternalMessageInfo -// Evidence is a wrapper over tendermint's DuplicateVoteEvidence +// Evidence is a wrapper over two conflicting Headers // that implements Evidence interface expected by ICS-02 type Evidence struct { - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" yaml:"chain_id"` - Header1 Header `protobuf:"bytes,3,opt,name=header_1,json=header1,proto3" json:"header_1" yaml:"header_1"` - Header2 Header `protobuf:"bytes,4,opt,name=header_2,json=header2,proto3" json:"header_2" yaml:"header_2"` + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" yaml:"chain_id"` + Header1 *Header `protobuf:"bytes,3,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty" yaml:"header_1"` + Header2 *Header `protobuf:"bytes,4,opt,name=header_2,json=header2,proto3" json:"header_2,omitempty" yaml:"header_2"` } func (m *Evidence) Reset() { *m = Evidence{} } @@ -184,10 +185,10 @@ var xxx_messageInfo_Evidence proto.InternalMessageInfo // hash to TrustedConsensusState.NextValidatorsHash since that is the last // trusted validator set at the TrustedHeight. type Header struct { - types1.SignedHeader `protobuf:"bytes,1,opt,name=signed_header,json=signedHeader,proto3,embedded=signed_header" json:"signed_header" yaml:"signed_header"` - ValidatorSet *types1.ValidatorSet `protobuf:"bytes,2,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty" yaml:"validator_set"` - TrustedHeight uint64 `protobuf:"varint,3,opt,name=trusted_height,json=trustedHeight,proto3" json:"trusted_height,omitempty" yaml:"trusted_height"` - TrustedValidators *types1.ValidatorSet `protobuf:"bytes,4,opt,name=trusted_validators,json=trustedValidators,proto3" json:"trusted_validators,omitempty" yaml:"trusted_validators"` + *types1.SignedHeader `protobuf:"bytes,1,opt,name=signed_header,json=signedHeader,proto3,embedded=signed_header" json:"signed_header,omitempty" yaml:"signed_header"` + ValidatorSet *types1.ValidatorSet `protobuf:"bytes,2,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty" yaml:"validator_set"` + TrustedHeight uint64 `protobuf:"varint,3,opt,name=trusted_height,json=trustedHeight,proto3" json:"trusted_height,omitempty" yaml:"trusted_height"` + TrustedValidators *types1.ValidatorSet `protobuf:"bytes,4,opt,name=trusted_validators,json=trustedValidators,proto3" json:"trusted_validators,omitempty" yaml:"trusted_validators"` } func (m *Header) Reset() { *m = Header{} } @@ -297,78 +298,216 @@ func (m *Fraction) GetDenominator() int64 { return 0 } +// MsgCreateClient defines a message to create a tendermint client. +type MsgCreateClient struct { + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + Header *Header `protobuf:"bytes,2,opt,name=header,proto3" json:"header,omitempty"` + TrustLevel Fraction `protobuf:"bytes,3,opt,name=trust_level,json=trustLevel,proto3" json:"trust_level" yaml:"trust_level"` + TrustingPeriod time.Duration `protobuf:"bytes,4,opt,name=trusting_period,json=trustingPeriod,proto3,stdduration" json:"trusting_period" yaml:"trusting_period"` + UnbondingPeriod time.Duration `protobuf:"bytes,5,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period" yaml:"unbonding_period"` + MaxClockDrift time.Duration `protobuf:"bytes,6,opt,name=max_clock_drift,json=maxClockDrift,proto3,stdduration" json:"max_clock_drift" yaml:"max_clock_drift"` + ProofSpecs []*_go.ProofSpec `protobuf:"bytes,8,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty" yaml:"proof_specs"` + Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,7,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` +} + +func (m *MsgCreateClient) Reset() { *m = MsgCreateClient{} } +func (m *MsgCreateClient) String() string { return proto.CompactTextString(m) } +func (*MsgCreateClient) ProtoMessage() {} +func (*MsgCreateClient) Descriptor() ([]byte, []int) { + return fileDescriptor_76a953d5a747dd66, []int{5} +} +func (m *MsgCreateClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateClient.Merge(m, src) +} +func (m *MsgCreateClient) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateClient) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateClient.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateClient proto.InternalMessageInfo + +// MsgCreateClient defines an sdk.Msg to update a tendermint client state to +// the given header. +type MsgUpdateClient struct { + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + Header *Header `protobuf:"bytes,2,opt,name=header,proto3" json:"header,omitempty"` + Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,3,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` +} + +func (m *MsgUpdateClient) Reset() { *m = MsgUpdateClient{} } +func (m *MsgUpdateClient) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateClient) ProtoMessage() {} +func (*MsgUpdateClient) Descriptor() ([]byte, []int) { + return fileDescriptor_76a953d5a747dd66, []int{6} +} +func (m *MsgUpdateClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateClient.Merge(m, src) +} +func (m *MsgUpdateClient) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateClient) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateClient.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateClient proto.InternalMessageInfo + +// MsgSubmitClientMisbehaviour defines an sdk.Msg type that submits Evidence for +// light client misbehaviour. +type MsgSubmitClientMisbehaviour struct { + Evidence *Evidence `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"` + Submitter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=submitter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"submitter,omitempty"` +} + +func (m *MsgSubmitClientMisbehaviour) Reset() { *m = MsgSubmitClientMisbehaviour{} } +func (m *MsgSubmitClientMisbehaviour) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitClientMisbehaviour) ProtoMessage() {} +func (*MsgSubmitClientMisbehaviour) Descriptor() ([]byte, []int) { + return fileDescriptor_76a953d5a747dd66, []int{7} +} +func (m *MsgSubmitClientMisbehaviour) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitClientMisbehaviour) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitClientMisbehaviour.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSubmitClientMisbehaviour) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitClientMisbehaviour.Merge(m, src) +} +func (m *MsgSubmitClientMisbehaviour) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitClientMisbehaviour) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitClientMisbehaviour.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitClientMisbehaviour proto.InternalMessageInfo + func init() { proto.RegisterType((*ClientState)(nil), "ibc.tendermint.ClientState") proto.RegisterType((*ConsensusState)(nil), "ibc.tendermint.ConsensusState") proto.RegisterType((*Evidence)(nil), "ibc.tendermint.Evidence") proto.RegisterType((*Header)(nil), "ibc.tendermint.Header") proto.RegisterType((*Fraction)(nil), "ibc.tendermint.Fraction") + proto.RegisterType((*MsgCreateClient)(nil), "ibc.tendermint.MsgCreateClient") + proto.RegisterType((*MsgUpdateClient)(nil), "ibc.tendermint.MsgUpdateClient") + proto.RegisterType((*MsgSubmitClientMisbehaviour)(nil), "ibc.tendermint.MsgSubmitClientMisbehaviour") } func init() { proto.RegisterFile("ibc/tendermint/tendermint.proto", fileDescriptor_76a953d5a747dd66) } var fileDescriptor_76a953d5a747dd66 = []byte{ - // 945 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0xae, 0xd3, 0x6c, 0x9b, 0x4e, 0x92, 0xb6, 0xcc, 0x96, 0x92, 0x86, 0x25, 0x8e, 0xcc, 0xa5, - 0x97, 0xb5, 0x69, 0x76, 0x05, 0x52, 0x25, 0x24, 0xe4, 0x2e, 0xa8, 0x45, 0x20, 0x55, 0x2e, 0x1f, - 0x12, 0x12, 0xb2, 0x1c, 0x7b, 0x92, 0x8c, 0x6a, 0xcf, 0x44, 0x9e, 0x49, 0x95, 0xf2, 0x0b, 0x96, - 0xdb, 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0xa8, 0x15, 0x27, 0xeb, 0x97, - 0x52, 0x75, 0x0f, 0x16, 0x99, 0xf9, 0x7e, 0x65, 0x31, 0x16, 0x71, 0xcb, 0x6b, 0x6b, 0x87, 0x1e, - 0xe1, 0x18, 0xc0, 0x3c, 0xa3, 0x14, 0xaa, 0xee, 0xfe, 0xdb, 0x6e, 0xf9, 0xd1, 0x22, 0x33, 0x0f, - 0x96, 0xab, 0x94, 0x1c, 0x96, 0xf7, 0x9e, 0x76, 0x96, 0x92, 0xb5, 0xbe, 0x06, 0x8d, 0xfc, 0xe3, - 0x00, 0x9f, 0x80, 0x2d, 0x32, 0x4b, 0x50, 0x2a, 0x22, 0xb2, 0xfb, 0xeb, 0x5e, 0xe9, 0x80, 0x7d, - 0xd0, 0x8c, 0x10, 0xa1, 0x09, 0x26, 0x32, 0x5e, 0x93, 0xf1, 0xaa, 0xcb, 0x3d, 0x7f, 0x73, 0xdb, - 0x33, 0x6e, 0x6e, 0x7b, 0xc6, 0xdf, 0xb7, 0x3d, 0xe3, 0xd5, 0x5d, 0x6f, 0xed, 0xe6, 0xae, 0xb7, - 0xf6, 0xe7, 0x5d, 0x6f, 0xed, 0xa7, 0x4f, 0x2b, 0xe3, 0x15, 0x52, 0x96, 0x50, 0xa6, 0xff, 0x3d, - 0x65, 0xd1, 0xa5, 0x33, 0x77, 0xc4, 0x67, 0xf2, 0x93, 0xcf, 0x9e, 0xae, 0x7e, 0xa1, 0x87, 0x1b, - 0x72, 0x9f, 0x3c, 0xfb, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x47, 0x40, 0xa0, 0xf1, 0x0f, 0x08, 0x00, - 0x00, + // 1103 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x4f, 0xe3, 0xc6, + 0x17, 0xc7, 0x21, 0x84, 0x30, 0x09, 0x3f, 0xbe, 0xb3, 0x7c, 0x69, 0x60,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0xdd, 0x1b, 0x89, 0xdd, 0x57, 0xb7, + 0x76, 0x6e, 0x62, 0x7d, 0xbb, 0x30, 0x9f, 0x5d, 0xca, 0x02, 0xca, 0xd4, 0xbf, 0x6d, 0xe6, 0x9d, + 0xaa, 0x0f, 0xb9, 0xc7, 0xae, 0xfb, 0xd8, 0xf3, 0x22, 0xcc, 0x18, 0x52, 0x00, 0x6a, 0x18, 0xff, + 0xa1, 0x09, 0x8e, 0x3e, 0x1d, 0x7a, 0xf7, 0xca, 0xd1, 0x3c, 0x8f, 0xd9, 0xb7, 0x93, 0xc7, 0x6f, + 0x1a, 0x78, 0x78, 0xc4, 0xfa, 0x27, 0xa3, 0x6e, 0x40, 0xb8, 0xcc, 0xe3, 0x88, 0xb0, 0x2e, 0x1e, + 0x38, 0x67, 0x84, 0x8e, 0x22, 0xb8, 0x0b, 0xaa, 0x58, 0xed, 0x1c, 0x35, 0x44, 0x6f, 0x75, 0x44, + 0xba, 0x93, 0x50, 0x66, 0x09, 0xbf, 0x02, 0x0b, 0x4c, 0x20, 0x72, 0x95, 0xd9, 0x1b, 0xbd, 0x34, + 0xc7, 0x90, 0x8f, 0xb5, 0x8e, 0x5f, 0x5e, 0x35, 0xb5, 0xcb, 0xab, 0xa6, 0xf6, 0xf7, 0x55, 0x53, + 0x7b, 0x7e, 0xdd, 0x9c, 0xb9, 0xbc, 0x6e, 0xce, 0xfc, 0x79, 0xdd, 0x9c, 0xf9, 0xfe, 0xa3, 0x57, + 0x22, 0x9f, 0xb7, 0x93, 0x6f, 0xe6, 0x0f, 0x3f, 0xde, 0x9e, 0xfe, 0x5c, 0xef, 0x56, 0x04, 0x51, + 0x1f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x59, 0x41, 0xd4, 0xdb, 0x1c, 0x0c, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { @@ -532,26 +671,30 @@ func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Header2.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Header2 != nil { + { + size, err := m.Header2.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTendermint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 } - i-- - dAtA[i] = 0x22 - { - size, err := m.Header1.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Header1 != nil { + { + size, err := m.Header1.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTendermint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if len(m.ChainId) > 0 { i -= len(m.ChainId) copy(dAtA[i:], m.ChainId) @@ -618,16 +761,18 @@ func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - { - size, err := m.SignedHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.SignedHeader != nil { + { + size, err := m.SignedHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTendermint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -664,6 +809,194 @@ func (m *Fraction) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgCreateClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreateClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ProofSpecs) > 0 { + for iNdEx := len(m.ProofSpecs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ProofSpecs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTendermint(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x3a + } + n12, err12 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):]) + if err12 != nil { + return 0, err12 + } + i -= n12 + i = encodeVarintTendermint(dAtA, i, uint64(n12)) + i-- + dAtA[i] = 0x32 + n13, err13 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err13 != nil { + return 0, err13 + } + i -= n13 + i = encodeVarintTendermint(dAtA, i, uint64(n13)) + i-- + dAtA[i] = 0x2a + n14, err14 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):]) + if err14 != nil { + return 0, err14 + } + i -= n14 + i = encodeVarintTendermint(dAtA, i, uint64(n14)) + i-- + dAtA[i] = 0x22 + { + size, err := m.TrustLevel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTendermint(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTendermint(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTendermint(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitClientMisbehaviour) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSubmitClientMisbehaviour) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitClientMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTendermint(dAtA, i, uint64(len(m.Submitter))) + i-- + dAtA[i] = 0x12 + } + if m.Evidence != nil { + { + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTendermint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTendermint(dAtA []byte, offset int, v uint64) int { offset -= sovTendermint(v) base := offset @@ -742,10 +1075,14 @@ func (m *Evidence) Size() (n int) { if l > 0 { n += 1 + l + sovTendermint(uint64(l)) } - l = m.Header1.Size() - n += 1 + l + sovTendermint(uint64(l)) - l = m.Header2.Size() - n += 1 + l + sovTendermint(uint64(l)) + if m.Header1 != nil { + l = m.Header1.Size() + n += 1 + l + sovTendermint(uint64(l)) + } + if m.Header2 != nil { + l = m.Header2.Size() + n += 1 + l + sovTendermint(uint64(l)) + } return n } @@ -755,8 +1092,10 @@ func (m *Header) Size() (n int) { } var l int _ = l - l = m.SignedHeader.Size() - n += 1 + l + sovTendermint(uint64(l)) + if m.SignedHeader != nil { + l = m.SignedHeader.Size() + n += 1 + l + sovTendermint(uint64(l)) + } if m.ValidatorSet != nil { l = m.ValidatorSet.Size() n += 1 + l + sovTendermint(uint64(l)) @@ -786,6 +1125,79 @@ func (m *Fraction) Size() (n int) { return n } +func (m *MsgCreateClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTendermint(uint64(l)) + } + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovTendermint(uint64(l)) + } + l = m.TrustLevel.Size() + n += 1 + l + sovTendermint(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod) + n += 1 + l + sovTendermint(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod) + n += 1 + l + sovTendermint(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift) + n += 1 + l + sovTendermint(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTendermint(uint64(l)) + } + if len(m.ProofSpecs) > 0 { + for _, e := range m.ProofSpecs { + l = e.Size() + n += 1 + l + sovTendermint(uint64(l)) + } + } + return n +} + +func (m *MsgUpdateClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTendermint(uint64(l)) + } + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovTendermint(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTendermint(uint64(l)) + } + return n +} + +func (m *MsgSubmitClientMisbehaviour) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Evidence != nil { + l = m.Evidence.Size() + n += 1 + l + sovTendermint(uint64(l)) + } + l = len(m.Submitter) + if l > 0 { + n += 1 + l + sovTendermint(uint64(l)) + } + return n +} + func sovTendermint(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1124,28 +1536,659 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Root.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextValidatorsHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextValidatorsHash = append(m.NextValidatorsHash[:0], dAtA[iNdEx:postIndex]...) + if m.NextValidatorsHash == nil { + m.NextValidatorsHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTendermint(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Evidence) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Evidence: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Evidence: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header1", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header1 == nil { + m.Header1 = &Header{} + } + if err := m.Header1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header2", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header2 == nil { + m.Header2 = &Header{} + } + if err := m.Header2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTendermint(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Header) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Header: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SignedHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SignedHeader == nil { + m.SignedHeader = &types1.SignedHeader{} + } + if err := m.SignedHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ValidatorSet == nil { + m.ValidatorSet = &types1.ValidatorSet{} + } + if err := m.ValidatorSet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TrustedHeight", wireType) + } + m.TrustedHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TrustedHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TrustedValidators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TrustedValidators == nil { + m.TrustedValidators = &types1.ValidatorSet{} + } + if err := m.TrustedValidators.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTendermint(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Fraction) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Fraction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Fraction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Numerator", wireType) + } + m.Numerator = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Numerator |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Denominator", wireType) + } + m.Denominator = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Denominator |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTendermint(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTendermint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTendermint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTendermint } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTendermint } if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1172,15 +2215,18 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Root.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Header == nil { + m.Header = &Header{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TrustLevel", wireType) } - m.Height = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1190,16 +2236,30 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TrustLevel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NextValidatorsHash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TrustingPeriod", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1209,84 +2269,30 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTendermint } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTendermint } if postIndex > l { return io.ErrUnexpectedEOF } - m.NextValidatorsHash = append(m.NextValidatorsHash[:0], dAtA[iNdEx:postIndex]...) - if m.NextValidatorsHash == nil { - m.NextValidatorsHash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTendermint(dAtA[iNdEx:]) - if err != nil { + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.TrustingPeriod, dAtA[iNdEx:postIndex]); err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTendermint - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTendermint - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Evidence) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTendermint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Evidence: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Evidence: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1296,29 +2302,30 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTendermint } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTendermint } if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientId = string(dAtA[iNdEx:postIndex]) + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.UnbondingPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MaxClockDrift", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1328,29 +2335,30 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTendermint } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTendermint } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxClockDrift, dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header1", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1360,28 +2368,29 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTendermint } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTendermint } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Header1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} } iNdEx = postIndex - case 4: + case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header2", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofSpecs", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1408,7 +2417,8 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Header2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ProofSpecs = append(m.ProofSpecs, &_go.ProofSpec{}) + if err := m.ProofSpecs[len(m.ProofSpecs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1436,7 +2446,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { } return nil } -func (m *Header) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateClient) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1459,17 +2469,17 @@ func (m *Header) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Header: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateClient: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateClient: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SignedHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1479,28 +2489,27 @@ func (m *Header) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTendermint } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTendermint } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.SignedHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSet", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1527,37 +2536,18 @@ func (m *Header) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.ValidatorSet == nil { - m.ValidatorSet = &types1.ValidatorSet{} + if m.Header == nil { + m.Header = &Header{} } - if err := m.ValidatorSet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TrustedHeight", wireType) - } - m.TrustedHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTendermint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TrustedHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TrustedValidators", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1567,26 +2557,24 @@ func (m *Header) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTendermint } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTendermint } if postIndex > l { return io.ErrUnexpectedEOF } - if m.TrustedValidators == nil { - m.TrustedValidators = &types1.ValidatorSet{} - } - if err := m.TrustedValidators.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} } iNdEx = postIndex default: @@ -1613,7 +2601,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { } return nil } -func (m *Fraction) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitClientMisbehaviour) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1636,17 +2624,17 @@ func (m *Fraction) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Fraction: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitClientMisbehaviour: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Fraction: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitClientMisbehaviour: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Numerator", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) } - m.Numerator = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1656,16 +2644,33 @@ func (m *Fraction) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Numerator |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Evidence == nil { + m.Evidence = &Evidence{} + } + if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Denominator", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) } - m.Denominator = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTendermint @@ -1675,11 +2680,26 @@ func (m *Fraction) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Denominator |= int64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthTendermint + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTendermint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Submitter = append(m.Submitter[:0], dAtA[iNdEx:postIndex]...) + if m.Submitter == nil { + m.Submitter = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTendermint(dAtA[iNdEx:]) diff --git a/x/ibc/07-tendermint/types/tendermint_test.go b/x/ibc/07-tendermint/types/tendermint_test.go index 5d18b9e83fec..894a589e50bf 100644 --- a/x/ibc/07-tendermint/types/tendermint_test.go +++ b/x/ibc/07-tendermint/types/tendermint_test.go @@ -36,12 +36,11 @@ type TendermintTestSuite struct { // TODO: deprecate usage in favor of testing package ctx sdk.Context - aminoCdc *codec.LegacyAmino cdc codec.Marshaler privVal tmtypes.PrivValidator valSet *tmtypes.ValidatorSet valsHash tmbytes.HexBytes - header ibctmtypes.Header + header *ibctmtypes.Header now time.Time headerTime time.Time clientTime time.Time @@ -56,7 +55,6 @@ func (suite *TendermintTestSuite) SetupTest() { checkTx := false app := simapp.Setup(checkTx) - suite.aminoCdc = app.LegacyAmino() suite.cdc = app.AppCodec() // now is the time of the current chain, must be after the updating header diff --git a/x/ibc/07-tendermint/types/test_utils.go b/x/ibc/07-tendermint/types/test_utils.go index fcab3d3be896..b06461ea2822 100644 --- a/x/ibc/07-tendermint/types/test_utils.go +++ b/x/ibc/07-tendermint/types/test_utils.go @@ -22,7 +22,7 @@ func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.Bl } // CreateTestHeader creates a mock header for testing only. -func CreateTestHeader(chainID string, height, trustedHeight int64, timestamp time.Time, tmValSet, tmTrustedVals *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator) Header { +func CreateTestHeader(chainID string, height, trustedHeight int64, timestamp time.Time, tmValSet, tmTrustedVals *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator) *Header { var ( valSet *tmproto.ValidatorSet trustedVals *tmproto.ValidatorSet @@ -72,8 +72,8 @@ func CreateTestHeader(chainID string, height, trustedHeight int64, timestamp tim } } - return Header{ - SignedHeader: signedHeader, + return &Header{ + SignedHeader: &signedHeader, ValidatorSet: valSet, TrustedHeight: uint64(trustedHeight), TrustedValidators: trustedVals, diff --git a/x/ibc/07-tendermint/types/update.go b/x/ibc/07-tendermint/types/update.go index ae176ffe5f87..911b65b82113 100644 --- a/x/ibc/07-tendermint/types/update.go +++ b/x/ibc/07-tendermint/types/update.go @@ -38,10 +38,10 @@ func (cs ClientState) CheckHeaderAndUpdateState( ctx sdk.Context, cdc codec.BinaryMarshaler, clientStore sdk.KVStore, header clientexported.Header, ) (clientexported.ClientState, clientexported.ConsensusState, error) { - tmHeader, ok := header.(Header) + tmHeader, ok := header.(*Header) if !ok { return nil, nil, sdkerrors.Wrapf( - clienttypes.ErrInvalidHeader, "expected type %T, got %T", Header{}, header, + clienttypes.ErrInvalidHeader, "expected type %T, got %T", &Header{}, header, ) } @@ -62,7 +62,7 @@ func (cs ClientState) CheckHeaderAndUpdateState( } // checkTrustedHeader checks that consensus state matches trusted fields of Header -func checkTrustedHeader(header Header, consState *ConsensusState) error { +func checkTrustedHeader(header *Header, consState *ConsensusState) error { if header.TrustedHeight != consState.Height { return sdkerrors.Wrapf( ErrInvalidHeaderHeight, @@ -93,7 +93,7 @@ func checkTrustedHeader(header Header, consState *ConsensusState) error { // CONTRACT: consState.Height == header.TrustedHeight func checkValidity( clientState *ClientState, consState *ConsensusState, - header Header, currentTimestamp time.Time, + header *Header, currentTimestamp time.Time, ) error { if err := checkTrustedHeader(header, consState); err != nil { return err @@ -104,7 +104,7 @@ func checkValidity( return sdkerrors.Wrap(err, "trusted validator set in not tendermint validator set type") } - tmSignedHeader, err := tmtypes.SignedHeaderFromProto(&header.SignedHeader) + tmSignedHeader, err := tmtypes.SignedHeaderFromProto(header.SignedHeader) if err != nil { return sdkerrors.Wrap(err, "signed header in not tendermint signed header type") } @@ -150,7 +150,7 @@ func checkValidity( } // update the consensus state from a new header -func update(clientState *ClientState, header Header) (*ClientState, *ConsensusState) { +func update(clientState *ClientState, header *Header) (*ClientState, *ConsensusState) { if header.GetHeight() > clientState.LatestHeight { clientState.LatestHeight = header.GetHeight() } diff --git a/x/ibc/07-tendermint/types/update_test.go b/x/ibc/07-tendermint/types/update_test.go index aebf2cdc875f..505e812e54dc 100644 --- a/x/ibc/07-tendermint/types/update_test.go +++ b/x/ibc/07-tendermint/types/update_test.go @@ -13,7 +13,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { var ( clientState *types.ClientState consensusState *types.ConsensusState - newHeader types.Header + newHeader *types.Header currentTime time.Time ) diff --git a/x/ibc/09-localhost/types/codec.go b/x/ibc/09-localhost/types/codec.go index 684e40be0073..7cac129d5234 100644 --- a/x/ibc/09-localhost/types/codec.go +++ b/x/ibc/09-localhost/types/codec.go @@ -7,11 +7,6 @@ import ( clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" ) -// REMOVE: once simapp uses proto -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(ClientState{}, "ibc/client/localhost/ClientState", nil) -} - // RegisterInterfaces register the ibc interfaces submodule implementations to protobuf // Any. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { diff --git a/x/ibc/23-commitment/types/codec.go b/x/ibc/23-commitment/types/codec.go index 8a976ae560d0..76e851abd33a 100644 --- a/x/ibc/23-commitment/types/codec.go +++ b/x/ibc/23-commitment/types/codec.go @@ -43,33 +43,11 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { ) } -// RegisterCodec registers the necessary x/ibc/23-commitment interfaces and concrete types -// on the provided Amino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterInterface((*exported.Root)(nil), nil) - cdc.RegisterInterface((*exported.Prefix)(nil), nil) - cdc.RegisterInterface((*exported.Path)(nil), nil) - cdc.RegisterInterface((*exported.Proof)(nil), nil) - - cdc.RegisterConcrete(MerkleRoot{}, "ibc/commitment/MerkleRoot", nil) - cdc.RegisterConcrete(MerklePrefix{}, "ibc/commitment/MerklePrefix", nil) - cdc.RegisterConcrete(MerklePath{}, "ibc/commitment/MerklePath", nil) - cdc.RegisterConcrete(MerkleProof{}, "ibc/commitment/MerkleProof", nil) -} - var ( - amino = codec.New() - // SubModuleCdc references the global x/ibc/23-commitmentl module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. + // ONLY be used in certain instances of tests and for JSON encoding. // // The actual codec used for serialization should be provided to x/ibc/23-commitmentl and // defined at the application level. SubModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) ) - -func init() { - RegisterCodec(amino) - amino.Seal() -} diff --git a/x/ibc/ibc_test.go b/x/ibc/ibc_test.go index 10a41703dbf3..9458691add84 100644 --- a/x/ibc/ibc_test.go +++ b/x/ibc/ibc_test.go @@ -8,7 +8,6 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" @@ -42,10 +41,9 @@ const ( type IBCTestSuite struct { suite.Suite - cdc *codec.LegacyAmino ctx sdk.Context app *simapp.SimApp - header ibctmtypes.Header + header *ibctmtypes.Header } func (suite *IBCTestSuite) SetupTest() { @@ -63,7 +61,6 @@ func (suite *IBCTestSuite) SetupTest() { suite.header = ibctmtypes.CreateTestHeader(chainID, height, height-1, now, valSet, valSet, []tmtypes.PrivValidator{privVal}) - suite.cdc = suite.app.LegacyAmino() suite.ctx = suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) } diff --git a/x/ibc/keeper/keeper_test.go b/x/ibc/keeper/keeper_test.go deleted file mode 100644 index c35a1e3dccbf..000000000000 --- a/x/ibc/keeper/keeper_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/ibc/keeper" -) - -type KeeperTestSuite struct { - suite.Suite - - cdc *codec.LegacyAmino - ctx sdk.Context - keeper *keeper.Keeper -} - -func (suite *KeeperTestSuite) SetupTest() { - isCheckTx := false - app := simapp.Setup(isCheckTx) - - suite.cdc = app.LegacyAmino() - suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) - suite.keeper = app.IBCKeeper -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) -} diff --git a/x/ibc/light-clients/solomachine/client/cli/tx.go b/x/ibc/light-clients/solomachine/client/cli/tx.go index a62185f1621f..54bdfb2b2821 100644 --- a/x/ibc/light-clients/solomachine/client/cli/tx.go +++ b/x/ibc/light-clients/solomachine/client/cli/tx.go @@ -76,7 +76,7 @@ func NewUpdateClientCmd() *cobra.Command { cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - var header types.Header + var header *types.Header if err := cdc.UnmarshalJSON([]byte(args[1]), &header); err != nil { // check for file path if JSON input is not provided contents, err := ioutil.ReadFile(args[1]) @@ -116,7 +116,7 @@ func NewSubmitMisbehaviourCmd() *cobra.Command { cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - var ev types.Evidence + var ev *types.Evidence if err := cdc.UnmarshalJSON([]byte(args[0]), &ev); err != nil { // check for file path if JSON input is not provided contents, err := ioutil.ReadFile(args[0]) diff --git a/x/ibc/light-clients/solomachine/types/evidence_test.go b/x/ibc/light-clients/solomachine/types/evidence_test.go index f27f6c4d717a..87bb39a887df 100644 --- a/x/ibc/light-clients/solomachine/types/evidence_test.go +++ b/x/ibc/light-clients/solomachine/types/evidence_test.go @@ -15,7 +15,7 @@ func (suite *SoloMachineTestSuite) TestEvidence() { suite.Require().Equal(suite.solomachine.ClientID, ev.GetClientID()) suite.Require().Equal("client", ev.Route()) suite.Require().Equal("client_misbehaviour", ev.Type()) - suite.Require().Equal(tmbytes.HexBytes(tmhash.Sum(types.SubModuleCdc.MustMarshalBinaryBare(&ev))), ev.Hash()) + suite.Require().Equal(tmbytes.HexBytes(tmhash.Sum(types.SubModuleCdc.MustMarshalBinaryBare(ev))), ev.Hash()) suite.Require().Equal(int64(suite.solomachine.Sequence), ev.GetHeight()) } @@ -94,7 +94,7 @@ func (suite *SoloMachineTestSuite) TestEvidenceValidateBasic() { suite.Run(tc.name, func() { ev := suite.solomachine.CreateEvidence() - tc.malleateEvidence(&ev) + tc.malleateEvidence(ev) err := ev.ValidateBasic() diff --git a/x/ibc/light-clients/solomachine/types/header_test.go b/x/ibc/light-clients/solomachine/types/header_test.go index ba67a72238fb..4f9b29efa878 100644 --- a/x/ibc/light-clients/solomachine/types/header_test.go +++ b/x/ibc/light-clients/solomachine/types/header_test.go @@ -10,7 +10,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { cases := []struct { name string - header types.Header + header *types.Header expPass bool }{ { @@ -20,7 +20,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "sequence is zero", - types.Header{ + &types.Header{ Sequence: 0, Signature: header.Signature, NewPublicKey: header.NewPublicKey, @@ -29,7 +29,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "signature is empty", - types.Header{ + &types.Header{ Sequence: header.Sequence, Signature: []byte{}, NewPublicKey: header.NewPublicKey, @@ -38,7 +38,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "public key is nil", - types.Header{ + &types.Header{ Sequence: header.Sequence, Signature: header.Signature, NewPublicKey: nil, diff --git a/x/ibc/light-clients/solomachine/types/misbehaviour.go b/x/ibc/light-clients/solomachine/types/misbehaviour.go index be0aaf41dd9c..6e9204790438 100644 --- a/x/ibc/light-clients/solomachine/types/misbehaviour.go +++ b/x/ibc/light-clients/solomachine/types/misbehaviour.go @@ -18,11 +18,11 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( misbehaviour clientexported.Misbehaviour, ) (clientexported.ClientState, error) { - evidence, ok := misbehaviour.(Evidence) + evidence, ok := misbehaviour.(*Evidence) if !ok { return nil, sdkerrors.Wrapf( clienttypes.ErrInvalidClientType, - "evidence type %T, expected %T", misbehaviour, Evidence{}, + "evidence type %T, expected %T", misbehaviour, &Evidence{}, ) } @@ -42,7 +42,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( // over two different messages at the same sequence. // NOTE: a check that the evidence message data are not equal is done by // evidence.ValidateBasic which is called by the 02-client keeper. -func checkMisbehaviour(clientState ClientState, evidence Evidence) error { +func checkMisbehaviour(clientState ClientState, evidence *Evidence) error { pubKey := clientState.ConsensusState.GetPubKey() data := EvidenceSignBytes(evidence.Sequence, evidence.SignatureOne.Data) diff --git a/x/ibc/light-clients/solomachine/types/msgs.go b/x/ibc/light-clients/solomachine/types/msgs.go index 4b4a4c800dd5..e75380511838 100644 --- a/x/ibc/light-clients/solomachine/types/msgs.go +++ b/x/ibc/light-clients/solomachine/types/msgs.go @@ -5,6 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" evidenceexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" + clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -34,6 +35,9 @@ func (msg MsgCreateClient) Type() string { // ValidateBasic implements sdk.Msg func (msg MsgCreateClient) ValidateBasic() error { + if msg.ConsensusState == nil { + return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be nil") + } if err := msg.ConsensusState.ValidateBasic(); err != nil { return err } @@ -72,7 +76,7 @@ func (msg MsgCreateClient) InitializeClientState() clientexported.ClientState { } // NewMsgUpdateClient creates a new MsgUpdateClient instance -func NewMsgUpdateClient(id string, header Header) *MsgUpdateClient { +func NewMsgUpdateClient(id string, header *Header) *MsgUpdateClient { return &MsgUpdateClient{ ClientId: id, Header: header, @@ -91,6 +95,9 @@ func (msg MsgUpdateClient) Type() string { // ValidateBasic implements sdk.Msg func (msg MsgUpdateClient) ValidateBasic() error { + if msg.Header == nil { + return sdkerrors.Wrap(ErrInvalidHeader, "header cannot be nil") + } if err := msg.Header.ValidateBasic(); err != nil { return err } @@ -119,7 +126,7 @@ func (msg MsgUpdateClient) GetHeader() clientexported.Header { // NewMsgSubmitClientMisbehaviour creates a new MsgSubmitClientMisbehaviour // instance. -func NewMsgSubmitClientMisbehaviour(e Evidence, s sdk.AccAddress) *MsgSubmitClientMisbehaviour { +func NewMsgSubmitClientMisbehaviour(e *Evidence, s sdk.AccAddress) *MsgSubmitClientMisbehaviour { return &MsgSubmitClientMisbehaviour{Evidence: e, Submitter: s} } @@ -155,7 +162,7 @@ func (msg MsgSubmitClientMisbehaviour) GetSigners() []sdk.AccAddress { } func (msg MsgSubmitClientMisbehaviour) GetEvidence() evidenceexported.Evidence { - return &msg.Evidence + return msg.Evidence } func (msg MsgSubmitClientMisbehaviour) GetSubmitter() sdk.AccAddress { diff --git a/x/ibc/light-clients/solomachine/types/msgs_test.go b/x/ibc/light-clients/solomachine/types/msgs_test.go index 17375932c367..69bb50154838 100644 --- a/x/ibc/light-clients/solomachine/types/msgs_test.go +++ b/x/ibc/light-clients/solomachine/types/msgs_test.go @@ -12,6 +12,7 @@ func (suite *SoloMachineTestSuite) TestMsgCreateClientValidateBasic() { }{ {"valid msg", types.NewMsgCreateClient(suite.solomachine.ClientID, suite.solomachine.ConsensusState()), true}, {"invalid client id", types.NewMsgCreateClient("(BADCLIENTID)", suite.solomachine.ConsensusState()), false}, + {"nil consensus state", types.NewMsgCreateClient(suite.solomachine.ClientID, nil), false}, {"invalid consensus state with zero sequence", types.NewMsgCreateClient(suite.solomachine.ClientID, &types.ConsensusState{0, suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Time}), false}, {"invalid consensus state with zero timestamp", types.NewMsgCreateClient(suite.solomachine.ClientID, &types.ConsensusState{1, suite.solomachine.ConsensusState().PublicKey, 0}), false}, {"invalid consensus state with nil pubkey", types.NewMsgCreateClient(suite.solomachine.ClientID, &types.ConsensusState{suite.solomachine.Sequence, nil, suite.solomachine.Time}), false}, @@ -37,9 +38,10 @@ func (suite *SoloMachineTestSuite) TestMsgUpdateClientValidateBasic() { }{ {"valid msg", types.NewMsgUpdateClient(suite.solomachine.ClientID, header), true}, {"invalid client id", types.NewMsgUpdateClient("(BADCLIENTID)", header), false}, - {"invalid header - sequence is zero", types.NewMsgUpdateClient(suite.solomachine.ClientID, types.Header{0, header.Signature, header.NewPublicKey}), false}, - {"invalid header - signature is empty", types.NewMsgUpdateClient(suite.solomachine.ClientID, types.Header{header.Sequence, []byte{}, header.NewPublicKey}), false}, - {"invalid header - pubkey is empty", types.NewMsgUpdateClient(suite.solomachine.ClientID, types.Header{header.Sequence, header.Signature, nil}), false}, + {"nil header", types.NewMsgUpdateClient(suite.solomachine.ClientID, nil), false}, + {"invalid header - sequence is zero", types.NewMsgUpdateClient(suite.solomachine.ClientID, &types.Header{0, header.Signature, header.NewPublicKey}), false}, + {"invalid header - signature is empty", types.NewMsgUpdateClient(suite.solomachine.ClientID, &types.Header{header.Sequence, []byte{}, header.NewPublicKey}), false}, + {"invalid header - pubkey is empty", types.NewMsgUpdateClient(suite.solomachine.ClientID, &types.Header{header.Sequence, header.Signature, nil}), false}, } for i, tc := range cases { diff --git a/x/ibc/light-clients/solomachine/types/proof.go b/x/ibc/light-clients/solomachine/types/proof.go index 8b22de6f09b5..6de06096ccdb 100644 --- a/x/ibc/light-clients/solomachine/types/proof.go +++ b/x/ibc/light-clients/solomachine/types/proof.go @@ -38,7 +38,7 @@ func EvidenceSignBytes(sequence uint64, data []byte) []byte { // HeaderSignBytes returns the sign bytes for verification of misbehaviour. // // Format: {sequence}{header.newPubKey} -func HeaderSignBytes(header Header) []byte { +func HeaderSignBytes(header *Header) []byte { return append( sdk.Uint64ToBigEndian(header.Sequence), header.GetPubKey().Bytes()..., diff --git a/x/ibc/light-clients/solomachine/types/solomachine.pb.go b/x/ibc/light-clients/solomachine/types/solomachine.pb.go index 9bc0137f9b41..4f753ba53edd 100644 --- a/x/ibc/light-clients/solomachine/types/solomachine.pb.go +++ b/x/ibc/light-clients/solomachine/types/solomachine.pb.go @@ -311,8 +311,8 @@ var xxx_messageInfo_MsgCreateClient proto.InternalMessageInfo // MsgUpdateClient defines a message to update an IBC client type MsgUpdateClient struct { - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - Header Header `protobuf:"bytes,2,opt,name=header,proto3" json:"header"` + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + Header *Header `protobuf:"bytes,2,opt,name=header,proto3" json:"header,omitempty"` } func (m *MsgUpdateClient) Reset() { *m = MsgUpdateClient{} } @@ -352,7 +352,7 @@ var xxx_messageInfo_MsgUpdateClient proto.InternalMessageInfo // arbitrary Evidence. type MsgSubmitClientMisbehaviour struct { Submitter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=submitter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"submitter,omitempty"` - Evidence Evidence `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence"` + Evidence *Evidence `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence,omitempty"` } func (m *MsgSubmitClientMisbehaviour) Reset() { *m = MsgSubmitClientMisbehaviour{} } @@ -405,52 +405,52 @@ func init() { } var fileDescriptor_6cc2ee18f7f86d4e = []byte{ - // 718 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,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x27, 0x99, 0x55, 0xc1, 0x7c, - 0x73, 0x2e, 0x73, 0x3e, 0xda, 0x66, 0xe1, 0x34, 0x56, 0x72, 0x96, 0x38, 0x2c, 0x38, 0x7d, 0x91, - 0xc0, 0xad, 0x03, 0xda, 0x6e, 0x46, 0xb6, 0x87, 0x19, 0xe7, 0x74, 0x80, 0xa9, 0x8d, 0x3a, 0xb0, - 0x87, 0x49, 0x14, 0xca, 0x87, 0xa0, 0x44, 0x93, 0x7f, 0x0c, 0x85, 0xbc, 0x70, 0xa6, 0xf1, 0x33, - 0x56, 0xb6, 0xdb, 0x98, 0x75, 0x22, 0x5b, 0x73, 0x88, 0xa7, 0x8b, 0xbb, 0x9f, 0x7f, 0xb6, 0xa9, - 0x7b, 0xa2, 0xb3, 0x41, 0x80, 0xa8, 0xb6, 0xeb, 0x38, 0xbb, 0xae, 0x1b, 0x22, 0x4a, 0xad, 0x09, - 0x86, 0xbc, 0x0f, 0x8a, 0x48, 0x8c, 0xad, 0xe0, 0x7f, 0x67, 0x2e, 0xff, 0xf1, 0x9c, 0x0b, 0x05, - 0x29, 0x00, 0xd7, 0x60, 0xbe, 0x38, 0x3d, 0xaf, 0x4b, 0x67, 0xe7, 0x75, 0xe9, 0xc7, 0x79, 0x5d, - 0x7a, 0x7b, 0x51, 0xcf, 0x9d, 0x5d, 0xd4, 0x73, 0xdf, 0x2f, 0xea, 0xb9, 0x67, 0xe6, 0x95, 0x34, - 0x5f, 0xe9, 0xe9, 0x53, 0xb8, 0x7d, 0xd9, 0x5b, 0x98, 0xc8, 0xb0, 0x17, 0x93, 0x37, 0xea, 0xde, - 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0xca, 0x1e, 0x4a, 0x38, 0x07, 0x00, 0x00, + // 716 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x4d, 0x6f, 0xd3, 0x4c, + 0x10, 0x8e, 0xd3, 0xa8, 0x4a, 0xb6, 0x7d, 0xd3, 0xbe, 0x56, 0x8a, 0x42, 0xa8, 0xe2, 0xca, 0x12, + 0x6a, 0x39, 0xd4, 0x96, 0xe1, 0xd6, 0x0b, 0xaa, 0x43, 0x25, 0x3e, 0x54, 0x15, 0x39, 0x45, 0x42, + 0x80, 0x14, 0xad, 0xed, 0xad, 0xb3, 0x6a, 0xec, 0x35, 0xde, 0x75, 0x42, 0xf8, 0x05, 0x48, 0x5c, + 0x38, 0x72, 0xe4, 0x0f, 0x20, 0x71, 0xe7, 0xc2, 0x0d, 0x4e, 0xa8, 0x47, 0x4e, 0x11, 0x6a, 0xfe, + 0x41, 0x8e, 0x9c, 0x50, 0xbc, 0x1b, 0x27, 0x8e, 0xaa, 0x46, 0x7c, 0x48, 0x9c, 0xbc, 0x3b, 0x9e, + 0x79, 0xe6, 0x79, 0x66, 0x66, 0x77, 0x81, 0x81, 0x6d, 0x47, 0xef, 0x60, 0xaf, 0xcd, 0x9c, 0x0e, + 0x46, 0x01, 0xa3, 0x3a, 0x25, 0x1d, 0xe2, 0x43, 0xa7, 0x8d, 0x03, 0xa4, 0x77, 0x8d, 0xd9, 0xad, + 0x16, 0x46, 0x84, 0x11, 0x59, 0xc1, 0xb6, 0xa3, 0xcd, 0x86, 0x68, 0xb3, 0x3e, 0x5d, 0xa3, 0xb6, + 0xed, 0x10, 0xea, 0x13, 0xaa, 0xdb, 0x90, 0x22, 0xdd, 0x89, 0xfa, 0x21, 0x23, 0x7a, 0xd7, 0xb0, + 0x11, 0x83, 0x86, 0xd8, 0x72, 0xa4, 0x5a, 0xc5, 0x23, 0x1e, 0x49, 0x96, 0xfa, 0x78, 0xc5, 0xad, + 0xea, 0x57, 0x09, 0xac, 0x34, 0x12, 0xe4, 0x26, 0x83, 0x0c, 0xc9, 0x0d, 0xb0, 0x76, 0x12, 0x91, + 0x97, 0x28, 0x68, 0x51, 0xf4, 0x3c, 0x46, 0x81, 0x83, 0xaa, 0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, 0xb4, 0x2d, 0x11, 0x26, 0xd8, 0x7c, 0x94, 0xc0, + 0xb5, 0x43, 0xea, 0x35, 0x63, 0xdb, 0xc7, 0x8c, 0xb3, 0x39, 0xc4, 0xd4, 0x46, 0x6d, 0xd8, 0xc5, + 0x24, 0x8e, 0xe4, 0x23, 0x50, 0xa2, 0xc9, 0x3f, 0x86, 0x22, 0xde, 0x32, 0xd3, 0xf8, 0x31, 0x50, + 0x76, 0x3d, 0xcc, 0xda, 0xb1, 0xad, 0x39, 0xc4, 0xd7, 0xc5, 0xad, 0xcf, 0x3f, 0xbb, 0xd4, 0x3d, + 0xd5, 0x59, 0x3f, 0x44, 0x54, 0xdb, 0x77, 0x9c, 0x7d, 0xd7, 0x8d, 0x10, 0xa5, 0xd6, 0x14, 0x43, + 0x3e, 0x00, 0x45, 0x24, 0x0e, 0xac, 0x60, 0x7e, 0x63, 0x21, 0xf3, 0xc9, 0x09, 0xb7, 0xd2, 0x50, + 0xce, 0xde, 0x7c, 0xf6, 0xe5, 0xbc, 0x2e, 0x9d, 0x9d, 0xd7, 0xa5, 0xef, 0xe7, 0x75, 0xe9, 0xcd, + 0xb0, 0x9e, 0x3b, 0x1b, 0xd6, 0x73, 0xdf, 0x86, 0xf5, 0xdc, 0x13, 0xf3, 0x52, 0x82, 0x2f, 0xf4, + 0xf4, 0xf9, 0xdb, 0xbd, 0xe8, 0xfd, 0x4b, 0x04, 0xd8, 0xcb, 0xc9, 0xbb, 0x74, 0xeb, 0x67, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xee, 0x37, 0x2c, 0xb2, 0x2c, 0x07, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { @@ -778,16 +778,18 @@ func (m *MsgUpdateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSolomachine(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintSolomachine(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) @@ -818,16 +820,18 @@ func (m *MsgSubmitClientMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l - { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Evidence != nil { + { + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSolomachine(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintSolomachine(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.Submitter) > 0 { i -= len(m.Submitter) copy(dAtA[i:], m.Submitter) @@ -988,8 +992,10 @@ func (m *MsgUpdateClient) Size() (n int) { if l > 0 { n += 1 + l + sovSolomachine(uint64(l)) } - l = m.Header.Size() - n += 1 + l + sovSolomachine(uint64(l)) + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovSolomachine(uint64(l)) + } return n } @@ -1003,8 +1009,10 @@ func (m *MsgSubmitClientMisbehaviour) Size() (n int) { if l > 0 { n += 1 + l + sovSolomachine(uint64(l)) } - l = m.Evidence.Size() - n += 1 + l + sovSolomachine(uint64(l)) + if m.Evidence != nil { + l = m.Evidence.Size() + n += 1 + l + sovSolomachine(uint64(l)) + } return n } @@ -2005,6 +2013,9 @@ func (m *MsgUpdateClient) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + if m.Header == nil { + m.Header = &Header{} + } if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2125,6 +2136,9 @@ func (m *MsgSubmitClientMisbehaviour) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + if m.Evidence == nil { + m.Evidence = &Evidence{} + } if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/ibc/light-clients/solomachine/types/update.go b/x/ibc/light-clients/solomachine/types/update.go index 2e44e25c5238..292c3a8acacd 100644 --- a/x/ibc/light-clients/solomachine/types/update.go +++ b/x/ibc/light-clients/solomachine/types/update.go @@ -16,10 +16,10 @@ func (cs ClientState) CheckHeaderAndUpdateState( ctx sdk.Context, cdc codec.BinaryMarshaler, clientStore sdk.KVStore, header clientexported.Header, ) (clientexported.ClientState, clientexported.ConsensusState, error) { - smHeader, ok := header.(Header) + smHeader, ok := header.(*Header) if !ok { return nil, nil, sdkerrors.Wrapf( - clienttypes.ErrInvalidHeader, "header type %T is not solomachine", header, + clienttypes.ErrInvalidHeader, "header type %T, expected %T", header, &Header{}, ) } @@ -32,7 +32,7 @@ func (cs ClientState) CheckHeaderAndUpdateState( } // checkHeader checks if the Solo Machine update signature is valid. -func checkHeader(clientState *ClientState, header Header) error { +func checkHeader(clientState *ClientState, header *Header) error { // assert update sequence is current sequence if header.Sequence != clientState.ConsensusState.Sequence { return sdkerrors.Wrapf( @@ -51,7 +51,7 @@ func checkHeader(clientState *ClientState, header Header) error { } // update the consensus state to the new public key and an incremented sequence -func update(clientState *ClientState, header Header) (*ClientState, *ConsensusState) { +func update(clientState *ClientState, header *Header) (*ClientState, *ConsensusState) { consensusState := &ConsensusState{ // increment sequence number Sequence: clientState.ConsensusState.Sequence + 1, diff --git a/x/ibc/light-clients/solomachine/types/update_test.go b/x/ibc/light-clients/solomachine/types/update_test.go index f8573f29ab74..16c1d437060b 100644 --- a/x/ibc/light-clients/solomachine/types/update_test.go +++ b/x/ibc/light-clients/solomachine/types/update_test.go @@ -38,7 +38,7 @@ func (suite *SoloMachineTestSuite) TestCheckHeaderAndUpdateState() { "invalid header type", func() { clientState = suite.solomachine.ClientState() - header = ibctmtypes.Header{} + header = &ibctmtypes.Header{} }, false, }, @@ -113,9 +113,9 @@ func (suite *SoloMachineTestSuite) TestCheckHeaderAndUpdateState() { if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(header.(types.Header).NewPublicKey, clientState.(*types.ClientState).ConsensusState.PublicKey) + suite.Require().Equal(header.(*types.Header).NewPublicKey, clientState.(*types.ClientState).ConsensusState.PublicKey) suite.Require().Equal(uint64(0), clientState.(*types.ClientState).FrozenSequence) - suite.Require().Equal(header.(types.Header).Sequence+1, clientState.(*types.ClientState).ConsensusState.Sequence) + suite.Require().Equal(header.(*types.Header).Sequence+1, clientState.(*types.ClientState).ConsensusState.Sequence) suite.Require().Equal(consensusState, clientState.(*types.ClientState).ConsensusState) } else { suite.Require().Error(err) diff --git a/x/ibc/module.go b/x/ibc/module.go index 8c68a0b0d0b1..e015e773fcaf 100644 --- a/x/ibc/module.go +++ b/x/ibc/module.go @@ -41,10 +41,8 @@ func (AppModuleBasic) Name() string { return host.ModuleName } -// RegisterCodec registers the ibc module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) -} +// RegisterCodec does nothing. IBC does not support amino. +func (AppModuleBasic) RegisterCodec(*codec.LegacyAmino) {} // DefaultGenesis returns default genesis state as raw bytes for the ibc // module. @@ -62,9 +60,8 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config client.TxE return gs.Validate() } -// RegisterRESTRoutes registers the REST routes for the ibc module. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { -} +// RegisterRESTRoutes does nothing. IBC does not support legacy REST routes. +func (AppModuleBasic) RegisterRESTRoutes(client.Context, *mux.Router) {} // GetTxCmd returns the root tx command for the ibc module. func (AppModuleBasic) GetTxCmd() *cobra.Command { diff --git a/x/ibc/simulation/genesis_test.go b/x/ibc/simulation/genesis_test.go index ccd2e5fc626a..d52f5391eeb7 100644 --- a/x/ibc/simulation/genesis_test.go +++ b/x/ibc/simulation/genesis_test.go @@ -22,10 +22,6 @@ func TestRandomizedGenState(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - // Make sure to register cdc. - // Otherwise RandomizedGenState will panic! - types.RegisterCodec(cdc) - simState := module.SimulationState{ AppParams: make(simtypes.AppParams), Cdc: cdc, diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 4f5e8df1a305..b2f41743510b 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -66,8 +66,8 @@ type TestChain struct { App *simapp.SimApp ChainID string - LastHeader ibctmtypes.Header // header for last block height committed - CurrentHeader tmproto.Header // header for current block height + LastHeader *ibctmtypes.Header // header for last block height committed + CurrentHeader tmproto.Header // header for current block height QueryServer types.QueryServer TxConfig client.TxConfig Codec codec.BinaryMarshaler @@ -407,7 +407,7 @@ func (chain *TestChain) UpdateTMClient(counterparty *TestChain, clientID string) } // CreateTMClientHeader creates a TM header to update the TM client. -func (chain *TestChain) CreateTMClientHeader() ibctmtypes.Header { +func (chain *TestChain) CreateTMClientHeader() *ibctmtypes.Header { vsetHash := chain.Vals.Hash() tmHeader := tmtypes.Header{ Version: version.Consensus{Block: 2, App: 2}, @@ -434,7 +434,7 @@ func (chain *TestChain) CreateTMClientHeader() ibctmtypes.Header { commit, err := tmtypes.MakeCommit(blockID, chain.CurrentHeader.Height, 1, voteSet, chain.Signers, chain.CurrentHeader.Time) require.NoError(chain.t, err) - signedHeader := tmproto.SignedHeader{ + signedHeader := &tmproto.SignedHeader{ Header: tmHeader.ToProto(), Commit: commit.ToProto(), } @@ -446,7 +446,7 @@ func (chain *TestChain) CreateTMClientHeader() ibctmtypes.Header { // Do not set trusted field here, these fields can be inserted before relaying messages to a client. // The relayer is responsible for querying client and injecting appropriate trusted fields. - return ibctmtypes.Header{ + return &ibctmtypes.Header{ SignedHeader: signedHeader, ValidatorSet: valSet, } diff --git a/x/ibc/testing/solomachine.go b/x/ibc/testing/solomachine.go index f5268917a37d..8c82f9be834d 100644 --- a/x/ibc/testing/solomachine.go +++ b/x/ibc/testing/solomachine.go @@ -56,7 +56,7 @@ func (solo *Solomachine) ConsensusState() *solomachinetypes.ConsensusState { // CreateHeader generates a new private/public key pair and creates the // necessary signature to construct a valid solo machine header. -func (solo *Solomachine) CreateHeader() solomachinetypes.Header { +func (solo *Solomachine) CreateHeader() *solomachinetypes.Header { // generate new private key and signature for header newPrivKey := ed25519.GenPrivKey() data := append(sdk.Uint64ToBigEndian(solo.Sequence), newPrivKey.PubKey().Bytes()...) @@ -66,7 +66,7 @@ func (solo *Solomachine) CreateHeader() solomachinetypes.Header { publicKey, err := std.DefaultPublicKeyCodec{}.Encode(newPrivKey.PubKey()) require.NoError(solo.t, err) - header := solomachinetypes.Header{ + header := &solomachinetypes.Header{ Sequence: solo.Sequence, Signature: signature, NewPublicKey: publicKey, @@ -82,7 +82,7 @@ func (solo *Solomachine) CreateHeader() solomachinetypes.Header { // CreateEvidence constructs testing evidence for the solo machine client // by signing over two different data bytes at the same sequence. -func (solo *Solomachine) CreateEvidence() solomachinetypes.Evidence { +func (solo *Solomachine) CreateEvidence() *solomachinetypes.Evidence { dataOne := []byte("DATA ONE") dataTwo := []byte("DATA TWO") @@ -102,7 +102,7 @@ func (solo *Solomachine) CreateEvidence() solomachinetypes.Evidence { Data: dataTwo, } - return solomachinetypes.Evidence{ + return &solomachinetypes.Evidence{ ClientId: solo.ClientID, Sequence: solo.Sequence, SignatureOne: &signatureOne, diff --git a/x/ibc/types/codec.go b/x/ibc/types/codec.go index 40b15a5bd1c3..4218af4a628c 100644 --- a/x/ibc/types/codec.go +++ b/x/ibc/types/codec.go @@ -1,7 +1,6 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" @@ -12,15 +11,6 @@ import ( solomachinetypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types" ) -// RegisterCodec registers the necessary x/ibc interfaces and concrete types -// on the provided Amino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { - clienttypes.RegisterCodec(cdc) - ibctmtypes.RegisterCodec(cdc) - localhosttypes.RegisterCodec(cdc) - commitmenttypes.RegisterCodec(cdc) -} - // RegisterInterfaces registers x/ibc interfaces into protobuf Any. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { clienttypes.RegisterInterfaces(registry)