From 7fe3b68bee369d3f61cf91562f9abf0487f3af24 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Fri, 17 Mar 2023 10:41:59 +0800 Subject: [PATCH] fix: refine the code of crosschain and oracle module --- proto/cosmos/crosschain/v1/crosschain.proto | 1 + proto/cosmos/crosschain/v1/query.proto | 7 +++++++ proto/cosmos/oracle/v1/tx.proto | 8 ++++++++ x/crosschain/types/crosschain.pb.go | 1 + x/crosschain/types/keys.go | 2 -- x/crosschain/types/query.pb.go | 9 ++++++++- x/oracle/keeper/grpc_query_test.go | 10 +++++----- x/oracle/types/oracle.pb.go | 2 +- x/oracle/types/params.go | 1 - x/oracle/types/tx.pb.go | 22 ++++++++++++++------- 10 files changed, 46 insertions(+), 17 deletions(-) diff --git a/proto/cosmos/crosschain/v1/crosschain.proto b/proto/cosmos/crosschain/v1/crosschain.proto index 222197305a..2d8622e999 100644 --- a/proto/cosmos/crosschain/v1/crosschain.proto +++ b/proto/cosmos/crosschain/v1/crosschain.proto @@ -5,5 +5,6 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/crosschain/types"; // Params holds parameters for the cross chain module. message Params { + // initial balance to mint for crosschain module when the chain starts string init_module_balance = 1; } diff --git a/proto/cosmos/crosschain/v1/query.proto b/proto/cosmos/crosschain/v1/query.proto index 9d721b6436..45555a83bc 100644 --- a/proto/cosmos/crosschain/v1/query.proto +++ b/proto/cosmos/crosschain/v1/query.proto @@ -41,31 +41,38 @@ message QueryParamsResponse { // QueryCrossChainPackageRequest is the request type for the Query/CrossChainPackage RPC method. message QueryCrossChainPackageRequest { + // channel id of the cross chain package uint32 channel_id = 1; + // sequence of the cross chain package uint64 sequence = 2; } // QueryCrossChainPackageResponse is the response type for the Query/CrossChainPackage RPC method. message QueryCrossChainPackageResponse { + // content of the cross chain package bytes package = 1; } // QuerySendSequenceRequest is the request type for the Query/SendSequence RPC method. message QuerySendSequenceRequest { + // channel id of the cross chain package uint32 channel_id = 1; } // QuerySendSequenceResponse is the response type for the Query/SendSequence RPC method. message QuerySendSequenceResponse { + // sequence of the cross chain package uint64 sequence = 1; } // QuerySendSequenceRequest is the request type for the Query/ReceiveSequence RPC method. message QueryReceiveSequenceRequest { + // channel id of the cross chain package uint32 channel_id = 1; } // QuerySendSequenceResponse is the response type for the Query/ReceiveSequence RPC method. message QueryReceiveSequenceResponse { + // sequence of the cross chain package uint64 sequence = 1; } diff --git a/proto/cosmos/oracle/v1/tx.proto b/proto/cosmos/oracle/v1/tx.proto index 93c4b414a4..695fba5164 100644 --- a/proto/cosmos/oracle/v1/tx.proto +++ b/proto/cosmos/oracle/v1/tx.proto @@ -21,13 +21,21 @@ message MsgClaim { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; + // sender address of the msg string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // source chain id uint32 src_chain_id = 2; + // destination chain id uint32 dest_chain_id = 3; + // sequence of the oracle channel uint64 sequence = 4; + // timestamp of the claim uint64 timestamp = 5; + // payload of the claim bytes payload = 6; + // bit map of the voted validators repeated fixed64 vote_address_set = 7; + // bls signature of the claim bytes agg_signature = 8; } diff --git a/x/crosschain/types/crosschain.pb.go b/x/crosschain/types/crosschain.pb.go index 9e3e1bbd23..727c0836fc 100644 --- a/x/crosschain/types/crosschain.pb.go +++ b/x/crosschain/types/crosschain.pb.go @@ -24,6 +24,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the cross chain module. type Params struct { + // initial balance to mint for crosschain module when the chain starts InitModuleBalance string `protobuf:"bytes,1,opt,name=init_module_balance,json=initModuleBalance,proto3" json:"init_module_balance,omitempty"` } diff --git a/x/crosschain/types/keys.go b/x/crosschain/types/keys.go index f4c8a83df6..efa23c4632 100644 --- a/x/crosschain/types/keys.go +++ b/x/crosschain/types/keys.go @@ -24,8 +24,6 @@ const ( SequenceLength = 8 GovChannelId = sdk.ChannelID(9) - - QueryParameters = "parameters" ) var ( diff --git a/x/crosschain/types/query.pb.go b/x/crosschain/types/query.pb.go index 984242259e..26adb0fbd2 100644 --- a/x/crosschain/types/query.pb.go +++ b/x/crosschain/types/query.pb.go @@ -114,8 +114,10 @@ func (m *QueryParamsResponse) GetParams() Params { // QueryCrossChainPackageRequest is the request type for the Query/CrossChainPackage RPC method. type QueryCrossChainPackageRequest struct { + // channel id of the cross chain package ChannelId uint32 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // sequence of the cross chain package + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (m *QueryCrossChainPackageRequest) Reset() { *m = QueryCrossChainPackageRequest{} } @@ -167,6 +169,7 @@ func (m *QueryCrossChainPackageRequest) GetSequence() uint64 { // QueryCrossChainPackageResponse is the response type for the Query/CrossChainPackage RPC method. type QueryCrossChainPackageResponse struct { + // content of the cross chain package Package []byte `protobuf:"bytes,1,opt,name=package,proto3" json:"package,omitempty"` } @@ -212,6 +215,7 @@ func (m *QueryCrossChainPackageResponse) GetPackage() []byte { // QuerySendSequenceRequest is the request type for the Query/SendSequence RPC method. type QuerySendSequenceRequest struct { + // channel id of the cross chain package ChannelId uint32 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` } @@ -257,6 +261,7 @@ func (m *QuerySendSequenceRequest) GetChannelId() uint32 { // QuerySendSequenceResponse is the response type for the Query/SendSequence RPC method. type QuerySendSequenceResponse struct { + // sequence of the cross chain package Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` } @@ -302,6 +307,7 @@ func (m *QuerySendSequenceResponse) GetSequence() uint64 { // QuerySendSequenceRequest is the request type for the Query/ReceiveSequence RPC method. type QueryReceiveSequenceRequest struct { + // channel id of the cross chain package ChannelId uint32 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` } @@ -347,6 +353,7 @@ func (m *QueryReceiveSequenceRequest) GetChannelId() uint32 { // QuerySendSequenceResponse is the response type for the Query/ReceiveSequence RPC method. type QueryReceiveSequenceResponse struct { + // sequence of the cross chain package Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` } diff --git a/x/oracle/keeper/grpc_query_test.go b/x/oracle/keeper/grpc_query_test.go index 31b98f3606..9b9bc316bf 100644 --- a/x/oracle/keeper/grpc_query_test.go +++ b/x/oracle/keeper/grpc_query_test.go @@ -6,9 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/oracle/types" ) -func (suite *TestSuite) TestQueryParams() { - res, err := suite.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().Equal(suite.app.OracleKeeper.GetParams(suite.ctx), res.GetParams()) +func (s *TestSuite) TestQueryParams() { + res, err := s.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) + s.Require().NoError(err) + s.Require().NotNil(res) + s.Require().Equal(s.app.OracleKeeper.GetParams(s.ctx), res.GetParams()) } diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index 148e776481..66de90e8bb 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -87,7 +87,7 @@ func (m *Params) GetRelayerRewardShare() uint32 { return 0 } -// RelayInterval holds start and end tiem of in-turn relayer +// RelayInterval holds start and end(exclusive) time of in-turn relayer, [start, end) type RelayInterval struct { Start uint64 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"` End uint64 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index 1e3be60d4c..149331c0a1 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -14,7 +14,6 @@ const ( var ( KeyParamRelayerTimeout = []byte("RelayerTimeout") - KeyParamRelayerBackoffTime = []byte("RelayerBackoffTime") KeyParamRelayerRewardShare = []byte("RelayerRewardShare") KeyParamRelayerInterval = []byte("RelayerInterval") ) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 72a3c3e2dc..48fde0ff8c 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -33,14 +33,22 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgClaim defines the Msg/Claim request type type MsgClaim struct { - FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` - SrcChainId uint32 `protobuf:"varint,2,opt,name=src_chain_id,json=srcChainId,proto3" json:"src_chain_id,omitempty"` - DestChainId uint32 `protobuf:"varint,3,opt,name=dest_chain_id,json=destChainId,proto3" json:"dest_chain_id,omitempty"` - Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` - Timestamp uint64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Payload []byte `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` + // sender address of the msg + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` + // source chain id + SrcChainId uint32 `protobuf:"varint,2,opt,name=src_chain_id,json=srcChainId,proto3" json:"src_chain_id,omitempty"` + // destination chain id + DestChainId uint32 `protobuf:"varint,3,opt,name=dest_chain_id,json=destChainId,proto3" json:"dest_chain_id,omitempty"` + // sequence of the oracle channel + Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` + // timestamp of the claim + Timestamp uint64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // payload of the claim + Payload []byte `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` + // bit map of the voted validators VoteAddressSet []uint64 `protobuf:"fixed64,7,rep,packed,name=vote_address_set,json=voteAddressSet,proto3" json:"vote_address_set,omitempty"` - AggSignature []byte `protobuf:"bytes,8,opt,name=agg_signature,json=aggSignature,proto3" json:"agg_signature,omitempty"` + // bls signature of the claim + AggSignature []byte `protobuf:"bytes,8,opt,name=agg_signature,json=aggSignature,proto3" json:"agg_signature,omitempty"` } func (m *MsgClaim) Reset() { *m = MsgClaim{} }