diff --git a/math/uint_test.go b/math/uint_test.go index fbe59f44fb..d7f8fe8fd7 100644 --- a/math/uint_test.go +++ b/math/uint_test.go @@ -370,5 +370,4 @@ func (s *uintTestSuite) TestUintBigEndian() { u2 = u2.SetBytes(u1b) s.Require().Equal(u1, u2) - } diff --git a/proto/cosmos/auth/v1beta1/query.proto b/proto/cosmos/auth/v1beta1/query.proto index 0b66da6050..b5c65e28c8 100644 --- a/proto/cosmos/auth/v1beta1/query.proto +++ b/proto/cosmos/auth/v1beta1/query.proto @@ -48,12 +48,12 @@ service Query { option (google.api.http).get = "/cosmos/auth/v1beta1/module_accounts/{name}"; } -// // Bech32Prefix queries bech32Prefix -// // -// // Since: cosmos-sdk 0.46 -// rpc Bech32Prefix(Bech32PrefixRequest) returns (Bech32PrefixResponse) { -// option (google.api.http).get = "/cosmos/auth/v1beta1/bech32"; -// } + // // Bech32Prefix queries bech32Prefix + // // + // // Since: cosmos-sdk 0.46 + // rpc Bech32Prefix(Bech32PrefixRequest) returns (Bech32PrefixResponse) { + // option (google.api.http).get = "/cosmos/auth/v1beta1/bech32"; + // } // AddressBytesToString converts Account Address bytes to string // @@ -138,12 +138,12 @@ message QueryModuleAccountByNameResponse { //// Bech32PrefixRequest is the request type for Bech32Prefix rpc method. //// //// Since: cosmos-sdk 0.46 -//message Bech32PrefixRequest {} +// message Bech32PrefixRequest {} //// Bech32PrefixResponse is the response type for Bech32Prefix rpc method. //// //// Since: cosmos-sdk 0.46 -//message Bech32PrefixResponse { +// message Bech32PrefixResponse { // string bech32_prefix = 1; //} diff --git a/proto/cosmos/crosschain/v1/query.proto b/proto/cosmos/crosschain/v1/query.proto index b5a5086448..9d721b6436 100644 --- a/proto/cosmos/crosschain/v1/query.proto +++ b/proto/cosmos/crosschain/v1/query.proto @@ -42,7 +42,7 @@ message QueryParamsResponse { // QueryCrossChainPackageRequest is the request type for the Query/CrossChainPackage RPC method. message QueryCrossChainPackageRequest { uint32 channel_id = 1; - uint64 sequence = 2; + uint64 sequence = 2; } // QueryCrossChainPackageResponse is the response type for the Query/CrossChainPackage RPC method. diff --git a/proto/cosmos/crypto/eth/bls/keys.proto b/proto/cosmos/crypto/eth/bls/keys.proto index f5289d8347..4e4a3d4c9e 100644 --- a/proto/cosmos/crypto/eth/bls/keys.proto +++ b/proto/cosmos/crypto/eth/bls/keys.proto @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/eth/bls"; // PubKey defines a bls public key -// Key is the compressed form of the pubkey. +// Key is the compressed form of the pubkey. message PubKey { option (gogoproto.goproto_stringer) = false; diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 4d911da161..2408bb7e71 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -18,9 +18,9 @@ message Params { // MsgGasParams defines gas for a msg type message MsgGasParams { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string msg_type_url = 1 [(gogoproto.customname) = "MsgTypeUrl"]; + string msg_type_url = 1 [(gogoproto.customname) = "MsgTypeUrl"]; // gas_params is the oneof that represents either fixed_gas_params or dynamic_gas_params oneof gas_params { // fixed_type specifies fixed type gas params. @@ -34,14 +34,14 @@ message MsgGasParams { } // FixedGasParams defines the parameters for fixed gas type. message FixedGasParams { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; uint64 fixed_gas = 1 [(gogoproto.customname) = "FixedGas"]; } // DynamicGasParams defines the parameters for dynamic gas type. message DynamicGasParams { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; uint64 fixed_gas = 1 [(gogoproto.customname) = "FixedGas"]; uint64 gas_per_item = 2 [(gogoproto.customname) = "GasPerItem"]; diff --git a/proto/cosmos/gashub/v1alpha1/tx.proto b/proto/cosmos/gashub/v1alpha1/tx.proto index cceb2b773a..a0eeb94891 100644 --- a/proto/cosmos/gashub/v1alpha1/tx.proto +++ b/proto/cosmos/gashub/v1alpha1/tx.proto @@ -22,7 +22,7 @@ message MsgUpdateMsgGasParams { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; repeated MsgGasParams new_params_set = 2; } diff --git a/proto/cosmos/oracle/v1/event.proto b/proto/cosmos/oracle/v1/event.proto index fed8591578..311afc1a87 100644 --- a/proto/cosmos/oracle/v1/event.proto +++ b/proto/cosmos/oracle/v1/event.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package cosmos.oracle.v1; - option go_package = "github.com/cosmos/cosmos-sdk/x/oracle/types"; // EventPackageClaim is emitted when a cross chain package is processed diff --git a/proto/cosmos/oracle/v1/oracle.proto b/proto/cosmos/oracle/v1/oracle.proto index 0739e2e90d..673272fd80 100644 --- a/proto/cosmos/oracle/v1/oracle.proto +++ b/proto/cosmos/oracle/v1/oracle.proto @@ -7,9 +7,15 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/oracle/types"; message Params { // Timeout for the in turn relayer uint64 relayer_timeout = 1; // in s - // Backoff time for the other relayers - uint64 relayer_backoff_time = 2; // in s + // RelayInterval is for in-turn relayer + uint64 relayer_interval = 2; // in s // Reward share for the relayer sends the claim message, // the other relayers signed the bls message will share the reward evenly. uint32 relayer_reward_share = 3; // in percentage } + +// RelayInterval holds start and end(exclusive) time of in-turn relayer, [start, end) +message RelayInterval { + uint64 start = 1; + uint64 end = 2; +} diff --git a/proto/cosmos/oracle/v1/query.proto b/proto/cosmos/oracle/v1/query.proto index dd6cc191a9..65d4b6a5ac 100644 --- a/proto/cosmos/oracle/v1/query.proto +++ b/proto/cosmos/oracle/v1/query.proto @@ -13,6 +13,11 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/cosmos/oracle/v1/params"; } + + // InturnRelayer returns the inturn relayer bls pub key and its relay interval + rpc InturnRelayer(QueryInturnRelayerRequest) returns (QueryInturnRelayerResponse) { + option (google.api.http).get = "/cosmos/oracle/v1/inturn_relayer"; + } } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -22,4 +27,13 @@ message QueryParamsRequest {} message QueryParamsResponse { // params defines the parameters of the module. Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryInturnRelayerRequest is the request type for the Query In-turn relayer RPC method. +message QueryInturnRelayerRequest {} + +// QueryInturnRelayerResponse is the response type for the Query In-turn relayer RPC method. +message QueryInturnRelayerResponse { + string bls_pub_key = 1; + RelayInterval relay_interval = 2; } \ No newline at end of file diff --git a/proto/cosmos/oracle/v1/tx.proto b/proto/cosmos/oracle/v1/tx.proto index e0b2920a76..93c4b414a4 100644 --- a/proto/cosmos/oracle/v1/tx.proto +++ b/proto/cosmos/oracle/v1/tx.proto @@ -21,14 +21,14 @@ message MsgClaim { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - uint32 src_chain_id = 2; - uint32 dest_chain_id = 3; - uint64 sequence = 4; - uint64 timestamp = 5; - bytes payload = 6; - repeated fixed64 vote_address_set = 7; - bytes agg_signature = 8; + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + uint32 src_chain_id = 2; + uint32 dest_chain_id = 3; + uint64 sequence = 4; + uint64 timestamp = 5; + bytes payload = 6; + repeated fixed64 vote_address_set = 7; + bytes agg_signature = 8; } // MsgClaimResponse defines the Msg/Claim response type diff --git a/proto/cosmos/params/v1beta1/params.proto b/proto/cosmos/params/v1beta1/params.proto index 0a081a4631..83936c7d32 100644 --- a/proto/cosmos/params/v1beta1/params.proto +++ b/proto/cosmos/params/v1beta1/params.proto @@ -16,8 +16,8 @@ message ParameterChangeProposal { string title = 1; string description = 2; repeated ParamChange changes = 3 [(gogoproto.nullable) = false]; - bool cross_chain = 4; // flag for cross chain proposal - repeated string addresses = 5; // used with cross_chain field to specify destination smart contract address(es) + bool cross_chain = 4; // flag for cross chain proposal + repeated string addresses = 5; // used with cross_chain field to specify destination smart contract address(es) } // ParamChange defines an individual parameter change, for use in diff --git a/proto/cosmos/slashing/v1beta1/tx.proto b/proto/cosmos/slashing/v1beta1/tx.proto index ab80d73086..0e5d6e12f5 100644 --- a/proto/cosmos/slashing/v1beta1/tx.proto +++ b/proto/cosmos/slashing/v1beta1/tx.proto @@ -40,8 +40,8 @@ message MsgImpeach { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // MsgImpeachResponse defines the Msg/Impeach response type. diff --git a/proto/cosmos/staking/v1beta1/tx.proto b/proto/cosmos/staking/v1beta1/tx.proto index e6b0ef5952..8bbb201758 100644 --- a/proto/cosmos/staking/v1beta1/tx.proto +++ b/proto/cosmos/staking/v1beta1/tx.proto @@ -62,7 +62,7 @@ message MsgCreateValidator { string from = 8 [(cosmos_proto.scalar) = "cosmos.AddressString"]; string relayer_address = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string relayer_bls_key = 10; + string relayer_bls_key = 10; } // MsgCreateValidatorResponse defines the Msg/CreateValidator response type. @@ -87,8 +87,8 @@ message MsgEditValidator { string min_self_delegation = 4 [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; - string relayer_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string relayer_bls_key = 6; // The BLS pubkey for the authorized relayer + string relayer_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string relayer_bls_key = 6; // The BLS pubkey for the authorized relayer } // MsgEditValidatorResponse defines the Msg/EditValidator response type. diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index a57ca31d86..ba963bcf22 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -102,30 +102,30 @@ message SignDocEip712 { // chain_id is the identifier of the chain this transaction targets. // It prevents signed transactions from being used on another chain by an // attacker. - uint64 chain_id = 1[(gogoproto.jsontag) = "chain_id"]; + uint64 chain_id = 1 [(gogoproto.jsontag) = "chain_id"]; // account_number is the account number of the account in state. - uint64 account_number = 2[(gogoproto.jsontag) = "account_number"]; + uint64 account_number = 2 [(gogoproto.jsontag) = "account_number"]; // sequence is the sequence number of the signing account. - uint64 sequence = 3[(gogoproto.jsontag) = "sequence"]; + uint64 sequence = 3 [(gogoproto.jsontag) = "sequence"]; // Fee is the fee and gas limit for the transaction. The first signer is the // primary signer and the one which pays the fee. The fee can be calculated // based on the cost of evaluating the body and doing signature verification // of the signers. This can be estimated via simulation. - Fee fee = 4[(gogoproto.nullable) = false]; + Fee fee = 4 [(gogoproto.nullable) = false]; // msg is the msg in the EIP712 transaction. google.protobuf.Any msg = 5; // timeout_height is the transaction's timeout height (if set). - uint64 timeout_height = 6[(gogoproto.jsontag) = "timeout_height"]; + uint64 timeout_height = 6 [(gogoproto.jsontag) = "timeout_height"]; // memo is any arbitrary note/comment to be added to the transaction. // WARNING: in clients, any publicly exposed text should not be called memo, // but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). - string memo = 7[(gogoproto.jsontag) = "memo"]; + string memo = 7 [(gogoproto.jsontag) = "memo"]; // Tip is the optional tip used for transactions fees paid in another denom. // It should be left empty if the signer is not the tipper for this diff --git a/x/auth/tx/eip712_test.go b/x/auth/tx/eip712_test.go index 94538f70c0..3f83711b20 100644 --- a/x/auth/tx/eip712_test.go +++ b/x/auth/tx/eip712_test.go @@ -3,6 +3,7 @@ package tx import ( "fmt" "testing" + "time" "github.com/stretchr/testify/require" @@ -19,7 +20,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/group" - "time" ) func TestEIP712Handler(t *testing.T) { diff --git a/x/gashub/simulation/params_test.go b/x/gashub/simulation/params_test.go index 26422f7c45..64c3459a1a 100644 --- a/x/gashub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "fmt" "math/rand" "testing" @@ -8,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/gashub/simulation" "github.com/cosmos/cosmos-sdk/x/gashub/types" - "fmt" ) func TestParamChanges(t *testing.T) { diff --git a/x/oracle/keeper/grpc_query.go b/x/oracle/keeper/grpc_query.go index aa2280b2a9..357b7c4658 100644 --- a/x/oracle/keeper/grpc_query.go +++ b/x/oracle/keeper/grpc_query.go @@ -1,7 +1,22 @@ package keeper import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/oracle/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) var _ types.QueryServer = Keeper{} + +// InturnRelayer returns current in-turn relayer and its relaying start and end time +func (k Keeper) InturnRelayer(c context.Context, req *types.QueryInturnRelayerRequest) (*types.QueryInturnRelayerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + _, relayerInterval := k.GetRelayerParams(ctx) + return k.GetInturnRelayer(ctx, relayerInterval) +} diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 52a39e3359..c11b703cb4 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -1,9 +1,11 @@ package keeper import ( + "encoding/hex" "fmt" sdkerrors "cosmossdk.io/errors" + "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/tendermint/tendermint/libs/log" "github.com/willf/bitset" @@ -65,13 +67,13 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } -// GetRelayerParam returns the relayer timeout and backoff time for oracle claim -func (k Keeper) GetRelayerParam(ctx sdk.Context) (uint64, uint64) { +// GetRelayerParams returns the relayer timeout, relayer interval for oracle claim +func (k Keeper) GetRelayerParams(ctx sdk.Context) (uint64, uint64) { var relayerTimeoutParam uint64 - var relayerBackoffTimeParam uint64 + var relayerIntervalParam uint64 k.paramSpace.Get(ctx, types.KeyParamRelayerTimeout, &relayerTimeoutParam) - k.paramSpace.Get(ctx, types.KeyParamRelayerBackoffTime, &relayerBackoffTimeParam) - return relayerTimeoutParam, relayerBackoffTimeParam + k.paramSpace.Get(ctx, types.KeyParamRelayerInterval, &relayerIntervalParam) + return relayerTimeoutParam, relayerIntervalParam } // GetRelayerRewardShare returns the relayer reward share @@ -84,9 +86,11 @@ func (k Keeper) GetRelayerRewardShare(ctx sdk.Context) uint32 { // IsRelayerValid returns true if the relayer is valid and allowed to send the claim message func (k Keeper) IsRelayerValid(ctx sdk.Context, relayer sdk.AccAddress, validators []stakingtypes.Validator, claimTimestamp uint64) (bool, error) { var validatorIndex int64 = -1 + var vldr stakingtypes.Validator for index, validator := range validators { if validator.RelayerAddress == relayer.String() { validatorIndex = int64(index) + vldr = validator break } } @@ -95,23 +99,22 @@ func (k Keeper) IsRelayerValid(ctx sdk.Context, relayer sdk.AccAddress, validato return false, sdkerrors.Wrapf(types.ErrNotRelayer, fmt.Sprintf("sender(%s) is not a relayer", relayer.String())) } - // check inturn validator index - inturnValidatorIndex := claimTimestamp % uint64(len(validators)) + inturnRelayerTimeout, relayerInterval := k.GetRelayerParams(ctx) - curTime := ctx.BlockTime().Unix() - relayerTimeout, relayerBackoffTime := k.GetRelayerParam(ctx) + // check whether submitter of msgClaim is an in-turn relayer + inturnRelayer, err := k.GetInturnRelayer(ctx, relayerInterval) + if err != nil { + return false, err + } - // inturn validator can always relay package - if uint64(validatorIndex) == inturnValidatorIndex { + if inturnRelayer.BlsPubKey == hex.EncodeToString(vldr.RelayerBlsKey) { return true, nil } - // not inturn validators can not relay in the timeout duration - if uint64(curTime)-claimTimestamp <= relayerTimeout { - return false, nil - } - validatorDistance := (validatorIndex - int64(inturnValidatorIndex) + int64(len(validators))) % int64(len(validators)) - return curTime > int64(claimTimestamp+relayerTimeout)+(validatorDistance-1)*int64(relayerBackoffTime), nil + // It is possible that claim comes from out-turn relayers when exceeding the inturnRelayerTimeout, all other + // relayers can relay within the in-turn relayer's current interval + curTime := ctx.BlockTime().Unix() + return uint64(curTime)-claimTimestamp >= inturnRelayerTimeout, nil } // CheckClaim checks the bls signature @@ -131,6 +134,7 @@ func (k Keeper) CheckClaim(ctx sdk.Context, claim *types.MsgClaim) (sdk.AccAddre if err != nil { return sdk.AccAddress{}, nil, err } + if !isValid { return sdk.AccAddress{}, nil, sdkerrors.Wrapf(types.ErrRelayerNotInTurn, fmt.Sprintf("relayer(%s) is not in turn", claim.FromAddress)) } @@ -179,3 +183,36 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramSpace.GetParamSet(ctx, ¶ms) return params } + +func (k Keeper) GetInturnRelayer(ctx sdk.Context, relayerInterval uint64) (*types.QueryInturnRelayerResponse, error) { + historicalInfo, ok := k.StakingKeeper.GetHistoricalInfo(ctx, ctx.BlockHeight()) + if !ok { + return nil, sdkerrors.Wrapf(types.ErrValidatorSet, "get historical validators failed") + } + validators := historicalInfo.Valset + + validatorsSize := len(validators) + + // totalIntervals is sum of intervals from all relayers + totalIntervals := relayerInterval * uint64(validatorsSize) + + curTimeStamp := uint64(ctx.BlockTime().Unix()) + + // remainder is used to locate inturn relayer. + remainder := curTimeStamp % totalIntervals + inTurnRelayerIndex := remainder / relayerInterval + + start := curTimeStamp - (remainder - inTurnRelayerIndex*relayerInterval) + end := start + relayerInterval + + inturnRelayer := validators[inTurnRelayerIndex] + + res := &types.QueryInturnRelayerResponse{ + BlsPubKey: hex.EncodeToString(inturnRelayer.RelayerBlsKey), + RelayInterval: &types.RelayInterval{ + Start: start, + End: end, + }, + } + return res, nil +} diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index 28d488d7f5..1665f85f84 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -76,26 +76,24 @@ func TestTestSuite(t *testing.T) { func (s *TestSuite) TestProcessClaim() { s.app.OracleKeeper.SetParams(s.ctx, types.Params{ RelayerTimeout: 5, - RelayerBackoffTime: 3, RelayerRewardShare: 50, + RelayerInterval: 600, }) _, _, newValidators, blsKeys := createValidators(s.T(), s.ctx, s.app, []int64{9, 8, 7}) - validators := s.app.StakingKeeper.GetLastValidators(s.ctx) - s.app.StakingKeeper.SetHistoricalInfo(s.ctx, s.ctx.BlockHeight(), &stakingtypes.HistoricalInfo{ Header: s.ctx.BlockHeader(), - Valset: validators, + Valset: newValidators, }) validatorMap := make(map[string]int, 0) - for idx, validator := range validators { + for idx, validator := range newValidators { validatorMap[validator.RelayerAddress] = idx } msgClaim := types.MsgClaim{ - FromAddress: validators[0].RelayerAddress, + FromAddress: newValidators[0].RelayerAddress, SrcChainId: 1, DestChainId: 2, Sequence: 1, @@ -154,27 +152,37 @@ func (s *TestSuite) TestProcessClaim() { func (s *TestSuite) TestKeeper_IsRelayerValid() { s.app.OracleKeeper.SetParams(s.ctx, types.Params{ RelayerTimeout: 5, - RelayerBackoffTime: 3, RelayerRewardShare: 50, + RelayerInterval: 600, }) vals := make([]stakingtypes.Validator, 5) for i := range vals { pk := ed25519.GenPrivKey().PubKey() - vals[i] = newValidator(s.T(), sdk.AccAddress(pk.Address()), pk) + val := newValidator(s.T(), sdk.AccAddress(pk.Address()), pk) + privKey, _ := blst.RandKey() + val.RelayerBlsKey = privKey.PublicKey().Marshal() + vals[i] = val } + s.app.StakingKeeper.SetHistoricalInfo(s.ctx, s.ctx.BlockHeight(), &stakingtypes.HistoricalInfo{ + Header: s.ctx.BlockHeader(), + Valset: vals, + }) + val0Addr := vals[0].RelayerAddress val1Addr := vals[1].RelayerAddress + val3Addr := vals[3].RelayerAddress + // in-turn relayer is relayer 3 and interval is [1800, 2400) tests := []struct { claimMsg types.MsgClaim blockTime int64 expectedPass bool errorMsg string }{ - { + { // out-turn relayer within the in-turn relayer interval, and not exceeding the timeout, so is not eligible to relay types.MsgClaim{ FromAddress: val0Addr, SrcChainId: 1, @@ -186,33 +194,16 @@ func (s *TestSuite) TestKeeper_IsRelayerValid() { AggSignature: []byte("test sig"), }, 1992, - true, - "", - }, - // wrong validator in timeout - { - types.MsgClaim{ - FromAddress: val1Addr, - SrcChainId: 1, - DestChainId: 2, - Sequence: 1, - Timestamp: 1990, - Payload: []byte("test payload"), - VoteAddressSet: []uint64{0, 1}, - AggSignature: []byte("test sig"), - }, - 1992, false, "", }, - // right validator in backoff time - { + { // out-turn relayer within the in-turn relayer interval, but exceeding the timeout, so is eligible to relay types.MsgClaim{ FromAddress: val1Addr, SrcChainId: 1, DestChainId: 2, Sequence: 1, - Timestamp: 1985, + Timestamp: 1800, Payload: []byte("test payload"), VoteAddressSet: []uint64{0, 1}, AggSignature: []byte("test sig"), @@ -221,10 +212,10 @@ func (s *TestSuite) TestKeeper_IsRelayerValid() { true, "", }, - // wrong validator in backoff time + // in-turn relayer, even exceeding timeout { types.MsgClaim{ - FromAddress: val0Addr, + FromAddress: val3Addr, SrcChainId: 1, DestChainId: 2, Sequence: 1, @@ -237,19 +228,19 @@ func (s *TestSuite) TestKeeper_IsRelayerValid() { true, "", }, - // right validator in backoff time + // in-turn relayer, within the timeout { types.MsgClaim{ - FromAddress: val0Addr, + FromAddress: val3Addr, SrcChainId: 1, DestChainId: 2, Sequence: 1, - Timestamp: 1970, + Timestamp: 1990, Payload: []byte("test payload"), VoteAddressSet: []uint64{0, 1}, AggSignature: []byte("test sig"), }, - 1989, + 1992, true, "", }, diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index 94be454885..d1014d3e12 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -32,21 +32,19 @@ func (s *TestSuite) TestClaim() { s.app.OracleKeeper.SetParams(s.ctx, types.Params{ RelayerTimeout: 5, - RelayerBackoffTime: 3, RelayerRewardShare: 50, + RelayerInterval: 600, }) _, _, newValidators, blsKeys := createValidators(s.T(), s.ctx, s.app, []int64{9, 8, 7}) - validators := s.app.StakingKeeper.GetLastValidators(s.ctx) - s.app.StakingKeeper.SetHistoricalInfo(s.ctx, s.ctx.BlockHeight(), &stakingtypes.HistoricalInfo{ Header: s.ctx.BlockHeader(), - Valset: validators, + Valset: newValidators, }) validatorMap := make(map[string]int, 0) - for idx, validator := range validators { + for idx, validator := range newValidators { validatorMap[validator.RelayerAddress] = idx } @@ -67,7 +65,7 @@ func (s *TestSuite) TestClaim() { s.Require().Nil(err, "encode package error") msgClaim := types.MsgClaim{ - FromAddress: validators[0].RelayerAddress, + FromAddress: newValidators[0].RelayerAddress, SrcChainId: 56, DestChainId: 1, Sequence: 0, @@ -98,26 +96,24 @@ func (s *TestSuite) TestInvalidClaim() { s.app.OracleKeeper.SetParams(s.ctx, types.Params{ RelayerTimeout: 5, - RelayerBackoffTime: 3, RelayerRewardShare: 50, + RelayerInterval: 600, }) _, _, newValidators, blsKeys := createValidators(s.T(), s.ctx, s.app, []int64{9, 8, 7}) - validators := s.app.StakingKeeper.GetLastValidators(s.ctx) - s.app.StakingKeeper.SetHistoricalInfo(s.ctx, s.ctx.BlockHeight(), &stakingtypes.HistoricalInfo{ Header: s.ctx.BlockHeader(), - Valset: validators, + Valset: newValidators, }) validatorMap := make(map[string]int, 0) - for idx, validator := range validators { + for idx, validator := range newValidators { validatorMap[validator.RelayerAddress] = idx } msgClaim := types.MsgClaim{ - FromAddress: validators[0].RelayerAddress, + FromAddress: newValidators[0].RelayerAddress, SrcChainId: 65, DestChainId: 1, Sequence: 0, diff --git a/x/oracle/module.go b/x/oracle/module.go index c62cdffda2..574dbcb78f 100644 --- a/x/oracle/module.go +++ b/x/oracle/module.go @@ -1,6 +1,7 @@ package oracle import ( + "context" "encoding/json" "fmt" "math/rand" @@ -57,6 +58,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the params module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns no root tx command for the params module. diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 55859a5001..78ae0b7ea6 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -26,10 +26,6 @@ func ValidateGenesis(data GenesisState) error { return fmt.Errorf("relayer timeout should be positive, is %d", data.Params.RelayerTimeout) } - if data.Params.RelayerBackoffTime <= 0 { - return fmt.Errorf("the relayer backoff time must be positive, is %d", data.Params.RelayerBackoffTime) - } - if data.Params.RelayerRewardShare <= 0 { return fmt.Errorf("the relayer reward share must be positive, is %d", data.Params.RelayerRewardShare) } @@ -37,5 +33,9 @@ func ValidateGenesis(data GenesisState) error { if data.Params.RelayerRewardShare > 100 { return fmt.Errorf("the relayer reward share should not be larger than 100, is %d", data.Params.RelayerRewardShare) } + + if data.Params.RelayerInterval <= 0 { + return fmt.Errorf("the relayer interval should be positive, is %d", data.Params.RelayerInterval) + } return nil } diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index 3eda561d70..148e776481 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -26,8 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // Timeout for the in turn relayer RelayerTimeout uint64 `protobuf:"varint,1,opt,name=relayer_timeout,json=relayerTimeout,proto3" json:"relayer_timeout,omitempty"` - // Backoff time for the other relayers - RelayerBackoffTime uint64 `protobuf:"varint,2,opt,name=relayer_backoff_time,json=relayerBackoffTime,proto3" json:"relayer_backoff_time,omitempty"` + // RelayInterval is for in-turn relayer + RelayerInterval uint64 `protobuf:"varint,2,opt,name=relayer_interval,json=relayerInterval,proto3" json:"relayer_interval,omitempty"` // Reward share for the relayer sends the claim message, // the other relayers signed the bls message will share the reward evenly. RelayerRewardShare uint32 `protobuf:"varint,3,opt,name=relayer_reward_share,json=relayerRewardShare,proto3" json:"relayer_reward_share,omitempty"` @@ -73,9 +73,9 @@ func (m *Params) GetRelayerTimeout() uint64 { return 0 } -func (m *Params) GetRelayerBackoffTime() uint64 { +func (m *Params) GetRelayerInterval() uint64 { if m != nil { - return m.RelayerBackoffTime + return m.RelayerInterval } return 0 } @@ -87,28 +87,84 @@ func (m *Params) GetRelayerRewardShare() uint32 { return 0 } +// RelayInterval holds start and end tiem of in-turn relayer +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"` +} + +func (m *RelayInterval) Reset() { *m = RelayInterval{} } +func (m *RelayInterval) String() string { return proto.CompactTextString(m) } +func (*RelayInterval) ProtoMessage() {} +func (*RelayInterval) Descriptor() ([]byte, []int) { + return fileDescriptor_3dec273964b5043c, []int{1} +} +func (m *RelayInterval) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RelayInterval) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RelayInterval.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 *RelayInterval) XXX_Merge(src proto.Message) { + xxx_messageInfo_RelayInterval.Merge(m, src) +} +func (m *RelayInterval) XXX_Size() int { + return m.Size() +} +func (m *RelayInterval) XXX_DiscardUnknown() { + xxx_messageInfo_RelayInterval.DiscardUnknown(m) +} + +var xxx_messageInfo_RelayInterval proto.InternalMessageInfo + +func (m *RelayInterval) GetStart() uint64 { + if m != nil { + return m.Start + } + return 0 +} + +func (m *RelayInterval) GetEnd() uint64 { + if m != nil { + return m.End + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "cosmos.oracle.v1.Params") + proto.RegisterType((*RelayInterval)(nil), "cosmos.oracle.v1.RelayInterval") } func init() { proto.RegisterFile("cosmos/oracle/v1/oracle.proto", fileDescriptor_3dec273964b5043c) } var fileDescriptor_3dec273964b5043c = []byte{ - // 219 bytes of a gzipped FileDescriptorProto + // 252 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a, - 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x20, 0xd2, 0x7a, 0x50, 0xc1, 0x32, 0x43, 0xa5, 0xa9, 0x8c, - 0x5c, 0x6c, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x42, 0xea, 0x5c, 0xfc, 0x45, 0xa9, 0x39, 0x89, - 0x95, 0xa9, 0x45, 0xf1, 0x25, 0x99, 0xb9, 0xa9, 0xf9, 0xa5, 0x25, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, - 0x2c, 0x41, 0x7c, 0x50, 0xe1, 0x10, 0x88, 0xa8, 0x90, 0x01, 0x97, 0x08, 0x4c, 0x61, 0x52, 0x62, - 0x72, 0x76, 0x7e, 0x5a, 0x1a, 0x58, 0x83, 0x04, 0x13, 0x58, 0xb5, 0x10, 0x54, 0xce, 0x09, 0x22, - 0x05, 0xd2, 0x84, 0xac, 0xa3, 0x28, 0xb5, 0x3c, 0xb1, 0x28, 0x25, 0xbe, 0x38, 0x23, 0xb1, 0x28, - 0x55, 0x82, 0x59, 0x81, 0x51, 0x83, 0x17, 0xae, 0x23, 0x08, 0x2c, 0x15, 0x0c, 0x92, 0x71, 0x72, - 0x3d, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, - 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xed, 0xf4, 0xcc, 0x92, 0x8c, - 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x6f, 0x21, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, - 0x05, 0xcc, 0xeb, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x7f, 0x1b, 0x03, 0x02, 0x00, - 0x00, 0xff, 0xff, 0xcc, 0x35, 0x86, 0x1a, 0x18, 0x01, 0x00, 0x00, + 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x20, 0xd2, 0x7a, 0x50, 0xc1, 0x32, 0x43, 0xa5, 0x3e, 0x46, + 0x2e, 0xb6, 0x80, 0xc4, 0xa2, 0xc4, 0xdc, 0x62, 0x21, 0x75, 0x2e, 0xfe, 0xa2, 0xd4, 0x9c, 0xc4, + 0xca, 0xd4, 0xa2, 0xf8, 0x92, 0xcc, 0xdc, 0xd4, 0xfc, 0xd2, 0x12, 0x09, 0x46, 0x05, 0x46, 0x0d, + 0x96, 0x20, 0x3e, 0xa8, 0x70, 0x08, 0x44, 0x54, 0x48, 0x93, 0x4b, 0x00, 0xa6, 0x30, 0x33, 0xaf, + 0x24, 0xb5, 0xa8, 0x2c, 0x31, 0x47, 0x82, 0x09, 0xac, 0x12, 0x66, 0x80, 0x27, 0x54, 0x58, 0xc8, + 0x80, 0x4b, 0x04, 0xa6, 0xb4, 0x28, 0xb5, 0x3c, 0xb1, 0x28, 0x25, 0xbe, 0x38, 0x23, 0xb1, 0x28, + 0x55, 0x82, 0x59, 0x81, 0x51, 0x83, 0x37, 0x48, 0x08, 0x2a, 0x17, 0x04, 0x96, 0x0a, 0x06, 0xc9, + 0x28, 0x99, 0x73, 0xf1, 0x06, 0x81, 0x44, 0xe1, 0x46, 0x88, 0x70, 0xb1, 0x16, 0x97, 0x24, 0x16, + 0xc1, 0x1c, 0x03, 0xe1, 0x08, 0x09, 0x70, 0x31, 0xa7, 0xe6, 0xa5, 0x40, 0xad, 0x05, 0x31, 0x9d, + 0x5c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, + 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x3b, 0x3d, 0xb3, 0x24, + 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x1a, 0x3e, 0x10, 0x4a, 0xb7, 0x38, 0x25, 0x5b, + 0xbf, 0x02, 0x16, 0x58, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x90, 0x32, 0x06, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x59, 0x7c, 0xef, 0x48, 0x4a, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -136,8 +192,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - if m.RelayerBackoffTime != 0 { - i = encodeVarintOracle(dAtA, i, uint64(m.RelayerBackoffTime)) + if m.RelayerInterval != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RelayerInterval)) i-- dAtA[i] = 0x10 } @@ -149,6 +205,39 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *RelayInterval) 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 *RelayInterval) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RelayInterval) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.End != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.End)) + i-- + dAtA[i] = 0x10 + } + if m.Start != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.Start)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintOracle(dAtA []byte, offset int, v uint64) int { offset -= sovOracle(v) base := offset @@ -169,8 +258,8 @@ func (m *Params) Size() (n int) { if m.RelayerTimeout != 0 { n += 1 + sovOracle(uint64(m.RelayerTimeout)) } - if m.RelayerBackoffTime != 0 { - n += 1 + sovOracle(uint64(m.RelayerBackoffTime)) + if m.RelayerInterval != 0 { + n += 1 + sovOracle(uint64(m.RelayerInterval)) } if m.RelayerRewardShare != 0 { n += 1 + sovOracle(uint64(m.RelayerRewardShare)) @@ -178,6 +267,21 @@ func (m *Params) Size() (n int) { return n } +func (m *RelayInterval) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Start != 0 { + n += 1 + sovOracle(uint64(m.Start)) + } + if m.End != 0 { + n += 1 + sovOracle(uint64(m.End)) + } + return n +} + func sovOracle(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -234,9 +338,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RelayerBackoffTime", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RelayerInterval", wireType) } - m.RelayerBackoffTime = 0 + m.RelayerInterval = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOracle @@ -246,7 +350,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RelayerBackoffTime |= uint64(b&0x7F) << shift + m.RelayerInterval |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -291,6 +395,94 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } +func (m *RelayInterval) 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 ErrIntOverflowOracle + } + 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: RelayInterval: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelayInterval: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Start", wireType) + } + m.Start = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Start |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field End", wireType) + } + m.End = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.End |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipOracle(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index 846c45fe1c..1e3be60d4c 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -7,22 +7,23 @@ import ( ) const ( - DefaultRelayerTimeout uint64 = 40 // in s - DefaultRelayerBackoffTime uint64 = 5 // in s - DefaultRelayerRewardShare uint32 = 50 // in s + DefaultRelayerTimeout uint64 = 40 // in s + DefaultRelayerRewardShare uint32 = 50 // in s + DefaultRealyerInterval uint64 = 600 // in s ) var ( KeyParamRelayerTimeout = []byte("RelayerTimeout") KeyParamRelayerBackoffTime = []byte("RelayerBackoffTime") KeyParamRelayerRewardShare = []byte("RelayerRewardShare") + KeyParamRelayerInterval = []byte("RelayerInterval") ) func DefaultParams() Params { return Params{ RelayerTimeout: DefaultRelayerTimeout, - RelayerBackoffTime: DefaultRelayerBackoffTime, RelayerRewardShare: DefaultRelayerRewardShare, + RelayerInterval: DefaultRealyerInterval, } } @@ -34,8 +35,8 @@ func ParamKeyTable() paramtypes.KeyTable { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyParamRelayerTimeout, &p.RelayerTimeout, validateRelayerTimeout), - paramtypes.NewParamSetPair(KeyParamRelayerBackoffTime, &p.RelayerBackoffTime, validateRelayerBackoffTime), paramtypes.NewParamSetPair(KeyParamRelayerRewardShare, &p.RelayerRewardShare, validateRelayerRewardShare), + paramtypes.NewParamSetPair(KeyParamRelayerInterval, &p.RelayerInterval, validateRelayerInterval), } } @@ -52,31 +53,31 @@ func validateRelayerTimeout(i interface{}) error { return nil } -func validateRelayerBackoffTime(i interface{}) error { - v, ok := i.(uint64) +func validateRelayerRewardShare(i interface{}) error { + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } if v <= 0 { - return fmt.Errorf("the relayer backoff time must be positive: %d", v) + return fmt.Errorf("the relayer reward share should be positive: %d", v) + } + + if v > 100 { + return fmt.Errorf("the relayer reward share should not be larger than 100") } return nil } -func validateRelayerRewardShare(i interface{}) error { - v, ok := i.(uint32) +func validateRelayerInterval(i interface{}) error { + v, ok := i.(uint64) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } if v <= 0 { - return fmt.Errorf("the relayer reward share should be positive: %d", v) - } - - if v > 100 { - return fmt.Errorf("the relayer reward share should not be larger than 100") + return fmt.Errorf("the relayer relay interval should be positive: %d", v) } return nil diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index d5c13cdf13..cbfa67f99a 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -112,33 +112,132 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryInturnRelayerRequest is the request type for the Query In-turn relayer RPC method. +type QueryInturnRelayerRequest struct { +} + +func (m *QueryInturnRelayerRequest) Reset() { *m = QueryInturnRelayerRequest{} } +func (m *QueryInturnRelayerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryInturnRelayerRequest) ProtoMessage() {} +func (*QueryInturnRelayerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9f804c4644f3aaef, []int{2} +} +func (m *QueryInturnRelayerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInturnRelayerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInturnRelayerRequest.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 *QueryInturnRelayerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInturnRelayerRequest.Merge(m, src) +} +func (m *QueryInturnRelayerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryInturnRelayerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInturnRelayerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInturnRelayerRequest proto.InternalMessageInfo + +// QueryInturnRelayerResponse is the response type for the Query In-turn relayer RPC method. +type QueryInturnRelayerResponse struct { + BlsPubKey string `protobuf:"bytes,1,opt,name=bls_pub_key,json=blsPubKey,proto3" json:"bls_pub_key,omitempty"` + RelayInterval *RelayInterval `protobuf:"bytes,2,opt,name=relay_interval,json=relayInterval,proto3" json:"relay_interval,omitempty"` +} + +func (m *QueryInturnRelayerResponse) Reset() { *m = QueryInturnRelayerResponse{} } +func (m *QueryInturnRelayerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryInturnRelayerResponse) ProtoMessage() {} +func (*QueryInturnRelayerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9f804c4644f3aaef, []int{3} +} +func (m *QueryInturnRelayerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInturnRelayerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInturnRelayerResponse.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 *QueryInturnRelayerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInturnRelayerResponse.Merge(m, src) +} +func (m *QueryInturnRelayerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryInturnRelayerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInturnRelayerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInturnRelayerResponse proto.InternalMessageInfo + +func (m *QueryInturnRelayerResponse) GetBlsPubKey() string { + if m != nil { + return m.BlsPubKey + } + return "" +} + +func (m *QueryInturnRelayerResponse) GetRelayInterval() *RelayInterval { + if m != nil { + return m.RelayInterval + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.oracle.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.oracle.v1.QueryParamsResponse") + proto.RegisterType((*QueryInturnRelayerRequest)(nil), "cosmos.oracle.v1.QueryInturnRelayerRequest") + proto.RegisterType((*QueryInturnRelayerResponse)(nil), "cosmos.oracle.v1.QueryInturnRelayerResponse") } func init() { proto.RegisterFile("cosmos/oracle/v1/query.proto", fileDescriptor_9f804c4644f3aaef) } var fileDescriptor_9f804c4644f3aaef = []byte{ - // 276 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, - 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0xc8, 0xea, 0x41, 0x64, 0xf5, - 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x94, - 0x4c, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, - 0x49, 0x62, 0x49, 0x66, 0x7e, 0x5e, 0x31, 0x54, 0x56, 0x16, 0xc3, 0x0e, 0xa8, 0x79, 0x60, 0x69, - 0x25, 0x11, 0x2e, 0xa1, 0x40, 0x90, 0x9d, 0x01, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x41, 0xa9, 0x85, - 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0xbe, 0x5c, 0xc2, 0x28, 0xa2, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, - 0x42, 0x66, 0x5c, 0x6c, 0x05, 0x60, 0x11, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x09, 0x3d, - 0x74, 0x27, 0xea, 0x41, 0x74, 0x38, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0x55, 0x6d, 0xd4, - 0xc0, 0xc8, 0xc5, 0x0a, 0x36, 0x4f, 0xa8, 0x9c, 0x8b, 0x0d, 0xa2, 0x42, 0x48, 0x05, 0x53, 0x2f, - 0xa6, 0x43, 0xa4, 0x54, 0x09, 0xa8, 0x82, 0x38, 0x4c, 0x49, 0xa1, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, - 0x52, 0x42, 0x12, 0xfa, 0x18, 0xbe, 0x85, 0x38, 0xc1, 0xc9, 0xf5, 0xc4, 0x23, 0x39, 0xc6, 0x0b, - 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, - 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xb4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, - 0x61, 0xba, 0x21, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x05, 0xcc, 0xa8, 0x92, 0xca, 0x82, 0xd4, - 0xe2, 0x24, 0x36, 0x70, 0xa8, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x3b, 0xd3, 0x95, - 0xba, 0x01, 0x00, 0x00, + // 400 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x41, 0x6b, 0xe2, 0x40, + 0x18, 0x4d, 0x64, 0x57, 0x70, 0xc4, 0x65, 0x99, 0xf5, 0x90, 0xcd, 0xba, 0x51, 0xc2, 0x2e, 0x08, + 0xee, 0x66, 0xd0, 0x85, 0xfd, 0x01, 0x42, 0x0b, 0x52, 0x0a, 0x36, 0xc7, 0x5e, 0xc2, 0xc4, 0x0e, + 0x69, 0x30, 0x66, 0xe2, 0xcc, 0xc4, 0x36, 0xd7, 0xd2, 0x1f, 0x50, 0x68, 0xa1, 0x7f, 0xc9, 0xa3, + 0xd0, 0x4b, 0x4f, 0xa5, 0x68, 0x7f, 0x48, 0x71, 0x26, 0x42, 0x6d, 0x2c, 0xed, 0x29, 0xc9, 0xbc, + 0xf7, 0xbd, 0xf7, 0xbe, 0x97, 0x01, 0x8d, 0x11, 0xe5, 0x13, 0xca, 0x11, 0x65, 0x78, 0x14, 0x11, + 0x34, 0xeb, 0xa2, 0x69, 0x4a, 0x58, 0xe6, 0x24, 0x8c, 0x0a, 0x0a, 0xbf, 0x2a, 0xd4, 0x51, 0xa8, + 0x33, 0xeb, 0x9a, 0xf5, 0x80, 0x06, 0x54, 0x82, 0x68, 0xfd, 0xa6, 0x78, 0x66, 0x23, 0xa0, 0x34, + 0x88, 0x08, 0xc2, 0x49, 0x88, 0x70, 0x1c, 0x53, 0x81, 0x45, 0x48, 0x63, 0x9e, 0xa3, 0x3f, 0x0b, + 0x1e, 0xb9, 0x9e, 0x84, 0xed, 0x3a, 0x80, 0x47, 0x6b, 0xcf, 0x21, 0x66, 0x78, 0xc2, 0x5d, 0x32, + 0x4d, 0x09, 0x17, 0xf6, 0x21, 0xf8, 0xb6, 0x75, 0xca, 0x13, 0x1a, 0x73, 0x02, 0xff, 0x83, 0x72, + 0x22, 0x4f, 0x0c, 0xbd, 0xa5, 0xb7, 0xab, 0x3d, 0xc3, 0x79, 0x1d, 0xd1, 0x51, 0x13, 0xfd, 0x4f, + 0xf3, 0x87, 0xa6, 0xe6, 0xe6, 0x6c, 0xfb, 0x07, 0xf8, 0x2e, 0xe5, 0x06, 0xb1, 0x48, 0x59, 0xec, + 0x92, 0x08, 0x67, 0x84, 0x6d, 0xbc, 0x2e, 0x75, 0x60, 0xee, 0x42, 0x73, 0x4f, 0x0b, 0x54, 0xfd, + 0x88, 0x7b, 0x49, 0xea, 0x7b, 0x63, 0x92, 0x49, 0xe3, 0x8a, 0x5b, 0xf1, 0x23, 0x3e, 0x4c, 0xfd, + 0x03, 0x92, 0xc1, 0x7d, 0xf0, 0x85, 0xad, 0x47, 0xbc, 0x30, 0x16, 0x84, 0xcd, 0x70, 0x64, 0x94, + 0x64, 0xb6, 0x66, 0x31, 0x9b, 0x94, 0x1e, 0xe4, 0x34, 0xb7, 0xc6, 0x5e, 0x7e, 0xf6, 0x6e, 0x4b, + 0xe0, 0xb3, 0x8c, 0x01, 0xcf, 0x40, 0x59, 0x6d, 0x01, 0x7f, 0x15, 0x35, 0x8a, 0x65, 0x99, 0xbf, + 0xdf, 0x61, 0xa9, 0x45, 0xec, 0xd6, 0xc5, 0xdd, 0xd3, 0x75, 0xc9, 0x84, 0x06, 0x2a, 0xfc, 0x11, + 0x55, 0x13, 0xbc, 0xd1, 0x41, 0x6d, 0xab, 0x04, 0xd8, 0x79, 0x43, 0x7a, 0x57, 0x91, 0xe6, 0x9f, + 0x8f, 0x91, 0xf3, 0x38, 0x6d, 0x19, 0xc7, 0x86, 0xad, 0x62, 0x9c, 0x50, 0x0e, 0x78, 0x4c, 0x4d, + 0xf4, 0xf7, 0xe6, 0x4b, 0x4b, 0x5f, 0x2c, 0x2d, 0xfd, 0x71, 0x69, 0xe9, 0x57, 0x2b, 0x4b, 0x5b, + 0xac, 0x2c, 0xed, 0x7e, 0x65, 0x69, 0xc7, 0x9d, 0x20, 0x14, 0xa7, 0xa9, 0xef, 0x8c, 0xe8, 0x64, + 0xa3, 0xa2, 0x1e, 0x7f, 0xf9, 0xc9, 0x18, 0x9d, 0x6f, 0x24, 0x45, 0x96, 0x10, 0xee, 0x97, 0xe5, + 0x85, 0xfb, 0xf7, 0x1c, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x7d, 0x7d, 0x85, 0xf5, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -155,6 +254,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Params returns the total set of cross chain parameters. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // InturnRelayer returns the inturn relayer bls pub key and its relay interval + InturnRelayer(ctx context.Context, in *QueryInturnRelayerRequest, opts ...grpc.CallOption) (*QueryInturnRelayerResponse, error) } type queryClient struct { @@ -174,10 +275,21 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) InturnRelayer(ctx context.Context, in *QueryInturnRelayerRequest, opts ...grpc.CallOption) (*QueryInturnRelayerResponse, error) { + out := new(QueryInturnRelayerResponse) + err := c.cc.Invoke(ctx, "/cosmos.oracle.v1.Query/InturnRelayer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params returns the total set of cross chain parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // InturnRelayer returns the inturn relayer bls pub key and its relay interval + InturnRelayer(context.Context, *QueryInturnRelayerRequest) (*QueryInturnRelayerResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -187,6 +299,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) InturnRelayer(ctx context.Context, req *QueryInturnRelayerRequest) (*QueryInturnRelayerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InturnRelayer not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -210,6 +325,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_InturnRelayer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryInturnRelayerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).InturnRelayer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.oracle.v1.Query/InturnRelayer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).InturnRelayer(ctx, req.(*QueryInturnRelayerRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.oracle.v1.Query", HandlerType: (*QueryServer)(nil), @@ -218,6 +351,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "InturnRelayer", + Handler: _Query_InturnRelayer_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/oracle/v1/query.proto", @@ -279,6 +416,71 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryInturnRelayerRequest) 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 *QueryInturnRelayerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInturnRelayerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryInturnRelayerResponse) 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 *QueryInturnRelayerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInturnRelayerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RelayInterval != nil { + { + size, err := m.RelayInterval.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.BlsPubKey) > 0 { + i -= len(m.BlsPubKey) + copy(dAtA[i:], m.BlsPubKey) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BlsPubKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -310,6 +512,32 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryInturnRelayerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryInturnRelayerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BlsPubKey) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.RelayInterval != nil { + l = m.RelayInterval.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -449,6 +677,174 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryInturnRelayerRequest) 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 ErrIntOverflowQuery + } + 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: QueryInturnRelayerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInturnRelayerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryInturnRelayerResponse) 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 ErrIntOverflowQuery + } + 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: QueryInturnRelayerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInturnRelayerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsPubKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlsPubKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayInterval", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RelayInterval == nil { + m.RelayInterval = &RelayInterval{} + } + if err := m.RelayInterval.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 9618c73c03..a882e7a39f 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -51,6 +51,24 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_InturnRelayer_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInturnRelayerRequest + var metadata runtime.ServerMetadata + + msg, err := client.InturnRelayer(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_InturnRelayer_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInturnRelayerRequest + var metadata runtime.ServerMetadata + + msg, err := server.InturnRelayer(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -80,6 +98,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_InturnRelayer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_InturnRelayer_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_InturnRelayer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +182,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_InturnRelayer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_InturnRelayer_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_InturnRelayer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "oracle", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_InturnRelayer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "oracle", "v1", "inturn_relayer"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_InturnRelayer_0 = runtime.ForwardResponseMessage ) diff --git a/x/params/types/proposal/proposal_test.go b/x/params/types/proposal/proposal_test.go index 74592f3a2b..3e95c2a3c9 100644 --- a/x/params/types/proposal/proposal_test.go +++ b/x/params/types/proposal/proposal_test.go @@ -59,5 +59,4 @@ func TestCrossChainUpgradeProposal(t *testing.T) { pcp = NewCrossChainParameterChangeProposal("test title", "test description", []ParamChange{pc2, pc3}, []string{"0x80C7Fa8FC825C5e622cdbcAEa0A22d188634BDd3", "0xA4A2957E858529FFABBBb483D1D704378a9fca6b"}) require.Equal(t, pcp.ValidateBasic(), ErrInvalidUpgradeProposal) - }