diff --git a/kava/client.go b/kava/client.go index 4fc2100..0e59a57 100644 --- a/kava/client.go +++ b/kava/client.go @@ -26,18 +26,21 @@ import ( "time" "github.com/coinbase/rosetta-sdk-go/types" + abci "github.com/cometbft/cometbft/abci/types" + ctypes "github.com/cometbft/cometbft/rpc/core/types" + tmrpctypes "github.com/cometbft/cometbft/rpc/jsonrpc/types" + tmtypes "github.com/cometbft/cometbft/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/ibc-go/v7/modules/core/exported" kava "github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app/params" - abci "github.com/cometbft/cometbft/abci/types" - ctypes "github.com/cometbft/cometbft/rpc/core/types" - tmrpctypes "github.com/cometbft/cometbft/rpc/jsonrpc/types" - tmtypes "github.com/cometbft/cometbft/types" + + migrations_v7 "github.com/cosmos/ibc-go/v7/modules/core/02-client/migrations/v7" ) var noBlockResultsForHeight = regexp.MustCompile(`could not find results for height #(\d+)`) @@ -52,6 +55,16 @@ type Client struct { // NewClient initialized a new Client with the provided rpc client func NewClient(rpc RPCClient, balanceServiceFactory BalanceServiceFactory) (*Client, error) { encodingConfig := kava.MakeEncodingConfig() + encodingConfig.InterfaceRegistry.RegisterInterface( + "ibc.lightclients.solomachine.v2.ClientState", + (*exported.ClientState)(nil), + &migrations_v7.ClientState{}, + ) + encodingConfig.InterfaceRegistry.RegisterInterface( + "ibc.lightclients.solomachine.v2.ConsensusState", + (*exported.ConsensusState)(nil), + &migrations_v7.ConsensusState{}, + ) return &Client{ rpc: rpc, diff --git a/kava/custom_types.go b/kava/custom_types.go new file mode 100644 index 0000000..76a88a5 --- /dev/null +++ b/kava/custom_types.go @@ -0,0 +1,148 @@ +package kava + +import ( + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/gogo/protobuf/proto" +) + +type ClientStateI interface { + proto.Message +} + +type ConsensusStateI interface { + proto.Message +} + +// ClientState defines a solo machine client that tracks the current consensus +// state and if the client is frozen. +type ClientState struct { + // latest sequence of the client state + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` + // frozen sequence of the solo machine + IsFrozen bool `protobuf:"varint,2,opt,name=is_frozen,json=isFrozen,proto3" json:"is_frozen,omitempty" yaml:"is_frozen"` + ConsensusState *ConsensusState `protobuf:"bytes,3,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml:"consensus_state"` + // when set to true, will allow governance to update a solo machine client. + // The client will be unfrozen if it is frozen. + AllowUpdateAfterProposal bool `protobuf:"varint,4,opt,name=allow_update_after_proposal,json=allowUpdateAfterProposal,proto3" json:"allow_update_after_proposal,omitempty" yaml:"allow_update_after_proposal"` +} + +func (m *ClientState) Reset() { *m = ClientState{} } +func (m *ClientState) String() string { return proto.CompactTextString(m) } +func (*ClientState) ProtoMessage() {} +func (*ClientState) Descriptor() ([]byte, []int) { + return fileDescriptor_141333b361aae010, []int{0} +} +func (*ClientState) XXX_MessageName() string { return "ibc.lightclients.solomachine.v2.ClientState" } + +// ConsensusState defines a solo machine consensus state. The sequence of a +// consensus state is contained in the "height" key used in storing the +// consensus state. +type ConsensusState struct { + // public key of the solo machine + PublicKey *types.Any `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty" yaml:"public_key"` + // diversifier allows the same public key to be re-used across different solo + // machine clients (potentially on different chains) without being considered + // misbehaviour. + Diversifier string `protobuf:"bytes,2,opt,name=diversifier,proto3" json:"diversifier,omitempty"` + Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *ConsensusState) Reset() { *m = ConsensusState{} } +func (m *ConsensusState) String() string { return proto.CompactTextString(m) } +func (*ConsensusState) ProtoMessage() {} +func (*ConsensusState) Descriptor() ([]byte, []int) { + return fileDescriptor_141333b361aae010, []int{1} +} +func (*ConsensusState) XXX_MessageName() string { + return "ibc.lightclients.solomachine.v2.ConsensusState" +} + +var fileDescriptor_141333b361aae010 = []byte{ + // 1370 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x5f, 0x8f, 0xdb, 0x44, + 0x10, 0x3f, 0xa7, 0xe9, 0xf5, 0x32, 0xb9, 0xde, 0x05, 0x37, 0x6d, 0x73, 0x6e, 0x95, 0x18, 0x23, + 0xca, 0x81, 0x68, 0xc2, 0x5d, 0x45, 0x85, 0x2a, 0x04, 0x38, 0x8e, 0x4b, 0xd3, 0xde, 0xf9, 0x82, + 0xe3, 0x03, 0x5a, 0x21, 0x19, 0xc7, 0xd9, 0x4b, 0xac, 0x26, 0xde, 0x34, 0x76, 0x92, 0x06, 0x09, + 0x09, 0xf1, 0x54, 0x22, 0x1e, 0xf8, 0x02, 0x91, 0x10, 0x88, 0xcf, 0xc1, 0x1b, 0xf0, 0xd8, 0x47, + 0x9e, 0x02, 0x6a, 0xbf, 0x41, 0x3e, 0x01, 0xb2, 0x77, 0x13, 0xdb, 0xb9, 0x5e, 0x4e, 0xfc, 0x7b, + 0xdb, 0x9d, 0xdf, 0xcc, 0x6f, 0x66, 0x67, 0xc6, 0xb3, 0x6b, 0xd8, 0xb1, 0x6a, 0x66, 0xa1, 0x65, + 0x35, 0x9a, 0xae, 0xd9, 0xb2, 0x90, 0xed, 0x3a, 0x05, 0x07, 0xb7, 0x70, 0xdb, 0x30, 0x9b, 0x96, + 0x8d, 0x0a, 0xfd, 0xdd, 0xf0, 0x36, 0xdf, 0xe9, 0x62, 0x17, 0xb3, 0x39, 0xab, 0x66, 0xe6, 0xc3, + 0x26, 0xf9, 0xb0, 0x4e, 0x7f, 0x97, 0x7b, 0xcd, 0xe3, 0x34, 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xad, 0x91, 0xc0, 0x3d, 0x64, 0x06, 0x78, 0x72, 0x96, 0x87, 0x54, 0x60, 0x77, 0x47, 0x16, 0x4b, + 0xb2, 0x9a, 0x4a, 0x90, 0xca, 0x90, 0x1d, 0x17, 0x7f, 0xf2, 0x63, 0x76, 0xa5, 0xf8, 0xf9, 0x6f, + 0xcf, 0xb2, 0xcc, 0xd3, 0x67, 0x59, 0xe6, 0xcf, 0x67, 0x59, 0xe6, 0xbb, 0xe7, 0xd9, 0x95, 0xa7, + 0xcf, 0xb3, 0x2b, 0xbf, 0x3f, 0xcf, 0xae, 0x3c, 0xb8, 0xdd, 0xb0, 0xdc, 0x66, 0xaf, 0x96, 0x37, + 0x71, 0xbb, 0x60, 0x62, 0xa7, 0x8d, 0x9d, 0x82, 0x55, 0x33, 0xaf, 0x37, 0x70, 0xa1, 0x7f, 0xa3, + 0xd0, 0xc6, 0xf5, 0x5e, 0x0b, 0x39, 0xe4, 0x7f, 0xea, 0xfa, 0xec, 0x87, 0xea, 0xad, 0x9b, 0xd7, + 0xc3, 0xff, 0x54, 0xde, 0x35, 0xe3, 0xd4, 0x56, 0xfd, 0x79, 0x76, 0xe3, 0xaf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x5d, 0xd4, 0x6c, 0xfb, 0x80, 0x0d, 0x00, 0x00, +} diff --git a/kava/rpc.go b/kava/rpc.go index 284cb8e..894837a 100644 --- a/kava/rpc.go +++ b/kava/rpc.go @@ -60,6 +60,11 @@ func NewHTTPClient(remote string) (*HTTPClient, error) { } encodingConfig := kava.MakeEncodingConfig() + encodingConfig.InterfaceRegistry.RegisterInterface( + "ibc.lightclients.solomachine.v2.ClientState", + (*ClientStateI)(nil), + &ClientState{}, + ) return &HTTPClient{ HTTP: http,