From 40a0922f3e0976a633f8003bd1cebf97871611b4 Mon Sep 17 00:00:00 2001 From: Roshan Date: Fri, 10 Feb 2023 13:26:46 +0800 Subject: [PATCH 01/13] feat: refactor gashub module --- proto/cosmos/gashub/v1alpha1/gashub.proto | 57 +- x/gashub/simulation/genesis.go | 19 +- x/gashub/simulation/genesis_test.go | 4 +- x/gashub/simulation/params.go | 10 +- x/gashub/simulation/params_test.go | 2 +- x/gashub/types/gas_calculator.go | 232 +-- x/gashub/types/gashub.pb.go | 2182 ++++----------------- x/gashub/types/params.go | 546 ++---- 8 files changed, 711 insertions(+), 2341 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 3b96c8119a..a87c20079c 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -10,48 +10,17 @@ message Params { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; - uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; - uint64 msg_grant_fixed_gas = 3 [(gogoproto.customname) = "MsgGrantFixedGas"]; - uint64 msg_grant_per_item_gas = 4 [(gogoproto.customname) = "MsgGrantPerItemGas"]; - uint64 msg_revoke_gas = 5 [(gogoproto.customname) = "MsgRevokeGas"]; - uint64 msg_exec_gas = 6 [(gogoproto.customname) = "MsgExecGas"]; - uint64 msg_send_gas = 7 [(gogoproto.customname) = "MsgSendGas"]; - uint64 msg_multi_send_fixed_gas = 8 [(gogoproto.customname) = "MsgMultiSendFixedGas"]; - uint64 msg_multi_send_per_item_gas = 9 [(gogoproto.customname) = "MsgMultiSendPerItemGas"]; - uint64 msg_withdraw_delegator_reward_gas = 10 [(gogoproto.customname) = "MsgWithdrawDelegatorRewardGas"]; - uint64 msg_withdraw_validator_commission_gas = 11 [(gogoproto.customname) = "MsgWithdrawValidatorCommissionGas"]; - uint64 msg_set_withdraw_address_gas = 12 [(gogoproto.customname) = "MsgSetWithdrawAddressGas"]; - uint64 msg_fund_community_pool_gas = 13 [(gogoproto.customname) = "MsgFundCommunityPoolGas"]; - uint64 msg_grant_allowance_fixed_gas = 14 [(gogoproto.customname) = "MsgGrantAllowanceFixedGas"]; - uint64 msg_grant_allowance_per_item_gas = 15 [(gogoproto.customname) = "MsgGrantAllowancePerItemGas"]; - uint64 msg_revoke_allowance_gas = 16 [(gogoproto.customname) = "MsgRevokeAllowanceGas"]; - uint64 msg_submit_proposal_gas = 17 [(gogoproto.customname) = "MsgSubmitProposalGas"]; - uint64 msg_vote_gas = 18 [(gogoproto.customname) = "MsgVoteGas"]; - uint64 msg_vote_weighted_gas = 19 [(gogoproto.customname) = "MsgVoteWeightedGas"]; - uint64 msg_deposit_gas = 20 [(gogoproto.customname) = "MsgDepositGas"]; - uint64 msg_unjail_gas = 21 [(gogoproto.customname) = "MsgUnjailGas"]; - uint64 msg_impeach_gas = 22 [(gogoproto.customname) = "MsgImpeachGas"]; - uint64 msg_edit_validator_gas = 23 [(gogoproto.customname) = "MsgEditValidatorGas"]; - uint64 msg_delegate_gas = 24 [(gogoproto.customname) = "MsgDelegateGas"]; - uint64 msg_undelegate_gas = 25 [(gogoproto.customname) = "MsgUndelegateGas"]; - uint64 msg_begin_redelegate_gas = 26 [(gogoproto.customname) = "MsgBeginRedelegateGas"]; - uint64 msg_cancel_unbonding_delegation_gas = 27 [(gogoproto.customname) = "MsgCancelUnbondingDelegationGas"]; - uint64 msg_create_validator_gas = 28 [(gogoproto.customname) = "MsgCreateValidatorGas"]; - uint64 msg_claim_gas = 29 [(gogoproto.customname) = "MsgClaimGas"]; - uint64 msg_transfer_out_gas = 30 [(gogoproto.customname) = "MsgTransferOutGas"]; - uint64 msg_create_storage_provider_gas = 31 [(gogoproto.customname) = "MsgCreateStorageProviderGas"]; - uint64 msg_edit_storage_provider_gas = 32 [(gogoproto.customname) = "MsgEditStorageProviderGas"]; - uint64 msg_sp_deposit_gas = 33 [(gogoproto.customname) = "MsgSpDepositGas"]; - uint64 msg_storage_create_bucket_gas = 34 [(gogoproto.customname) = "MsgStorageCreateBucket"]; - uint64 msg_storage_delete_bucket_gas = 35 [(gogoproto.customname) = "MsgStorageDeleteBucket"]; - uint64 msg_storage_create_object_gas = 36 [(gogoproto.customname) = "MsgStorageCreateObject"]; - uint64 msg_storage_delete_object_gas = 37 [(gogoproto.customname) = "MsgStorageDeleteObject"]; - uint64 msg_storage_seal_object_gas = 38 [(gogoproto.customname) = "MsgStorageSealObject"]; - uint64 msg_storage_copy_object_gas = 39 [(gogoproto.customname) = "MsgStorageCopyObject"]; - uint64 msg_storage_reject_seal_object_gas = 40 [(gogoproto.customname) = "MsgStorageRejectSealObject"]; - uint64 msg_storage_create_group_gas = 41 [(gogoproto.customname) = "MsgStorageCreateGroup"]; - uint64 msg_storage_delete_group_gas = 42 [(gogoproto.customname) = "MsgStorageDeleteGroup"]; - uint64 msg_storage_leave_group_gas = 43 [(gogoproto.customname) = "MsgStorageLeaveGroup"]; - uint64 msg_storage_update_group_member_gas = 44 [(gogoproto.customname) = "MsgStorageUpdateGroupMember"]; + uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; + uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; + + repeated MsgGasParams msg_gas_params_set = 3 [(gogoproto.customname) = "MsgGasParamsSet"]; +} + +// MsgGasParams is a +message MsgGasParams { + option (gogoproto.equal) = true; + + string msg_type_url = 1 [(gogoproto.customname) = "Msg_type_url"]; + + repeated uint64 params = 2 [(gogoproto.customname) = "Params"];; } diff --git a/x/gashub/simulation/genesis.go b/x/gashub/simulation/genesis.go index e46c405245..1467664595 100644 --- a/x/gashub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -27,9 +27,11 @@ func GenMinGasPerByte(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 2500, 5000)) } -// GenMsgGas randomized msg gas consumption -func GenMsgGas(r *rand.Rand) uint64 { - return uint64(simulation.RandIntBetween(r, 1e5, 1e7)) +// GenMsgGasParams randomized msg gas consumption +func GenMsgGasParams(r *rand.Rand) *types.MsgGasParams { + msgTypeUrl := simulation.RandStringOfLength(r, 12) + gas := uint64(simulation.RandIntBetween(r, 1e5, 1e7)) + return types.NewMsgGasParams(msgTypeUrl, gas) } // RandomizedGenState generates a random GenesisState for auth @@ -46,16 +48,13 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { minGasPerByte = GenMinGasPerByte(r) }, ) - var msgGas uint64 + var msgGasParams *types.MsgGasParams simState.AppParams.GetOrGenerate( - simState.Cdc, MsgGas, &msgGas, simState.Rand, - func(r *rand.Rand) { msgGas = GenMsgGas(r) }, + simState.Cdc, MsgGas, &msgGasParams, simState.Rand, + func(r *rand.Rand) { msgGasParams = GenMsgGasParams(r) }, ) - params := types.NewParams(maxTxSize, minGasPerByte, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, - msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, - msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, - msgGas, msgGas, msgGas, msgGas, msgGas, msgGas) + params := types.NewParams(maxTxSize, minGasPerByte, []*types.MsgGasParams{msgGasParams}) gashubGenesis := types.NewGenesisState(params) diff --git a/x/gashub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go index 9652a5ef87..0bfcbb995c 100644 --- a/x/gashub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -17,7 +17,7 @@ import ( ) // TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. -// Abonormal scenarios are not tested here. +// Abnormal scenarios are not tested here. func TestRandomizedGenState(t *testing.T) { interfaceRegistry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(interfaceRegistry) @@ -41,5 +41,5 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) require.Equal(t, uint64(2956), gashubGenesis.Params.MinGasPerByte) - require.Equal(t, uint64(2803300), gashubGenesis.Params.MsgSendGas) + require.Equal(t, uint64(4978511), gashubGenesis.Params.MsgGasParamsSet[0].Params[0]) } diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index f3bd2911d4..a28884713d 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -3,7 +3,7 @@ package simulation // DONTCOVER import ( - "fmt" + "encoding/json" "math/rand" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -15,9 +15,13 @@ import ( // on the simulation func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ - simulation.NewSimParamChange(types.ModuleName, string(types.KeyMsgSendGas), + simulation.NewSimParamChange(types.ModuleName, string(types.KeyMsgGasParamsSet), func(r *rand.Rand) string { - return fmt.Sprintf("\"%d\"", GenMsgGas(r)) + paramsBytes, err := json.Marshal(GenMsgGasParams(r)) + if err != nil { + panic(err) + } + return string(paramsBytes) }, ), } diff --git a/x/gashub/simulation/params_test.go b/x/gashub/simulation/params_test.go index e89d8f4e74..dd44781fb8 100644 --- a/x/gashub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -19,7 +19,7 @@ func TestParamChanges(t *testing.T) { simValue string subspace string }{ - {"gashub/MsgSendGas", "MsgSendGas", "\"1698081\"", "gashub"}, + {"gashub/MsgGasParamsSet", "MsgGasParamsSet", "{\"msg_type_url\":\"FpXzpLGIehps\",\"params\":[1631847]}", "gashub"}, } paramChanges := simulation.ParamChanges(r) diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 3600d37d56..5635a96160 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -8,11 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" bank "github.com/cosmos/cosmos-sdk/x/bank/types" - distribution "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/feegrant" - gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - oracletypes "github.com/cosmos/cosmos-sdk/x/oracle/types" - slashing "github.com/cosmos/cosmos-sdk/x/slashing/types" staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -105,178 +101,78 @@ func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { } var msgGrantGasCalculatorGen = func(params Params) GasCalculator { - fixedGas := params.GetMsgGrantFixedGas() - gasPerItem := params.GetMsgGrantPerItemGas() - return GrantCalculator(fixedGas, gasPerItem) + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsg_type_url() == "/cosmos.authz.v1beta1.MsgGrant" { + p := gasParams.GetParams() + if len(p) != 2 { + panic("wrong params for /cosmos.authz.v1beta1.MsgGrant") + } + fixedGas := p[0] + gasPerItem := p[1] + return GrantCalculator(fixedGas, gasPerItem) + } + } + panic("no params for /cosmos.authz.v1beta1.MsgGrant") } var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { - fixedGas := params.GetMsgMultiSendFixedGas() - gasPerItem := params.GetMsgMultiSendPerItemGas() - return MultiSendCalculator(fixedGas, gasPerItem) + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsg_type_url() == "/cosmos.bank.v1beta1.MsgMultiSend" { + p := gasParams.GetParams() + if len(p) != 2 { + panic("wrong params for /cosmos.bank.v1beta1.MsgMultiSend") + } + fixedGas := p[0] + gasPerItem := p[1] + return MultiSendCalculator(fixedGas, gasPerItem) + } + } + panic("no params for /cosmos.bank.v1beta1.MsgMultiSend") } var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { - fixedGas := params.GetMsgGrantAllowanceFixedGas() - gasPerItem := params.GetMsgGrantAllowancePerItemGas() - return GrantAllowanceCalculator(fixedGas, gasPerItem) + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsg_type_url() == "/cosmos.feegrant.v1beta1.MsgGrantAllowance" { + p := gasParams.GetParams() + if len(p) != 2 { + panic("wrong params for /cosmos.feegrant.v1beta1.MsgGrantAllowance") + } + fixedGas := p[0] + gasPerItem := p[1] + return GrantAllowanceCalculator(fixedGas, gasPerItem) + } + } + panic("no params for /cosmos.feegrant.v1beta1.MsgGrantAllowance") } func init() { - RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgGrant{}), msgGrantGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgRevoke{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgRevokeGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgExec{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgExecGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgSendGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgMultiSend{}), msgMultiSendGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawDelegatorReward{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgWithdrawDelegatorRewardGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawValidatorCommission{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgWithdrawValidatorCommissionGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgSetWithdrawAddress{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgSetWithdrawAddressGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgFundCommunityPool{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgFundCommunityPoolGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgGrantAllowance{}), msgGrantAllowanceGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgRevokeAllowanceGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgSubmitProposal{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgSubmitProposalGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVote{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgVoteGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVoteWeighted{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgVoteWeightedGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgDeposit{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgDepositGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgUnjail{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgUnjailGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgImpeach{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgImpeachGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgEditValidator{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgEditValidatorGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgDelegate{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgDelegateGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgUndelegate{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgUndelegateGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgBeginRedelegate{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgBeginRedelegateGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgCancelUnbondingDelegation{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgCancelUnbondingDelegationGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgCreateValidator{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgCreateValidatorGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen(types.MsgTypeURL(&oracletypes.MsgClaim{}), func(params Params) GasCalculator { - fixedGas := params.GetMsgClaimGas() - return FixedGasCalculator(fixedGas) - }) - - // these msgs are from greenfield, so the msg types need to be hard coded. - RegisterCalculatorGen("/bnbchain.greenfield.bridge.MsgTransferOut", func(params Params) GasCalculator { - fixedGas := params.GetMsgTransferOutGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen("/bnbchain.greenfield.sp.MsgCreateStorageProvider", func(params Params) GasCalculator { - fixedGas := params.GetMsgCreateStorageProviderGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen("/bnbchain.greenfield.sp.MsgEditStorageProvider", func(params Params) GasCalculator { - fixedGas := params.GetMsgEditStorageProviderGas() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen("/bnbchain.greenfield.sp.MsgDeposit", func(params Params) GasCalculator { - fixedGas := params.GetMsgSpDepositGas() - return FixedGasCalculator(fixedGas) - }) - - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCreateBucket", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageCreateBucket() - return FixedGasCalculator(fixedGas) - }) - - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgDeleteBucket", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageDeleteBucket() - return FixedGasCalculator(fixedGas) - }) - - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCreateObject", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageCreateObject() - return FixedGasCalculator(fixedGas) - }) - - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgDeleteObject", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageDeleteObject() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgSealObject", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageSealObject() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCopyObject", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageCopyObject() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgRejectSealObject", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageRejectSealObject() - return FixedGasCalculator(fixedGas) - }) - - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCreateGroup", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageCreateGroup() - return FixedGasCalculator(fixedGas) - }) - - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgDeleteGroup", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageDeleteGroup() - return FixedGasCalculator(fixedGas) - }) + // for fixed gas msgs + for _, gasParams := range DefaultMsgGasParamsSet { + if len(gasParams.GetParams()) != 1 { + continue + } + msgType := gasParams.GetMsg_type_url() + RegisterCalculatorGen(msgType, func(params Params) GasCalculator { + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsg_type_url() == msgType { + p := gasParams.GetParams() + if len(p) != 1 { + panic(fmt.Sprintf("wrong params for %s", msgType)) + } + fixedGas := p[0] + return FixedGasCalculator(fixedGas) + } + } + panic(fmt.Sprintf("no params for %s", msgType)) + }) + } - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgLeaveGroup", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageLeaveGroup() - return FixedGasCalculator(fixedGas) - }) - RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgUpdateGroupMember", func(params Params) GasCalculator { - fixedGas := params.GetMsgStorageUpdateGroupMember() - return FixedGasCalculator(fixedGas) - }) + // for dynamic gas msgs + RegisterCalculatorGen("/cosmos.authz.v1beta1.MsgGrant", msgGrantGasCalculatorGen) + RegisterCalculatorGen("/cosmos.feegrant.v1beta1.MsgGrantAllowance", msgGrantAllowanceGasCalculatorGen) + RegisterCalculatorGen("/cosmos.bank.v1beta1.MsgMultiSend", msgMultiSendGasCalculatorGen) } diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index 6a33e41632..6e900527e7 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -25,50 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the gashub module. type Params struct { - MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` - MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` - MsgGrantFixedGas uint64 `protobuf:"varint,3,opt,name=msg_grant_fixed_gas,json=msgGrantFixedGas,proto3" json:"msg_grant_fixed_gas,omitempty"` - MsgGrantPerItemGas uint64 `protobuf:"varint,4,opt,name=msg_grant_per_item_gas,json=msgGrantPerItemGas,proto3" json:"msg_grant_per_item_gas,omitempty"` - MsgRevokeGas uint64 `protobuf:"varint,5,opt,name=msg_revoke_gas,json=msgRevokeGas,proto3" json:"msg_revoke_gas,omitempty"` - MsgExecGas uint64 `protobuf:"varint,6,opt,name=msg_exec_gas,json=msgExecGas,proto3" json:"msg_exec_gas,omitempty"` - MsgSendGas uint64 `protobuf:"varint,7,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` - MsgMultiSendFixedGas uint64 `protobuf:"varint,8,opt,name=msg_multi_send_fixed_gas,json=msgMultiSendFixedGas,proto3" json:"msg_multi_send_fixed_gas,omitempty"` - MsgMultiSendPerItemGas uint64 `protobuf:"varint,9,opt,name=msg_multi_send_per_item_gas,json=msgMultiSendPerItemGas,proto3" json:"msg_multi_send_per_item_gas,omitempty"` - MsgWithdrawDelegatorRewardGas uint64 `protobuf:"varint,10,opt,name=msg_withdraw_delegator_reward_gas,json=msgWithdrawDelegatorRewardGas,proto3" json:"msg_withdraw_delegator_reward_gas,omitempty"` - MsgWithdrawValidatorCommissionGas uint64 `protobuf:"varint,11,opt,name=msg_withdraw_validator_commission_gas,json=msgWithdrawValidatorCommissionGas,proto3" json:"msg_withdraw_validator_commission_gas,omitempty"` - MsgSetWithdrawAddressGas uint64 `protobuf:"varint,12,opt,name=msg_set_withdraw_address_gas,json=msgSetWithdrawAddressGas,proto3" json:"msg_set_withdraw_address_gas,omitempty"` - MsgFundCommunityPoolGas uint64 `protobuf:"varint,13,opt,name=msg_fund_community_pool_gas,json=msgFundCommunityPoolGas,proto3" json:"msg_fund_community_pool_gas,omitempty"` - MsgGrantAllowanceFixedGas uint64 `protobuf:"varint,14,opt,name=msg_grant_allowance_fixed_gas,json=msgGrantAllowanceFixedGas,proto3" json:"msg_grant_allowance_fixed_gas,omitempty"` - MsgGrantAllowancePerItemGas uint64 `protobuf:"varint,15,opt,name=msg_grant_allowance_per_item_gas,json=msgGrantAllowancePerItemGas,proto3" json:"msg_grant_allowance_per_item_gas,omitempty"` - MsgRevokeAllowanceGas uint64 `protobuf:"varint,16,opt,name=msg_revoke_allowance_gas,json=msgRevokeAllowanceGas,proto3" json:"msg_revoke_allowance_gas,omitempty"` - MsgSubmitProposalGas uint64 `protobuf:"varint,17,opt,name=msg_submit_proposal_gas,json=msgSubmitProposalGas,proto3" json:"msg_submit_proposal_gas,omitempty"` - MsgVoteGas uint64 `protobuf:"varint,18,opt,name=msg_vote_gas,json=msgVoteGas,proto3" json:"msg_vote_gas,omitempty"` - MsgVoteWeightedGas uint64 `protobuf:"varint,19,opt,name=msg_vote_weighted_gas,json=msgVoteWeightedGas,proto3" json:"msg_vote_weighted_gas,omitempty"` - MsgDepositGas uint64 `protobuf:"varint,20,opt,name=msg_deposit_gas,json=msgDepositGas,proto3" json:"msg_deposit_gas,omitempty"` - MsgUnjailGas uint64 `protobuf:"varint,21,opt,name=msg_unjail_gas,json=msgUnjailGas,proto3" json:"msg_unjail_gas,omitempty"` - MsgImpeachGas uint64 `protobuf:"varint,22,opt,name=msg_impeach_gas,json=msgImpeachGas,proto3" json:"msg_impeach_gas,omitempty"` - MsgEditValidatorGas uint64 `protobuf:"varint,23,opt,name=msg_edit_validator_gas,json=msgEditValidatorGas,proto3" json:"msg_edit_validator_gas,omitempty"` - MsgDelegateGas uint64 `protobuf:"varint,24,opt,name=msg_delegate_gas,json=msgDelegateGas,proto3" json:"msg_delegate_gas,omitempty"` - MsgUndelegateGas uint64 `protobuf:"varint,25,opt,name=msg_undelegate_gas,json=msgUndelegateGas,proto3" json:"msg_undelegate_gas,omitempty"` - MsgBeginRedelegateGas uint64 `protobuf:"varint,26,opt,name=msg_begin_redelegate_gas,json=msgBeginRedelegateGas,proto3" json:"msg_begin_redelegate_gas,omitempty"` - MsgCancelUnbondingDelegationGas uint64 `protobuf:"varint,27,opt,name=msg_cancel_unbonding_delegation_gas,json=msgCancelUnbondingDelegationGas,proto3" json:"msg_cancel_unbonding_delegation_gas,omitempty"` - MsgCreateValidatorGas uint64 `protobuf:"varint,28,opt,name=msg_create_validator_gas,json=msgCreateValidatorGas,proto3" json:"msg_create_validator_gas,omitempty"` - MsgClaimGas uint64 `protobuf:"varint,29,opt,name=msg_claim_gas,json=msgClaimGas,proto3" json:"msg_claim_gas,omitempty"` - MsgTransferOutGas uint64 `protobuf:"varint,30,opt,name=msg_transfer_out_gas,json=msgTransferOutGas,proto3" json:"msg_transfer_out_gas,omitempty"` - MsgCreateStorageProviderGas uint64 `protobuf:"varint,31,opt,name=msg_create_storage_provider_gas,json=msgCreateStorageProviderGas,proto3" json:"msg_create_storage_provider_gas,omitempty"` - MsgEditStorageProviderGas uint64 `protobuf:"varint,32,opt,name=msg_edit_storage_provider_gas,json=msgEditStorageProviderGas,proto3" json:"msg_edit_storage_provider_gas,omitempty"` - MsgSpDepositGas uint64 `protobuf:"varint,33,opt,name=msg_sp_deposit_gas,json=msgSpDepositGas,proto3" json:"msg_sp_deposit_gas,omitempty"` - MsgStorageCreateBucket uint64 `protobuf:"varint,34,opt,name=msg_storage_create_bucket_gas,json=msgStorageCreateBucketGas,proto3" json:"msg_storage_create_bucket_gas,omitempty"` - MsgStorageDeleteBucket uint64 `protobuf:"varint,35,opt,name=msg_storage_delete_bucket_gas,json=msgStorageDeleteBucketGas,proto3" json:"msg_storage_delete_bucket_gas,omitempty"` - MsgStorageCreateObject uint64 `protobuf:"varint,36,opt,name=msg_storage_create_object_gas,json=msgStorageCreateObjectGas,proto3" json:"msg_storage_create_object_gas,omitempty"` - MsgStorageDeleteObject uint64 `protobuf:"varint,37,opt,name=msg_storage_delete_object_gas,json=msgStorageDeleteObjectGas,proto3" json:"msg_storage_delete_object_gas,omitempty"` - MsgStorageSealObject uint64 `protobuf:"varint,38,opt,name=msg_storage_seal_object_gas,json=msgStorageSealObjectGas,proto3" json:"msg_storage_seal_object_gas,omitempty"` - MsgStorageCopyObject uint64 `protobuf:"varint,39,opt,name=msg_storage_copy_object_gas,json=msgStorageCopyObjectGas,proto3" json:"msg_storage_copy_object_gas,omitempty"` - MsgStorageRejectSealObject uint64 `protobuf:"varint,40,opt,name=msg_storage_reject_seal_object_gas,json=msgStorageRejectSealObjectGas,proto3" json:"msg_storage_reject_seal_object_gas,omitempty"` - MsgStorageCreateGroup uint64 `protobuf:"varint,41,opt,name=msg_storage_create_group_gas,json=msgStorageCreateGroupGas,proto3" json:"msg_storage_create_group_gas,omitempty"` - MsgStorageDeleteGroup uint64 `protobuf:"varint,42,opt,name=msg_storage_delete_group_gas,json=msgStorageDeleteGroupGas,proto3" json:"msg_storage_delete_group_gas,omitempty"` - MsgStorageLeaveGroup uint64 `protobuf:"varint,43,opt,name=msg_storage_leave_group_gas,json=msgStorageLeaveGroupGas,proto3" json:"msg_storage_leave_group_gas,omitempty"` - MsgStorageUpdateGroupMember uint64 `protobuf:"varint,44,opt,name=msg_storage_update_group_member_gas,json=msgStorageUpdateGroupMemberGas,proto3" json:"msg_storage_update_group_member_gas,omitempty"` + MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` + MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` + MsgGasParamsSet []*MsgGasParams `protobuf:"bytes,3,rep,name=msg_gas_params_set,json=msgGasParamsSet,proto3" json:"msg_gas_params_set,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -117,302 +76,69 @@ func (m *Params) GetMinGasPerByte() uint64 { return 0 } -func (m *Params) GetMsgGrantFixedGas() uint64 { +func (m *Params) GetMsgGasParamsSet() []*MsgGasParams { if m != nil { - return m.MsgGrantFixedGas + return m.MsgGasParamsSet } - return 0 -} - -func (m *Params) GetMsgGrantPerItemGas() uint64 { - if m != nil { - return m.MsgGrantPerItemGas - } - return 0 -} - -func (m *Params) GetMsgRevokeGas() uint64 { - if m != nil { - return m.MsgRevokeGas - } - return 0 -} - -func (m *Params) GetMsgExecGas() uint64 { - if m != nil { - return m.MsgExecGas - } - return 0 -} - -func (m *Params) GetMsgSendGas() uint64 { - if m != nil { - return m.MsgSendGas - } - return 0 -} - -func (m *Params) GetMsgMultiSendFixedGas() uint64 { - if m != nil { - return m.MsgMultiSendFixedGas - } - return 0 -} - -func (m *Params) GetMsgMultiSendPerItemGas() uint64 { - if m != nil { - return m.MsgMultiSendPerItemGas - } - return 0 -} - -func (m *Params) GetMsgWithdrawDelegatorRewardGas() uint64 { - if m != nil { - return m.MsgWithdrawDelegatorRewardGas - } - return 0 -} - -func (m *Params) GetMsgWithdrawValidatorCommissionGas() uint64 { - if m != nil { - return m.MsgWithdrawValidatorCommissionGas - } - return 0 -} - -func (m *Params) GetMsgSetWithdrawAddressGas() uint64 { - if m != nil { - return m.MsgSetWithdrawAddressGas - } - return 0 -} - -func (m *Params) GetMsgFundCommunityPoolGas() uint64 { - if m != nil { - return m.MsgFundCommunityPoolGas - } - return 0 -} - -func (m *Params) GetMsgGrantAllowanceFixedGas() uint64 { - if m != nil { - return m.MsgGrantAllowanceFixedGas - } - return 0 -} - -func (m *Params) GetMsgGrantAllowancePerItemGas() uint64 { - if m != nil { - return m.MsgGrantAllowancePerItemGas - } - return 0 -} - -func (m *Params) GetMsgRevokeAllowanceGas() uint64 { - if m != nil { - return m.MsgRevokeAllowanceGas - } - return 0 -} - -func (m *Params) GetMsgSubmitProposalGas() uint64 { - if m != nil { - return m.MsgSubmitProposalGas - } - return 0 -} - -func (m *Params) GetMsgVoteGas() uint64 { - if m != nil { - return m.MsgVoteGas - } - return 0 -} - -func (m *Params) GetMsgVoteWeightedGas() uint64 { - if m != nil { - return m.MsgVoteWeightedGas - } - return 0 -} - -func (m *Params) GetMsgDepositGas() uint64 { - if m != nil { - return m.MsgDepositGas - } - return 0 -} - -func (m *Params) GetMsgUnjailGas() uint64 { - if m != nil { - return m.MsgUnjailGas - } - return 0 -} - -func (m *Params) GetMsgImpeachGas() uint64 { - if m != nil { - return m.MsgImpeachGas - } - return 0 -} - -func (m *Params) GetMsgEditValidatorGas() uint64 { - if m != nil { - return m.MsgEditValidatorGas - } - return 0 -} - -func (m *Params) GetMsgDelegateGas() uint64 { - if m != nil { - return m.MsgDelegateGas - } - return 0 -} - -func (m *Params) GetMsgUndelegateGas() uint64 { - if m != nil { - return m.MsgUndelegateGas - } - return 0 -} - -func (m *Params) GetMsgBeginRedelegateGas() uint64 { - if m != nil { - return m.MsgBeginRedelegateGas - } - return 0 -} - -func (m *Params) GetMsgCancelUnbondingDelegationGas() uint64 { - if m != nil { - return m.MsgCancelUnbondingDelegationGas - } - return 0 -} - -func (m *Params) GetMsgCreateValidatorGas() uint64 { - if m != nil { - return m.MsgCreateValidatorGas - } - return 0 -} - -func (m *Params) GetMsgClaimGas() uint64 { - if m != nil { - return m.MsgClaimGas - } - return 0 -} - -func (m *Params) GetMsgTransferOutGas() uint64 { - if m != nil { - return m.MsgTransferOutGas - } - return 0 -} - -func (m *Params) GetMsgCreateStorageProviderGas() uint64 { - if m != nil { - return m.MsgCreateStorageProviderGas - } - return 0 -} - -func (m *Params) GetMsgEditStorageProviderGas() uint64 { - if m != nil { - return m.MsgEditStorageProviderGas - } - return 0 -} - -func (m *Params) GetMsgSpDepositGas() uint64 { - if m != nil { - return m.MsgSpDepositGas - } - return 0 -} - -func (m *Params) GetMsgStorageCreateBucket() uint64 { - if m != nil { - return m.MsgStorageCreateBucket - } - return 0 + return nil } -func (m *Params) GetMsgStorageDeleteBucket() uint64 { - if m != nil { - return m.MsgStorageDeleteBucket - } - return 0 +// MsgGasParams is a +type MsgGasParams struct { + Msg_type_url string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + Params []uint64 `protobuf:"varint,2,rep,packed,name=params,proto3" json:"params,omitempty"` } -func (m *Params) GetMsgStorageCreateObject() uint64 { - if m != nil { - return m.MsgStorageCreateObject - } - return 0 +func (m *MsgGasParams) Reset() { *m = MsgGasParams{} } +func (m *MsgGasParams) String() string { return proto.CompactTextString(m) } +func (*MsgGasParams) ProtoMessage() {} +func (*MsgGasParams) Descriptor() ([]byte, []int) { + return fileDescriptor_f79bf23b48853a4a, []int{1} } - -func (m *Params) GetMsgStorageDeleteObject() uint64 { - if m != nil { - return m.MsgStorageDeleteObject - } - return 0 +func (m *MsgGasParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -func (m *Params) GetMsgStorageSealObject() uint64 { - if m != nil { - return m.MsgStorageSealObject +func (m *MsgGasParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGasParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return 0 } - -func (m *Params) GetMsgStorageCopyObject() uint64 { - if m != nil { - return m.MsgStorageCopyObject - } - return 0 +func (m *MsgGasParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGasParams.Merge(m, src) } - -func (m *Params) GetMsgStorageRejectSealObject() uint64 { - if m != nil { - return m.MsgStorageRejectSealObject - } - return 0 +func (m *MsgGasParams) XXX_Size() int { + return m.Size() } - -func (m *Params) GetMsgStorageCreateGroup() uint64 { - if m != nil { - return m.MsgStorageCreateGroup - } - return 0 +func (m *MsgGasParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGasParams.DiscardUnknown(m) } -func (m *Params) GetMsgStorageDeleteGroup() uint64 { - if m != nil { - return m.MsgStorageDeleteGroup - } - return 0 -} +var xxx_messageInfo_MsgGasParams proto.InternalMessageInfo -func (m *Params) GetMsgStorageLeaveGroup() uint64 { +func (m *MsgGasParams) GetMsg_type_url() string { if m != nil { - return m.MsgStorageLeaveGroup + return m.Msg_type_url } - return 0 + return "" } -func (m *Params) GetMsgStorageUpdateGroupMember() uint64 { +func (m *MsgGasParams) GetParams() []uint64 { if m != nil { - return m.MsgStorageUpdateGroupMember + return m.Params } - return 0 + return nil } func init() { proto.RegisterType((*Params)(nil), "cosmos.gashub.v1alpha1.Params") + proto.RegisterType((*MsgGasParams)(nil), "cosmos.gashub.v1alpha1.MsgGasParams") } func init() { @@ -420,94 +146,30 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 1379 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x97, 0x5d, 0x6f, 0xd4, 0x46, - 0x17, 0xc7, 0x93, 0xe7, 0xe1, 0xe1, 0x81, 0x09, 0x79, 0x9b, 0xbc, 0x6d, 0xde, 0x76, 0x08, 0x29, - 0x2d, 0x2d, 0x85, 0x14, 0x21, 0x55, 0x2a, 0xea, 0x45, 0x49, 0x02, 0x11, 0x15, 0x2b, 0x56, 0x1b, - 0x02, 0x6a, 0x85, 0x64, 0xcd, 0xae, 0x27, 0x8e, 0x89, 0xc7, 0xe3, 0x7a, 0xec, 0x64, 0xc3, 0x87, - 0xa8, 0x7a, 0xd9, 0x4b, 0x3e, 0x4e, 0x2f, 0xb9, 0xec, 0x95, 0x55, 0x0d, 0x37, 0xfd, 0x18, 0xd5, - 0x9c, 0xf1, 0xec, 0x7a, 0xb2, 0x5e, 0x7a, 0xb5, 0x9e, 0x73, 0xfe, 0xe7, 0x77, 0xe6, 0xed, 0x1c, - 0xaf, 0xd1, 0x76, 0x4f, 0x48, 0x2e, 0xe4, 0x4e, 0x40, 0xe5, 0x49, 0xde, 0xdd, 0x39, 0x7b, 0x40, - 0xa3, 0xe4, 0x84, 0x3e, 0x28, 0xc7, 0xf7, 0x93, 0x54, 0x64, 0x02, 0x2f, 0x1b, 0xd1, 0xfd, 0xd2, - 0x68, 0x45, 0x6b, 0x8b, 0x81, 0x08, 0x04, 0x48, 0x76, 0xf4, 0x93, 0x51, 0xdf, 0xfa, 0x75, 0x03, - 0x5d, 0x6d, 0xd3, 0x94, 0x72, 0x89, 0xef, 0xa1, 0x29, 0x4e, 0xfb, 0x5e, 0xd6, 0xf7, 0x64, 0xf8, - 0x8e, 0x35, 0x26, 0x6f, 0x4e, 0xde, 0xb9, 0xb2, 0x3b, 0xad, 0x0a, 0x72, 0xbd, 0x45, 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0x1e, 0x87, 0xd9, 0x85, 0x97, - 0x08, 0x11, 0x01, 0x7c, 0x1a, 0xe0, 0xeb, 0xaa, 0x20, 0x2b, 0x2d, 0x19, 0x3c, 0xcd, 0x63, 0x7f, - 0xcf, 0x8a, 0xda, 0x42, 0x44, 0x9a, 0xbd, 0xc2, 0xeb, 0x1d, 0xd8, 0x43, 0x9b, 0xc3, 0x8a, 0xa1, - 0x51, 0x24, 0xce, 0x69, 0xdc, 0x63, 0x95, 0xeb, 0x34, 0x03, 0xf0, 0x4d, 0x55, 0x90, 0x55, 0x5b, - 0x38, 0x8f, 0xad, 0x6c, 0x70, 0xa7, 0x56, 0xf9, 0x38, 0x17, 0x3e, 0x46, 0x37, 0xeb, 0x12, 0x38, - 0xb7, 0x6b, 0x16, 0x72, 0x10, 0x55, 0x90, 0xf5, 0x91, 0x1c, 0x95, 0x2b, 0xb6, 0xce, 0xc7, 0x3b, - 0x71, 0xc7, 0x94, 0x44, 0x59, 0xae, 0xc3, 0x44, 0x9a, 0x3f, 0x07, 0xfc, 0x55, 0x55, 0x90, 0xa5, - 0x41, 0xe1, 0x0e, 0x18, 0x9a, 0xbc, 0xc4, 0xeb, 0xcc, 0xf8, 0x05, 0x5a, 0x81, 0x53, 0xcd, 0xbb, - 0x3c, 0xcc, 0xbc, 0x24, 0x15, 0x89, 0x90, 0xd4, 0xec, 0xf9, 0xbc, 0x53, 0x65, 0x87, 0xa0, 0x68, - 0x97, 0x02, 0x5b, 0x65, 0x23, 0x56, 0x5b, 0xe9, 0x67, 0x22, 0x33, 0x13, 0xc3, 0x4e, 0xa5, 0xbf, - 0x12, 0x19, 0xb3, 0x95, 0x5e, 0x3e, 0xe3, 0x67, 0x68, 0x69, 0x10, 0x71, 0xce, 0xc2, 0xe0, 0x24, - 0x2b, 0xcf, 0x65, 0xc1, 0x69, 0x68, 0x5a, 0xfe, 0xba, 0x74, 0xdb, 0x86, 0x76, 0xc9, 0x86, 0xbf, - 0x43, 0xb3, 0x1a, 0x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 0x2d, 0x37, 0x4f, 0xfc, 0xe1, 0x6e, 0x70, 0xc6, 0xbb, 0x65, 0x27, 0xf9, 0xda, - 0x69, 0x57, 0x25, 0xe9, 0x08, 0xc4, 0x80, 0x6a, 0x81, 0xb4, 0xd3, 0xe4, 0xe3, 0x9d, 0x07, 0x54, - 0x3e, 0xba, 0xf6, 0xfb, 0x7b, 0x32, 0xf1, 0xf7, 0x7b, 0x32, 0xb9, 0xfb, 0xe4, 0x0f, 0xd5, 0x9c, - 0xfc, 0xa0, 0x9a, 0x93, 0x7f, 0xa9, 0xe6, 0xe4, 0x6f, 0x1f, 0x9b, 0x13, 0x1f, 0x3e, 0x36, 0x27, - 0xfe, 0xfc, 0xd8, 0x9c, 0xf8, 0xf9, 0x6e, 0x10, 0x66, 0xfa, 0x8b, 0xb2, 0x27, 0xf8, 0x4e, 0xf9, - 0x21, 0x6a, 0x7e, 0xee, 0x49, 0xff, 0x74, 0xa7, 0x6f, 0xbf, 0x4a, 0xb3, 0x8b, 0x84, 0xc9, 0xee, - 0x55, 0xf8, 0xbc, 0x7c, 0xf8, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb8, 0xff, 0x69, 0xe5, 0xb3, - 0x0e, 0x00, 0x00, + // 364 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x6b, 0xfa, 0x30, + 0x14, 0xc7, 0x5b, 0x15, 0xf9, 0x19, 0x15, 0xfd, 0x75, 0x63, 0x94, 0x1d, 0x5a, 0x71, 0x3b, 0x08, + 0xc3, 0x16, 0xdd, 0xcd, 0x63, 0x61, 0xec, 0x24, 0x48, 0x75, 0x97, 0x5d, 0x4a, 0x74, 0x59, 0x2c, + 0x6b, 0x4c, 0x69, 0xe2, 0x68, 0xfd, 0x2b, 0x76, 0xdc, 0xd1, 0x3f, 0x67, 0x47, 0x8f, 0x3b, 0x95, + 0x11, 0x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x40, 0xe3, 0x98, 0xd6, 0x86, 0xa0, 0x21, 0x27, + 0xe0, 0x49, 0x88, 0xbc, 0x75, 0x14, 0x64, 0xdb, 0xd6, 0x9c, 0xb6, 0x48, 0x4d, 0xc9, 0xfd, 0xe8, + 0x2e, 0x20, 0x0c, 0xcf, 0x92, 0x10, 0xdd, 0x45, 0x81, 0xd6, 0x05, 0xd5, 0x7c, 0x5a, 0xbd, 0xd4, + 0x29, 0xf7, 0x2a, 0x0e, 0x10, 0xa9, 0x59, 0x7c, 0x9e, 0x5b, 0xdc, 0x8c, 0x2a, 0xb2, 0x9b, 0x73, + 0xf3, 0x26, 0x0c, 0x75, 0x27, 0x0c, 0xf5, 0x43, 0x18, 0xea, 0xcb, 0xde, 0x50, 0x76, 0x7b, 0x43, + 0x79, 0xdf, 0x1b, 0xca, 0xfd, 0x15, 0xf6, 0xb9, 0xdc, 0x6a, 0x41, 0x89, 0x5d, 0xb8, 0x99, 0x1f, + 0x7d, 0xf6, 0xf0, 0x64, 0xc7, 0x07, 0x6b, 0x65, 0x7f, 0x36, 0xaf, 0x66, 0x1e, 0x5d, 0x7f, 0x07, + 0x00, 0x00, 0xff, 0xff, 0x4f, 0xce, 0x43, 0x21, 0xf8, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -535,1254 +197,235 @@ func (this *Params) Equal(that interface{}) bool { if this.MinGasPerByte != that1.MinGasPerByte { return false } - if this.MsgGrantFixedGas != that1.MsgGrantFixedGas { + if len(this.MsgGasParamsSet) != len(that1.MsgGasParamsSet) { return false } - if this.MsgGrantPerItemGas != that1.MsgGrantPerItemGas { - return false + for i := range this.MsgGasParamsSet { + if !this.MsgGasParamsSet[i].Equal(that1.MsgGasParamsSet[i]) { + return false + } } - if this.MsgRevokeGas != that1.MsgRevokeGas { - return false + return true +} +func (this *MsgGasParams) Equal(that interface{}) bool { + if that == nil { + return this == nil } - if this.MsgExecGas != that1.MsgExecGas { - return false + + that1, ok := that.(*MsgGasParams) + if !ok { + that2, ok := that.(MsgGasParams) + if ok { + that1 = &that2 + } else { + return false + } } - if this.MsgSendGas != that1.MsgSendGas { + if that1 == nil { + return this == nil + } else if this == nil { return false } - if this.MsgMultiSendFixedGas != that1.MsgMultiSendFixedGas { + if this.Msg_type_url != that1.Msg_type_url { return false } - if this.MsgMultiSendPerItemGas != that1.MsgMultiSendPerItemGas { + if len(this.Params) != len(that1.Params) { return false } - if this.MsgWithdrawDelegatorRewardGas != that1.MsgWithdrawDelegatorRewardGas { - return false + for i := range this.Params { + if this.Params[i] != that1.Params[i] { + return false + } } - if this.MsgWithdrawValidatorCommissionGas != that1.MsgWithdrawValidatorCommissionGas { - return false + return true +} +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - if this.MsgSetWithdrawAddressGas != that1.MsgSetWithdrawAddressGas { - return false + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MsgGasParamsSet) > 0 { + for iNdEx := len(m.MsgGasParamsSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MsgGasParamsSet[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGashub(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } } - if this.MsgFundCommunityPoolGas != that1.MsgFundCommunityPoolGas { - return false + if m.MinGasPerByte != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MinGasPerByte)) + i-- + dAtA[i] = 0x10 } - if this.MsgGrantAllowanceFixedGas != that1.MsgGrantAllowanceFixedGas { - return false + if m.MaxTxSize != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MaxTxSize)) + i-- + dAtA[i] = 0x8 } - if this.MsgGrantAllowancePerItemGas != that1.MsgGrantAllowancePerItemGas { - return false - } - if this.MsgRevokeAllowanceGas != that1.MsgRevokeAllowanceGas { - return false - } - if this.MsgSubmitProposalGas != that1.MsgSubmitProposalGas { - return false - } - if this.MsgVoteGas != that1.MsgVoteGas { - return false - } - if this.MsgVoteWeightedGas != that1.MsgVoteWeightedGas { - return false - } - if this.MsgDepositGas != that1.MsgDepositGas { - return false - } - if this.MsgUnjailGas != that1.MsgUnjailGas { - return false - } - if this.MsgImpeachGas != that1.MsgImpeachGas { - return false - } - if this.MsgEditValidatorGas != that1.MsgEditValidatorGas { - return false - } - if this.MsgDelegateGas != that1.MsgDelegateGas { - return false - } - if this.MsgUndelegateGas != that1.MsgUndelegateGas { - return false - } - if this.MsgBeginRedelegateGas != that1.MsgBeginRedelegateGas { - return false - } - if this.MsgCancelUnbondingDelegationGas != that1.MsgCancelUnbondingDelegationGas { - return false - } - if this.MsgCreateValidatorGas != that1.MsgCreateValidatorGas { - return false - } - if this.MsgClaimGas != that1.MsgClaimGas { - return false - } - if this.MsgTransferOutGas != that1.MsgTransferOutGas { - return false - } - if this.MsgCreateStorageProviderGas != that1.MsgCreateStorageProviderGas { - return false - } - if this.MsgEditStorageProviderGas != that1.MsgEditStorageProviderGas { - return false - } - if this.MsgSpDepositGas != that1.MsgSpDepositGas { - return false - } - if this.MsgStorageCreateBucket != that1.MsgStorageCreateBucket { - return false - } - if this.MsgStorageDeleteBucket != that1.MsgStorageDeleteBucket { - return false - } - if this.MsgStorageCreateObject != that1.MsgStorageCreateObject { - return false - } - if this.MsgStorageDeleteObject != that1.MsgStorageDeleteObject { - return false - } - if this.MsgStorageSealObject != that1.MsgStorageSealObject { - return false - } - if this.MsgStorageCopyObject != that1.MsgStorageCopyObject { - return false - } - if this.MsgStorageRejectSealObject != that1.MsgStorageRejectSealObject { - return false - } - if this.MsgStorageCreateGroup != that1.MsgStorageCreateGroup { - return false - } - if this.MsgStorageDeleteGroup != that1.MsgStorageDeleteGroup { - return false - } - if this.MsgStorageLeaveGroup != that1.MsgStorageLeaveGroup { - return false - } - if this.MsgStorageUpdateGroupMember != that1.MsgStorageUpdateGroupMember { - return false - } - return true + return len(dAtA) - i, nil } -func (m *Params) Marshal() (dAtA []byte, err error) { + +func (m *MsgGasParams) 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 *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.MsgStorageUpdateGroupMember != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageUpdateGroupMember)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xe0 - } - if m.MsgStorageLeaveGroup != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageLeaveGroup)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xd8 - } - if m.MsgStorageDeleteGroup != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageDeleteGroup)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xd0 - } - if m.MsgStorageCreateGroup != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageCreateGroup)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xc8 - } - if m.MsgStorageRejectSealObject != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageRejectSealObject)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xc0 - } - if m.MsgStorageCopyObject != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageCopyObject)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xb8 - } - if m.MsgStorageSealObject != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageSealObject)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xb0 - } - if m.MsgStorageDeleteObject != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageDeleteObject)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xa8 - } - if m.MsgStorageCreateObject != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageCreateObject)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xa0 - } - if m.MsgStorageDeleteBucket != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageDeleteBucket)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x98 - } - if m.MsgStorageCreateBucket != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgStorageCreateBucket)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x90 - } - if m.MsgSpDepositGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgSpDepositGas)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x88 - } - if m.MsgEditStorageProviderGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgEditStorageProviderGas)) - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x80 - } - if m.MsgCreateStorageProviderGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgCreateStorageProviderGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xf8 - } - if m.MsgTransferOutGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgTransferOutGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xf0 - } - if m.MsgClaimGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgClaimGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xe8 - } - if m.MsgCreateValidatorGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgCreateValidatorGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xe0 - } - if m.MsgCancelUnbondingDelegationGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgCancelUnbondingDelegationGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xd8 - } - if m.MsgBeginRedelegateGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgBeginRedelegateGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xd0 - } - if m.MsgUndelegateGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgUndelegateGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xc8 - } - if m.MsgDelegateGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgDelegateGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xc0 - } - if m.MsgEditValidatorGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgEditValidatorGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xb8 - } - if m.MsgImpeachGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgImpeachGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xb0 - } - if m.MsgUnjailGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgUnjailGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa8 - } - if m.MsgDepositGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgDepositGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa0 - } - if m.MsgVoteWeightedGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteWeightedGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x98 - } - if m.MsgVoteGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x90 - } - if m.MsgSubmitProposalGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgSubmitProposalGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x88 - } - if m.MsgRevokeAllowanceGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeAllowanceGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x80 - } - if m.MsgGrantAllowancePerItemGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantAllowancePerItemGas)) - i-- - dAtA[i] = 0x78 - } - if m.MsgGrantAllowanceFixedGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantAllowanceFixedGas)) - i-- - dAtA[i] = 0x70 - } - if m.MsgFundCommunityPoolGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgFundCommunityPoolGas)) - i-- - dAtA[i] = 0x68 - } - if m.MsgSetWithdrawAddressGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgSetWithdrawAddressGas)) - i-- - dAtA[i] = 0x60 - } - if m.MsgWithdrawValidatorCommissionGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawValidatorCommissionGas)) - i-- - dAtA[i] = 0x58 - } - if m.MsgWithdrawDelegatorRewardGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawDelegatorRewardGas)) - i-- - dAtA[i] = 0x50 - } - if m.MsgMultiSendPerItemGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendPerItemGas)) - i-- - dAtA[i] = 0x48 - } - if m.MsgMultiSendFixedGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendFixedGas)) - i-- - dAtA[i] = 0x40 - } - if m.MsgSendGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgSendGas)) - i-- - dAtA[i] = 0x38 - } - if m.MsgExecGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgExecGas)) - i-- - dAtA[i] = 0x30 - } - if m.MsgRevokeGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeGas)) - i-- - dAtA[i] = 0x28 - } - if m.MsgGrantPerItemGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantPerItemGas)) - i-- - dAtA[i] = 0x20 - } - if m.MsgGrantFixedGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantFixedGas)) - i-- - dAtA[i] = 0x18 - } - if m.MinGasPerByte != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MinGasPerByte)) - i-- - dAtA[i] = 0x10 - } - if m.MaxTxSize != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MaxTxSize)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintGashub(dAtA []byte, offset int, v uint64) int { - offset -= sovGashub(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MaxTxSize != 0 { - n += 1 + sovGashub(uint64(m.MaxTxSize)) - } - if m.MinGasPerByte != 0 { - n += 1 + sovGashub(uint64(m.MinGasPerByte)) - } - if m.MsgGrantFixedGas != 0 { - n += 1 + sovGashub(uint64(m.MsgGrantFixedGas)) - } - if m.MsgGrantPerItemGas != 0 { - n += 1 + sovGashub(uint64(m.MsgGrantPerItemGas)) - } - if m.MsgRevokeGas != 0 { - n += 1 + sovGashub(uint64(m.MsgRevokeGas)) - } - if m.MsgExecGas != 0 { - n += 1 + sovGashub(uint64(m.MsgExecGas)) - } - if m.MsgSendGas != 0 { - n += 1 + sovGashub(uint64(m.MsgSendGas)) - } - if m.MsgMultiSendFixedGas != 0 { - n += 1 + sovGashub(uint64(m.MsgMultiSendFixedGas)) - } - if m.MsgMultiSendPerItemGas != 0 { - n += 1 + sovGashub(uint64(m.MsgMultiSendPerItemGas)) - } - if m.MsgWithdrawDelegatorRewardGas != 0 { - n += 1 + sovGashub(uint64(m.MsgWithdrawDelegatorRewardGas)) - } - if m.MsgWithdrawValidatorCommissionGas != 0 { - n += 1 + sovGashub(uint64(m.MsgWithdrawValidatorCommissionGas)) - } - if m.MsgSetWithdrawAddressGas != 0 { - n += 1 + sovGashub(uint64(m.MsgSetWithdrawAddressGas)) - } - if m.MsgFundCommunityPoolGas != 0 { - n += 1 + sovGashub(uint64(m.MsgFundCommunityPoolGas)) - } - if m.MsgGrantAllowanceFixedGas != 0 { - n += 1 + sovGashub(uint64(m.MsgGrantAllowanceFixedGas)) - } - if m.MsgGrantAllowancePerItemGas != 0 { - n += 1 + sovGashub(uint64(m.MsgGrantAllowancePerItemGas)) - } - if m.MsgRevokeAllowanceGas != 0 { - n += 2 + sovGashub(uint64(m.MsgRevokeAllowanceGas)) - } - if m.MsgSubmitProposalGas != 0 { - n += 2 + sovGashub(uint64(m.MsgSubmitProposalGas)) - } - if m.MsgVoteGas != 0 { - n += 2 + sovGashub(uint64(m.MsgVoteGas)) - } - if m.MsgVoteWeightedGas != 0 { - n += 2 + sovGashub(uint64(m.MsgVoteWeightedGas)) - } - if m.MsgDepositGas != 0 { - n += 2 + sovGashub(uint64(m.MsgDepositGas)) - } - if m.MsgUnjailGas != 0 { - n += 2 + sovGashub(uint64(m.MsgUnjailGas)) - } - if m.MsgImpeachGas != 0 { - n += 2 + sovGashub(uint64(m.MsgImpeachGas)) - } - if m.MsgEditValidatorGas != 0 { - n += 2 + sovGashub(uint64(m.MsgEditValidatorGas)) - } - if m.MsgDelegateGas != 0 { - n += 2 + sovGashub(uint64(m.MsgDelegateGas)) - } - if m.MsgUndelegateGas != 0 { - n += 2 + sovGashub(uint64(m.MsgUndelegateGas)) - } - if m.MsgBeginRedelegateGas != 0 { - n += 2 + sovGashub(uint64(m.MsgBeginRedelegateGas)) - } - if m.MsgCancelUnbondingDelegationGas != 0 { - n += 2 + sovGashub(uint64(m.MsgCancelUnbondingDelegationGas)) - } - if m.MsgCreateValidatorGas != 0 { - n += 2 + sovGashub(uint64(m.MsgCreateValidatorGas)) - } - if m.MsgClaimGas != 0 { - n += 2 + sovGashub(uint64(m.MsgClaimGas)) - } - if m.MsgTransferOutGas != 0 { - n += 2 + sovGashub(uint64(m.MsgTransferOutGas)) - } - if m.MsgCreateStorageProviderGas != 0 { - n += 2 + sovGashub(uint64(m.MsgCreateStorageProviderGas)) - } - if m.MsgEditStorageProviderGas != 0 { - n += 2 + sovGashub(uint64(m.MsgEditStorageProviderGas)) - } - if m.MsgSpDepositGas != 0 { - n += 2 + sovGashub(uint64(m.MsgSpDepositGas)) - } - if m.MsgStorageCreateBucket != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageCreateBucket)) - } - if m.MsgStorageDeleteBucket != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageDeleteBucket)) - } - if m.MsgStorageCreateObject != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageCreateObject)) - } - if m.MsgStorageDeleteObject != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageDeleteObject)) - } - if m.MsgStorageSealObject != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageSealObject)) - } - if m.MsgStorageCopyObject != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageCopyObject)) - } - if m.MsgStorageRejectSealObject != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageRejectSealObject)) - } - if m.MsgStorageCreateGroup != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageCreateGroup)) - } - if m.MsgStorageDeleteGroup != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageDeleteGroup)) - } - if m.MsgStorageLeaveGroup != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageLeaveGroup)) - } - if m.MsgStorageUpdateGroupMember != 0 { - n += 2 + sovGashub(uint64(m.MsgStorageUpdateGroupMember)) - } - return n -} - -func sovGashub(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGashub(x uint64) (n int) { - return sovGashub(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) 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 ErrIntOverflowGashub - } - 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: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxTxSize", wireType) - } - m.MaxTxSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxTxSize |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinGasPerByte", wireType) - } - m.MinGasPerByte = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinGasPerByte |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantFixedGas", wireType) - } - m.MsgGrantFixedGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgGrantFixedGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantPerItemGas", wireType) - } - m.MsgGrantPerItemGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgGrantPerItemGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeGas", wireType) - } - m.MsgRevokeGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgRevokeGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgExecGas", wireType) - } - m.MsgExecGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgExecGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSendGas", wireType) - } - m.MsgSendGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgSendGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendFixedGas", wireType) - } - m.MsgMultiSendFixedGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgMultiSendFixedGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendPerItemGas", wireType) - } - m.MsgMultiSendPerItemGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgMultiSendPerItemGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawDelegatorRewardGas", wireType) - } - m.MsgWithdrawDelegatorRewardGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgWithdrawDelegatorRewardGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawValidatorCommissionGas", wireType) - } - m.MsgWithdrawValidatorCommissionGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgWithdrawValidatorCommissionGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSetWithdrawAddressGas", wireType) - } - m.MsgSetWithdrawAddressGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgSetWithdrawAddressGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 13: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgFundCommunityPoolGas", wireType) - } - m.MsgFundCommunityPoolGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgFundCommunityPoolGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 14: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowanceFixedGas", wireType) - } - m.MsgGrantAllowanceFixedGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgGrantAllowanceFixedGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 15: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowancePerItemGas", wireType) - } - m.MsgGrantAllowancePerItemGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgGrantAllowancePerItemGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 16: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeAllowanceGas", wireType) - } - m.MsgRevokeAllowanceGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgRevokeAllowanceGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 17: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitProposalGas", wireType) - } - m.MsgSubmitProposalGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgSubmitProposalGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 18: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteGas", wireType) - } - m.MsgVoteGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgVoteGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 19: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteWeightedGas", wireType) - } - m.MsgVoteWeightedGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgVoteWeightedGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 20: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgDepositGas", wireType) - } - m.MsgDepositGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgDepositGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 21: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgUnjailGas", wireType) - } - m.MsgUnjailGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgUnjailGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 22: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgImpeachGas", wireType) - } - m.MsgImpeachGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgImpeachGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 23: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgEditValidatorGas", wireType) - } - m.MsgEditValidatorGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgEditValidatorGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 24: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgDelegateGas", wireType) - } - m.MsgDelegateGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgDelegateGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 25: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgUndelegateGas", wireType) - } - m.MsgUndelegateGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgUndelegateGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 26: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgBeginRedelegateGas", wireType) - } - m.MsgBeginRedelegateGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgBeginRedelegateGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 27: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgCancelUnbondingDelegationGas", wireType) - } - m.MsgCancelUnbondingDelegationGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgCancelUnbondingDelegationGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 28: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgCreateValidatorGas", wireType) - } - m.MsgCreateValidatorGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgCreateValidatorGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 29: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgClaimGas", wireType) - } - m.MsgClaimGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgClaimGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 30: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgTransferOutGas", wireType) - } - m.MsgTransferOutGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgTransferOutGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 31: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgCreateStorageProviderGas", wireType) - } - m.MsgCreateStorageProviderGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgCreateStorageProviderGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 32: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgEditStorageProviderGas", wireType) - } - m.MsgEditStorageProviderGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgEditStorageProviderGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgGasParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Params) > 0 { + dAtA2 := make([]byte, len(m.Params)*10) + var j1 int + for _, num := range m.Params { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintGashub(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x12 + } + if len(m.Msg_type_url) > 0 { + i -= len(m.Msg_type_url) + copy(dAtA[i:], m.Msg_type_url) + i = encodeVarintGashub(dAtA, i, uint64(len(m.Msg_type_url))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGashub(dAtA []byte, offset int, v uint64) int { + offset -= sovGashub(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MaxTxSize != 0 { + n += 1 + sovGashub(uint64(m.MaxTxSize)) + } + if m.MinGasPerByte != 0 { + n += 1 + sovGashub(uint64(m.MinGasPerByte)) + } + if len(m.MsgGasParamsSet) > 0 { + for _, e := range m.MsgGasParamsSet { + l = e.Size() + n += 1 + l + sovGashub(uint64(l)) + } + } + return n +} + +func (m *MsgGasParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Msg_type_url) + if l > 0 { + n += 1 + l + sovGashub(uint64(l)) + } + if len(m.Params) > 0 { + l = 0 + for _, e := range m.Params { + l += sovGashub(uint64(e)) + } + n += 1 + sovGashub(uint64(l)) + l + } + return n +} + +func sovGashub(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGashub(x uint64) (n int) { + return sovGashub(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowGashub } - case 33: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSpDepositGas", wireType) + if iNdEx >= l { + return io.ErrUnexpectedEOF } - m.MsgSpDepositGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgSpDepositGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - case 34: + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageCreateBucket", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MaxTxSize", wireType) } - m.MsgStorageCreateBucket = 0 + m.MaxTxSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -1792,16 +435,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgStorageCreateBucket |= uint64(b&0x7F) << shift + m.MaxTxSize |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 35: + case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageDeleteBucket", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinGasPerByte", wireType) } - m.MsgStorageDeleteBucket = 0 + m.MinGasPerByte = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -1811,16 +454,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgStorageDeleteBucket |= uint64(b&0x7F) << shift + m.MinGasPerByte |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 36: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageCreateObject", wireType) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgGasParamsSet", wireType) } - m.MsgStorageCreateObject = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -1830,111 +473,81 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgStorageCreateObject |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 37: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageDeleteObject", wireType) + if msglen < 0 { + return ErrInvalidLengthGashub } - m.MsgStorageDeleteObject = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgStorageDeleteObject |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGashub } - case 38: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageSealObject", wireType) + if postIndex > l { + return io.ErrUnexpectedEOF } - m.MsgStorageSealObject = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgStorageSealObject |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + m.MsgGasParamsSet = append(m.MsgGasParamsSet, &MsgGasParams{}) + if err := m.MsgGasParamsSet[len(m.MsgGasParamsSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - case 39: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageCopyObject", wireType) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGashub(dAtA[iNdEx:]) + if err != nil { + return err } - m.MsgStorageCopyObject = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgStorageCopyObject |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGashub } - case 40: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageRejectSealObject", wireType) + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF } - m.MsgStorageRejectSealObject = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgStorageRejectSealObject |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgGasParams) 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 ErrIntOverflowGashub } - case 41: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageCreateGroup", wireType) + if iNdEx >= l { + return io.ErrUnexpectedEOF } - m.MsgStorageCreateGroup = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgStorageCreateGroup |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - case 42: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageDeleteGroup", wireType) + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgGasParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGasParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg_type_url", wireType) } - m.MsgStorageDeleteGroup = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -1944,48 +557,99 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgStorageDeleteGroup |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 43: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageLeaveGroup", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGashub } - m.MsgStorageLeaveGroup = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgStorageLeaveGroup |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGashub } - case 44: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgStorageUpdateGroupMember", wireType) + if postIndex > l { + return io.ErrUnexpectedEOF } - m.MsgStorageUpdateGroupMember = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgStorageUpdateGroupMember |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + m.Msg_type_url = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Params = append(m.Params, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGashub + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGashub + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Params) == 0 { + m.Params = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Params = append(m.Params, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } default: iNdEx = preIndex diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index a0a8cac650..cd0bb20062 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -10,158 +10,194 @@ import ( // Default parameter values const ( - DefaultMaxTxSize uint64 = 1024 - DefaultMinGasPerByte uint64 = 5 - DefaultMsgGrantFixedGas uint64 = 1e5 - DefaultMsgGrantPerItemGas uint64 = 1e5 - DefaultMsgRevokeGas uint64 = 1e5 - DefaultMsgExecGas uint64 = 1e5 - DefaultMsgSendGas uint64 = 1e5 - DefaultMsgMultiSendFixedGas uint64 = 1e5 - DefaultMsgMultiSendPerItemGas uint64 = 1e5 - DefaultMsgWithdrawDelegatorRewardGas uint64 = 1e5 - DefaultMsgWithdrawValidatorCommissionGas uint64 = 1e5 - DefaultMsgSetWithdrawAddressGas uint64 = 1e5 - DefaultMsgFundCommunityPoolGas uint64 = 1e5 - DefaultMsgGrantAllowanceFixedGas uint64 = 1e5 - DefaultMsgGrantAllowancePerItemGas uint64 = 1e5 - DefaultMsgRevokeAllowanceGas uint64 = 1e5 - DefaultMsgSubmitProposalGas uint64 = 1e5 - DefaultMsgVoteGas uint64 = 1e5 - DefaultMsgVoteWeightedGas uint64 = 1e5 - DefaultMsgDepositGas uint64 = 1e5 - DefaultMsgUnjailGas uint64 = 1e5 - DefaultMsgImpeachGas uint64 = 1e5 - DefaultMsgEditValidatorGas uint64 = 1e5 - DefaultMsgDelegateGas uint64 = 1e5 - DefaultMsgUndelegateGas uint64 = 1e5 - DefaultMsgBeginRedelegateGas uint64 = 1e5 - DefaultMsgCancelUnbondingDelegationGas uint64 = 1e5 - DefaultMsgCreateValidatorGas uint64 = 1e5 - DefaultMsgClaimGas uint64 = 1e5 - DefaultMsgTransferOutGas uint64 = 1e5 - DefaultMsgCreateStorageProviderGas uint64 = 1e5 - DefaultMsgEditStorageProviderGas uint64 = 1e5 - DefaultMsgSpDepositGas uint64 = 1e5 - DefaultMsgStorageCreateBucket uint64 = 1e5 - DefaultMsgStorageDeleteBucket uint64 = 1e5 - DefaultMsgStorageCreateObject uint64 = 1e5 - DefaultMsgStorageDeleteObject uint64 = 1e5 - DefaultMsgStorageSealObject uint64 = 1e5 - DefaultMsgStorageCopyObject uint64 = 1e5 - DefaultMsgStorageRejectSealObject uint64 = 1e5 - DefaultMsgStorageCreateGroup uint64 = 1e5 - DefaultMsgStorageDeleteGroup uint64 = 1e5 - DefaultMsgStorageLeaveGroup uint64 = 1e5 - DefaultMsgStorageUpdateGroupMember uint64 = 1e5 + DefaultMaxTxSize uint64 = 1024 + DefaultMinGasPerByte uint64 = 5 ) +var DefaultMsgGasParamsSet = []*MsgGasParams{ + { + Msg_type_url: "/cosmos.staking.v1beta1.MsgCreateValidator", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgRejectSealObject", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgDeleteGroup", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.authz.v1beta1.MsgRevoke", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.slashing.v1beta1.MsgImpeach", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.staking.v1beta1.MsgEditValidator", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.bridge.MsgTransferOut", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgCreateObject", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.bank.v1beta1.MsgSend", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.gov.v1.MsgVote", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.gov.v1.MsgVoteWeighted", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgSealObject", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgDeleteBucket", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.slashing.v1beta1.MsgUnjail", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.sp.MsgCreateStorageProvider", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.sp.MsgDeposit", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgUpdateGroupMember", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.gov.v1.MsgDeposit", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.sp.MsgEditStorageProvider", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgCreateBucket", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgLeaveGroup", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.oracle.v1.MsgClaim", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgCopyObject", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.gov.v1.MsgSubmitProposal", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.staking.v1beta1.MsgUndelegate", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.staking.v1beta1.MsgDelegate", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgDeleteObject", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/bnbchain.greenfield.storage.MsgCreateGroup", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.authz.v1beta1.MsgExec", + Params: []uint64{1e5}, + }, + { + Msg_type_url: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + Params: []uint64{1e5, 1e5}, + }, + { + Msg_type_url: "/cosmos.authz.v1beta1.MsgGrant", + Params: []uint64{1e5, 1e5}, + }, + { + Msg_type_url: "/cosmos.bank.v1beta1.MsgMultiSend", + Params: []uint64{1e5, 1e5}, + }, +} + // Parameter keys var ( - KeyMaxTxSize = []byte("MaxTxSize") - KeyMinGasPerByte = []byte("MinGasPerByte") - KeyMsgGrantFixedGas = []byte("MsgGrantFixedGas") - KeyMsgGrantPerItemGas = []byte("MsgGrantPerItemGas") - KeyMsgRevokeGas = []byte("MsgRevokeGas") - KeyMsgExecGas = []byte("MsgExecGas") - KeyMsgSendGas = []byte("MsgSendGas") - KeyMsgMultiSendFixedGas = []byte("MsgMultiSendFixedGas") - KeyMsgMultiSendPerItemGas = []byte("MsgMultiSendPerItemGas") - KeyMsgWithdrawDelegatorRewardGas = []byte("MsgWithdrawDelegatorRewardGas") - KeyMsgWithdrawValidatorCommissionGas = []byte("MsgWithdrawValidatorCommissionGas") - KeyMsgSetWithdrawAddressGas = []byte("MsgSetWithdrawAddressGas") - KeyMsgFundCommunityPoolGas = []byte("MsgFundCommunityPoolGas") - KeyMsgGrantAllowanceFixedGas = []byte("MsgGrantAllowanceFixedGas") - KeyMsgGrantAllowancePerItemGas = []byte("MsgGrantAllowancePerItemGas") - KeyMsgRevokeAllowanceGas = []byte("MsgRevokeAllowanceGas") - KeyMsgSubmitProposalGas = []byte("MsgSubmitProposalGas") - KeyMsgVoteGas = []byte("MsgVoteGas") - KeyMsgVoteWeightedGas = []byte("MsgVoteWeightedGas") - KeyMsgDepositGas = []byte("MsgDepositGas") - KeyMsgUnjailGas = []byte("MsgUnjailGas") - KeyMsgImpeachGas = []byte("MsgImpeachGas") - KeyMsgEditValidatorGas = []byte("MsgEditValidatorGas") - KeyMsgDelegateGas = []byte("MsgDelegateGas") - KeyMsgUndelegateGas = []byte("MsgUndelegateGas") - KeyMsgBeginRedelegateGas = []byte("MsgBeginRedelegateGas") - KeyMsgCancelUnbondingDelegationGas = []byte("MsgCancelUnbondingDelegationGas") - KeyMsgCreateValidatorGas = []byte("MsgCreateValidatorGas") - KeyMsgClaimGas = []byte("MsgClaimGas") - KeyMsgTransferOutGas = []byte("MsgTransferOutGas") - KeyMsgCreateStorageProviderGas = []byte("MsgCreateStorageProviderGas") - KeyMsgEditStorageProviderGas = []byte("MsgEditStorageProviderGas") - KeyMsgSpDepositGas = []byte("MsgSpDepositGas") - KeyMsgStorageCreateBucket = []byte("MsgStorageCreateBucket") - KeyMsgStorageDeleteBucket = []byte("MsgStorageDeleteBucket") - KeyMsgStorageCreateObject = []byte("MsgStorageCreateObject") - KeyMsgStorageDeleteObject = []byte("MsgStorageDeleteObject") - KeyMsgStorageSealObject = []byte("MsgStorageSealObject") - KeyMsgStorageCopyObject = []byte("MsgStorageCopyObject") - KeyMsgStorageRejectSealObject = []byte("MsgStorageRejectSealObject") - KeyMsgStorageCreateGroup = []byte("MsgStorageCreateGroup") - KeyMsgStorageDeleteGroup = []byte("MsgStorageDeleteGroup") - KeyMsgStorageLeaveGroup = []byte("MsgStorageLeaveGroup") - KeyMsgStorageUpdateGroupMember = []byte("MsgStorageUpdateGroupMember") + KeyMaxTxSize = []byte("MaxTxSize") + KeyMinGasPerByte = []byte("MinGasPerByte") + KeyMsgGasParamsSet = []byte("MsgGasParamsSet") ) var _ paramtypes.ParamSet = &Params{} +// NewMsgGasParams creates a new MsgGasParams object +func NewMsgGasParams(msgTypeUrl string, Params ...uint64, ) *MsgGasParams { + return &MsgGasParams{ + Msg_type_url: msgTypeUrl, + Params: Params, + } +} + // NewParams creates a new Params object func NewParams( - maxTxSize, minGasPerByte, msgGrantFixedGas, msgGrantPerItemGas, msgRevokeGas, msgExecGas, msgSendGas, msgMultiSendFixedGas, - msgMultiSendPerItemGas, msgWithdrawDelegatorRewardGas, msgWithdrawValidatorCommissionGas, msgSetWithdrawAddressGas, - msgFundCommunityPoolGas, msgGrantAllowanceFixedGas, msgGrantAllowancePerItemGas, msgRevokeAllowanceGas, msgSubmitProposalGas, - msgVoteGas, msgVoteWeightedGas, msgDepositGas, msgUnjailGas, msgImpeachGas, msgEditValidatorGas, msgDelegateGas, - msgUndelegateGas, msgBeginRedelegateGas, msgCancelUnbondingDelegationGas, msgCreateValidatorGas, msgClaimGas, - msgTransferOutGas, msgCreateStorageProviderGas, msgEditStorageProviderGas, msgSpDepositGas, msgStorageCreateBucket, - msgStorageDeleteBucket, msgStorageCreateObject, msgStorageDeleteObject, msgStorageSealObject, msgStorageCopyObject, - msgStorageRejectSealObject, msgStorageCreateGroup, msgStorageDeleteGroup, msgStorageLeaveGroup, msgStorageUpdateGroupMember uint64, + maxTxSize, minGasPerByte uint64, msgGasParamsSet []*MsgGasParams, ) Params { return Params{ - MaxTxSize: maxTxSize, - MinGasPerByte: minGasPerByte, - MsgGrantFixedGas: msgGrantFixedGas, - MsgGrantPerItemGas: msgGrantPerItemGas, - MsgRevokeGas: msgRevokeGas, - MsgExecGas: msgExecGas, - MsgSendGas: msgSendGas, - MsgMultiSendFixedGas: msgMultiSendFixedGas, - MsgMultiSendPerItemGas: msgMultiSendPerItemGas, - MsgWithdrawDelegatorRewardGas: msgWithdrawDelegatorRewardGas, - MsgWithdrawValidatorCommissionGas: msgWithdrawValidatorCommissionGas, - MsgSetWithdrawAddressGas: msgSetWithdrawAddressGas, - MsgFundCommunityPoolGas: msgFundCommunityPoolGas, - MsgGrantAllowanceFixedGas: msgGrantAllowanceFixedGas, - MsgGrantAllowancePerItemGas: msgGrantAllowancePerItemGas, - MsgRevokeAllowanceGas: msgRevokeAllowanceGas, - MsgSubmitProposalGas: msgSubmitProposalGas, - MsgVoteGas: msgVoteGas, - MsgVoteWeightedGas: msgVoteWeightedGas, - MsgDepositGas: msgDepositGas, - MsgUnjailGas: msgUnjailGas, - MsgImpeachGas: msgImpeachGas, - MsgEditValidatorGas: msgEditValidatorGas, - MsgDelegateGas: msgDelegateGas, - MsgUndelegateGas: msgUndelegateGas, - MsgBeginRedelegateGas: msgBeginRedelegateGas, - MsgCancelUnbondingDelegationGas: msgCancelUnbondingDelegationGas, - MsgCreateValidatorGas: msgCreateValidatorGas, - MsgClaimGas: msgClaimGas, - MsgTransferOutGas: msgTransferOutGas, - MsgCreateStorageProviderGas: msgCreateStorageProviderGas, - MsgEditStorageProviderGas: msgEditStorageProviderGas, - MsgSpDepositGas: msgSpDepositGas, - MsgStorageCreateBucket: msgStorageCreateBucket, - MsgStorageDeleteBucket: msgStorageDeleteBucket, - MsgStorageCreateObject: msgStorageCreateObject, - MsgStorageDeleteObject: msgStorageDeleteObject, - MsgStorageSealObject: msgStorageSealObject, - MsgStorageCopyObject: msgStorageCopyObject, - MsgStorageRejectSealObject: msgStorageRejectSealObject, - MsgStorageCreateGroup: msgStorageCreateGroup, - MsgStorageDeleteGroup: msgStorageDeleteGroup, - MsgStorageLeaveGroup: msgStorageLeaveGroup, - MsgStorageUpdateGroupMember: msgStorageUpdateGroupMember, + MaxTxSize: maxTxSize, + MinGasPerByte: minGasPerByte, + MsgGasParamsSet: msgGasParamsSet, } } @@ -176,98 +212,16 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), - paramtypes.NewParamSetPair(KeyMsgGrantFixedGas, &p.MsgGrantFixedGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgGrantPerItemGas, &p.MsgGrantPerItemGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgRevokeGas, &p.MsgRevokeGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgExecGas, &p.MsgExecGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgMultiSendFixedGas, &p.MsgMultiSendFixedGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgMultiSendPerItemGas, &p.MsgMultiSendPerItemGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgWithdrawDelegatorRewardGas, &p.MsgWithdrawDelegatorRewardGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgWithdrawValidatorCommissionGas, &p.MsgWithdrawValidatorCommissionGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgSetWithdrawAddressGas, &p.MsgSetWithdrawAddressGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgFundCommunityPoolGas, &p.MsgFundCommunityPoolGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgGrantAllowanceFixedGas, &p.MsgGrantAllowanceFixedGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgGrantAllowancePerItemGas, &p.MsgGrantAllowancePerItemGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgRevokeAllowanceGas, &p.MsgRevokeAllowanceGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgSubmitProposalGas, &p.MsgSubmitProposalGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgVoteGas, &p.MsgVoteGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgVoteWeightedGas, &p.MsgVoteWeightedGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgDepositGas, &p.MsgDepositGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgUnjailGas, &p.MsgUnjailGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgImpeachGas, &p.MsgImpeachGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgEditValidatorGas, &p.MsgEditValidatorGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgDelegateGas, &p.MsgDelegateGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgUndelegateGas, &p.MsgUndelegateGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgBeginRedelegateGas, &p.MsgBeginRedelegateGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgCancelUnbondingDelegationGas, &p.MsgCancelUnbondingDelegationGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgCreateValidatorGas, &p.MsgCreateValidatorGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgClaimGas, &p.MsgClaimGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgTransferOutGas, &p.MsgTransferOutGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgCreateStorageProviderGas, &p.MsgCreateStorageProviderGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgEditStorageProviderGas, &p.MsgEditStorageProviderGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgSpDepositGas, &p.MsgSpDepositGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageCreateBucket, &p.MsgStorageCreateBucket, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageDeleteBucket, &p.MsgStorageDeleteBucket, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageCreateObject, &p.MsgStorageCreateObject, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageDeleteObject, &p.MsgStorageDeleteObject, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageSealObject, &p.MsgStorageSealObject, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageCopyObject, &p.MsgStorageCopyObject, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageRejectSealObject, &p.MsgStorageRejectSealObject, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageCreateGroup, &p.MsgStorageCreateGroup, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageDeleteGroup, &p.MsgStorageDeleteGroup, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageLeaveGroup, &p.MsgStorageLeaveGroup, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgStorageUpdateGroupMember, &p.MsgStorageUpdateGroupMember, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgGasParamsSet, &p.MsgGasParamsSet, validateMsgGasParams), } } // DefaultParams returns a default set of parameters. func DefaultParams() Params { return Params{ - MaxTxSize: DefaultMaxTxSize, - MinGasPerByte: DefaultMinGasPerByte, - MsgGrantFixedGas: DefaultMsgGrantFixedGas, - MsgGrantPerItemGas: DefaultMsgGrantPerItemGas, - MsgRevokeGas: DefaultMsgRevokeGas, - MsgExecGas: DefaultMsgExecGas, - MsgSendGas: DefaultMsgSendGas, - MsgMultiSendFixedGas: DefaultMsgMultiSendFixedGas, - MsgMultiSendPerItemGas: DefaultMsgMultiSendPerItemGas, - MsgWithdrawDelegatorRewardGas: DefaultMsgWithdrawDelegatorRewardGas, - MsgWithdrawValidatorCommissionGas: DefaultMsgWithdrawValidatorCommissionGas, - MsgSetWithdrawAddressGas: DefaultMsgSetWithdrawAddressGas, - MsgFundCommunityPoolGas: DefaultMsgFundCommunityPoolGas, - MsgGrantAllowanceFixedGas: DefaultMsgGrantAllowanceFixedGas, - MsgGrantAllowancePerItemGas: DefaultMsgGrantAllowancePerItemGas, - MsgRevokeAllowanceGas: DefaultMsgRevokeAllowanceGas, - MsgSubmitProposalGas: DefaultMsgSubmitProposalGas, - MsgVoteGas: DefaultMsgVoteGas, - MsgVoteWeightedGas: DefaultMsgVoteWeightedGas, - MsgDepositGas: DefaultMsgDepositGas, - MsgUnjailGas: DefaultMsgUnjailGas, - MsgImpeachGas: DefaultMsgImpeachGas, - MsgEditValidatorGas: DefaultMsgEditValidatorGas, - MsgDelegateGas: DefaultMsgDelegateGas, - MsgUndelegateGas: DefaultMsgUndelegateGas, - MsgBeginRedelegateGas: DefaultMsgBeginRedelegateGas, - MsgCancelUnbondingDelegationGas: DefaultMsgCancelUnbondingDelegationGas, - MsgCreateValidatorGas: DefaultMsgCreateValidatorGas, - MsgClaimGas: DefaultMsgClaimGas, - MsgTransferOutGas: DefaultMsgTransferOutGas, - MsgCreateStorageProviderGas: DefaultMsgCreateStorageProviderGas, - MsgEditStorageProviderGas: DefaultMsgEditStorageProviderGas, - MsgSpDepositGas: DefaultMsgSpDepositGas, - MsgStorageCreateBucket: DefaultMsgStorageCreateBucket, - MsgStorageDeleteBucket: DefaultMsgStorageDeleteBucket, - MsgStorageCreateObject: DefaultMsgStorageCreateObject, - MsgStorageDeleteObject: DefaultMsgStorageDeleteObject, - MsgStorageSealObject: DefaultMsgStorageSealObject, - MsgStorageCopyObject: DefaultMsgStorageCopyObject, - MsgStorageRejectSealObject: DefaultMsgStorageRejectSealObject, - MsgStorageCreateGroup: DefaultMsgStorageCreateGroup, - MsgStorageDeleteGroup: DefaultMsgStorageDeleteGroup, - MsgStorageLeaveGroup: DefaultMsgStorageLeaveGroup, - MsgStorageUpdateGroupMember: DefaultMsgStorageUpdateGroupMember, + MaxTxSize: DefaultMaxTxSize, + MinGasPerByte: DefaultMinGasPerByte, + MsgGasParamsSet: DefaultMsgGasParamsSet, } } @@ -303,14 +257,21 @@ func validateMinGasPerByte(i interface{}) error { return nil } -func validateMsgGas(i interface{}) error { - v, ok := i.(uint64) +func validateMsgGasParams(i interface{}) error { + v, ok := i.([]*MsgGasParams) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - if v == 0 { - return fmt.Errorf("invalid msg gas: %d", v) + for _, msgGasParams := range v { + if len(msgGasParams.Params) == 0 { + return fmt.Errorf("params cannot be empty") + } + for _, param := range msgGasParams.Params { + if param == 0 { + return fmt.Errorf("invalid msg gas param: %d", param) + } + } } return nil @@ -324,130 +285,7 @@ func (p Params) Validate() error { if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { return err } - if err := validateMsgGas(p.MsgGrantFixedGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgGrantPerItemGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgRevokeGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgExecGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgSendGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgMultiSendFixedGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgMultiSendPerItemGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgWithdrawDelegatorRewardGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgWithdrawValidatorCommissionGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgSetWithdrawAddressGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgFundCommunityPoolGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgGrantAllowanceFixedGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgGrantAllowancePerItemGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgRevokeAllowanceGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgSubmitProposalGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgVoteGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgVoteWeightedGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgDepositGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgUnjailGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgImpeachGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgEditValidatorGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgDelegateGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgUndelegateGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgBeginRedelegateGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgCancelUnbondingDelegationGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgCreateValidatorGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgClaimGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgTransferOutGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgCreateStorageProviderGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgEditStorageProviderGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgSpDepositGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageCreateBucket); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageDeleteBucket); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageCreateObject); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageDeleteObject); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageSealObject); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageCopyObject); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageRejectSealObject); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageCreateGroup); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageDeleteGroup); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageLeaveGroup); err != nil { - return err - } - if err := validateMsgGas(p.MsgStorageUpdateGroupMember); err != nil { + if err := validateMsgGasParams(p.MsgGasParamsSet); err != nil { return err } From c7d2d810451316ae13353677411f10604a72d631 Mon Sep 17 00:00:00 2001 From: Roshan Date: Fri, 10 Feb 2023 13:41:36 +0800 Subject: [PATCH 02/13] fix lint issues --- x/gashub/types/params.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index cd0bb20062..2b533e6d3b 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -10,8 +10,8 @@ import ( // Default parameter values const ( - DefaultMaxTxSize uint64 = 1024 - DefaultMinGasPerByte uint64 = 5 + DefaultMaxTxSize uint64 = 1024 + DefaultMinGasPerByte uint64 = 5 ) var DefaultMsgGasParamsSet = []*MsgGasParams{ @@ -183,10 +183,10 @@ var ( var _ paramtypes.ParamSet = &Params{} // NewMsgGasParams creates a new MsgGasParams object -func NewMsgGasParams(msgTypeUrl string, Params ...uint64, ) *MsgGasParams { +func NewMsgGasParams(msgTypeUrl string, params ...uint64) *MsgGasParams { return &MsgGasParams{ Msg_type_url: msgTypeUrl, - Params: Params, + Params: params, } } From 09540bcc30c7b98c1ecd263f7943e55e25d1fe2e Mon Sep 17 00:00:00 2001 From: Roshan Date: Sun, 12 Feb 2023 23:50:55 +0800 Subject: [PATCH 03/13] update gas params to oneof type --- proto/cosmos/gashub/v1alpha1/gashub.proto | 33 +- x/auth/vesting/types/codec.go | 2 +- x/gashub/module.go | 4 +- x/gashub/simulation/genesis.go | 7 +- x/gashub/simulation/genesis_test.go | 5 +- x/gashub/simulation/params.go | 2 +- x/gashub/simulation/params_test.go | 2 +- x/gashub/types/codec.go | 20 +- x/gashub/types/gas_calculator.go | 93 ++- x/gashub/types/gashub.pb.go | 889 ++++++++++++++++++---- x/gashub/types/params.go | 241 ++---- x/gov/types/v1/proposal.go | 2 +- 12 files changed, 941 insertions(+), 359 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index a87c20079c..4232f92ac1 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package cosmos.gashub.v1alpha1; import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; @@ -16,11 +17,37 @@ message Params { repeated MsgGasParams msg_gas_params_set = 3 [(gogoproto.customname) = "MsgGasParamsSet"]; } -// MsgGasParams is a +// MsgGasParams defines gas for a msg type message MsgGasParams { option (gogoproto.equal) = true; - string msg_type_url = 1 [(gogoproto.customname) = "Msg_type_url"]; + string msg_type_url = 1 [(gogoproto.customname) = "MsgTypeUrl"]; + GasType gas_type = 2 [(gogoproto.customname) = "GasType"]; + // 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. + FixedGasParams fixed_type = 3; + // dynamic_type specifies dynamic type gas params. + DynamicGasParams dynamic_type = 4; + } + // FixedGasParams defines the parameters for fixed gas type. + message FixedGasParams { + 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; + + uint64 fixed_gas = 1 [(gogoproto.customname) = "FixedGas"]; + uint64 gas_per_item = 2 [(gogoproto.customname) = "GasPerItem"]; + } +} - repeated uint64 params = 2 [(gogoproto.customname) = "Params"];; +enum GasType { + UNSPECIFIED = 0; + FIXED = 1; + DYNAMIC = 2; } diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 270116671e..39dfb81ed9 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -25,7 +25,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgCreatePermanentLockedAccount{}, "cosmos-sdk/MsgCreatePermLockedAccount") } -// RegisterInterface associates protoName with AccountI and VestingAccount +// RegisterInterfaces associates protoName with AccountI and VestingAccount // Interfaces and creates a registry of it's concrete implementations func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface( diff --git a/x/gashub/module.go b/x/gashub/module.go index 15e84b4e6e..4e3074b518 100644 --- a/x/gashub/module.go +++ b/x/gashub/module.go @@ -37,7 +37,9 @@ func (AppModuleBasic) Name() string { } // RegisterLegacyAminoCodec registers the gashub module's types for the given codec. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} // DefaultGenesis returns default genesis state as raw bytes for the gashub // module. diff --git a/x/gashub/simulation/genesis.go b/x/gashub/simulation/genesis.go index 1467664595..2b3e33c1f4 100644 --- a/x/gashub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -1,13 +1,13 @@ package simulation import ( - "encoding/json" "fmt" "math/rand" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gashub/types" + "github.com/gogo/protobuf/jsonpb" ) // Simulation parameter constants @@ -31,7 +31,7 @@ func GenMinGasPerByte(r *rand.Rand) uint64 { func GenMsgGasParams(r *rand.Rand) *types.MsgGasParams { msgTypeUrl := simulation.RandStringOfLength(r, 12) gas := uint64(simulation.RandIntBetween(r, 1e5, 1e7)) - return types.NewMsgGasParams(msgTypeUrl, gas) + return types.NewMsgGasParamsWithFixedGas(msgTypeUrl, gas) } // RandomizedGenState generates a random GenesisState for auth @@ -58,7 +58,8 @@ func RandomizedGenState(simState *module.SimulationState) { gashubGenesis := types.NewGenesisState(params) - bz, err := json.MarshalIndent(&gashubGenesis.Params, "", " ") + cdc := jsonpb.Marshaler{Indent: " "} + bz, err := cdc.MarshalToString(&gashubGenesis.Params) if err != nil { panic(err) } diff --git a/x/gashub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go index 0bfcbb995c..fecfcd5685 100644 --- a/x/gashub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -20,6 +20,7 @@ import ( // Abnormal scenarios are not tested here. func TestRandomizedGenState(t *testing.T) { interfaceRegistry := codectypes.NewInterfaceRegistry() + types.RegisterInterfaces(interfaceRegistry) cdc := codec.NewProtoCodec(interfaceRegistry) s := rand.NewSource(1) r := rand.New(s) @@ -41,5 +42,7 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) require.Equal(t, uint64(2956), gashubGenesis.Params.MinGasPerByte) - require.Equal(t, uint64(4978511), gashubGenesis.Params.MsgGasParamsSet[0].Params[0]) + + gas := gashubGenesis.Params.MsgGasParamsSet[0].GasParams.(*types.MsgGasParams_FixedType) + require.Equal(t, uint64(4978511), gas.FixedType.FixedGas) } diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index a28884713d..a0ab2b3e03 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -3,12 +3,12 @@ package simulation // DONTCOVER import ( - "encoding/json" "math/rand" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gashub/types" "github.com/cosmos/cosmos-sdk/x/simulation" + "encoding/json" ) // ParamChanges defines the parameters that can be modified by param change proposals diff --git a/x/gashub/simulation/params_test.go b/x/gashub/simulation/params_test.go index dd44781fb8..594355db15 100644 --- a/x/gashub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -19,7 +19,7 @@ func TestParamChanges(t *testing.T) { simValue string subspace string }{ - {"gashub/MsgGasParamsSet", "MsgGasParamsSet", "{\"msg_type_url\":\"FpXzpLGIehps\",\"params\":[1631847]}", "gashub"}, + {"gashub/MsgGasParamsSet", "MsgGasParamsSet", "{\"msg_type_url\":\"FpXzpLGIehps\",\"gas_type\":1,\"GasParams\":{\"fixed_type\":{\"fixed_gas\":1631847}}}", "gashub"}, } paramChanges := simulation.ParamChanges(r) diff --git a/x/gashub/types/codec.go b/x/gashub/types/codec.go index da6aced74c..c388450216 100644 --- a/x/gashub/types/codec.go +++ b/x/gashub/types/codec.go @@ -8,25 +8,23 @@ import ( authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) -// RegisterLegacyAminoCodec registers the account interfaces and concrete types on the -// provided LegacyAmino codec. These types are used for Amino JSON serialization func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterInterface((*isMsgGasParams_GasParams)(nil), nil) + cdc.RegisterConcrete(&MsgGasParams_FixedType{}, "cosmos-sdk/MsgGasParams/FixedType", nil) + cdc.RegisterConcrete(&MsgGasParams_DynamicType{}, "cosmos-sdk/MsgGasParams/DynamicType", nil) } -// RegisterInterfaces associates protoName with AccountI interface -// and creates a registry of it's concrete implementations -func RegisterInterfaces(registry types.InterfaceRegistry) { -} +func RegisterInterfaces(registry types.InterfaceRegistry) {} var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(Amino) ) func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - sdk.RegisterLegacyAminoCodec(amino) + RegisterLegacyAminoCodec(Amino) + cryptocodec.RegisterCrypto(Amino) + sdk.RegisterLegacyAminoCodec(Amino) // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be // used to properly serialize MsgGrant and MsgExec instances diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 5635a96160..0b9d202b0f 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -103,14 +103,12 @@ func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { var msgGrantGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsg_type_url() == "/cosmos.authz.v1beta1.MsgGrant" { - p := gasParams.GetParams() - if len(p) != 2 { - panic("wrong params for /cosmos.authz.v1beta1.MsgGrant") + if gasParams.GetMsgTypeUrl() == "/cosmos.authz.v1beta1.MsgGrant" { + p, ok := gasParams.GasParams.(*MsgGasParams_DynamicType) + if !ok { + panic("type conversion failed for /cosmos.authz.v1beta1.MsgGrant") } - fixedGas := p[0] - gasPerItem := p[1] - return GrantCalculator(fixedGas, gasPerItem) + return GrantCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) } } panic("no params for /cosmos.authz.v1beta1.MsgGrant") @@ -119,14 +117,12 @@ var msgGrantGasCalculatorGen = func(params Params) GasCalculator { var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsg_type_url() == "/cosmos.bank.v1beta1.MsgMultiSend" { - p := gasParams.GetParams() - if len(p) != 2 { - panic("wrong params for /cosmos.bank.v1beta1.MsgMultiSend") + if gasParams.GetMsgTypeUrl() == "/cosmos.bank.v1beta1.MsgMultiSend" { + p, ok := gasParams.GasParams.(*MsgGasParams_DynamicType) + if !ok { + panic("type conversion failed for /cosmos.bank.v1beta1.MsgMultiSend") } - fixedGas := p[0] - gasPerItem := p[1] - return MultiSendCalculator(fixedGas, gasPerItem) + return MultiSendCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) } } panic("no params for /cosmos.bank.v1beta1.MsgMultiSend") @@ -135,36 +131,73 @@ var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsg_type_url() == "/cosmos.feegrant.v1beta1.MsgGrantAllowance" { - p := gasParams.GetParams() - if len(p) != 2 { - panic("wrong params for /cosmos.feegrant.v1beta1.MsgGrantAllowance") + if gasParams.GetMsgTypeUrl() == "/cosmos.feegrant.v1beta1.MsgGrantAllowance" { + p, ok := gasParams.GasParams.(*MsgGasParams_DynamicType) + if !ok { + panic("type conversion failed for /cosmos.feegrant.v1beta1.MsgGrantAllowance") } - fixedGas := p[0] - gasPerItem := p[1] - return GrantAllowanceCalculator(fixedGas, gasPerItem) + return MultiSendCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) } } panic("no params for /cosmos.feegrant.v1beta1.MsgGrantAllowance") } func init() { + var defaultMsgGasParamsSet = []*MsgGasParams{ + NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgExec", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgRevoke", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.bank.v1beta1.MsgSend", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgFundCommunityPool", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.feegrant.v1beta1.MsgRevokeAllowance", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgDeposit", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgSubmitProposal", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVote", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVoteWeighted", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.oracle.v1.MsgClaim", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgImpeach", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgUnjail", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgBeginRedelegate", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCreateValidator", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgDelegate", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgEditValidator", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgUndelegate", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.bridge.MsgTransferOut", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgCreateStorageProvider", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgDeposit", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgEditStorageProvider", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCopyObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateBucket", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateGroup", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteBucket", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteGroup", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgLeaveGroup", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgRejectSealObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgSealObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgUpdateGroupMember", 1e5), + NewMsgGasParamsWithDynamicGas("/cosmos.authz.v1beta1.MsgGrant", 1e5, 1e5), + NewMsgGasParamsWithDynamicGas("/cosmos.bank.v1beta1.MsgMultiSend", 1e5, 1e5), + NewMsgGasParamsWithDynamicGas("/cosmos.feegrant.v1beta1.MsgGrantAllowance", 1e5, 1e5), + } // for fixed gas msgs - for _, gasParams := range DefaultMsgGasParamsSet { - if len(gasParams.GetParams()) != 1 { + for _, gasParams := range defaultMsgGasParamsSet { + if gasParams.GetGasType() != GasType_FIXED { continue } - msgType := gasParams.GetMsg_type_url() + msgType := gasParams.GetMsgTypeUrl() RegisterCalculatorGen(msgType, func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsg_type_url() == msgType { - p := gasParams.GetParams() - if len(p) != 1 { - panic(fmt.Sprintf("wrong params for %s", msgType)) + if gasParams.GetMsgTypeUrl() == msgType { + p, ok := gasParams.GasParams.(*MsgGasParams_FixedType) + if !ok { + panic(fmt.Errorf("unpack failed for %s", msgType)) } - fixedGas := p[0] - return FixedGasCalculator(fixedGas) + return FixedGasCalculator(p.FixedType.FixedGas) } } panic(fmt.Sprintf("no params for %s", msgType)) diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index 6e900527e7..c49e1e99ac 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -23,6 +24,34 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type GasType int32 + +const ( + GasType_UNSPECIFIED GasType = 0 + GasType_FIXED GasType = 1 + GasType_DYNAMIC GasType = 2 +) + +var GasType_name = map[int32]string{ + 0: "UNSPECIFIED", + 1: "FIXED", + 2: "DYNAMIC", +} + +var GasType_value = map[string]int32{ + "UNSPECIFIED": 0, + "FIXED": 1, + "DYNAMIC": 2, +} + +func (x GasType) String() string { + return proto.EnumName(GasType_name, int32(x)) +} + +func (GasType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_f79bf23b48853a4a, []int{0} +} + // Params defines the parameters for the gashub module. type Params struct { MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` @@ -83,10 +112,16 @@ func (m *Params) GetMsgGasParamsSet() []*MsgGasParams { return nil } -// MsgGasParams is a +// MsgGasParams defines gas for a msg type type MsgGasParams struct { - Msg_type_url string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` - Params []uint64 `protobuf:"varint,2,rep,packed,name=params,proto3" json:"params,omitempty"` + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + GasType GasType `protobuf:"varint,2,opt,name=gas_type,json=gasType,proto3,enum=cosmos.gashub.v1alpha1.GasType" json:"gas_type,omitempty"` + // gas_params is the oneof that represents either fixed_gas_params or dynamic_gas_params + // + // Types that are valid to be assigned to GasParams: + // *MsgGasParams_FixedType + // *MsgGasParams_DynamicType + GasParams isMsgGasParams_GasParams `protobuf_oneof:"gas_params"` } func (m *MsgGasParams) Reset() { *m = MsgGasParams{} } @@ -122,23 +157,170 @@ func (m *MsgGasParams) XXX_DiscardUnknown() { var xxx_messageInfo_MsgGasParams proto.InternalMessageInfo -func (m *MsgGasParams) GetMsg_type_url() string { +type isMsgGasParams_GasParams interface { + isMsgGasParams_GasParams() + Equal(interface{}) bool + MarshalTo([]byte) (int, error) + Size() int +} + +type MsgGasParams_FixedType struct { + FixedType *MsgGasParams_FixedGasParams `protobuf:"bytes,3,opt,name=fixed_type,json=fixedType,proto3,oneof" json:"fixed_type,omitempty"` +} +type MsgGasParams_DynamicType struct { + DynamicType *MsgGasParams_DynamicGasParams `protobuf:"bytes,4,opt,name=dynamic_type,json=dynamicType,proto3,oneof" json:"dynamic_type,omitempty"` +} + +func (*MsgGasParams_FixedType) isMsgGasParams_GasParams() {} +func (*MsgGasParams_DynamicType) isMsgGasParams_GasParams() {} + +func (m *MsgGasParams) GetGasParams() isMsgGasParams_GasParams { + if m != nil { + return m.GasParams + } + return nil +} + +func (m *MsgGasParams) GetMsgTypeUrl() string { if m != nil { - return m.Msg_type_url + return m.MsgTypeUrl } return "" } -func (m *MsgGasParams) GetParams() []uint64 { +func (m *MsgGasParams) GetGasType() GasType { if m != nil { - return m.Params + return m.GasType + } + return GasType_UNSPECIFIED +} + +func (m *MsgGasParams) GetFixedType() *MsgGasParams_FixedGasParams { + if x, ok := m.GetGasParams().(*MsgGasParams_FixedType); ok { + return x.FixedType + } + return nil +} + +func (m *MsgGasParams) GetDynamicType() *MsgGasParams_DynamicGasParams { + if x, ok := m.GetGasParams().(*MsgGasParams_DynamicType); ok { + return x.DynamicType } return nil } +// XXX_OneofWrappers is for the internal use of the proto package. +func (*MsgGasParams) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*MsgGasParams_FixedType)(nil), + (*MsgGasParams_DynamicType)(nil), + } +} + +// FixedGasParams defines the parameters for fixed gas type. +type MsgGasParams_FixedGasParams struct { + FixedGas uint64 `protobuf:"varint,1,opt,name=fixed_gas,json=fixedGas,proto3" json:"fixed_gas,omitempty"` +} + +func (m *MsgGasParams_FixedGasParams) Reset() { *m = MsgGasParams_FixedGasParams{} } +func (m *MsgGasParams_FixedGasParams) String() string { return proto.CompactTextString(m) } +func (*MsgGasParams_FixedGasParams) ProtoMessage() {} +func (*MsgGasParams_FixedGasParams) Descriptor() ([]byte, []int) { + return fileDescriptor_f79bf23b48853a4a, []int{1, 0} +} +func (m *MsgGasParams_FixedGasParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGasParams_FixedGasParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGasParams_FixedGasParams.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 *MsgGasParams_FixedGasParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGasParams_FixedGasParams.Merge(m, src) +} +func (m *MsgGasParams_FixedGasParams) XXX_Size() int { + return m.Size() +} +func (m *MsgGasParams_FixedGasParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGasParams_FixedGasParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGasParams_FixedGasParams proto.InternalMessageInfo + +func (m *MsgGasParams_FixedGasParams) GetFixedGas() uint64 { + if m != nil { + return m.FixedGas + } + return 0 +} + +// DynamicGasParams defines the parameters for dynamic gas type. +type MsgGasParams_DynamicGasParams struct { + FixedGas uint64 `protobuf:"varint,1,opt,name=fixed_gas,json=fixedGas,proto3" json:"fixed_gas,omitempty"` + GasPerItem uint64 `protobuf:"varint,2,opt,name=gas_per_item,json=gasPerItem,proto3" json:"gas_per_item,omitempty"` +} + +func (m *MsgGasParams_DynamicGasParams) Reset() { *m = MsgGasParams_DynamicGasParams{} } +func (m *MsgGasParams_DynamicGasParams) String() string { return proto.CompactTextString(m) } +func (*MsgGasParams_DynamicGasParams) ProtoMessage() {} +func (*MsgGasParams_DynamicGasParams) Descriptor() ([]byte, []int) { + return fileDescriptor_f79bf23b48853a4a, []int{1, 1} +} +func (m *MsgGasParams_DynamicGasParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGasParams_DynamicGasParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGasParams_DynamicGasParams.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 *MsgGasParams_DynamicGasParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGasParams_DynamicGasParams.Merge(m, src) +} +func (m *MsgGasParams_DynamicGasParams) XXX_Size() int { + return m.Size() +} +func (m *MsgGasParams_DynamicGasParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGasParams_DynamicGasParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGasParams_DynamicGasParams proto.InternalMessageInfo + +func (m *MsgGasParams_DynamicGasParams) GetFixedGas() uint64 { + if m != nil { + return m.FixedGas + } + return 0 +} + +func (m *MsgGasParams_DynamicGasParams) GetGasPerItem() uint64 { + if m != nil { + return m.GasPerItem + } + return 0 +} + func init() { + proto.RegisterEnum("cosmos.gashub.v1alpha1.GasType", GasType_name, GasType_value) proto.RegisterType((*Params)(nil), "cosmos.gashub.v1alpha1.Params") proto.RegisterType((*MsgGasParams)(nil), "cosmos.gashub.v1alpha1.MsgGasParams") + proto.RegisterType((*MsgGasParams_FixedGasParams)(nil), "cosmos.gashub.v1alpha1.MsgGasParams.FixedGasParams") + proto.RegisterType((*MsgGasParams_DynamicGasParams)(nil), "cosmos.gashub.v1alpha1.MsgGasParams.DynamicGasParams") } func init() { @@ -146,30 +328,43 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 364 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x6b, 0xfa, 0x30, - 0x14, 0xc7, 0x5b, 0x15, 0xf9, 0x19, 0x15, 0xfd, 0x75, 0x63, 0x94, 0x1d, 0x5a, 0x71, 0x3b, 0x08, - 0xc3, 0x16, 0xdd, 0xcd, 0x63, 0x61, 0xec, 0x24, 0x48, 0x75, 0x97, 0x5d, 0x4a, 0x74, 0x59, 0x2c, - 0x6b, 0x4c, 0x69, 0xe2, 0x68, 0xfd, 0x2b, 0x76, 0xdc, 0xd1, 0x3f, 0x67, 0x47, 0x8f, 0x3b, 0x95, - 0x11, 0x19, 0xec, 0xcf, 0x18, 0x69, 0xeb, 0x70, 0xb0, 0x53, 0xde, 0xfb, 0xe6, 0xf3, 0xf2, 0xde, - 0xcb, 0x17, 0x5c, 0x2c, 0x28, 0x23, 0x94, 0xd9, 0x18, 0xb2, 0xe5, 0x7a, 0x6e, 0x3f, 0x0f, 0x60, - 0x10, 0x2e, 0xe1, 0xa0, 0xc8, 0xad, 0x30, 0xa2, 0x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xd4, - 0x29, 0xf7, 0x2a, 0x0e, 0x10, 0xa9, 0x59, 0x7c, 0x9e, 0x5b, 0xdc, 0x8c, 0x2a, 0xb2, 0x9b, 0x73, - 0xf3, 0x26, 0x0c, 0x75, 0x27, 0x0c, 0xf5, 0x43, 0x18, 0xea, 0xcb, 0xde, 0x50, 0x76, 0x7b, 0x43, - 0x79, 0xdf, 0x1b, 0xca, 0xfd, 0x15, 0xf6, 0xb9, 0xdc, 0x6a, 0x41, 0x89, 0x5d, 0xb8, 0x99, 0x1f, - 0x7d, 0xf6, 0xf0, 0x64, 0xc7, 0x07, 0x6b, 0x65, 0x7f, 0x36, 0xaf, 0x66, 0x1e, 0x5d, 0x7f, 0x07, - 0x00, 0x00, 0xff, 0xff, 0x4f, 0xce, 0x43, 0x21, 0xf8, 0x01, 0x00, 0x00, + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0xb5, 0xdb, 0xd0, 0x26, 0xeb, 0xb4, 0x0d, 0x0b, 0x42, 0x25, 0x07, 0xbb, 0x2a, 0x1c, 0x02, + 0xa8, 0x31, 0x4d, 0xc5, 0x25, 0xb7, 0xba, 0xf9, 0x20, 0x87, 0x54, 0x91, 0x93, 0x4a, 0xd0, 0x8b, + 0xb5, 0x49, 0x36, 0x5b, 0x8b, 0x6c, 0x1c, 0x79, 0x1d, 0x64, 0xf7, 0x1f, 0x70, 0xe3, 0xc8, 0xb1, + 0x3f, 0x87, 0x63, 0x8f, 0x9c, 0x2c, 0xe4, 0x08, 0x89, 0x9f, 0x81, 0x76, 0xd7, 0x0e, 0x29, 0x02, + 0xa9, 0x5c, 0xec, 0x99, 0xf5, 0x7b, 0x6f, 0x76, 0xfc, 0x66, 0xc0, 0xb3, 0x91, 0xc7, 0xa8, 0xc7, + 0x4c, 0x82, 0xd8, 0xd5, 0x62, 0x68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 0xd7, 0x3c, 0xeb, 0xb4, 0x3a, 0xcd, 0x46, 0x49, 0x81, 0x05, 0xf0, 0xa0, + 0xd5, 0x79, 0xd7, 0x6c, 0x94, 0x54, 0xa8, 0x81, 0xed, 0xc6, 0xfb, 0xf3, 0xd3, 0x6e, 0xe7, 0xac, + 0xb4, 0x61, 0x35, 0xbf, 0x26, 0xba, 0x7a, 0x9b, 0xe8, 0xea, 0xf7, 0x44, 0x57, 0x3f, 0x2f, 0x75, + 0xe5, 0x76, 0xa9, 0x2b, 0xdf, 0x96, 0xba, 0x72, 0xf9, 0x8a, 0xb8, 0x01, 0xff, 0xb3, 0x23, 0x8f, + 0x9a, 0xe9, 0xea, 0xca, 0xd7, 0x11, 0x1b, 0x7f, 0x30, 0xc3, 0x6c, 0x8f, 0xb9, 0x27, 0x6c, 0xb8, + 0x25, 0xb6, 0xee, 0xe4, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x5d, 0x42, 0x69, 0xe5, 0x03, + 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -226,16 +421,119 @@ func (this *MsgGasParams) Equal(that interface{}) bool { } else if this == nil { return false } - if this.Msg_type_url != that1.Msg_type_url { + if this.MsgTypeUrl != that1.MsgTypeUrl { return false } - if len(this.Params) != len(that1.Params) { + if this.GasType != that1.GasType { return false } - for i := range this.Params { - if this.Params[i] != that1.Params[i] { + if that1.GasParams == nil { + if this.GasParams != nil { return false } + } else if this.GasParams == nil { + return false + } else if !this.GasParams.Equal(that1.GasParams) { + return false + } + return true +} +func (this *MsgGasParams_FixedType) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgGasParams_FixedType) + if !ok { + that2, ok := that.(MsgGasParams_FixedType) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.FixedType.Equal(that1.FixedType) { + return false + } + return true +} +func (this *MsgGasParams_DynamicType) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgGasParams_DynamicType) + if !ok { + that2, ok := that.(MsgGasParams_DynamicType) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.DynamicType.Equal(that1.DynamicType) { + return false + } + return true +} +func (this *MsgGasParams_FixedGasParams) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgGasParams_FixedGasParams) + if !ok { + that2, ok := that.(MsgGasParams_FixedGasParams) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.FixedGas != that1.FixedGas { + return false + } + return true +} +func (this *MsgGasParams_DynamicGasParams) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgGasParams_DynamicGasParams) + if !ok { + that2, ok := that.(MsgGasParams_DynamicGasParams) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.FixedGas != that1.FixedGas { + return false + } + if this.GasPerItem != that1.GasPerItem { + return false } return true } @@ -306,34 +604,133 @@ func (m *MsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Params) > 0 { - dAtA2 := make([]byte, len(m.Params)*10) - var j1 int - for _, num := range m.Params { - for num >= 1<<7 { - dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j1++ - } - dAtA2[j1] = uint8(num) - j1++ - } - i -= j1 - copy(dAtA[i:], dAtA2[:j1]) - i = encodeVarintGashub(dAtA, i, uint64(j1)) + if m.GasParams != nil { + { + size := m.GasParams.Size() + i -= size + if _, err := m.GasParams.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + if m.GasType != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.GasType)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } - if len(m.Msg_type_url) > 0 { - i -= len(m.Msg_type_url) - copy(dAtA[i:], m.Msg_type_url) - i = encodeVarintGashub(dAtA, i, uint64(len(m.Msg_type_url))) + if len(m.MsgTypeUrl) > 0 { + i -= len(m.MsgTypeUrl) + copy(dAtA[i:], m.MsgTypeUrl) + i = encodeVarintGashub(dAtA, i, uint64(len(m.MsgTypeUrl))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } +func (m *MsgGasParams_FixedType) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGasParams_FixedType) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.FixedType != nil { + { + size, err := m.FixedType.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGashub(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *MsgGasParams_DynamicType) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGasParams_DynamicType) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.DynamicType != nil { + { + size, err := m.DynamicType.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGashub(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *MsgGasParams_FixedGasParams) 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 *MsgGasParams_FixedGasParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGasParams_FixedGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FixedGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.FixedGas)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgGasParams_DynamicGasParams) 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 *MsgGasParams_DynamicGasParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGasParams_DynamicGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GasPerItem != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.GasPerItem)) + i-- + dAtA[i] = 0x10 + } + if m.FixedGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.FixedGas)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintGashub(dAtA []byte, offset int, v uint64) int { offset -= sovGashub(v) base := offset @@ -372,16 +769,66 @@ func (m *MsgGasParams) Size() (n int) { } var l int _ = l - l = len(m.Msg_type_url) + l = len(m.MsgTypeUrl) if l > 0 { n += 1 + l + sovGashub(uint64(l)) } - if len(m.Params) > 0 { - l = 0 - for _, e := range m.Params { - l += sovGashub(uint64(e)) - } - n += 1 + sovGashub(uint64(l)) + l + if m.GasType != 0 { + n += 1 + sovGashub(uint64(m.GasType)) + } + if m.GasParams != nil { + n += m.GasParams.Size() + } + return n +} + +func (m *MsgGasParams_FixedType) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FixedType != nil { + l = m.FixedType.Size() + n += 1 + l + sovGashub(uint64(l)) + } + return n +} +func (m *MsgGasParams_DynamicType) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.DynamicType != nil { + l = m.DynamicType.Size() + n += 1 + l + sovGashub(uint64(l)) + } + return n +} +func (m *MsgGasParams_FixedGasParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FixedGas != 0 { + n += 1 + sovGashub(uint64(m.FixedGas)) + } + return n +} + +func (m *MsgGasParams_DynamicGasParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FixedGas != 0 { + n += 1 + sovGashub(uint64(m.FixedGas)) + } + if m.GasPerItem != 0 { + n += 1 + sovGashub(uint64(m.GasPerItem)) } return n } @@ -545,7 +992,7 @@ func (m *MsgGasParams) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msg_type_url", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -573,83 +1020,253 @@ func (m *MsgGasParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Msg_type_url = string(dAtA[iNdEx:postIndex]) + m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Params = append(m.Params, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthGashub - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthGashub - } - if postIndex > l { + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasType", wireType) + } + m.GasType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasType |= GasType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FixedType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.Params) == 0 { - m.Params = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Params = append(m.Params, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGashub + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGashub + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MsgGasParams_FixedGasParams{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.GasParams = &MsgGasParams_FixedType{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DynamicType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGashub + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGashub + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MsgGasParams_DynamicGasParams{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.GasParams = &MsgGasParams_DynamicType{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGashub(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGashub + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgGasParams_FixedGasParams) 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 ErrIntOverflowGashub + } + 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: FixedGasParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FixedGasParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FixedGas", wireType) + } + m.FixedGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FixedGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGashub(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGashub + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgGasParams_DynamicGasParams) 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 ErrIntOverflowGashub + } + 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: DynamicGasParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DynamicGasParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FixedGas", wireType) + } + m.FixedGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FixedGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasPerItem", wireType) + } + m.GasPerItem = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasPerItem |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } default: iNdEx = preIndex diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 2b533e6d3b..4a0d8e61fd 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -5,6 +5,7 @@ import ( "sigs.k8s.io/yaml" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -14,165 +15,6 @@ const ( DefaultMinGasPerByte uint64 = 5 ) -var DefaultMsgGasParamsSet = []*MsgGasParams{ - { - Msg_type_url: "/cosmos.staking.v1beta1.MsgCreateValidator", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgRejectSealObject", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgDeleteGroup", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.authz.v1beta1.MsgRevoke", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.slashing.v1beta1.MsgImpeach", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.staking.v1beta1.MsgEditValidator", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.bridge.MsgTransferOut", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgCreateObject", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.bank.v1beta1.MsgSend", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.gov.v1.MsgVote", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.gov.v1.MsgVoteWeighted", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgSealObject", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgDeleteBucket", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.slashing.v1beta1.MsgUnjail", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.sp.MsgCreateStorageProvider", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.sp.MsgDeposit", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgUpdateGroupMember", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.gov.v1.MsgDeposit", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.sp.MsgEditStorageProvider", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgCreateBucket", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgLeaveGroup", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.oracle.v1.MsgClaim", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgCopyObject", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.gov.v1.MsgSubmitProposal", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.staking.v1beta1.MsgUndelegate", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.staking.v1beta1.MsgBeginRedelegate", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.staking.v1beta1.MsgDelegate", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgDeleteObject", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/bnbchain.greenfield.storage.MsgCreateGroup", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.authz.v1beta1.MsgExec", - Params: []uint64{1e5}, - }, - { - Msg_type_url: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", - Params: []uint64{1e5, 1e5}, - }, - { - Msg_type_url: "/cosmos.authz.v1beta1.MsgGrant", - Params: []uint64{1e5, 1e5}, - }, - { - Msg_type_url: "/cosmos.bank.v1beta1.MsgMultiSend", - Params: []uint64{1e5, 1e5}, - }, -} - // Parameter keys var ( KeyMaxTxSize = []byte("MaxTxSize") @@ -182,11 +24,24 @@ var ( var _ paramtypes.ParamSet = &Params{} -// NewMsgGasParams creates a new MsgGasParams object -func NewMsgGasParams(msgTypeUrl string, params ...uint64) *MsgGasParams { +// NewMsgGasParamsWithFixedGas creates a new MsgGasParams object with fixed gas +func NewMsgGasParamsWithFixedGas(msgTypeUrl string, gas uint64) *MsgGasParams { return &MsgGasParams{ - Msg_type_url: msgTypeUrl, - Params: params, + MsgTypeUrl: msgTypeUrl, + GasType: GasType_FIXED, + GasParams: &MsgGasParams_FixedType{FixedType: &MsgGasParams_FixedGasParams{FixedGas: gas}}, + } +} + +// NewMsgGasParamsWithDynamicGas creates a new MsgGasParams object with dynamic gas +func NewMsgGasParamsWithDynamicGas(msgTypeUrl string, gasFixed, gasPerItem uint64) *MsgGasParams { + return &MsgGasParams{ + MsgTypeUrl: msgTypeUrl, + GasType: GasType_DYNAMIC, + GasParams: &MsgGasParams_DynamicType{DynamicType: &MsgGasParams_DynamicGasParams{ + FixedGas: gasFixed, + GasPerItem: gasPerItem, + }}, } } @@ -218,10 +73,50 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { // DefaultParams returns a default set of parameters. func DefaultParams() Params { + var defaultMsgGasParamsSet = []*MsgGasParams{ + NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgExec", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgRevoke", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.bank.v1beta1.MsgSend", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgFundCommunityPool", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.feegrant.v1beta1.MsgRevokeAllowance", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgDeposit", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgSubmitProposal", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVote", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVoteWeighted", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.oracle.v1.MsgClaim", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgImpeach", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgUnjail", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgBeginRedelegate", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCreateValidator", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgDelegate", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgEditValidator", 1e5), + NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgUndelegate", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.bridge.MsgTransferOut", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgCreateStorageProvider", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgDeposit", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgEditStorageProvider", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCopyObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateBucket", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateGroup", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteBucket", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteGroup", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgLeaveGroup", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgRejectSealObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgSealObject", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgUpdateGroupMember", 1e5), + NewMsgGasParamsWithDynamicGas("/cosmos.authz.v1beta1.MsgGrant", 1e5, 1e5), + NewMsgGasParamsWithDynamicGas("/cosmos.bank.v1beta1.MsgMultiSend", 1e5, 1e5), + NewMsgGasParamsWithDynamicGas("/cosmos.feegrant.v1beta1.MsgGrantAllowance", 1e5, 1e5), + } return Params{ MaxTxSize: DefaultMaxTxSize, MinGasPerByte: DefaultMinGasPerByte, - MsgGasParamsSet: DefaultMsgGasParamsSet, + MsgGasParamsSet: defaultMsgGasParamsSet, } } @@ -263,14 +158,20 @@ func validateMsgGasParams(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + anyUnpacker := codectypes.NewInterfaceRegistry() + RegisterInterfaces(anyUnpacker) for _, msgGasParams := range v { - if len(msgGasParams.Params) == 0 { - return fmt.Errorf("params cannot be empty") - } - for _, param := range msgGasParams.Params { - if param == 0 { - return fmt.Errorf("invalid msg gas param: %d", param) + switch p := msgGasParams.GasParams.(type) { + case *MsgGasParams_FixedType: + if p.FixedType.FixedGas == 0 { + return fmt.Errorf("invalid gas. cannot be zero") + } + case *MsgGasParams_DynamicType: + if p.DynamicType.FixedGas == 0 || p.DynamicType.GasPerItem == 0 { + return fmt.Errorf("invalid gas. cannot be zero") } + default: + return fmt.Errorf("unknown or unspecified gas type") } } diff --git a/x/gov/types/v1/proposal.go b/x/gov/types/v1/proposal.go index 63982fef04..51863f908a 100644 --- a/x/gov/types/v1/proposal.go +++ b/x/gov/types/v1/proposal.go @@ -44,7 +44,7 @@ func NewProposal(messages []sdk.Msg, id uint64, metadata string, submitTime, dep return p, nil } -// GetMessages returns the proposal messages +// GetMsgs returns the proposal messages func (p Proposal) GetMsgs() ([]sdk.Msg, error) { return sdktx.GetMsgs(p.Messages, "sdk.MsgProposal") } From a92c6a352269d939f0f3af7bca40aad90cd3a408 Mon Sep 17 00:00:00 2001 From: Roshan Date: Mon, 13 Feb 2023 14:37:01 +0800 Subject: [PATCH 04/13] feat: add new msg for MsgGasParamsSet governance --- proto/cosmos/gashub/v1alpha1/event.proto | 11 + proto/cosmos/gashub/v1alpha1/tx.proto | 32 ++ x/gashub/keeper/msg_server.go | 65 +++ x/gashub/module.go | 1 + x/gashub/simulation/params.go | 2 +- x/gashub/types/codec.go | 10 +- x/gashub/types/event.pb.go | 356 +++++++++++++ x/gashub/types/gas_calculator.go | 2 +- x/gashub/types/key.go | 5 +- x/gashub/types/msg.go | 56 ++ x/gashub/types/params.go | 4 +- x/gashub/types/tx.pb.go | 619 +++++++++++++++++++++++ 12 files changed, 1156 insertions(+), 7 deletions(-) create mode 100644 proto/cosmos/gashub/v1alpha1/event.proto create mode 100644 proto/cosmos/gashub/v1alpha1/tx.proto create mode 100644 x/gashub/keeper/msg_server.go create mode 100644 x/gashub/types/event.pb.go create mode 100644 x/gashub/types/msg.go create mode 100644 x/gashub/types/tx.pb.go diff --git a/proto/cosmos/gashub/v1alpha1/event.proto b/proto/cosmos/gashub/v1alpha1/event.proto new file mode 100644 index 0000000000..4684692d24 --- /dev/null +++ b/proto/cosmos/gashub/v1alpha1/event.proto @@ -0,0 +1,11 @@ +// Since: cosmos-sdk 0.43 +syntax = "proto3"; +package cosmos.gashub.v1alpha1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; + +// EventUpdateMsgGasParams is emitted when update a msg's gas params +message EventUpdateMsgGasParams { + string msg_type_url = 1; + uint64 gas_type = 2; +} diff --git a/proto/cosmos/gashub/v1alpha1/tx.proto b/proto/cosmos/gashub/v1alpha1/tx.proto new file mode 100644 index 0000000000..6dde2280ff --- /dev/null +++ b/proto/cosmos/gashub/v1alpha1/tx.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package cosmos.gashub.v1alpha1; + +import "gogoproto/gogo.proto"; +import "cosmos/gashub/v1alpha1/gashub.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; + +// Msg defines the gashub Msg service. +service Msg { + // UpdateMsgGasParams defines a method for updating msg gas params. + rpc UpdateMsgGasParams(MsgUpdateMsgGasParams) returns (MsgUpdateMsgGasParamsResponse); +} + +// MsgUpdateMsgGasParams represents a message to update msg gas params. +message MsgUpdateMsgGasParams { + // NOTE: The params should be updated by the gov module account after the proposal passes. + option (cosmos.msg.v1.signer) = "sender"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // the params is for a new msg type or existed msg type + bool is_new = 2; + MsgGasParams new_params = 3; +} + +// MsgUpdateMsgGasParamsResponse defines the Msg/UpdateMsgGasParams response type. +message MsgUpdateMsgGasParamsResponse {} diff --git a/x/gashub/keeper/msg_server.go b/x/gashub/keeper/msg_server.go new file mode 100644 index 0000000000..92558b6a2c --- /dev/null +++ b/x/gashub/keeper/msg_server.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the gashub MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) UpdateMsgGasParams(goCtx context.Context, msg *types.MsgUpdateMsgGasParams) (*types.MsgUpdateMsgGasParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + signers := msg.GetSigners() + if len(signers) != 1 || !signers[0].Equals(authtypes.NewModuleAddress(gov.ModuleName)) { + return nil, slashingtypes.ErrSignerNotGovModule + } + + isNew := msg.IsNew + params := k.GetParams(ctx) + newMsgGasParams := msg.NewParams + + if isNew { + params.MsgGasParamsSet = append(params.MsgGasParamsSet, newMsgGasParams) + } else { + msgGasParamsSet := params.MsgGasParamsSet + typeUrl := msg.NewParams.MsgTypeUrl + + var find bool + for idx, msgGasParams := range msgGasParamsSet { + if msgGasParams.MsgTypeUrl == typeUrl { + msgGasParamsSet[idx] = newMsgGasParams + find = true + break + } + } + if !find { + return nil, fmt.Errorf("msg type not find: %s", typeUrl) + } + } + + ctx.EventManager().EmitTypedEvent( + &types.EventUpdateMsgGasParams{ + MsgTypeUrl: msg.NewParams.MsgTypeUrl, + GasType: uint64(msg.NewParams.GasType), + }, + ) + + return &types.MsgUpdateMsgGasParamsResponse{}, nil +} diff --git a/x/gashub/module.go b/x/gashub/module.go index 4e3074b518..69bfa403dc 100644 --- a/x/gashub/module.go +++ b/x/gashub/module.go @@ -120,6 +120,7 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index a0ab2b3e03..a28884713d 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -3,12 +3,12 @@ package simulation // DONTCOVER import ( + "encoding/json" "math/rand" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gashub/types" "github.com/cosmos/cosmos-sdk/x/simulation" - "encoding/json" ) // ParamChanges defines the parameters that can be modified by param change proposals diff --git a/x/gashub/types/codec.go b/x/gashub/types/codec.go index c388450216..30df08ac68 100644 --- a/x/gashub/types/codec.go +++ b/x/gashub/types/codec.go @@ -2,19 +2,27 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + legacy.RegisterAminoMsg(cdc, &MsgUpdateMsgGasParams{}, "cosmos-sdk/MsgUpdateMsgGasParams") + cdc.RegisterInterface((*isMsgGasParams_GasParams)(nil), nil) cdc.RegisterConcrete(&MsgGasParams_FixedType{}, "cosmos-sdk/MsgGasParams/FixedType", nil) cdc.RegisterConcrete(&MsgGasParams_DynamicType{}, "cosmos-sdk/MsgGasParams/DynamicType", nil) } -func RegisterInterfaces(registry types.InterfaceRegistry) {} +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateMsgGasParams{}) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} var ( Amino = codec.NewLegacyAmino() diff --git a/x/gashub/types/event.pb.go b/x/gashub/types/event.pb.go new file mode 100644 index 0000000000..4560edd1ee --- /dev/null +++ b/x/gashub/types/event.pb.go @@ -0,0 +1,356 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/gashub/v1alpha1/event.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// EventUpdateMsgGasParams is emitted when update a msg's gas params +type EventUpdateMsgGasParams struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + GasType uint64 `protobuf:"varint,2,opt,name=gas_type,json=gasType,proto3" json:"gas_type,omitempty"` +} + +func (m *EventUpdateMsgGasParams) Reset() { *m = EventUpdateMsgGasParams{} } +func (m *EventUpdateMsgGasParams) String() string { return proto.CompactTextString(m) } +func (*EventUpdateMsgGasParams) ProtoMessage() {} +func (*EventUpdateMsgGasParams) Descriptor() ([]byte, []int) { + return fileDescriptor_de0e3393fe9bac86, []int{0} +} +func (m *EventUpdateMsgGasParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUpdateMsgGasParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUpdateMsgGasParams.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 *EventUpdateMsgGasParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUpdateMsgGasParams.Merge(m, src) +} +func (m *EventUpdateMsgGasParams) XXX_Size() int { + return m.Size() +} +func (m *EventUpdateMsgGasParams) XXX_DiscardUnknown() { + xxx_messageInfo_EventUpdateMsgGasParams.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUpdateMsgGasParams proto.InternalMessageInfo + +func (m *EventUpdateMsgGasParams) GetMsgTypeUrl() string { + if m != nil { + return m.MsgTypeUrl + } + return "" +} + +func (m *EventUpdateMsgGasParams) GetGasType() uint64 { + if m != nil { + return m.GasType + } + return 0 +} + +func init() { + proto.RegisterType((*EventUpdateMsgGasParams)(nil), "cosmos.gashub.v1alpha1.EventUpdateMsgGasParams") +} + +func init() { + proto.RegisterFile("cosmos/gashub/v1alpha1/event.proto", fileDescriptor_de0e3393fe9bac86) +} + +var fileDescriptor_de0e3393fe9bac86 = []byte{ + // 210 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, + 0x48, 0x34, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x83, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xa9, 0x51, 0x0a, 0xe3, 0x12, 0x77, 0x05, 0x29, 0x0b, + 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xf5, 0x2d, 0x4e, 0x77, 0x4f, 0x2c, 0x0e, 0x48, 0x2c, 0x4a, 0xcc, + 0x2d, 0x16, 0x52, 0xe0, 0xe2, 0xc9, 0x2d, 0x4e, 0x8f, 0x2f, 0xa9, 0x2c, 0x48, 0x8d, 0x2f, 0x2d, + 0xca, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0xca, 0x2d, 0x4e, 0x0f, 0xa9, 0x2c, 0x48, + 0x0d, 0x2d, 0xca, 0x11, 0x92, 0xe4, 0xe2, 0x48, 0x4f, 0x2c, 0x06, 0xab, 0x90, 0x60, 0x52, 0x60, + 0xd4, 0x60, 0x09, 0x62, 0x4f, 0x4f, 0x2c, 0x06, 0xc9, 0x3a, 0xb9, 0x9e, 0x78, 0x24, 0xc7, 0x78, + 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, + 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x76, 0x7a, 0x66, 0x09, 0xc8, 0x09, 0xc9, 0xf9, 0xb9, 0xfa, + 0x50, 0x87, 0x43, 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0x98, 0x2f, 0x40, 0x86, 0x16, 0x27, + 0xb1, 0x81, 0x5d, 0x6f, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x36, 0x6b, 0xd6, 0xf1, 0xe3, 0x00, + 0x00, 0x00, +} + +func (m *EventUpdateMsgGasParams) 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 *EventUpdateMsgGasParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUpdateMsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GasType != 0 { + i = encodeVarintEvent(dAtA, i, uint64(m.GasType)) + i-- + dAtA[i] = 0x10 + } + if len(m.MsgTypeUrl) > 0 { + i -= len(m.MsgTypeUrl) + copy(dAtA[i:], m.MsgTypeUrl) + i = encodeVarintEvent(dAtA, i, uint64(len(m.MsgTypeUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { + offset -= sovEvent(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventUpdateMsgGasParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MsgTypeUrl) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if m.GasType != 0 { + n += 1 + sovEvent(uint64(m.GasType)) + } + return n +} + +func sovEvent(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvent(x uint64) (n int) { + return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventUpdateMsgGasParams) 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 ErrIntOverflowEvent + } + 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: EventUpdateMsgGasParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateMsgGasParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasType", wireType) + } + m.GasType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasType |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvent(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEvent + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvent + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvent + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 0b9d202b0f..55ec4bd785 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -143,7 +143,7 @@ var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { } func init() { - var defaultMsgGasParamsSet = []*MsgGasParams{ + defaultMsgGasParamsSet := []*MsgGasParams{ NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgExec", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgRevoke", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.bank.v1beta1.MsgSend", 1e5), diff --git a/x/gashub/types/key.go b/x/gashub/types/key.go index 904d7b068a..e9eeb08a52 100644 --- a/x/gashub/types/key.go +++ b/x/gashub/types/key.go @@ -1,12 +1,15 @@ package types const ( - // module name + // ModuleName is the module name ModuleName = "gashub" // StoreKey defines the primary module store key StoreKey = ModuleName + // RouterKey defines the module's message routing key + RouterKey = ModuleName + // QuerierRoute defines the module's query routing key QuerierRoute = ModuleName ) diff --git a/x/gashub/types/msg.go b/x/gashub/types/msg.go new file mode 100644 index 0000000000..abead3d261 --- /dev/null +++ b/x/gashub/types/msg.go @@ -0,0 +1,56 @@ +package types + +import ( + "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// bank message types +const ( + TypeMsgUpdateMsgGasParams = "update_msg_gas_params" +) + +var _ sdk.Msg = &MsgUpdateMsgGasParams{} + +// MsgUpdateMsgGasParams - construct a msg to update msg gas params. +// +//nolint:interfacer +func NewMsgUpdateMsgGasParams(from sdk.AccAddress, isNew bool, msgGasParams *MsgGasParams) *MsgUpdateMsgGasParams { + return &MsgUpdateMsgGasParams{ + From: from.String(), + IsNew: isNew, + NewParams: msgGasParams, + } +} + +// Route Implements Msg. +func (msg MsgUpdateMsgGasParams) Route() string { return RouterKey } + +// Type Implements Msg. +func (msg MsgUpdateMsgGasParams) Type() string { return TypeMsgUpdateMsgGasParams } + +// ValidateBasic Implements Msg. +func (msg MsgUpdateMsgGasParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromHexUnsafe(msg.From); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid sender address: %s", err) + } + + if err := validateMsgGasParams(msg.NewParams); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid msg gas params: %s", err) + } + + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgUpdateMsgGasParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners Implements Msg. +func (msg MsgUpdateMsgGasParams) GetSigners() []sdk.AccAddress { + fromAddress, _ := sdk.AccAddressFromHexUnsafe(msg.From) + return []sdk.AccAddress{fromAddress} +} diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 4a0d8e61fd..19a64c2c79 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -73,7 +73,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { // DefaultParams returns a default set of parameters. func DefaultParams() Params { - var defaultMsgGasParamsSet = []*MsgGasParams{ + defaultMsgGasParamsSet := []*MsgGasParams{ NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgExec", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgRevoke", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.bank.v1beta1.MsgSend", 1e5), @@ -87,7 +87,6 @@ func DefaultParams() Params { NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVote", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVoteWeighted", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.oracle.v1.MsgClaim", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgImpeach", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgUnjail", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgBeginRedelegate", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", 1e5), @@ -96,7 +95,6 @@ func DefaultParams() Params { NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgEditValidator", 1e5), NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgUndelegate", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.bridge.MsgTransferOut", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgCreateStorageProvider", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgDeposit", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgEditStorageProvider", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCopyObject", 1e5), diff --git a/x/gashub/types/tx.pb.go b/x/gashub/types/tx.pb.go new file mode 100644 index 0000000000..c8efcc4319 --- /dev/null +++ b/x/gashub/types/tx.pb.go @@ -0,0 +1,619 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/gashub/v1alpha1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUpdateMsgGasParams represents a message to update msg gas params. +type MsgUpdateMsgGasParams struct { + From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + // the params is for a new msg type or existed msg type + IsNew bool `protobuf:"varint,2,opt,name=is_new,json=isNew,proto3" json:"is_new,omitempty"` + NewParams *MsgGasParams `protobuf:"bytes,3,opt,name=new_params,json=newParams,proto3" json:"new_params,omitempty"` +} + +func (m *MsgUpdateMsgGasParams) Reset() { *m = MsgUpdateMsgGasParams{} } +func (m *MsgUpdateMsgGasParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMsgGasParams) ProtoMessage() {} +func (*MsgUpdateMsgGasParams) Descriptor() ([]byte, []int) { + return fileDescriptor_08053c9491c72816, []int{0} +} +func (m *MsgUpdateMsgGasParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMsgGasParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMsgGasParams.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 *MsgUpdateMsgGasParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMsgGasParams.Merge(m, src) +} +func (m *MsgUpdateMsgGasParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMsgGasParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMsgGasParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMsgGasParams proto.InternalMessageInfo + +// MsgUpdateMsgGasParamsResponse defines the Msg/UpdateMsgGasParams response type. +type MsgUpdateMsgGasParamsResponse struct { +} + +func (m *MsgUpdateMsgGasParamsResponse) Reset() { *m = MsgUpdateMsgGasParamsResponse{} } +func (m *MsgUpdateMsgGasParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMsgGasParamsResponse) ProtoMessage() {} +func (*MsgUpdateMsgGasParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_08053c9491c72816, []int{1} +} +func (m *MsgUpdateMsgGasParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMsgGasParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMsgGasParamsResponse.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 *MsgUpdateMsgGasParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMsgGasParamsResponse.Merge(m, src) +} +func (m *MsgUpdateMsgGasParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMsgGasParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMsgGasParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMsgGasParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateMsgGasParams)(nil), "cosmos.gashub.v1alpha1.MsgUpdateMsgGasParams") + proto.RegisterType((*MsgUpdateMsgGasParamsResponse)(nil), "cosmos.gashub.v1alpha1.MsgUpdateMsgGasParamsResponse") +} + +func init() { proto.RegisterFile("cosmos/gashub/v1alpha1/tx.proto", fileDescriptor_08053c9491c72816) } + +var fileDescriptor_08053c9491c72816 = []byte{ + // 354 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, + 0x48, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0x28, 0xd0, + 0x83, 0x28, 0xd0, 0x83, 0x29, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd1, 0x07, 0xb1, + 0x20, 0xaa, 0xa5, 0x94, 0x71, 0x18, 0x07, 0xd5, 0x0d, 0x51, 0x24, 0x09, 0x51, 0x14, 0x0f, 0xd1, + 0x0d, 0x35, 0x1f, 0x22, 0x25, 0x0e, 0xd5, 0x9f, 0x5b, 0x9c, 0xae, 0x5f, 0x66, 0x08, 0xa2, 0x20, + 0x12, 0x4a, 0xdb, 0x18, 0xb9, 0x44, 0x7d, 0x8b, 0xd3, 0x43, 0x0b, 0x52, 0x12, 0x4b, 0x52, 0x7d, + 0x8b, 0xd3, 0xdd, 0x13, 0x8b, 0x03, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x85, 0x74, 0xb8, 0x58, 0xd2, + 0x8a, 0xf2, 0x73, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x9d, 0x24, 0x2e, 0x6d, 0xd1, 0x15, 0x81, + 0x1a, 0xe9, 0x98, 0x92, 0x52, 0x94, 0x5a, 0x5c, 0x1c, 0x5c, 0x52, 0x94, 0x99, 0x97, 0x1e, 0x04, + 0x56, 0x25, 0x24, 0xca, 0xc5, 0x96, 0x59, 0x1c, 0x9f, 0x97, 0x5a, 0x2e, 0xc1, 0xa4, 0xc0, 0xa8, + 0xc1, 0x11, 0xc4, 0x9a, 0x59, 0xec, 0x97, 0x5a, 0x2e, 0xe4, 0xcc, 0xc5, 0x95, 0x97, 0x5a, 0x1e, + 0x5f, 0x00, 0x36, 0x52, 0x82, 0x59, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x45, 0x0f, 0xbb, 0xd7, 0xf5, + 0x90, 0xad, 0x0f, 0xe2, 0xcc, 0x4b, 0x2d, 0x87, 0x30, 0xad, 0x84, 0x3b, 0x16, 0xc8, 0x33, 0xbc, + 0x58, 0x20, 0xcf, 0xd0, 0xf4, 0x7c, 0x83, 0x16, 0x5b, 0x71, 0x6a, 0x5e, 0x4a, 0x6a, 0x91, 0x92, + 0x3c, 0x97, 0x2c, 0x56, 0x77, 0x07, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x1a, 0x35, 0x32, + 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x55, 0x71, 0x09, 0x61, 0xf1, 0x9d, 0x2e, 0x1e, 0x47, 0x60, + 0x2a, 0x97, 0x32, 0x25, 0x49, 0x39, 0xcc, 0x0d, 0x4e, 0xae, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, + 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, + 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9d, 0x9e, 0x59, 0x02, 0x32, 0x28, 0x39, 0x3f, 0x17, 0x1a, 0x53, + 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x16, 0xd1, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, + 0x6c, 0xe0, 0xb8, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x04, 0x69, 0x4a, 0xf1, 0x55, 0x02, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // UpdateMsgGasParams defines a method for updating msg gas params. + UpdateMsgGasParams(ctx context.Context, in *MsgUpdateMsgGasParams, opts ...grpc.CallOption) (*MsgUpdateMsgGasParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateMsgGasParams(ctx context.Context, in *MsgUpdateMsgGasParams, opts ...grpc.CallOption) (*MsgUpdateMsgGasParamsResponse, error) { + out := new(MsgUpdateMsgGasParamsResponse) + err := c.cc.Invoke(ctx, "/cosmos.gashub.v1alpha1.Msg/UpdateMsgGasParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UpdateMsgGasParams defines a method for updating msg gas params. + UpdateMsgGasParams(context.Context, *MsgUpdateMsgGasParams) (*MsgUpdateMsgGasParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateMsgGasParams(ctx context.Context, req *MsgUpdateMsgGasParams) (*MsgUpdateMsgGasParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMsgGasParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateMsgGasParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateMsgGasParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateMsgGasParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.gashub.v1alpha1.Msg/UpdateMsgGasParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateMsgGasParams(ctx, req.(*MsgUpdateMsgGasParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.gashub.v1alpha1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateMsgGasParams", + Handler: _Msg_UpdateMsgGasParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/gashub/v1alpha1/tx.proto", +} + +func (m *MsgUpdateMsgGasParams) 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 *MsgUpdateMsgGasParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NewParams != nil { + { + size, err := m.NewParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.IsNew { + i-- + if m.IsNew { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.From) > 0 { + i -= len(m.From) + copy(dAtA[i:], m.From) + i = encodeVarintTx(dAtA, i, uint64(len(m.From))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateMsgGasParamsResponse) 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 *MsgUpdateMsgGasParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMsgGasParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateMsgGasParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.From) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.IsNew { + n += 2 + } + if m.NewParams != nil { + l = m.NewParams.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateMsgGasParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateMsgGasParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateMsgGasParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMsgGasParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.From = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsNew", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsNew = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NewParams == nil { + m.NewParams = &MsgGasParams{} + } + if err := m.NewParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateMsgGasParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateMsgGasParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMsgGasParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 9e508ffcc5f08d797559174d6cd3bb2ad96e3ad5 Mon Sep 17 00:00:00 2001 From: Roshan Date: Mon, 13 Feb 2023 15:03:29 +0800 Subject: [PATCH 05/13] fix CI issues --- proto/cosmos/gashub/v1alpha1/gashub.proto | 11 ++- x/gashub/simulation/params.go | 10 +-- x/gashub/simulation/params_test.go | 2 +- x/gashub/types/gas_calculator.go | 2 +- x/gashub/types/gashub.pb.go | 98 ++++++++++++----------- x/gashub/types/params.go | 4 +- 6 files changed, 64 insertions(+), 63 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 4232f92ac1..36008a0e37 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package cosmos.gashub.v1alpha1; import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; @@ -46,8 +45,12 @@ message MsgGasParams { } } +// GasType defines the msg's gas type enum GasType { - UNSPECIFIED = 0; - FIXED = 1; - DYNAMIC = 2; + // GAS_TYPE_UNSPECIFIED defines the unspecified type gas which is not allowed + GAS_TYPE_UNSPECIFIED = 0; + // GAS_TYPE_FIXED defines the fixed type gas + GAS_TYPE_FIXED = 1; + // GAS_TYPE_DYNAMIC defines the dynamic type gas + GAS_TYPE_DYNAMIC = 2; } diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index a28884713d..6689d734c4 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -3,7 +3,7 @@ package simulation // DONTCOVER import ( - "encoding/json" + "fmt" "math/rand" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -15,13 +15,9 @@ import ( // on the simulation func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ - simulation.NewSimParamChange(types.ModuleName, string(types.KeyMsgGasParamsSet), + simulation.NewSimParamChange(types.ModuleName, string(types.KeyMaxTxSize), func(r *rand.Rand) string { - paramsBytes, err := json.Marshal(GenMsgGasParams(r)) - if err != nil { - panic(err) - } - return string(paramsBytes) + return fmt.Sprintf("%d", GenMaxTxSize(r)) }, ), } diff --git a/x/gashub/simulation/params_test.go b/x/gashub/simulation/params_test.go index 594355db15..d06f19b5e6 100644 --- a/x/gashub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -19,7 +19,7 @@ func TestParamChanges(t *testing.T) { simValue string subspace string }{ - {"gashub/MsgGasParamsSet", "MsgGasParamsSet", "{\"msg_type_url\":\"FpXzpLGIehps\",\"gas_type\":1,\"GasParams\":{\"fixed_type\":{\"fixed_gas\":1631847}}}", "gashub"}, + {"gashub/MaxTxSize", "MaxTxSize", "3081", "gashub"}, } paramChanges := simulation.ParamChanges(r) diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 55ec4bd785..222e153e20 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -185,7 +185,7 @@ func init() { } // for fixed gas msgs for _, gasParams := range defaultMsgGasParamsSet { - if gasParams.GetGasType() != GasType_FIXED { + if gasParams.GetGasType() != GasType_GAS_TYPE_FIXED { continue } msgType := gasParams.GetMsgTypeUrl() diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index c49e1e99ac..ca8e5ec5a0 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -24,24 +23,28 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// GasType defines the msg's gas type type GasType int32 const ( - GasType_UNSPECIFIED GasType = 0 - GasType_FIXED GasType = 1 - GasType_DYNAMIC GasType = 2 + // GAS_TYPE_UNSPECIFIED defines the unspecified type gas which is not allowed + GasType_GAS_TYPE_UNSPECIFIED GasType = 0 + // GAS_TYPE_FIXED defines the fixed type gas + GasType_GAS_TYPE_FIXED GasType = 1 + // GAS_TYPE_DYNAMIC defines the dynamic type gas + GasType_GAS_TYPE_DYNAMIC GasType = 2 ) var GasType_name = map[int32]string{ - 0: "UNSPECIFIED", - 1: "FIXED", - 2: "DYNAMIC", + 0: "GAS_TYPE_UNSPECIFIED", + 1: "GAS_TYPE_FIXED", + 2: "GAS_TYPE_DYNAMIC", } var GasType_value = map[string]int32{ - "UNSPECIFIED": 0, - "FIXED": 1, - "DYNAMIC": 2, + "GAS_TYPE_UNSPECIFIED": 0, + "GAS_TYPE_FIXED": 1, + "GAS_TYPE_DYNAMIC": 2, } func (x GasType) String() string { @@ -192,7 +195,7 @@ func (m *MsgGasParams) GetGasType() GasType { if m != nil { return m.GasType } - return GasType_UNSPECIFIED + return GasType_GAS_TYPE_UNSPECIFIED } func (m *MsgGasParams) GetFixedType() *MsgGasParams_FixedGasParams { @@ -328,43 +331,42 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 562 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0xb5, 0xdb, 0xd0, 0x26, 0xeb, 0xb4, 0x0d, 0x0b, 0x42, 0x25, 0x07, 0xbb, 0x2a, 0x1c, 0x02, - 0xa8, 0x31, 0x4d, 0xc5, 0x25, 0xb7, 0xba, 0xf9, 0x20, 0x87, 0x54, 0x91, 0x93, 0x4a, 0xd0, 0x8b, - 0xb5, 0x49, 0x36, 0x5b, 0x8b, 0x6c, 0x1c, 0x79, 0x1d, 0x64, 0xf7, 0x1f, 0x70, 0xe3, 0xc8, 0xb1, - 0x3f, 0x87, 0x63, 0x8f, 0x9c, 0x2c, 0xe4, 0x08, 0x89, 0x9f, 0x81, 0x76, 0xd7, 0x0e, 0x29, 0x02, - 0xa9, 0x5c, 0xec, 0x99, 0xf5, 0x7b, 0x6f, 0x76, 0xfc, 0x66, 0xc0, 0xb3, 0x91, 0xc7, 0xa8, 0xc7, - 0x4c, 0x82, 0xd8, 0xd5, 0x62, 0x68, 0x7e, 0x3c, 0x46, 0xd3, 0xf9, 0x15, 0x3a, 0x4e, 0xf3, 0xea, - 0xdc, 0xf7, 0x02, 0x0f, 0x3e, 0x91, 0xa0, 0x6a, 0x7a, 0x98, 0x81, 0xca, 0x8f, 0x89, 0x47, 0x3c, - 0x01, 0x31, 0x79, 0x24, 0xd1, 0xe5, 0xa7, 0xc4, 0xf3, 0xc8, 0x14, 0x9b, 0x22, 0x1b, 0x2e, 0x26, - 0x26, 0x9a, 0x45, 0xf2, 0xd3, 0xe1, 0x0f, 0x15, 0x6c, 0xf5, 0x90, 0x8f, 0x28, 0x83, 0x47, 0x40, - 0xa3, 0x28, 0x74, 0x82, 0xd0, 0x61, 0xee, 0x35, 0xde, 0x57, 0x0f, 0xd4, 0x4a, 0xce, 0xda, 0x49, - 0x62, 0xa3, 0xd0, 0x45, 0xe1, 0x20, 0xec, 0xbb, 0xd7, 0xd8, 0x2e, 0xd0, 0x2c, 0x84, 0x75, 0x50, - 0xa2, 0xee, 0xcc, 0x21, 0x88, 0x39, 0x73, 0xec, 0x3b, 0xc3, 0x28, 0xc0, 0xfb, 0x1b, 0x82, 0xf3, - 0x30, 0x89, 0x8d, 0x9d, 0xae, 0x3b, 0x6b, 0x23, 0xd6, 0xc3, 0xbe, 0x15, 0x05, 0xd8, 0xde, 0xa1, - 0xeb, 0x29, 0x9c, 0x00, 0x48, 0x19, 0x91, 0x5c, 0x51, 0xdc, 0x61, 0x38, 0xd8, 0xdf, 0x3c, 0xd8, - 0xac, 0x68, 0xb5, 0xe7, 0xd5, 0xbf, 0xf7, 0x56, 0xed, 0x32, 0xc2, 0x25, 0x04, 0xde, 0x7a, 0x94, - 0xc4, 0xc6, 0xde, 0xfa, 0x49, 0x1f, 0x07, 0xf6, 0x1e, 0xbd, 0x7b, 0x50, 0xcf, 0x7f, 0xb9, 0x31, - 0x94, 0x9f, 0x37, 0x86, 0x7a, 0xf8, 0x29, 0x07, 0x8a, 0xeb, 0x70, 0xf8, 0x1a, 0x14, 0xf9, 0x15, - 0x82, 0x68, 0x8e, 0x9d, 0x85, 0x3f, 0x15, 0xed, 0x16, 0xac, 0xdd, 0x24, 0x36, 0x40, 0x97, 0x91, - 0x41, 0x34, 0xc7, 0x17, 0xfe, 0xd4, 0x06, 0x74, 0x15, 0xc3, 0x36, 0xc8, 0xf3, 0x0b, 0x73, 0x86, - 0x68, 0x74, 0xb7, 0x66, 0xfc, 0xeb, 0xaa, 0x6d, 0xc4, 0x38, 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, - 0xe5, 0x76, 0xa9, 0x2b, 0xdf, 0x96, 0xba, 0x72, 0xf9, 0x8a, 0xb8, 0x01, 0xff, 0xb3, 0x23, 0x8f, - 0x9a, 0xe9, 0xea, 0xca, 0xd7, 0x11, 0x1b, 0x7f, 0x30, 0xc3, 0x6c, 0x8f, 0xb9, 0x27, 0x6c, 0xb8, - 0x25, 0xb6, 0xee, 0xe4, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x5d, 0x42, 0x69, 0xe5, 0x03, - 0x00, 0x00, + // 556 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xda, 0x40, + 0x10, 0xb5, 0x13, 0x94, 0xc0, 0xf0, 0x11, 0x77, 0x8b, 0x2a, 0xc4, 0xc1, 0x46, 0x69, 0x0f, 0xb4, + 0x55, 0xa0, 0x21, 0xea, 0x85, 0x1b, 0x0e, 0x1f, 0xe5, 0xe0, 0x08, 0x19, 0x22, 0x35, 0xb9, 0x58, + 0x06, 0x16, 0xc7, 0x2a, 0x8b, 0x91, 0xd7, 0x54, 0x26, 0xff, 0xa0, 0xb7, 0x1e, 0x7b, 0xcc, 0xcf, + 0xe9, 0x31, 0xc7, 0x9e, 0xac, 0xca, 0xa8, 0x52, 0x7f, 0x46, 0xb5, 0x5e, 0x9b, 0x92, 0xaa, 0x95, + 0xd2, 0x8b, 0x3d, 0x33, 0x7e, 0xef, 0xcd, 0x8e, 0xdf, 0x2c, 0x3c, 0x9f, 0x38, 0x94, 0x38, 0xb4, + 0x6e, 0x99, 0xf4, 0x66, 0x35, 0xae, 0x7f, 0x3c, 0x35, 0xe7, 0xcb, 0x1b, 0xf3, 0x34, 0xce, 0x6b, + 0x4b, 0xd7, 0xf1, 0x1c, 0xf4, 0x8c, 0x83, 0x6a, 0x71, 0x31, 0x01, 0x95, 0x8b, 0x96, 0x63, 0x39, + 0x11,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5, 0xf3, 0x35, 0x94, 0xc5, + 0xfb, 0x50, 0x16, 0xbf, 0x87, 0xb2, 0xf8, 0x79, 0x23, 0x0b, 0xf7, 0x1b, 0x59, 0xf8, 0xb6, 0x91, + 0x85, 0xeb, 0xd7, 0x96, 0xed, 0xb1, 0x9f, 0x3e, 0x71, 0x48, 0x3d, 0xbe, 0xba, 0xfc, 0x75, 0x42, + 0xa7, 0x1f, 0xea, 0x7e, 0x72, 0x8f, 0x99, 0x5d, 0x74, 0x7c, 0x10, 0x5d, 0xc8, 0xb3, 0x5f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x54, 0xf8, 0x37, 0xba, 0xe5, 0x03, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 19a64c2c79..cae2fc95c5 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -28,7 +28,7 @@ var _ paramtypes.ParamSet = &Params{} func NewMsgGasParamsWithFixedGas(msgTypeUrl string, gas uint64) *MsgGasParams { return &MsgGasParams{ MsgTypeUrl: msgTypeUrl, - GasType: GasType_FIXED, + GasType: GasType_GAS_TYPE_FIXED, GasParams: &MsgGasParams_FixedType{FixedType: &MsgGasParams_FixedGasParams{FixedGas: gas}}, } } @@ -37,7 +37,7 @@ func NewMsgGasParamsWithFixedGas(msgTypeUrl string, gas uint64) *MsgGasParams { func NewMsgGasParamsWithDynamicGas(msgTypeUrl string, gasFixed, gasPerItem uint64) *MsgGasParams { return &MsgGasParams{ MsgTypeUrl: msgTypeUrl, - GasType: GasType_DYNAMIC, + GasType: GasType_GAS_TYPE_DYNAMIC, GasParams: &MsgGasParams_DynamicType{DynamicType: &MsgGasParams_DynamicGasParams{ FixedGas: gasFixed, GasPerItem: gasPerItem, From b7d9789fb53c6b5d586007b54096747d0d58dccd Mon Sep 17 00:00:00 2001 From: Roshan Date: Tue, 14 Feb 2023 16:27:02 +0800 Subject: [PATCH 06/13] fix review comments and add new tx fee check logic --- baseapp/baseapp.go | 3 +- client/tx/tx.go | 15 +- proto/cosmos/base/abci/v1beta1/abci.proto | 3 + proto/cosmos/gashub/v1alpha1/event.proto | 2 +- proto/cosmos/gashub/v1alpha1/gashub.proto | 18 +- proto/cosmos/gashub/v1alpha1/tx.proto | 4 +- types/abci.pb.go | 170 ++++++++++++------ x/auth/ante/ante.go | 3 +- x/auth/ante/fee.go | 8 +- x/auth/ante/fee_test.go | 6 +- x/auth/ante/feegrant_test.go | 2 +- x/auth/ante/validator_tx_fee.go | 8 +- x/gashub/keeper/genesis.go | 37 +++- x/gashub/keeper/msg_server.go | 32 ++-- x/gashub/simulation/genesis.go | 18 +- x/gashub/simulation/genesis_test.go | 5 +- x/gashub/simulation/params.go | 2 +- x/gashub/simulation/params_test.go | 2 +- x/gashub/types/event.pb.go | 46 ++--- x/gashub/types/gas_calculator.go | 76 +------- x/gashub/types/gashub.pb.go | 210 ++++++++++------------ x/gashub/types/msg.go | 3 +- x/gashub/types/params.go | 31 +++- x/gashub/types/tx.pb.go | 69 ++----- 24 files changed, 391 insertions(+), 382 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 5e54b98b7a..c85d535190 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -645,6 +645,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re ctx := app.getContextForTx(mode, txBytes) ms := ctx.MultiStore() + gInfo.MinGasPrices = app.minGasPrices.String() // only run the tx if there is block gas remaining if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() { @@ -657,7 +658,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re err, result = processRecovery(r, recoveryMW), nil } - gInfo = sdk.GasInfo{GasWanted: gasWanted, GasUsed: ctx.GasMeter().GasConsumed()} + gInfo = sdk.GasInfo{GasWanted: gasWanted, GasUsed: ctx.GasMeter().GasConsumed(), MinGasPrices: app.minGasPrices.String()} }() blockGasConsumed := false diff --git a/client/tx/tx.go b/client/tx/tx.go index 183d9e1f58..8530ac1832 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -69,13 +69,26 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error { } if txf.SimulateAndExecute() || clientCtx.Simulate { - _, adjusted, err := CalculateGas(clientCtx, txf, msgs...) + gInfo, adjusted, err := CalculateGas(clientCtx, txf, msgs...) if err != nil { return err } txf = txf.WithGas(adjusted) _, _ = fmt.Fprintf(os.Stderr, "%s\n", GasEstimateResponse{GasEstimate: txf.Gas()}) + + parsedGasPrices, err := sdk.ParseCoinsNormalized(gInfo.GasInfo.MinGasPrices) + if err != nil { + return err + } + fees := make(sdk.Coins, len(parsedGasPrices)) + + gasLimit := sdk.NewInt(int64(adjusted)) + for i, gasPrice := range parsedGasPrices { + fee := gasPrice.Amount.Mul(gasLimit) + fees[i] = sdk.NewCoin(gasPrice.Denom, fee) + } + txf = txf.WithFees(fees.String()) } if clientCtx.Simulate { diff --git a/proto/cosmos/base/abci/v1beta1/abci.proto b/proto/cosmos/base/abci/v1beta1/abci.proto index ddaa635617..d575b064fe 100644 --- a/proto/cosmos/base/abci/v1beta1/abci.proto +++ b/proto/cosmos/base/abci/v1beta1/abci.proto @@ -83,6 +83,9 @@ message GasInfo { // GasUsed is the amount of gas actually consumed. uint64 gas_used = 2; + + // MinGasPrices are the min gas prices. + string min_gas_prices = 3; } // Result is the union of ResponseFormat and ResponseCheckTx. diff --git a/proto/cosmos/gashub/v1alpha1/event.proto b/proto/cosmos/gashub/v1alpha1/event.proto index 4684692d24..bbcf965a7e 100644 --- a/proto/cosmos/gashub/v1alpha1/event.proto +++ b/proto/cosmos/gashub/v1alpha1/event.proto @@ -7,5 +7,5 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; // EventUpdateMsgGasParams is emitted when update a msg's gas params message EventUpdateMsgGasParams { string msg_type_url = 1; - uint64 gas_type = 2; + bool is_new = 2; } diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 36008a0e37..1e28f5cfa3 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -12,8 +12,9 @@ message Params { uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; + string min_gas_price = 3 [(gogoproto.customname) = "MinGasPrice"]; - repeated MsgGasParams msg_gas_params_set = 3 [(gogoproto.customname) = "MsgGasParamsSet"]; + repeated MsgGasParams msg_gas_params_set = 4 [(gogoproto.customname) = "MsgGasParamsSet"]; } // MsgGasParams defines gas for a msg type @@ -21,13 +22,12 @@ message MsgGasParams { option (gogoproto.equal) = true; string msg_type_url = 1 [(gogoproto.customname) = "MsgTypeUrl"]; - GasType gas_type = 2 [(gogoproto.customname) = "GasType"]; // 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. - FixedGasParams fixed_type = 3; + FixedGasParams fixed_type = 2; // dynamic_type specifies dynamic type gas params. - DynamicGasParams dynamic_type = 4; + DynamicGasParams dynamic_type = 3; } // FixedGasParams defines the parameters for fixed gas type. message FixedGasParams { @@ -44,13 +44,3 @@ message MsgGasParams { uint64 gas_per_item = 2 [(gogoproto.customname) = "GasPerItem"]; } } - -// GasType defines the msg's gas type -enum GasType { - // GAS_TYPE_UNSPECIFIED defines the unspecified type gas which is not allowed - GAS_TYPE_UNSPECIFIED = 0; - // GAS_TYPE_FIXED defines the fixed type gas - GAS_TYPE_FIXED = 1; - // GAS_TYPE_DYNAMIC defines the dynamic type gas - GAS_TYPE_DYNAMIC = 2; -} diff --git a/proto/cosmos/gashub/v1alpha1/tx.proto b/proto/cosmos/gashub/v1alpha1/tx.proto index 6dde2280ff..456b685e6a 100644 --- a/proto/cosmos/gashub/v1alpha1/tx.proto +++ b/proto/cosmos/gashub/v1alpha1/tx.proto @@ -23,9 +23,7 @@ message MsgUpdateMsgGasParams { option (gogoproto.goproto_getters) = false; string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // the params is for a new msg type or existed msg type - bool is_new = 2; - MsgGasParams new_params = 3; + MsgGasParams new_params = 2; } // MsgUpdateMsgGasParamsResponse defines the Msg/UpdateMsgGasParams response type. diff --git a/types/abci.pb.go b/types/abci.pb.go index 80d0bf6fb4..a079678d37 100644 --- a/types/abci.pb.go +++ b/types/abci.pb.go @@ -272,6 +272,8 @@ type GasInfo struct { GasWanted uint64 `protobuf:"varint,1,opt,name=gas_wanted,json=gasWanted,proto3" json:"gas_wanted,omitempty"` // GasUsed is the amount of gas actually consumed. GasUsed uint64 `protobuf:"varint,2,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + // MinGasPrices are the min gas prices. + MinGasPrices string `protobuf:"bytes,3,opt,name=min_gas_prices,json=minGasPrices,proto3" json:"min_gas_prices,omitempty"` } func (m *GasInfo) Reset() { *m = GasInfo{} } @@ -320,6 +322,13 @@ func (m *GasInfo) GetGasUsed() uint64 { return 0 } +func (m *GasInfo) GetMinGasPrices() string { + if m != nil { + return m.MinGasPrices + } + return "" +} + // Result is the union of ResponseFormat and ResponseCheckTx. type Result struct { // Data is any data returned from message or handler execution. It MUST be @@ -637,64 +646,66 @@ func init() { } var fileDescriptor_4e37629bc7eb0df8 = []byte{ - // 909 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xda, 0xdb, 0x75, 0x3c, 0x8e, 0x29, 0x1a, 0x45, 0xe9, 0xa4, 0x80, 0x6d, 0xdc, 0x22, - 0x59, 0x48, 0xac, 0xd5, 0xb4, 0x42, 0xb4, 0xa7, 0xd6, 0xe1, 0x2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 0x92, 0xda, 0x58, 0x4d, 0x84, 0x9e, 0xf3, 0xb1, 0x60, 0x15, 0x08, 0x8b, 0x56, 0x00, - 0xa5, 0xc4, 0x87, 0x03, 0xf3, 0xdb, 0x5e, 0xb7, 0x11, 0xa1, 0x0d, 0xd8, 0x84, 0x1b, 0xce, 0xae, - 0x61, 0x30, 0xda, 0xf4, 0x06, 0xa9, 0x66, 0xfc, 0x64, 0x38, 0x53, 0x92, 0x05, 0x08, 0x07, 0x19, - 0x3f, 0x79, 0xac, 0x24, 0x7d, 0x4a, 0xfc, 0x99, 0x92, 0x9a, 0x55, 0xdb, 0x95, 0x6e, 0x7d, 0xbf, - 0x1b, 0x6e, 0x22, 0x28, 0x7c, 0xd4, 0x3f, 0x38, 0x7c, 0x22, 0xb4, 0xe6, 0x52, 0x3c, 0x56, 0xb2, - 0x7f, 0xe3, 0xc5, 0x79, 0xab, 0xf4, 0xc7, 0x5f, 0xad, 0xeb, 0xaf, 0xe3, 0x3a, 0xc2, 0x72, 0xd0, - 0x43, 0x9c, 0x3e, 0x53, 0x6c, 0xcb, 0xf6, 0x00, 0x36, 0xfd, 0x88, 0x10, 0xc9, 0xf5, 0xf0, 0x84, - 0xa7, 0x46, 0x4c, 0x58, 0x0d, 0x99, 0xa8, 0x49, 0xae, 0xbf, 0x47, 0x80, 0xee, 0x91, 0x2d, 0x70, - 0xe7, 0x5a, 0x4c, 0x18, 0x41, 0x67, 0x55, 0x72, 0xfd, 0x54, 0x8b, 0x09, 0xbd, 0x4d, 0xca, 0xa6, - 0x60, 0xf5, 0xb6, 0xd7, 0xad, 0xef, 0xef, 0x84, 0x96, 0xf6, 0x70, 0x41, 0x7b, 0xf8, 0x28, 0x3d, - 0x8d, 0xca, 0xa6, 0x00, 0xa6, 0x4c, 0x9c, 0x08, 0x6d, 0x78, 0x32, 0x67, 0xdb, 0x96, 0xa9, 0x25, - 0x40, 0xef, 0x91, 0x40, 0x1c, 0x8b, 0xd4, 0x68, 0xd6, 0xc0, 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40, 0x40, 0xa0, 0xd6, 0x65, 0xd5, 0x65, 0x0f, 0x90, 0x36, 0xe7, - 0x52, 0x0c, 0xd3, 0x3c, 0x19, 0x89, 0x0c, 0xef, 0x5e, 0x3f, 0x22, 0x00, 0x7d, 0x87, 0x08, 0xc8, - 0x16, 0x03, 0xb0, 0x12, 0x5e, 0xc1, 0x7e, 0x54, 0x03, 0x64, 0x00, 0x00, 0x54, 0x9d, 0xc5, 0x49, - 0x6c, 0xf0, 0x22, 0xf6, 0x23, 0x7b, 0xa0, 0x9f, 0x93, 0x8a, 0x29, 0x34, 0x0b, 0x70, 0xae, 0xdb, - 0x9b, 0xb9, 0x59, 0x3d, 0x1f, 0x11, 0x24, 0xd8, 0xf1, 0xfa, 0x0f, 0x5f, 0xfe, 0xd3, 0x2c, 0xbd, - 0xb8, 0x68, 0x7a, 0x67, 0x17, 0x4d, 0xef, 0xef, 0x8b, 0xa6, 0xf7, 0xcb, 0x65, 0xb3, 0x74, 0x76, - 0xd9, 0x2c, 0xbd, 0xbc, 0x6c, 0x96, 0x7e, 0xe8, 0xc8, 0xd8, 0x4c, 0xf3, 0x51, 0x38, 0x56, 0x49, - 0xcf, 0x3d, 0x87, 0xf6, 0xe7, 0x33, 0x3d, 0x79, 0x6e, 0xdf, 0xae, 0x51, 0x80, 0x14, 0xde, 0xfd, - 0x2f, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xf1, 0x8e, 0x98, 0x30, 0x07, 0x00, 0x00, + // 932 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xda, 0xdb, 0x75, 0x3c, 0x76, 0x5a, 0x34, 0x8a, 0xd2, 0x49, 0x01, 0xdb, 0xb8, 0x45, + 0xb2, 0x90, 0x58, 0xab, 0x69, 0x85, 0x68, 0x4f, 0xad, 0x0b, 0x94, 0x48, 0x2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0xe3, 0xe9, 0xa0, 0xd0, 0x4e, 0x19, 0x2d, 0x52, 0x37, 0xca, + 0xf0, 0xd9, 0x70, 0xac, 0xf2, 0xd4, 0x38, 0x15, 0x12, 0x84, 0x1e, 0x01, 0x02, 0x32, 0xb6, 0x21, + 0xab, 0x41, 0xeb, 0xc0, 0xb1, 0x39, 0x97, 0x62, 0x98, 0xe6, 0xc9, 0x48, 0x64, 0x28, 0x3f, 0x3f, + 0x22, 0x00, 0x7d, 0x83, 0x08, 0x88, 0x1b, 0x13, 0xb0, 0x12, 0x3e, 0xd4, 0x7e, 0x54, 0x03, 0x64, + 0x00, 0x00, 0x54, 0x9d, 0xc5, 0x49, 0x6c, 0xf0, 0xb9, 0xf6, 0x23, 0xeb, 0xd0, 0xcf, 0x48, 0xc5, + 0x14, 0x9a, 0x05, 0x38, 0xd7, 0xad, 0xcd, 0xdc, 0xac, 0x3e, 0x32, 0x11, 0x1c, 0xb0, 0xe3, 0xf5, + 0x1f, 0xbc, 0xfa, 0xbb, 0x59, 0x7a, 0x79, 0xde, 0xf4, 0x4e, 0xcf, 0x9b, 0xde, 0x5f, 0xe7, 0x4d, + 0xef, 0xe7, 0x8b, 0x66, 0xe9, 0xf4, 0xa2, 0x59, 0x7a, 0x75, 0xd1, 0x2c, 0x7d, 0xdf, 0x91, 0xb1, + 0x99, 0xe6, 0xa3, 0x70, 0xac, 0x92, 0x9e, 0xfb, 0x68, 0xda, 0x9f, 0x4f, 0xf5, 0xe4, 0x85, 0xfd, + 0xc2, 0x8d, 0x02, 0xa4, 0xf0, 0xce, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x9a, 0x1a, 0xc7, + 0x56, 0x07, 0x00, 0x00, } func (m *TxResponse) Marshal() (dAtA []byte, err error) { @@ -972,6 +983,13 @@ func (m *GasInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.MinGasPrices) > 0 { + i -= len(m.MinGasPrices) + copy(dAtA[i:], m.MinGasPrices) + i = encodeVarintAbci(dAtA, i, uint64(len(m.MinGasPrices))) + i-- + dAtA[i] = 0x1a + } if m.GasUsed != 0 { i = encodeVarintAbci(dAtA, i, uint64(m.GasUsed)) i-- @@ -1387,6 +1405,10 @@ func (m *GasInfo) Size() (n int) { if m.GasUsed != 0 { n += 1 + sovAbci(uint64(m.GasUsed)) } + l = len(m.MinGasPrices) + if l > 0 { + n += 1 + l + sovAbci(uint64(l)) + } return n } @@ -2455,6 +2477,38 @@ func (m *GasInfo) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinGasPrices", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAbci + } + 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 ErrInvalidLengthAbci + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAbci + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MinGasPrices = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAbci(dAtA[iNdEx:]) diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go index a562e67ee3..c2ed116bd3 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -16,6 +16,7 @@ type HandlerOptions struct { FeegrantKeeper FeegrantKeeper SignModeHandler authsigning.SignModeHandler SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error + GashubKeeper GashubKeeper TxFeeChecker TxFeeChecker } @@ -42,7 +43,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { NewTxTimeoutHeightDecorator(), NewValidateMemoDecorator(options.AccountKeeper), NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), + NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.GashubKeeper, options.TxFeeChecker), NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators NewValidateSigCountDecorator(options.AccountKeeper), NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 4ab9dda9ee..2f29e64ef4 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -10,7 +10,7 @@ import ( // TxFeeChecker check if the provided fee is enough and returns the effective fee and tx priority, // the effective fee should be deducted later, and the priority should be returned in abci response. -type TxFeeChecker func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) +type TxFeeChecker func(ctx sdk.Context, ghk GashubKeeper, tx sdk.Tx) (sdk.Coins, int64, error) // DeductFeeDecorator deducts fees from the first signer of the tx // If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error @@ -21,9 +21,10 @@ type DeductFeeDecorator struct { bankKeeper types.BankKeeper feegrantKeeper FeegrantKeeper txFeeChecker TxFeeChecker + gashubKeeper GashubKeeper } -func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, tfc TxFeeChecker) DeductFeeDecorator { +func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, ghk GashubKeeper, tfc TxFeeChecker) DeductFeeDecorator { if tfc == nil { tfc = checkTxFeeWithValidatorMinGasPrices } @@ -33,6 +34,7 @@ func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKee bankKeeper: bk, feegrantKeeper: fk, txFeeChecker: tfc, + gashubKeeper: ghk, } } @@ -53,7 +55,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo fee := feeTx.GetFee() if !simulate { - fee, priority, err = dfd.txFeeChecker(ctx, tx) + fee, priority, err = dfd.txFeeChecker(ctx, dfd.gashubKeeper, tx) if err != nil { return ctx, err } diff --git a/x/auth/ante/fee_test.go b/x/auth/ante/fee_test.go index e1f46db510..d4cb2c1f9d 100644 --- a/x/auth/ante/fee_test.go +++ b/x/auth/ante/fee_test.go @@ -12,7 +12,7 @@ func (s *AnteTestSuite) TestDeductFeeDecorator_ZeroGas() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, nil) + mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.GashubKeeper, nil) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -46,7 +46,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFees() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, nil) + mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.GashubKeeper, nil) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -130,7 +130,7 @@ func (s *AnteTestSuite) TestDeductFees() { err = testutil.FundAccount(s.app.BankKeeper, s.ctx, addr1, coins) s.Require().NoError(err) - dfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, nil, nil) + dfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, nil, s.app.GashubKeeper, nil) antehandler := sdk.ChainAnteDecorators(dfd) _, err = antehandler(s.ctx, tx, false) diff --git a/x/auth/ante/feegrant_test.go b/x/auth/ante/feegrant_test.go index be1a4f1d29..5bdd1c19b7 100644 --- a/x/auth/ante/feegrant_test.go +++ b/x/auth/ante/feegrant_test.go @@ -32,7 +32,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(app.InterfaceRegistry()), tx.DefaultSignModes) // this just tests our handler - dfd := ante.NewDeductFeeDecorator(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, nil) + dfd := ante.NewDeductFeeDecorator(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.GashubKeeper, nil) feeAnteHandler := sdk.ChainAnteDecorators(dfd) // this tests the whole stack diff --git a/x/auth/ante/validator_tx_fee.go b/x/auth/ante/validator_tx_fee.go index dbb1398880..8d49c6fcdd 100644 --- a/x/auth/ante/validator_tx_fee.go +++ b/x/auth/ante/validator_tx_fee.go @@ -9,7 +9,7 @@ import ( // checkTxFeeWithValidatorMinGasPrices implements the default fee logic, where the minimum price per // unit of gas is fixed and set by each validator, can the tx priority is computed from the gas price. -func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { +func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, ghk GashubKeeper, tx sdk.Tx) (sdk.Coins, int64, error) { feeTx, ok := tx.(sdk.FeeTx) if !ok { return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") @@ -40,15 +40,15 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, } } - priority := getTxPriority(feeCoins, int64(gas)) + priority := GetTxPriority(feeCoins, int64(gas)) return feeCoins, priority, nil } -// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price +// GetTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price // provided in a transaction. // NOTE: This implementation should be used with a great consideration as it opens potential attack vectors // where txs with multiple coins could not be prioritize as expected. -func getTxPriority(fee sdk.Coins, gas int64) int64 { +func GetTxPriority(fee sdk.Coins, gas int64) int64 { var priority int64 for _, c := range fee { p := int64(math.MaxInt64) diff --git a/x/gashub/keeper/genesis.go b/x/gashub/keeper/genesis.go index 2a6a805b61..2d5733595e 100644 --- a/x/gashub/keeper/genesis.go +++ b/x/gashub/keeper/genesis.go @@ -1,16 +1,18 @@ package keeper import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // InitGenesis - Init store state from genesis data -// -// CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through -// a genesis port script to the new fee collector account func (ghk Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { ghk.SetParams(ctx, data.Params) + + // init gas calculators from genesis data + initGasCalculators(data.Params) } // ExportGenesis returns a GenesisState for a given context and keeper @@ -19,3 +21,32 @@ func (ghk Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return types.NewGenesisState(params) } + +func initGasCalculators(params types.Params) { + msgGasParamsSet := params.GetMsgGasParamsSet() + // for fixed gas msgs + for _, gasParams := range msgGasParamsSet { + if _, ok := gasParams.GasParams.(*types.MsgGasParams_FixedType); !ok { + continue + } + msgType := gasParams.GetMsgTypeUrl() + types.RegisterCalculatorGen(msgType, func(params types.Params) types.GasCalculator { + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsgTypeUrl() == msgType { + p, ok := gasParams.GasParams.(*types.MsgGasParams_FixedType) + if !ok { + panic(fmt.Errorf("unpack failed for %s", msgType)) + } + return types.FixedGasCalculator(p.FixedType.FixedGas) + } + } + panic(fmt.Sprintf("no params for %s", msgType)) + }) + } + + // for dynamic gas msgs + types.RegisterCalculatorGen("/cosmos.authz.v1beta1.MsgGrant", types.MsgGrantGasCalculatorGen) + types.RegisterCalculatorGen("/cosmos.feegrant.v1beta1.MsgGrantAllowance", types.MsgGrantAllowanceGasCalculatorGen) + types.RegisterCalculatorGen("/cosmos.bank.v1beta1.MsgMultiSend", types.MsgMultiSendGasCalculatorGen) +} diff --git a/x/gashub/keeper/msg_server.go b/x/gashub/keeper/msg_server.go index 92558b6a2c..4ec400c63f 100644 --- a/x/gashub/keeper/msg_server.go +++ b/x/gashub/keeper/msg_server.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -31,33 +30,30 @@ func (k msgServer) UpdateMsgGasParams(goCtx context.Context, msg *types.MsgUpdat return nil, slashingtypes.ErrSignerNotGovModule } - isNew := msg.IsNew params := k.GetParams(ctx) newMsgGasParams := msg.NewParams - if isNew { - params.MsgGasParamsSet = append(params.MsgGasParamsSet, newMsgGasParams) - } else { - msgGasParamsSet := params.MsgGasParamsSet - typeUrl := msg.NewParams.MsgTypeUrl + msgGasParamsSet := params.MsgGasParamsSet + typeUrl := msg.NewParams.MsgTypeUrl - var find bool - for idx, msgGasParams := range msgGasParamsSet { - if msgGasParams.MsgTypeUrl == typeUrl { - msgGasParamsSet[idx] = newMsgGasParams - find = true - break - } - } - if !find { - return nil, fmt.Errorf("msg type not find: %s", typeUrl) + isNew := true + for idx, msgGasParams := range msgGasParamsSet { + if msgGasParams.MsgTypeUrl == typeUrl { + msgGasParamsSet[idx] = newMsgGasParams + isNew = false + break } } + if isNew { + params.MsgGasParamsSet = append(params.MsgGasParamsSet, newMsgGasParams) + } + + k.SetParams(ctx, params) ctx.EventManager().EmitTypedEvent( &types.EventUpdateMsgGasParams{ MsgTypeUrl: msg.NewParams.MsgTypeUrl, - GasType: uint64(msg.NewParams.GasType), + IsNew: isNew, }, ) diff --git a/x/gashub/simulation/genesis.go b/x/gashub/simulation/genesis.go index 2b3e33c1f4..d72766e52d 100644 --- a/x/gashub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -3,6 +3,7 @@ package simulation import ( "fmt" "math/rand" + "strconv" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/simulation" @@ -14,6 +15,7 @@ import ( const ( MaxTxSize = "max_tx_size" MinGasPerByte = "min_gas_per_byte" + MinGasPrice = "min_gas_price" MsgGas = "msg_gas" ) @@ -24,7 +26,13 @@ func GenMaxTxSize(r *rand.Rand) uint64 { // GenMinGasPerByte randomized MinGasPerByte func GenMinGasPerByte(r *rand.Rand) uint64 { - return uint64(simulation.RandIntBetween(r, 2500, 5000)) + return uint64(simulation.RandIntBetween(r, 5, 50)) +} + +// GenMinGasPrice randomized MinGasPrice +func GenMinGasPrice(r *rand.Rand) string { + amount := simulation.RandIntBetween(r, 1, 10) + return strconv.FormatInt(int64(amount), 10) + "gweibnb" } // GenMsgGasParams randomized msg gas consumption @@ -48,13 +56,19 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { minGasPerByte = GenMinGasPerByte(r) }, ) + var minGasPrice string + simState.AppParams.GetOrGenerate( + simState.Cdc, MinGasPrice, &minGasPrice, simState.Rand, + func(r *rand.Rand) { minGasPrice = GenMinGasPrice(r) }, + ) + var msgGasParams *types.MsgGasParams simState.AppParams.GetOrGenerate( simState.Cdc, MsgGas, &msgGasParams, simState.Rand, func(r *rand.Rand) { msgGasParams = GenMsgGasParams(r) }, ) - params := types.NewParams(maxTxSize, minGasPerByte, []*types.MsgGasParams{msgGasParams}) + params := types.NewParams(maxTxSize, minGasPerByte, minGasPrice, []*types.MsgGasParams{msgGasParams}) gashubGenesis := types.NewGenesisState(params) diff --git a/x/gashub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go index fecfcd5685..6318ee5870 100644 --- a/x/gashub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -41,8 +41,9 @@ func TestRandomizedGenState(t *testing.T) { simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &gashubGenesis) require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) - require.Equal(t, uint64(2956), gashubGenesis.Params.MinGasPerByte) + require.Equal(t, uint64(36), gashubGenesis.Params.MinGasPerByte) + require.Equal(t, "7gweibnb", gashubGenesis.Params.MinGasPrice) gas := gashubGenesis.Params.MsgGasParamsSet[0].GasParams.(*types.MsgGasParams_FixedType) - require.Equal(t, uint64(4978511), gas.FixedType.FixedGas) + require.Equal(t, uint64(4828162), gas.FixedType.FixedGas) } diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index 6689d734c4..8dc6e90c77 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -17,7 +17,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, string(types.KeyMaxTxSize), func(r *rand.Rand) string { - return fmt.Sprintf("%d", GenMaxTxSize(r)) + return fmt.Sprintf("\"%d\"", GenMaxTxSize(r)) }, ), } diff --git a/x/gashub/simulation/params_test.go b/x/gashub/simulation/params_test.go index d06f19b5e6..6fcda5cc4b 100644 --- a/x/gashub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -19,7 +19,7 @@ func TestParamChanges(t *testing.T) { simValue string subspace string }{ - {"gashub/MaxTxSize", "MaxTxSize", "3081", "gashub"}, + {"gashub/MaxTxSize", "MaxTxSize", "\"3081\"", "gashub"}, } paramChanges := simulation.ParamChanges(r) diff --git a/x/gashub/types/event.pb.go b/x/gashub/types/event.pb.go index 4560edd1ee..7bd1964b9f 100644 --- a/x/gashub/types/event.pb.go +++ b/x/gashub/types/event.pb.go @@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // EventUpdateMsgGasParams is emitted when update a msg's gas params type EventUpdateMsgGasParams struct { MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` - GasType uint64 `protobuf:"varint,2,opt,name=gas_type,json=gasType,proto3" json:"gas_type,omitempty"` + IsNew bool `protobuf:"varint,2,opt,name=is_new,json=isNew,proto3" json:"is_new,omitempty"` } func (m *EventUpdateMsgGasParams) Reset() { *m = EventUpdateMsgGasParams{} } @@ -68,11 +68,11 @@ func (m *EventUpdateMsgGasParams) GetMsgTypeUrl() string { return "" } -func (m *EventUpdateMsgGasParams) GetGasType() uint64 { +func (m *EventUpdateMsgGasParams) GetIsNew() bool { if m != nil { - return m.GasType + return m.IsNew } - return 0 + return false } func init() { @@ -84,21 +84,21 @@ func init() { } var fileDescriptor_de0e3393fe9bac86 = []byte{ - // 210 bytes of a gzipped FileDescriptorProto + // 211 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, - 0x83, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xa9, 0x51, 0x0a, 0xe3, 0x12, 0x77, 0x05, 0x29, 0x0b, + 0x83, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xa9, 0x51, 0x0a, 0xe2, 0x12, 0x77, 0x05, 0x29, 0x0b, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xf5, 0x2d, 0x4e, 0x77, 0x4f, 0x2c, 0x0e, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0x16, 0x52, 0xe0, 0xe2, 0xc9, 0x2d, 0x4e, 0x8f, 0x2f, 0xa9, 0x2c, 0x48, 0x8d, 0x2f, 0x2d, 0xca, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0xca, 0x2d, 0x4e, 0x0f, 0xa9, 0x2c, 0x48, - 0x0d, 0x2d, 0xca, 0x11, 0x92, 0xe4, 0xe2, 0x48, 0x4f, 0x2c, 0x06, 0xab, 0x90, 0x60, 0x52, 0x60, - 0xd4, 0x60, 0x09, 0x62, 0x4f, 0x4f, 0x2c, 0x06, 0xc9, 0x3a, 0xb9, 0x9e, 0x78, 0x24, 0xc7, 0x78, - 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, - 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x76, 0x7a, 0x66, 0x09, 0xc8, 0x09, 0xc9, 0xf9, 0xb9, 0xfa, - 0x50, 0x87, 0x43, 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0x98, 0x2f, 0x40, 0x86, 0x16, 0x27, - 0xb1, 0x81, 0x5d, 0x6f, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x36, 0x6b, 0xd6, 0xf1, 0xe3, 0x00, - 0x00, 0x00, + 0x0d, 0x2d, 0xca, 0x11, 0x12, 0xe5, 0x62, 0xcb, 0x2c, 0x8e, 0xcf, 0x4b, 0x2d, 0x97, 0x60, 0x52, + 0x60, 0xd4, 0xe0, 0x08, 0x62, 0xcd, 0x2c, 0xf6, 0x4b, 0x2d, 0x77, 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, 0x12, 0x90, 0xf5, 0xc9, 0xf9, 0xb9, + 0xfa, 0x50, 0x47, 0x43, 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0x98, 0x0f, 0x40, 0x56, 0x16, + 0x27, 0xb1, 0x81, 0x5d, 0x6e, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xf4, 0xaf, 0xea, 0xdf, + 0x00, 0x00, 0x00, } func (m *EventUpdateMsgGasParams) Marshal() (dAtA []byte, err error) { @@ -121,8 +121,13 @@ func (m *EventUpdateMsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if m.GasType != 0 { - i = encodeVarintEvent(dAtA, i, uint64(m.GasType)) + if m.IsNew { + i-- + if m.IsNew { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } i-- dAtA[i] = 0x10 } @@ -157,8 +162,8 @@ func (m *EventUpdateMsgGasParams) Size() (n int) { if l > 0 { n += 1 + l + sovEvent(uint64(l)) } - if m.GasType != 0 { - n += 1 + sovEvent(uint64(m.GasType)) + if m.IsNew { + n += 2 } return n } @@ -232,9 +237,9 @@ func (m *EventUpdateMsgGasParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GasType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IsNew", wireType) } - m.GasType = 0 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvent @@ -244,11 +249,12 @@ func (m *EventUpdateMsgGasParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GasType |= uint64(b&0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } } + m.IsNew = bool(v != 0) default: iNdEx = preIndex skippy, err := skipEvent(dAtA[iNdEx:]) diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 222e153e20..8c480c53f3 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -100,7 +100,7 @@ func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { } } -var msgGrantGasCalculatorGen = func(params Params) GasCalculator { +var MsgGrantGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { if gasParams.GetMsgTypeUrl() == "/cosmos.authz.v1beta1.MsgGrant" { @@ -114,7 +114,7 @@ var msgGrantGasCalculatorGen = func(params Params) GasCalculator { panic("no params for /cosmos.authz.v1beta1.MsgGrant") } -var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { +var MsgMultiSendGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { if gasParams.GetMsgTypeUrl() == "/cosmos.bank.v1beta1.MsgMultiSend" { @@ -128,7 +128,7 @@ var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { panic("no params for /cosmos.bank.v1beta1.MsgMultiSend") } -var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { +var MsgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { if gasParams.GetMsgTypeUrl() == "/cosmos.feegrant.v1beta1.MsgGrantAllowance" { @@ -136,76 +136,8 @@ var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { if !ok { panic("type conversion failed for /cosmos.feegrant.v1beta1.MsgGrantAllowance") } - return MultiSendCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) + return GrantAllowanceCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) } } panic("no params for /cosmos.feegrant.v1beta1.MsgGrantAllowance") } - -func init() { - defaultMsgGasParamsSet := []*MsgGasParams{ - NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgExec", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgRevoke", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.bank.v1beta1.MsgSend", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgFundCommunityPool", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.feegrant.v1beta1.MsgRevokeAllowance", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgDeposit", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgSubmitProposal", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVote", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVoteWeighted", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.oracle.v1.MsgClaim", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgImpeach", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgUnjail", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgBeginRedelegate", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCreateValidator", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgDelegate", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgEditValidator", 1e5), - NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgUndelegate", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.bridge.MsgTransferOut", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgCreateStorageProvider", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgDeposit", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgEditStorageProvider", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCopyObject", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateBucket", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateGroup", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateObject", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteBucket", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteGroup", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgLeaveGroup", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgRejectSealObject", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgSealObject", 1e5), - NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgUpdateGroupMember", 1e5), - NewMsgGasParamsWithDynamicGas("/cosmos.authz.v1beta1.MsgGrant", 1e5, 1e5), - NewMsgGasParamsWithDynamicGas("/cosmos.bank.v1beta1.MsgMultiSend", 1e5, 1e5), - NewMsgGasParamsWithDynamicGas("/cosmos.feegrant.v1beta1.MsgGrantAllowance", 1e5, 1e5), - } - // for fixed gas msgs - for _, gasParams := range defaultMsgGasParamsSet { - if gasParams.GetGasType() != GasType_GAS_TYPE_FIXED { - continue - } - msgType := gasParams.GetMsgTypeUrl() - RegisterCalculatorGen(msgType, func(params Params) GasCalculator { - msgGasParamsSet := params.GetMsgGasParamsSet() - for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsgTypeUrl() == msgType { - p, ok := gasParams.GasParams.(*MsgGasParams_FixedType) - if !ok { - panic(fmt.Errorf("unpack failed for %s", msgType)) - } - return FixedGasCalculator(p.FixedType.FixedGas) - } - } - panic(fmt.Sprintf("no params for %s", msgType)) - }) - } - - // for dynamic gas msgs - RegisterCalculatorGen("/cosmos.authz.v1beta1.MsgGrant", msgGrantGasCalculatorGen) - RegisterCalculatorGen("/cosmos.feegrant.v1beta1.MsgGrantAllowance", msgGrantAllowanceGasCalculatorGen) - RegisterCalculatorGen("/cosmos.bank.v1beta1.MsgMultiSend", msgMultiSendGasCalculatorGen) -} diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index ca8e5ec5a0..7f2734ea06 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -23,43 +23,12 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GasType defines the msg's gas type -type GasType int32 - -const ( - // GAS_TYPE_UNSPECIFIED defines the unspecified type gas which is not allowed - GasType_GAS_TYPE_UNSPECIFIED GasType = 0 - // GAS_TYPE_FIXED defines the fixed type gas - GasType_GAS_TYPE_FIXED GasType = 1 - // GAS_TYPE_DYNAMIC defines the dynamic type gas - GasType_GAS_TYPE_DYNAMIC GasType = 2 -) - -var GasType_name = map[int32]string{ - 0: "GAS_TYPE_UNSPECIFIED", - 1: "GAS_TYPE_FIXED", - 2: "GAS_TYPE_DYNAMIC", -} - -var GasType_value = map[string]int32{ - "GAS_TYPE_UNSPECIFIED": 0, - "GAS_TYPE_FIXED": 1, - "GAS_TYPE_DYNAMIC": 2, -} - -func (x GasType) String() string { - return proto.EnumName(GasType_name, int32(x)) -} - -func (GasType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_f79bf23b48853a4a, []int{0} -} - // Params defines the parameters for the gashub module. type Params struct { MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` - MsgGasParamsSet []*MsgGasParams `protobuf:"bytes,3,rep,name=msg_gas_params_set,json=msgGasParamsSet,proto3" json:"msg_gas_params_set,omitempty"` + MinGasPrice string `protobuf:"bytes,3,opt,name=min_gas_price,json=minGasPrice,proto3" json:"min_gas_price,omitempty"` + MsgGasParamsSet []*MsgGasParams `protobuf:"bytes,4,rep,name=msg_gas_params_set,json=msgGasParamsSet,proto3" json:"msg_gas_params_set,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -108,6 +77,13 @@ func (m *Params) GetMinGasPerByte() uint64 { return 0 } +func (m *Params) GetMinGasPrice() string { + if m != nil { + return m.MinGasPrice + } + return "" +} + func (m *Params) GetMsgGasParamsSet() []*MsgGasParams { if m != nil { return m.MsgGasParamsSet @@ -117,8 +93,7 @@ func (m *Params) GetMsgGasParamsSet() []*MsgGasParams { // MsgGasParams defines gas for a msg type type MsgGasParams struct { - MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` - GasType GasType `protobuf:"varint,2,opt,name=gas_type,json=gasType,proto3,enum=cosmos.gashub.v1alpha1.GasType" json:"gas_type,omitempty"` + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` // gas_params is the oneof that represents either fixed_gas_params or dynamic_gas_params // // Types that are valid to be assigned to GasParams: @@ -168,10 +143,10 @@ type isMsgGasParams_GasParams interface { } type MsgGasParams_FixedType struct { - FixedType *MsgGasParams_FixedGasParams `protobuf:"bytes,3,opt,name=fixed_type,json=fixedType,proto3,oneof" json:"fixed_type,omitempty"` + FixedType *MsgGasParams_FixedGasParams `protobuf:"bytes,2,opt,name=fixed_type,json=fixedType,proto3,oneof" json:"fixed_type,omitempty"` } type MsgGasParams_DynamicType struct { - DynamicType *MsgGasParams_DynamicGasParams `protobuf:"bytes,4,opt,name=dynamic_type,json=dynamicType,proto3,oneof" json:"dynamic_type,omitempty"` + DynamicType *MsgGasParams_DynamicGasParams `protobuf:"bytes,3,opt,name=dynamic_type,json=dynamicType,proto3,oneof" json:"dynamic_type,omitempty"` } func (*MsgGasParams_FixedType) isMsgGasParams_GasParams() {} @@ -191,13 +166,6 @@ func (m *MsgGasParams) GetMsgTypeUrl() string { return "" } -func (m *MsgGasParams) GetGasType() GasType { - if m != nil { - return m.GasType - } - return GasType_GAS_TYPE_UNSPECIFIED -} - func (m *MsgGasParams) GetFixedType() *MsgGasParams_FixedGasParams { if x, ok := m.GetGasParams().(*MsgGasParams_FixedType); ok { return x.FixedType @@ -319,7 +287,6 @@ func (m *MsgGasParams_DynamicGasParams) GetGasPerItem() uint64 { } func init() { - proto.RegisterEnum("cosmos.gashub.v1alpha1.GasType", GasType_name, GasType_value) proto.RegisterType((*Params)(nil), "cosmos.gashub.v1alpha1.Params") proto.RegisterType((*MsgGasParams)(nil), "cosmos.gashub.v1alpha1.MsgGasParams") proto.RegisterType((*MsgGasParams_FixedGasParams)(nil), "cosmos.gashub.v1alpha1.MsgGasParams.FixedGasParams") @@ -331,42 +298,39 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 556 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xda, 0x40, - 0x10, 0xb5, 0x13, 0x94, 0xc0, 0xf0, 0x11, 0x77, 0x8b, 0x2a, 0xc4, 0xc1, 0x46, 0x69, 0x0f, 0xb4, - 0x55, 0xa0, 0x21, 0xea, 0x85, 0x1b, 0x0e, 0x1f, 0xe5, 0xe0, 0x08, 0x19, 0x22, 0x35, 0xb9, 0x58, - 0x06, 0x16, 0xc7, 0x2a, 0x8b, 0x91, 0xd7, 0x54, 0x26, 0xff, 0xa0, 0xb7, 0x1e, 0x7b, 0xcc, 0xcf, - 0xe9, 0x31, 0xc7, 0x9e, 0xac, 0xca, 0xa8, 0x52, 0x7f, 0x46, 0xb5, 0x5e, 0x9b, 0x92, 0xaa, 0x95, - 0xd2, 0x8b, 0x3d, 0x33, 0x7e, 0xef, 0xcd, 0x8e, 0xdf, 0x2c, 0x3c, 0x9f, 0x38, 0x94, 0x38, 0xb4, - 0x6e, 0x99, 0xf4, 0x66, 0x35, 0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0x77, 0xda, 0x92, 0x80, 0x10, 0x14, 0xb6, 0x5f, 0xba, 0xfd, 0xf7, 0x9d, 0xb6, 0x24, 0xa2, 0x22, - 0x48, 0xdb, 0x5a, 0xfb, 0xea, 0xa2, 0xa5, 0xf5, 0xcf, 0xa5, 0x3d, 0xb5, 0xf3, 0x35, 0x94, 0xc5, - 0xfb, 0x50, 0x16, 0xbf, 0x87, 0xb2, 0xf8, 0x79, 0x23, 0x0b, 0xf7, 0x1b, 0x59, 0xf8, 0xb6, 0x91, - 0x85, 0xeb, 0xd7, 0x96, 0xed, 0xb1, 0x9f, 0x3e, 0x71, 0x48, 0x3d, 0xbe, 0xba, 0xfc, 0x75, 0x42, - 0xa7, 0x1f, 0xea, 0x7e, 0x72, 0x8f, 0x99, 0x5d, 0x74, 0x7c, 0x10, 0x5d, 0xc8, 0xb3, 0x5f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x54, 0xf8, 0x37, 0xba, 0xe5, 0x03, 0x00, 0x00, + // 497 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0x8e, 0x9b, 0xa8, 0x4a, 0x9e, 0x9d, 0xa6, 0x1c, 0x08, 0x45, 0x19, 0xec, 0xa8, 0x30, 0x04, + 0xa1, 0xda, 0xb4, 0x11, 0x4b, 0x36, 0x2c, 0x7e, 0x0e, 0x91, 0x2a, 0x37, 0x2c, 0x5d, 0xac, 0x4b, + 0x72, 0x71, 0x2d, 0x72, 0xb1, 0xe5, 0xbb, 0x20, 0xbb, 0x7f, 0x05, 0x23, 0x62, 0xea, 0x9f, 0xc2, + 0xc8, 0xd8, 0x91, 0xc9, 0x42, 0xce, 0xc2, 0x9f, 0x81, 0xee, 0xce, 0x4e, 0x53, 0xc4, 0x50, 0x16, + 0xfb, 0xbd, 0xa7, 0xef, 0xfb, 0xde, 0xbb, 0x4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c, 0xda, 0xcf, 0x8d, 0x59, 0xbb, 0x78, 0x1e, 0x84, 0x5c, 0xb8, 0x34, 0x8b, 0xa8, + 0x53, 0xde, 0x95, 0xfa, 0x1d, 0xb3, 0xf9, 0x27, 0x27, 0xad, 0x8e, 0x4c, 0xf8, 0xcb, 0xa6, 0xfb, + 0xf2, 0x5a, 0x86, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc9, 0xeb, 0xf0, 0x9d, 0x82, 0x03, 0x00, + 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -394,6 +358,9 @@ func (this *Params) Equal(that interface{}) bool { if this.MinGasPerByte != that1.MinGasPerByte { return false } + if this.MinGasPrice != that1.MinGasPrice { + return false + } if len(this.MsgGasParamsSet) != len(that1.MsgGasParamsSet) { return false } @@ -426,9 +393,6 @@ func (this *MsgGasParams) Equal(that interface{}) bool { if this.MsgTypeUrl != that1.MsgTypeUrl { return false } - if this.GasType != that1.GasType { - return false - } if that1.GasParams == nil { if this.GasParams != nil { return false @@ -570,9 +534,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGashub(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } + if len(m.MinGasPrice) > 0 { + i -= len(m.MinGasPrice) + copy(dAtA[i:], m.MinGasPrice) + i = encodeVarintGashub(dAtA, i, uint64(len(m.MinGasPrice))) + i-- + dAtA[i] = 0x1a + } if m.MinGasPerByte != 0 { i = encodeVarintGashub(dAtA, i, uint64(m.MinGasPerByte)) i-- @@ -615,11 +586,6 @@ func (m *MsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { } } } - if m.GasType != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.GasType)) - i-- - dAtA[i] = 0x10 - } if len(m.MsgTypeUrl) > 0 { i -= len(m.MsgTypeUrl) copy(dAtA[i:], m.MsgTypeUrl) @@ -647,7 +613,7 @@ func (m *MsgGasParams_FixedType) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintGashub(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } return len(dAtA) - i, nil } @@ -668,7 +634,7 @@ func (m *MsgGasParams_DynamicType) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintGashub(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } return len(dAtA) - i, nil } @@ -756,6 +722,10 @@ func (m *Params) Size() (n int) { if m.MinGasPerByte != 0 { n += 1 + sovGashub(uint64(m.MinGasPerByte)) } + l = len(m.MinGasPrice) + if l > 0 { + n += 1 + l + sovGashub(uint64(l)) + } if len(m.MsgGasParamsSet) > 0 { for _, e := range m.MsgGasParamsSet { l = e.Size() @@ -775,9 +745,6 @@ func (m *MsgGasParams) Size() (n int) { if l > 0 { n += 1 + l + sovGashub(uint64(l)) } - if m.GasType != 0 { - n += 1 + sovGashub(uint64(m.GasType)) - } if m.GasParams != nil { n += m.GasParams.Size() } @@ -909,6 +876,38 @@ func (m *Params) Unmarshal(dAtA []byte) error { } } case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinGasPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + 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 ErrInvalidLengthGashub + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGashub + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MinGasPrice = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MsgGasParamsSet", wireType) } @@ -1025,25 +1024,6 @@ func (m *MsgGasParams) Unmarshal(dAtA []byte) error { m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GasType", wireType) - } - m.GasType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GasType |= GasType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FixedType", wireType) } @@ -1078,7 +1058,7 @@ func (m *MsgGasParams) Unmarshal(dAtA []byte) error { } m.GasParams = &MsgGasParams_FixedType{v} iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DynamicType", wireType) } diff --git a/x/gashub/types/msg.go b/x/gashub/types/msg.go index abead3d261..7339e32aad 100644 --- a/x/gashub/types/msg.go +++ b/x/gashub/types/msg.go @@ -17,10 +17,9 @@ var _ sdk.Msg = &MsgUpdateMsgGasParams{} // MsgUpdateMsgGasParams - construct a msg to update msg gas params. // //nolint:interfacer -func NewMsgUpdateMsgGasParams(from sdk.AccAddress, isNew bool, msgGasParams *MsgGasParams) *MsgUpdateMsgGasParams { +func NewMsgUpdateMsgGasParams(from sdk.AccAddress, msgGasParams *MsgGasParams) *MsgUpdateMsgGasParams { return &MsgUpdateMsgGasParams{ From: from.String(), - IsNew: isNew, NewParams: msgGasParams, } } diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index cae2fc95c5..92af20bbef 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -6,6 +6,7 @@ import ( "sigs.k8s.io/yaml" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -13,12 +14,14 @@ import ( const ( DefaultMaxTxSize uint64 = 1024 DefaultMinGasPerByte uint64 = 5 + DefaultMinGasPrice string = "1gweibnb" ) // Parameter keys var ( KeyMaxTxSize = []byte("MaxTxSize") KeyMinGasPerByte = []byte("MinGasPerByte") + KeyMinGasPrice = []byte("MinGasPrice") KeyMsgGasParamsSet = []byte("MsgGasParamsSet") ) @@ -28,7 +31,6 @@ var _ paramtypes.ParamSet = &Params{} func NewMsgGasParamsWithFixedGas(msgTypeUrl string, gas uint64) *MsgGasParams { return &MsgGasParams{ MsgTypeUrl: msgTypeUrl, - GasType: GasType_GAS_TYPE_FIXED, GasParams: &MsgGasParams_FixedType{FixedType: &MsgGasParams_FixedGasParams{FixedGas: gas}}, } } @@ -37,7 +39,6 @@ func NewMsgGasParamsWithFixedGas(msgTypeUrl string, gas uint64) *MsgGasParams { func NewMsgGasParamsWithDynamicGas(msgTypeUrl string, gasFixed, gasPerItem uint64) *MsgGasParams { return &MsgGasParams{ MsgTypeUrl: msgTypeUrl, - GasType: GasType_GAS_TYPE_DYNAMIC, GasParams: &MsgGasParams_DynamicType{DynamicType: &MsgGasParams_DynamicGasParams{ FixedGas: gasFixed, GasPerItem: gasPerItem, @@ -47,11 +48,12 @@ func NewMsgGasParamsWithDynamicGas(msgTypeUrl string, gasFixed, gasPerItem uint6 // NewParams creates a new Params object func NewParams( - maxTxSize, minGasPerByte uint64, msgGasParamsSet []*MsgGasParams, + maxTxSize, minGasPerByte uint64, minGasPrice string, msgGasParamsSet []*MsgGasParams, ) Params { return Params{ MaxTxSize: maxTxSize, MinGasPerByte: minGasPerByte, + MinGasPrice: minGasPrice, MsgGasParamsSet: msgGasParamsSet, } } @@ -67,6 +69,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), + paramtypes.NewParamSetPair(KeyMinGasPrice, &p.MinGasPrice, validateMinGasPrice), paramtypes.NewParamSetPair(KeyMsgGasParamsSet, &p.MsgGasParamsSet, validateMsgGasParams), } } @@ -107,6 +110,10 @@ func DefaultParams() Params { NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgRejectSealObject", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgSealObject", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgUpdateGroupMember", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreatePaymentAccount", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeposit", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgWithdraw", 1e5), + NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDisableRefund", 1e5), NewMsgGasParamsWithDynamicGas("/cosmos.authz.v1beta1.MsgGrant", 1e5, 1e5), NewMsgGasParamsWithDynamicGas("/cosmos.bank.v1beta1.MsgMultiSend", 1e5, 1e5), NewMsgGasParamsWithDynamicGas("/cosmos.feegrant.v1beta1.MsgGrantAllowance", 1e5, 1e5), @@ -114,6 +121,7 @@ func DefaultParams() Params { return Params{ MaxTxSize: DefaultMaxTxSize, MinGasPerByte: DefaultMinGasPerByte, + MinGasPrice: DefaultMinGasPrice, MsgGasParamsSet: defaultMsgGasParamsSet, } } @@ -150,6 +158,20 @@ func validateMinGasPerByte(i interface{}) error { return nil } +func validateMinGasPrice(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + gp, err := sdk.ParseCoinNormalized(v) + if err != nil || gp.Amount.IsZero() || gp.Amount.IsNil() { + return fmt.Errorf("invalid gas price") + } + + return nil +} + func validateMsgGasParams(i interface{}) error { v, ok := i.([]*MsgGasParams) if !ok { @@ -184,6 +206,9 @@ func (p Params) Validate() error { if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { return err } + if err := validateMinGasPrice(p.MinGasPrice); err != nil { + return err + } if err := validateMsgGasParams(p.MsgGasParamsSet); err != nil { return err } diff --git a/x/gashub/types/tx.pb.go b/x/gashub/types/tx.pb.go index c8efcc4319..8441afbad9 100644 --- a/x/gashub/types/tx.pb.go +++ b/x/gashub/types/tx.pb.go @@ -32,10 +32,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgUpdateMsgGasParams represents a message to update msg gas params. type MsgUpdateMsgGasParams struct { - From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` - // the params is for a new msg type or existed msg type - IsNew bool `protobuf:"varint,2,opt,name=is_new,json=isNew,proto3" json:"is_new,omitempty"` - NewParams *MsgGasParams `protobuf:"bytes,3,opt,name=new_params,json=newParams,proto3" json:"new_params,omitempty"` + From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + NewParams *MsgGasParams `protobuf:"bytes,2,opt,name=new_params,json=newParams,proto3" json:"new_params,omitempty"` } func (m *MsgUpdateMsgGasParams) Reset() { *m = MsgUpdateMsgGasParams{} } @@ -116,30 +114,28 @@ func init() { func init() { proto.RegisterFile("cosmos/gashub/v1alpha1/tx.proto", fileDescriptor_08053c9491c72816) } var fileDescriptor_08053c9491c72816 = []byte{ - // 354 bytes of a gzipped FileDescriptorProto + // 331 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0x28, 0xd0, 0x83, 0x28, 0xd0, 0x83, 0x29, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2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7c, 0x83, 0x16, 0x5b, 0x71, 0x6a, 0x5e, 0x4a, 0x6a, 0x91, 0x92, - 0x3c, 0x97, 0x2c, 0x56, 0x77, 0x07, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x1a, 0x35, 0x32, - 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x55, 0x71, 0x09, 0x61, 0xf1, 0x9d, 0x2e, 0x1e, 0x47, 0x60, - 0x2a, 0x97, 0x32, 0x25, 0x49, 0x39, 0xcc, 0x0d, 0x4e, 0xae, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, - 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, - 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9d, 0x9e, 0x59, 0x02, 0x32, 0x28, 0x39, 0x3f, 0x17, 0x1a, 0x53, - 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x16, 0xd1, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, - 0x6c, 0xe0, 0xb8, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x04, 0x69, 0x4a, 0xf1, 0x55, 0x02, - 0x00, 0x00, + 0x56, 0x25, 0xe4, 0xcc, 0xc5, 0x95, 0x97, 0x5a, 0x1e, 0x5f, 0x00, 0xd6, 0x2b, 0xc1, 0xa4, 0xc0, + 0xa8, 0xc1, 0x6d, 0xa4, 0xa2, 0x87, 0xdd, 0x8f, 0x7a, 0xc8, 0xf6, 0x04, 0x71, 0xe6, 0xa5, 0x96, + 0x43, 0x98, 0x56, 0xc2, 0x1d, 0x0b, 0xe4, 0x19, 0x5e, 0x2c, 0x90, 0x67, 0x68, 0x7a, 0xbe, 0x41, + 0x8b, 0xad, 0x38, 0x35, 0x2f, 0x25, 0xb5, 0x48, 0x49, 0x9e, 0x4b, 0x16, 0xab, 0x03, 0x83, 0x52, + 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x8d, 0x1a, 0x19, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0xaa, + 0xb8, 0x84, 0xb0, 0x78, 0x43, 0x17, 0x8f, 0x23, 0x30, 0x95, 0x4b, 0x99, 0x92, 0xa4, 0x1c, 0xe6, + 0x06, 0x27, 0xd7, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, + 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4e, 0xcf, + 0x2c, 0x01, 0x19, 0x94, 0x9c, 0x9f, 0x0b, 0x8d, 0x12, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, + 0x01, 0x8b, 0xd1, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xa4, 0x18, 0x03, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x93, 0x84, 0xee, 0x02, 0x3e, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -254,17 +250,7 @@ func (m *MsgUpdateMsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - if m.IsNew { - i-- - if m.IsNew { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } if len(m.From) > 0 { i -= len(m.From) @@ -320,9 +306,6 @@ func (m *MsgUpdateMsgGasParams) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.IsNew { - n += 2 - } if m.NewParams != nil { l = m.NewParams.Size() n += 1 + l + sovTx(uint64(l)) @@ -407,26 +390,6 @@ func (m *MsgUpdateMsgGasParams) Unmarshal(dAtA []byte) error { m.From = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsNew", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsNew = bool(v != 0) - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType) } From 9b7ca1ebf5c8be3e5b5a175a7fa8cde21eda615e Mon Sep 17 00:00:00 2001 From: Roshan Date: Tue, 14 Feb 2023 17:22:49 +0800 Subject: [PATCH 07/13] revert min gas price config --- proto/cosmos/gashub/v1alpha1/gashub.proto | 3 +- x/auth/ante/ante.go | 3 +- x/auth/ante/fee.go | 8 +- x/auth/ante/fee_test.go | 6 +- x/auth/ante/feegrant_test.go | 2 +- x/auth/ante/validator_tx_fee.go | 8 +- x/gashub/simulation/genesis.go | 16 +-- x/gashub/simulation/genesis_test.go | 3 +- x/gashub/types/gashub.pb.go | 120 ++++++---------------- x/gashub/types/params.go | 25 +---- 10 files changed, 48 insertions(+), 146 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 1e28f5cfa3..dce47ed3e7 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -12,9 +12,8 @@ message Params { uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; - string min_gas_price = 3 [(gogoproto.customname) = "MinGasPrice"]; - repeated MsgGasParams msg_gas_params_set = 4 [(gogoproto.customname) = "MsgGasParamsSet"]; + repeated MsgGasParams msg_gas_params_set = 3 [(gogoproto.customname) = "MsgGasParamsSet"]; } // MsgGasParams defines gas for a msg type diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go index c2ed116bd3..a562e67ee3 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -16,7 +16,6 @@ type HandlerOptions struct { FeegrantKeeper FeegrantKeeper SignModeHandler authsigning.SignModeHandler SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error - GashubKeeper GashubKeeper TxFeeChecker TxFeeChecker } @@ -43,7 +42,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { NewTxTimeoutHeightDecorator(), NewValidateMemoDecorator(options.AccountKeeper), NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.GashubKeeper, options.TxFeeChecker), + NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators NewValidateSigCountDecorator(options.AccountKeeper), NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 2f29e64ef4..4ab9dda9ee 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -10,7 +10,7 @@ import ( // TxFeeChecker check if the provided fee is enough and returns the effective fee and tx priority, // the effective fee should be deducted later, and the priority should be returned in abci response. -type TxFeeChecker func(ctx sdk.Context, ghk GashubKeeper, tx sdk.Tx) (sdk.Coins, int64, error) +type TxFeeChecker func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) // DeductFeeDecorator deducts fees from the first signer of the tx // If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error @@ -21,10 +21,9 @@ type DeductFeeDecorator struct { bankKeeper types.BankKeeper feegrantKeeper FeegrantKeeper txFeeChecker TxFeeChecker - gashubKeeper GashubKeeper } -func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, ghk GashubKeeper, tfc TxFeeChecker) DeductFeeDecorator { +func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, tfc TxFeeChecker) DeductFeeDecorator { if tfc == nil { tfc = checkTxFeeWithValidatorMinGasPrices } @@ -34,7 +33,6 @@ func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKee bankKeeper: bk, feegrantKeeper: fk, txFeeChecker: tfc, - gashubKeeper: ghk, } } @@ -55,7 +53,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo fee := feeTx.GetFee() if !simulate { - fee, priority, err = dfd.txFeeChecker(ctx, dfd.gashubKeeper, tx) + fee, priority, err = dfd.txFeeChecker(ctx, tx) if err != nil { return ctx, err } diff --git a/x/auth/ante/fee_test.go b/x/auth/ante/fee_test.go index d4cb2c1f9d..e1f46db510 100644 --- a/x/auth/ante/fee_test.go +++ b/x/auth/ante/fee_test.go @@ -12,7 +12,7 @@ func (s *AnteTestSuite) TestDeductFeeDecorator_ZeroGas() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.GashubKeeper, nil) + mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, nil) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -46,7 +46,7 @@ func (s *AnteTestSuite) TestEnsureMempoolFees() { s.SetupTest(true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.GashubKeeper, nil) + mfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, nil) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses @@ -130,7 +130,7 @@ func (s *AnteTestSuite) TestDeductFees() { err = testutil.FundAccount(s.app.BankKeeper, s.ctx, addr1, coins) s.Require().NoError(err) - dfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, nil, s.app.GashubKeeper, nil) + dfd := ante.NewDeductFeeDecorator(s.app.AccountKeeper, s.app.BankKeeper, nil, nil) antehandler := sdk.ChainAnteDecorators(dfd) _, err = antehandler(s.ctx, tx, false) diff --git a/x/auth/ante/feegrant_test.go b/x/auth/ante/feegrant_test.go index 5bdd1c19b7..be1a4f1d29 100644 --- a/x/auth/ante/feegrant_test.go +++ b/x/auth/ante/feegrant_test.go @@ -32,7 +32,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(app.InterfaceRegistry()), tx.DefaultSignModes) // this just tests our handler - dfd := ante.NewDeductFeeDecorator(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.GashubKeeper, nil) + dfd := ante.NewDeductFeeDecorator(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, nil) feeAnteHandler := sdk.ChainAnteDecorators(dfd) // this tests the whole stack diff --git a/x/auth/ante/validator_tx_fee.go b/x/auth/ante/validator_tx_fee.go index 8d49c6fcdd..dbb1398880 100644 --- a/x/auth/ante/validator_tx_fee.go +++ b/x/auth/ante/validator_tx_fee.go @@ -9,7 +9,7 @@ import ( // checkTxFeeWithValidatorMinGasPrices implements the default fee logic, where the minimum price per // unit of gas is fixed and set by each validator, can the tx priority is computed from the gas price. -func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, ghk GashubKeeper, tx sdk.Tx) (sdk.Coins, int64, error) { +func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { feeTx, ok := tx.(sdk.FeeTx) if !ok { return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") @@ -40,15 +40,15 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, ghk GashubKeeper, tx s } } - priority := GetTxPriority(feeCoins, int64(gas)) + priority := getTxPriority(feeCoins, int64(gas)) return feeCoins, priority, nil } -// GetTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price +// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price // provided in a transaction. // NOTE: This implementation should be used with a great consideration as it opens potential attack vectors // where txs with multiple coins could not be prioritize as expected. -func GetTxPriority(fee sdk.Coins, gas int64) int64 { +func getTxPriority(fee sdk.Coins, gas int64) int64 { var priority int64 for _, c := range fee { p := int64(math.MaxInt64) diff --git a/x/gashub/simulation/genesis.go b/x/gashub/simulation/genesis.go index d72766e52d..7312d9da68 100644 --- a/x/gashub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -3,7 +3,6 @@ package simulation import ( "fmt" "math/rand" - "strconv" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/simulation" @@ -15,7 +14,6 @@ import ( const ( MaxTxSize = "max_tx_size" MinGasPerByte = "min_gas_per_byte" - MinGasPrice = "min_gas_price" MsgGas = "msg_gas" ) @@ -29,12 +27,6 @@ func GenMinGasPerByte(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 5, 50)) } -// GenMinGasPrice randomized MinGasPrice -func GenMinGasPrice(r *rand.Rand) string { - amount := simulation.RandIntBetween(r, 1, 10) - return strconv.FormatInt(int64(amount), 10) + "gweibnb" -} - // GenMsgGasParams randomized msg gas consumption func GenMsgGasParams(r *rand.Rand) *types.MsgGasParams { msgTypeUrl := simulation.RandStringOfLength(r, 12) @@ -56,19 +48,13 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { minGasPerByte = GenMinGasPerByte(r) }, ) - var minGasPrice string - simState.AppParams.GetOrGenerate( - simState.Cdc, MinGasPrice, &minGasPrice, simState.Rand, - func(r *rand.Rand) { minGasPrice = GenMinGasPrice(r) }, - ) - var msgGasParams *types.MsgGasParams simState.AppParams.GetOrGenerate( simState.Cdc, MsgGas, &msgGasParams, simState.Rand, func(r *rand.Rand) { msgGasParams = GenMsgGasParams(r) }, ) - params := types.NewParams(maxTxSize, minGasPerByte, minGasPrice, []*types.MsgGasParams{msgGasParams}) + params := types.NewParams(maxTxSize, minGasPerByte, []*types.MsgGasParams{msgGasParams}) gashubGenesis := types.NewGenesisState(params) diff --git a/x/gashub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go index 6318ee5870..88078bf785 100644 --- a/x/gashub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -42,8 +42,7 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) require.Equal(t, uint64(36), gashubGenesis.Params.MinGasPerByte) - require.Equal(t, "7gweibnb", gashubGenesis.Params.MinGasPrice) gas := gashubGenesis.Params.MsgGasParamsSet[0].GasParams.(*types.MsgGasParams_FixedType) - require.Equal(t, uint64(4828162), gas.FixedType.FixedGas) + require.Equal(t, uint64(4978511), gas.FixedType.FixedGas) } diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index 7f2734ea06..f59f92c25e 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -27,8 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` - MinGasPrice string `protobuf:"bytes,3,opt,name=min_gas_price,json=minGasPrice,proto3" json:"min_gas_price,omitempty"` - MsgGasParamsSet []*MsgGasParams `protobuf:"bytes,4,rep,name=msg_gas_params_set,json=msgGasParamsSet,proto3" json:"msg_gas_params_set,omitempty"` + MsgGasParamsSet []*MsgGasParams `protobuf:"bytes,3,rep,name=msg_gas_params_set,json=msgGasParamsSet,proto3" json:"msg_gas_params_set,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -77,13 +76,6 @@ func (m *Params) GetMinGasPerByte() uint64 { return 0 } -func (m *Params) GetMinGasPrice() string { - if m != nil { - return m.MinGasPrice - } - return "" -} - func (m *Params) GetMsgGasParamsSet() []*MsgGasParams { if m != nil { return m.MsgGasParamsSet @@ -298,39 +290,37 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 497 bytes of a gzipped FileDescriptorProto + // 472 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0x8e, 0x9b, 0xa8, 0x4a, 0x9e, 0x9d, 0xa6, 0x1c, 0x08, 0x45, 0x19, 0xec, 0xa8, 0x30, 0x04, - 0xa1, 0xda, 0xb4, 0x11, 0x4b, 0x36, 0x2c, 0x7e, 0x0e, 0x91, 0x2a, 0x37, 0x2c, 0x5d, 0xac, 0x4b, - 0x72, 0x71, 0x2d, 0x72, 0xb1, 0xe5, 0xbb, 0x20, 0xbb, 0x7f, 0x05, 0x23, 0x62, 0xea, 0x9f, 0xc2, - 0xc8, 0xd8, 0x91, 0xc9, 0x42, 0xce, 0xc2, 0x9f, 0x81, 0xee, 0xce, 0x4e, 0x53, 0xc4, 0x50, 0x16, - 0xfb, 0xbd, 0xa7, 0xef, 0xfb, 0xde, 0xbb, 0x4f, 0xef, 0xc1, 0x93, 0x59, 0xc4, 0x68, 0xc4, 0x9c, - 0x00, 0xb3, 0xcb, 0xf5, 0xd4, 0xf9, 0x7c, 0x82, 0x97, 0xf1, 0x25, 0x3e, 0x29, 0x73, 0x3b, 0x4e, - 0x22, 0x1e, 0xa1, 0xc7, 0x0a, 0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41, 0x7b, 0x5e, + 0x45, 0xc3, 0x2d, 0xa9, 0xdb, 0x60, 0x05, 0x7b, 0x7f, 0x4f, 0xf9, 0x0f, 0x12, 0xa9, 0x72, 0x6d, + 0x90, 0x48, 0x10, 0x56, 0x19, 0x44, 0xa9, 0xac, 0xed, 0xf0, 0x5e, 0x10, 0x16, 0x00, 0xdd, 0xc4, + 0x7a, 0xac, 0xfe, 0xfa, 0x16, 0xc0, 0x1f, 0x8b, 0xf8, 0xaf, 0xbf, 0x95, 0xb6, 0x79, 0x53, 0xda, + 0xe6, 0x8f, 0xd2, 0x36, 0x3f, 0xaf, 0x6d, 0xe3, 0x66, 0x6d, 0x1b, 0xdf, 0xd7, 0xb6, 0x71, 0xf1, + 0x8c, 0x46, 0x42, 0xaa, 0x34, 0x8d, 0x99, 0x57, 0x3d, 0x11, 0xfd, 0x3b, 0xe2, 0xb3, 0x8f, 0x5e, + 0x56, 0xbf, 0x17, 0xa9, 0x2f, 0x9f, 0x6c, 0x2b, 0xe3, 0x9f, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, + 0x82, 0x64, 0x55, 0x0f, 0x4d, 0x03, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -358,9 +348,6 @@ func (this *Params) Equal(that interface{}) bool { if this.MinGasPerByte != that1.MinGasPerByte { return false } - if this.MinGasPrice != that1.MinGasPrice { - return false - } if len(this.MsgGasParamsSet) != len(that1.MsgGasParamsSet) { return false } @@ -534,16 +521,9 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGashub(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } } - if len(m.MinGasPrice) > 0 { - i -= len(m.MinGasPrice) - copy(dAtA[i:], m.MinGasPrice) - i = encodeVarintGashub(dAtA, i, uint64(len(m.MinGasPrice))) - i-- - dAtA[i] = 0x1a - } if m.MinGasPerByte != 0 { i = encodeVarintGashub(dAtA, i, uint64(m.MinGasPerByte)) i-- @@ -722,10 +702,6 @@ func (m *Params) Size() (n int) { if m.MinGasPerByte != 0 { n += 1 + sovGashub(uint64(m.MinGasPerByte)) } - l = len(m.MinGasPrice) - if l > 0 { - n += 1 + l + sovGashub(uint64(l)) - } if len(m.MsgGasParamsSet) > 0 { for _, e := range m.MsgGasParamsSet { l = e.Size() @@ -876,38 +852,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } } case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinGasPrice", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - 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 ErrInvalidLengthGashub - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGashub - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MinGasPrice = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MsgGasParamsSet", wireType) } diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 92af20bbef..927cef5731 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -6,7 +6,6 @@ import ( "sigs.k8s.io/yaml" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -14,14 +13,12 @@ import ( const ( DefaultMaxTxSize uint64 = 1024 DefaultMinGasPerByte uint64 = 5 - DefaultMinGasPrice string = "1gweibnb" ) // Parameter keys var ( KeyMaxTxSize = []byte("MaxTxSize") KeyMinGasPerByte = []byte("MinGasPerByte") - KeyMinGasPrice = []byte("MinGasPrice") KeyMsgGasParamsSet = []byte("MsgGasParamsSet") ) @@ -48,12 +45,11 @@ func NewMsgGasParamsWithDynamicGas(msgTypeUrl string, gasFixed, gasPerItem uint6 // NewParams creates a new Params object func NewParams( - maxTxSize, minGasPerByte uint64, minGasPrice string, msgGasParamsSet []*MsgGasParams, + maxTxSize, minGasPerByte uint64, msgGasParamsSet []*MsgGasParams, ) Params { return Params{ MaxTxSize: maxTxSize, MinGasPerByte: minGasPerByte, - MinGasPrice: minGasPrice, MsgGasParamsSet: msgGasParamsSet, } } @@ -69,7 +65,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), - paramtypes.NewParamSetPair(KeyMinGasPrice, &p.MinGasPrice, validateMinGasPrice), paramtypes.NewParamSetPair(KeyMsgGasParamsSet, &p.MsgGasParamsSet, validateMsgGasParams), } } @@ -121,7 +116,6 @@ func DefaultParams() Params { return Params{ MaxTxSize: DefaultMaxTxSize, MinGasPerByte: DefaultMinGasPerByte, - MinGasPrice: DefaultMinGasPrice, MsgGasParamsSet: defaultMsgGasParamsSet, } } @@ -158,20 +152,6 @@ func validateMinGasPerByte(i interface{}) error { return nil } -func validateMinGasPrice(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - gp, err := sdk.ParseCoinNormalized(v) - if err != nil || gp.Amount.IsZero() || gp.Amount.IsNil() { - return fmt.Errorf("invalid gas price") - } - - return nil -} - func validateMsgGasParams(i interface{}) error { v, ok := i.([]*MsgGasParams) if !ok { @@ -206,9 +186,6 @@ func (p Params) Validate() error { if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { return err } - if err := validateMinGasPrice(p.MinGasPrice); err != nil { - return err - } if err := validateMsgGasParams(p.MsgGasParamsSet); err != nil { return err } From 8a31638fdaac41a87d5ac882c90012cb387cb731 Mon Sep 17 00:00:00 2001 From: Roshan Date: Tue, 14 Feb 2023 18:50:29 +0800 Subject: [PATCH 08/13] fix some review comments --- baseapp/baseapp.go | 2 +- client/tx/tx.go | 11 ++- proto/cosmos/gashub/v1alpha1/event.proto | 3 +- x/gashub/keeper/genesis.go | 46 +++++---- x/gashub/keeper/msg_server.go | 9 +- x/gashub/types/event.pb.go | 116 +++++++++++++++++------ 6 files changed, 130 insertions(+), 57 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index c85d535190..e9f5d27328 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -645,7 +645,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re ctx := app.getContextForTx(mode, txBytes) ms := ctx.MultiStore() - gInfo.MinGasPrices = app.minGasPrices.String() + gInfo.MinGasPrices = ctx.MinGasPrices().String() // only run the tx if there is block gas remaining if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() { diff --git a/client/tx/tx.go b/client/tx/tx.go index 8530ac1832..eae408878c 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -81,13 +81,14 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error { if err != nil { return err } - fees := make(sdk.Coins, len(parsedGasPrices)) + // we only accept one type coin + gasPrice := parsedGasPrices[0] + fees := make(sdk.Coins, 1) gasLimit := sdk.NewInt(int64(adjusted)) - for i, gasPrice := range parsedGasPrices { - fee := gasPrice.Amount.Mul(gasLimit) - fees[i] = sdk.NewCoin(gasPrice.Denom, fee) - } + fee := gasPrice.Amount.Mul(gasLimit) + fees[0] = sdk.NewCoin(gasPrice.Denom, fee) + txf = txf.WithFees(fees.String()) } diff --git a/proto/cosmos/gashub/v1alpha1/event.proto b/proto/cosmos/gashub/v1alpha1/event.proto index bbcf965a7e..fd72c0969f 100644 --- a/proto/cosmos/gashub/v1alpha1/event.proto +++ b/proto/cosmos/gashub/v1alpha1/event.proto @@ -7,5 +7,6 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; // EventUpdateMsgGasParams is emitted when update a msg's gas params message EventUpdateMsgGasParams { string msg_type_url = 1; - bool is_new = 2; + string from_value = 2; + string to_value = 3; } diff --git a/x/gashub/keeper/genesis.go b/x/gashub/keeper/genesis.go index 2d5733595e..22c872dbea 100644 --- a/x/gashub/keeper/genesis.go +++ b/x/gashub/keeper/genesis.go @@ -24,29 +24,37 @@ func (ghk Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { func initGasCalculators(params types.Params) { msgGasParamsSet := params.GetMsgGasParamsSet() - // for fixed gas msgs for _, gasParams := range msgGasParamsSet { - if _, ok := gasParams.GasParams.(*types.MsgGasParams_FixedType); !ok { - continue - } msgType := gasParams.GetMsgTypeUrl() - types.RegisterCalculatorGen(msgType, func(params types.Params) types.GasCalculator { - msgGasParamsSet := params.GetMsgGasParamsSet() - for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsgTypeUrl() == msgType { - p, ok := gasParams.GasParams.(*types.MsgGasParams_FixedType) - if !ok { - panic(fmt.Errorf("unpack failed for %s", msgType)) + + switch gasParams.GasParams.(type) { + case *types.MsgGasParams_FixedType: + types.RegisterCalculatorGen(msgType, func(params types.Params) types.GasCalculator { + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsgTypeUrl() == msgType { + p, ok := gasParams.GasParams.(*types.MsgGasParams_FixedType) + if !ok { + panic(fmt.Errorf("unpack failed for %s", msgType)) + } + return types.FixedGasCalculator(p.FixedType.FixedGas) } - return types.FixedGasCalculator(p.FixedType.FixedGas) } + panic(fmt.Sprintf("no params for %s", msgType)) + }) + case *types.MsgGasParams_DynamicType: + switch msgType { + case "/cosmos.feegrant.v1beta1.MsgGrantAllowance": + types.RegisterCalculatorGen(msgType, types.MsgGrantAllowanceGasCalculatorGen) + case "/cosmos.bank.v1beta1.MsgMultiSend": + types.RegisterCalculatorGen(msgType, types.MsgMultiSendGasCalculatorGen) + case "/cosmos.authz.v1beta1.MsgGrant": + types.RegisterCalculatorGen(msgType, types.MsgGrantGasCalculatorGen) + default: + panic("unknown dynamic msg type") } - panic(fmt.Sprintf("no params for %s", msgType)) - }) + default: + panic("unknown gas consumption type") + } } - - // for dynamic gas msgs - types.RegisterCalculatorGen("/cosmos.authz.v1beta1.MsgGrant", types.MsgGrantGasCalculatorGen) - types.RegisterCalculatorGen("/cosmos.feegrant.v1beta1.MsgGrantAllowance", types.MsgGrantAllowanceGasCalculatorGen) - types.RegisterCalculatorGen("/cosmos.bank.v1beta1.MsgMultiSend", types.MsgMultiSendGasCalculatorGen) } diff --git a/x/gashub/keeper/msg_server.go b/x/gashub/keeper/msg_server.go index 4ec400c63f..670cdc1dda 100644 --- a/x/gashub/keeper/msg_server.go +++ b/x/gashub/keeper/msg_server.go @@ -36,15 +36,15 @@ func (k msgServer) UpdateMsgGasParams(goCtx context.Context, msg *types.MsgUpdat msgGasParamsSet := params.MsgGasParamsSet typeUrl := msg.NewParams.MsgTypeUrl - isNew := true + fromValue := "" for idx, msgGasParams := range msgGasParamsSet { if msgGasParams.MsgTypeUrl == typeUrl { + fromValue = msgGasParams.String() msgGasParamsSet[idx] = newMsgGasParams - isNew = false break } } - if isNew { + if fromValue == "" { params.MsgGasParamsSet = append(params.MsgGasParamsSet, newMsgGasParams) } @@ -53,7 +53,8 @@ func (k msgServer) UpdateMsgGasParams(goCtx context.Context, msg *types.MsgUpdat ctx.EventManager().EmitTypedEvent( &types.EventUpdateMsgGasParams{ MsgTypeUrl: msg.NewParams.MsgTypeUrl, - IsNew: isNew, + FromValue: fromValue, + ToValue: newMsgGasParams.String(), }, ) diff --git a/x/gashub/types/event.pb.go b/x/gashub/types/event.pb.go index 7bd1964b9f..da4d652361 100644 --- a/x/gashub/types/event.pb.go +++ b/x/gashub/types/event.pb.go @@ -25,7 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // EventUpdateMsgGasParams is emitted when update a msg's gas params type EventUpdateMsgGasParams struct { MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` - IsNew bool `protobuf:"varint,2,opt,name=is_new,json=isNew,proto3" json:"is_new,omitempty"` + FromValue string `protobuf:"bytes,2,opt,name=from_value,json=fromValue,proto3" json:"from_value,omitempty"` + ToValue string `protobuf:"bytes,3,opt,name=to_value,json=toValue,proto3" json:"to_value,omitempty"` } func (m *EventUpdateMsgGasParams) Reset() { *m = EventUpdateMsgGasParams{} } @@ -68,11 +69,18 @@ func (m *EventUpdateMsgGasParams) GetMsgTypeUrl() string { return "" } -func (m *EventUpdateMsgGasParams) GetIsNew() bool { +func (m *EventUpdateMsgGasParams) GetFromValue() string { if m != nil { - return m.IsNew + return m.FromValue } - return false + return "" +} + +func (m *EventUpdateMsgGasParams) GetToValue() string { + if m != nil { + return m.ToValue + } + return "" } func init() { @@ -84,21 +92,22 @@ func init() { } var fileDescriptor_de0e3393fe9bac86 = []byte{ - // 211 bytes of a gzipped FileDescriptorProto + // 228 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, - 0x83, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xa9, 0x51, 0x0a, 0xe2, 0x12, 0x77, 0x05, 0x29, 0x0b, + 0x83, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xa9, 0x51, 0x2a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c, 0x1c, 0x25, + 0xf9, 0x50, 0x49, 0x66, 0xb0, 0x24, 0x7b, 0x49, 0x3e, 0x58, 0xca, 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, 0x40, 0x2e, 0x4c, 0xce, 0xcf, + 0xd5, 0x87, 0xfa, 0x0b, 0x42, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x57, 0xc0, 0x3c, 0x09, 0x72, 0x55, + 0x71, 0x12, 0x1b, 0xd8, 0x73, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x13, 0xa9, 0x8f, 0x38, + 0x02, 0x01, 0x00, 0x00, } func (m *EventUpdateMsgGasParams) Marshal() (dAtA []byte, err error) { @@ -121,15 +130,19 @@ func (m *EventUpdateMsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if m.IsNew { + if len(m.ToValue) > 0 { + i -= len(m.ToValue) + copy(dAtA[i:], m.ToValue) + i = encodeVarintEvent(dAtA, i, uint64(len(m.ToValue))) i-- - if m.IsNew { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } + dAtA[i] = 0x1a + } + if len(m.FromValue) > 0 { + i -= len(m.FromValue) + copy(dAtA[i:], m.FromValue) + i = encodeVarintEvent(dAtA, i, uint64(len(m.FromValue))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } if len(m.MsgTypeUrl) > 0 { i -= len(m.MsgTypeUrl) @@ -162,8 +175,13 @@ func (m *EventUpdateMsgGasParams) Size() (n int) { if l > 0 { n += 1 + l + sovEvent(uint64(l)) } - if m.IsNew { - n += 2 + l = len(m.FromValue) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.ToValue) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) } return n } @@ -236,10 +254,42 @@ func (m *EventUpdateMsgGasParams) Unmarshal(dAtA []byte) error { m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsNew", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - var v int + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromValue = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ToValue", wireType) + } + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvent @@ -249,12 +299,24 @@ func (m *EventUpdateMsgGasParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.IsNew = bool(v != 0) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ToValue = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvent(dAtA[iNdEx:]) From 5871a3b551002d589fee15a5eece0504f9733d5a Mon Sep 17 00:00:00 2001 From: Roshan Date: Tue, 14 Feb 2023 21:24:38 +0800 Subject: [PATCH 09/13] fix some review comments --- proto/cosmos/gashub/v1alpha1/gashub.proto | 8 +- x/gashub/keeper/genesis.go | 64 +++-- x/gashub/keeper/keeper.go | 5 + x/gashub/keeper/msg_server.go | 6 + x/gashub/types/codec.go | 4 +- x/gashub/types/gas_calculator.go | 24 +- x/gashub/types/gashub.pb.go | 319 ++++++++++++++++++---- x/gashub/types/params.go | 49 +++- 8 files changed, 365 insertions(+), 114 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index dce47ed3e7..4d911da161 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -25,8 +25,12 @@ message MsgGasParams { oneof gas_params { // fixed_type specifies fixed type gas params. FixedGasParams fixed_type = 2; - // dynamic_type specifies dynamic type gas params. - DynamicGasParams dynamic_type = 3; + // grant_type specifies dynamic type gas params for msg/grant. + DynamicGasParams grant_type = 3; + // grant_type specifies dynamic type gas params for msg/multiSend. + DynamicGasParams multi_send_type = 4; + // grant_type specifies dynamic type gas params for msg/grantAllowance. + DynamicGasParams grant_allowance_type = 5; } // FixedGasParams defines the parameters for fixed gas type. message FixedGasParams { diff --git a/x/gashub/keeper/genesis.go b/x/gashub/keeper/genesis.go index 22c872dbea..fe7b988776 100644 --- a/x/gashub/keeper/genesis.go +++ b/x/gashub/keeper/genesis.go @@ -12,7 +12,7 @@ func (ghk Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { ghk.SetParams(ctx, data.Params) // init gas calculators from genesis data - initGasCalculators(data.Params) + registerGasCalculators(data.Params) } // ExportGenesis returns a GenesisState for a given context and keeper @@ -22,39 +22,43 @@ func (ghk Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return types.NewGenesisState(params) } -func initGasCalculators(params types.Params) { +func registerGasCalculators(params types.Params) { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - msgType := gasParams.GetMsgTypeUrl() - - switch gasParams.GasParams.(type) { - case *types.MsgGasParams_FixedType: - types.RegisterCalculatorGen(msgType, func(params types.Params) types.GasCalculator { - msgGasParamsSet := params.GetMsgGasParamsSet() - for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsgTypeUrl() == msgType { - p, ok := gasParams.GasParams.(*types.MsgGasParams_FixedType) - if !ok { - panic(fmt.Errorf("unpack failed for %s", msgType)) - } - return types.FixedGasCalculator(p.FixedType.FixedGas) + err := registerGasCalculator(gasParams) + if err != nil { + panic(err) + } + } +} + +func registerGasCalculator(gasParams *types.MsgGasParams) error { + msgType := gasParams.GetMsgTypeUrl() + + switch gasParams.GasParams.(type) { + case *types.MsgGasParams_FixedType: + types.RegisterCalculatorGen(msgType, func(params types.Params) types.GasCalculator { + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsgTypeUrl() == msgType { + p := gasParams.GetFixedType() + if p == nil { + panic(fmt.Errorf("get msg gas params failed for %s", msgType)) } + return types.FixedGasCalculator(p.FixedGas) } - panic(fmt.Sprintf("no params for %s", msgType)) - }) - case *types.MsgGasParams_DynamicType: - switch msgType { - case "/cosmos.feegrant.v1beta1.MsgGrantAllowance": - types.RegisterCalculatorGen(msgType, types.MsgGrantAllowanceGasCalculatorGen) - case "/cosmos.bank.v1beta1.MsgMultiSend": - types.RegisterCalculatorGen(msgType, types.MsgMultiSendGasCalculatorGen) - case "/cosmos.authz.v1beta1.MsgGrant": - types.RegisterCalculatorGen(msgType, types.MsgGrantGasCalculatorGen) - default: - panic("unknown dynamic msg type") } - default: - panic("unknown gas consumption type") - } + panic(fmt.Sprintf("no params for %s", msgType)) + }) + case *types.MsgGasParams_GrantType: + types.RegisterCalculatorGen(msgType, types.MsgGrantGasCalculatorGen) + case *types.MsgGasParams_MultiSendType: + types.RegisterCalculatorGen(msgType, types.MsgMultiSendGasCalculatorGen) + case *types.MsgGasParams_GrantAllowanceType: + types.RegisterCalculatorGen(msgType, types.MsgGrantAllowanceGasCalculatorGen) + default: + return fmt.Errorf("unknown gas params type") } + + return nil } diff --git a/x/gashub/keeper/keeper.go b/x/gashub/keeper/keeper.go index 8e227390e1..f441391616 100644 --- a/x/gashub/keeper/keeper.go +++ b/x/gashub/keeper/keeper.go @@ -41,3 +41,8 @@ func (ghk Keeper) Logger(ctx sdk.Context) log.Logger { // GetCodec return codec.Codec object used by the keeper func (ghk Keeper) GetCodec() codec.BinaryCodec { return ghk.cdc } + +func (ghk Keeper) RegisterGasCalculators(ctx sdk.Context) { + params := ghk.GetParams(ctx) + registerGasCalculators(params) +} diff --git a/x/gashub/keeper/msg_server.go b/x/gashub/keeper/msg_server.go index 670cdc1dda..f46e3a6f8c 100644 --- a/x/gashub/keeper/msg_server.go +++ b/x/gashub/keeper/msg_server.go @@ -44,8 +44,14 @@ func (k msgServer) UpdateMsgGasParams(goCtx context.Context, msg *types.MsgUpdat break } } + + // for new msg gas type, add it to params and register gas calculator if fromValue == "" { params.MsgGasParamsSet = append(params.MsgGasParamsSet, newMsgGasParams) + err := registerGasCalculator(newMsgGasParams) + if err != nil { + return nil, err + } } k.SetParams(ctx, params) diff --git a/x/gashub/types/codec.go b/x/gashub/types/codec.go index 30df08ac68..aa8d17c550 100644 --- a/x/gashub/types/codec.go +++ b/x/gashub/types/codec.go @@ -15,7 +15,9 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*isMsgGasParams_GasParams)(nil), nil) cdc.RegisterConcrete(&MsgGasParams_FixedType{}, "cosmos-sdk/MsgGasParams/FixedType", nil) - cdc.RegisterConcrete(&MsgGasParams_DynamicType{}, "cosmos-sdk/MsgGasParams/DynamicType", nil) + cdc.RegisterConcrete(&MsgGasParams_GrantType{}, "cosmos-sdk/MsgGasParams/GrantType", nil) + cdc.RegisterConcrete(&MsgGasParams_MultiSendType{}, "cosmos-sdk/MsgGasParams/MultiSendType", nil) + cdc.RegisterConcrete(&MsgGasParams_GrantAllowanceType{}, "cosmos-sdk/MsgGasParams/GrantAllowanceType", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 8c480c53f3..4d26491f75 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -103,12 +103,8 @@ func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { var MsgGrantGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsgTypeUrl() == "/cosmos.authz.v1beta1.MsgGrant" { - p, ok := gasParams.GasParams.(*MsgGasParams_DynamicType) - if !ok { - panic("type conversion failed for /cosmos.authz.v1beta1.MsgGrant") - } - return GrantCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) + if p := gasParams.GetGrantType(); p != nil { + return GrantCalculator(p.FixedGas, p.GasPerItem) } } panic("no params for /cosmos.authz.v1beta1.MsgGrant") @@ -117,12 +113,8 @@ var MsgGrantGasCalculatorGen = func(params Params) GasCalculator { var MsgMultiSendGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsgTypeUrl() == "/cosmos.bank.v1beta1.MsgMultiSend" { - p, ok := gasParams.GasParams.(*MsgGasParams_DynamicType) - if !ok { - panic("type conversion failed for /cosmos.bank.v1beta1.MsgMultiSend") - } - return MultiSendCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) + if p := gasParams.GetMultiSendType(); p != nil { + return MultiSendCalculator(p.FixedGas, p.GasPerItem) } } panic("no params for /cosmos.bank.v1beta1.MsgMultiSend") @@ -131,12 +123,8 @@ var MsgMultiSendGasCalculatorGen = func(params Params) GasCalculator { var MsgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsgTypeUrl() == "/cosmos.feegrant.v1beta1.MsgGrantAllowance" { - p, ok := gasParams.GasParams.(*MsgGasParams_DynamicType) - if !ok { - panic("type conversion failed for /cosmos.feegrant.v1beta1.MsgGrantAllowance") - } - return GrantAllowanceCalculator(p.DynamicType.FixedGas, p.DynamicType.GasPerItem) + if p := gasParams.GetGrantAllowanceType(); p != nil { + return GrantAllowanceCalculator(p.FixedGas, p.GasPerItem) } } panic("no params for /cosmos.feegrant.v1beta1.MsgGrantAllowance") diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index f59f92c25e..e44e8b6e98 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -90,7 +90,9 @@ type MsgGasParams struct { // // Types that are valid to be assigned to GasParams: // *MsgGasParams_FixedType - // *MsgGasParams_DynamicType + // *MsgGasParams_GrantType + // *MsgGasParams_MultiSendType + // *MsgGasParams_GrantAllowanceType GasParams isMsgGasParams_GasParams `protobuf_oneof:"gas_params"` } @@ -137,12 +139,20 @@ type isMsgGasParams_GasParams interface { type MsgGasParams_FixedType struct { FixedType *MsgGasParams_FixedGasParams `protobuf:"bytes,2,opt,name=fixed_type,json=fixedType,proto3,oneof" json:"fixed_type,omitempty"` } -type MsgGasParams_DynamicType struct { - DynamicType *MsgGasParams_DynamicGasParams `protobuf:"bytes,3,opt,name=dynamic_type,json=dynamicType,proto3,oneof" json:"dynamic_type,omitempty"` +type MsgGasParams_GrantType struct { + GrantType *MsgGasParams_DynamicGasParams `protobuf:"bytes,3,opt,name=grant_type,json=grantType,proto3,oneof" json:"grant_type,omitempty"` +} +type MsgGasParams_MultiSendType struct { + MultiSendType *MsgGasParams_DynamicGasParams `protobuf:"bytes,4,opt,name=multi_send_type,json=multiSendType,proto3,oneof" json:"multi_send_type,omitempty"` +} +type MsgGasParams_GrantAllowanceType struct { + GrantAllowanceType *MsgGasParams_DynamicGasParams `protobuf:"bytes,5,opt,name=grant_allowance_type,json=grantAllowanceType,proto3,oneof" json:"grant_allowance_type,omitempty"` } -func (*MsgGasParams_FixedType) isMsgGasParams_GasParams() {} -func (*MsgGasParams_DynamicType) isMsgGasParams_GasParams() {} +func (*MsgGasParams_FixedType) isMsgGasParams_GasParams() {} +func (*MsgGasParams_GrantType) isMsgGasParams_GasParams() {} +func (*MsgGasParams_MultiSendType) isMsgGasParams_GasParams() {} +func (*MsgGasParams_GrantAllowanceType) isMsgGasParams_GasParams() {} func (m *MsgGasParams) GetGasParams() isMsgGasParams_GasParams { if m != nil { @@ -165,9 +175,23 @@ func (m *MsgGasParams) GetFixedType() *MsgGasParams_FixedGasParams { return nil } -func (m *MsgGasParams) GetDynamicType() *MsgGasParams_DynamicGasParams { - if x, ok := m.GetGasParams().(*MsgGasParams_DynamicType); ok { - return x.DynamicType +func (m *MsgGasParams) GetGrantType() *MsgGasParams_DynamicGasParams { + if x, ok := m.GetGasParams().(*MsgGasParams_GrantType); ok { + return x.GrantType + } + return nil +} + +func (m *MsgGasParams) GetMultiSendType() *MsgGasParams_DynamicGasParams { + if x, ok := m.GetGasParams().(*MsgGasParams_MultiSendType); ok { + return x.MultiSendType + } + return nil +} + +func (m *MsgGasParams) GetGrantAllowanceType() *MsgGasParams_DynamicGasParams { + if x, ok := m.GetGasParams().(*MsgGasParams_GrantAllowanceType); ok { + return x.GrantAllowanceType } return nil } @@ -176,7 +200,9 @@ func (m *MsgGasParams) GetDynamicType() *MsgGasParams_DynamicGasParams { func (*MsgGasParams) XXX_OneofWrappers() []interface{} { return []interface{}{ (*MsgGasParams_FixedType)(nil), - (*MsgGasParams_DynamicType)(nil), + (*MsgGasParams_GrantType)(nil), + (*MsgGasParams_MultiSendType)(nil), + (*MsgGasParams_GrantAllowanceType)(nil), } } @@ -290,37 +316,40 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 472 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0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xdb, 0x60, 0x05, 0x7b, 0x7f, 0x4f, 0xf9, 0x0f, 0x12, 0xa9, 0x72, 0x6d, - 0x90, 0x48, 0x10, 0x56, 0x19, 0x44, 0xa9, 0xac, 0xed, 0xf0, 0x5e, 0x10, 0x16, 0x00, 0xdd, 0xc4, - 0x7a, 0xac, 0xfe, 0xfa, 0x16, 0xc0, 0x1f, 0x8b, 0xf8, 0xaf, 0xbf, 0x95, 0xb6, 0x79, 0x53, 0xda, - 0xe6, 0x8f, 0xd2, 0x36, 0x3f, 0xaf, 0x6d, 0xe3, 0x66, 0x6d, 0x1b, 0xdf, 0xd7, 0xb6, 0x71, 0xf1, - 0x8c, 0x46, 0x42, 0xaa, 0x34, 0x8d, 0x99, 0x57, 0x3d, 0x11, 0xfd, 0x3b, 0xe2, 0xb3, 0x8f, 0x5e, - 0x56, 0xbf, 0x17, 0xa9, 0x2f, 0x9f, 0x6c, 0x2b, 0xe3, 0x9f, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, - 0x82, 0x64, 0x55, 0x0f, 0x4d, 0x03, 0x00, 0x00, + // 521 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6f, 0xda, 0x4c, + 0x10, 0xc6, 0xf1, 0x0b, 0x89, 0x60, 0x80, 0x90, 0x77, 0x1b, 0x55, 0x88, 0x83, 0x1d, 0xa5, 0x3d, + 0xa4, 0xaa, 0x02, 0x4d, 0xa2, 0x5e, 0xb8, 0xc5, 0xea, 0xdf, 0x03, 0x52, 0x64, 0x68, 0x0f, 0xbd, + 0x58, 0x0b, 0x59, 0x36, 0xab, 0x7a, 0x6d, 0xe4, 0x5d, 0x5a, 0x93, 0x4f, 0xd0, 0x63, 0x8f, 0x3d, + 0xe6, 0xe3, 0xf4, 0x98, 0x63, 0x4f, 0x56, 0x65, 0x54, 0xa9, 0x1f, 0xa3, 0xda, 0x5d, 0x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f5, 0x6b, 0x49, 0xb8, 0x07, 0x74, 0x15, 0x9b, + 0xb2, 0xe6, 0xd7, 0x6d, 0x00, 0xfc, 0xb6, 0xba, 0xfb, 0xfc, 0x6b, 0x66, 0x5b, 0x37, 0x99, 0x6d, + 0x7d, 0xcf, 0x6c, 0xeb, 0xf3, 0xd2, 0x2e, 0xdd, 0x2c, 0xed, 0xd2, 0xb7, 0xa5, 0x5d, 0x7a, 0xf7, + 0x98, 0x32, 0xa9, 0x86, 0x35, 0x89, 0x78, 0x2f, 0x5f, 0x75, 0xf3, 0x77, 0x24, 0x2e, 0xde, 0xf7, + 0x92, 0x62, 0xef, 0xd5, 0x98, 0xc5, 0x78, 0x5b, 0x2f, 0xf0, 0xe9, 0xaf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xce, 0xaf, 0x02, 0x3e, 0x15, 0x04, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -415,14 +444,38 @@ func (this *MsgGasParams_FixedType) Equal(that interface{}) bool { } return true } -func (this *MsgGasParams_DynamicType) Equal(that interface{}) bool { +func (this *MsgGasParams_GrantType) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgGasParams_GrantType) + if !ok { + that2, ok := that.(MsgGasParams_GrantType) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.GrantType.Equal(that1.GrantType) { + return false + } + return true +} +func (this *MsgGasParams_MultiSendType) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*MsgGasParams_DynamicType) + that1, ok := that.(*MsgGasParams_MultiSendType) if !ok { - that2, ok := that.(MsgGasParams_DynamicType) + that2, ok := that.(MsgGasParams_MultiSendType) if ok { that1 = &that2 } else { @@ -434,7 +487,31 @@ func (this *MsgGasParams_DynamicType) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.DynamicType.Equal(that1.DynamicType) { + if !this.MultiSendType.Equal(that1.MultiSendType) { + return false + } + return true +} +func (this *MsgGasParams_GrantAllowanceType) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgGasParams_GrantAllowanceType) + if !ok { + that2, ok := that.(MsgGasParams_GrantAllowanceType) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.GrantAllowanceType.Equal(that1.GrantAllowanceType) { return false } return true @@ -597,16 +674,16 @@ func (m *MsgGasParams_FixedType) MarshalToSizedBuffer(dAtA []byte) (int, error) } return len(dAtA) - i, nil } -func (m *MsgGasParams_DynamicType) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgGasParams_GrantType) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgGasParams_DynamicType) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgGasParams_GrantType) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - if m.DynamicType != nil { + if m.GrantType != nil { { - size, err := m.DynamicType.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.GrantType.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -618,6 +695,48 @@ func (m *MsgGasParams_DynamicType) MarshalToSizedBuffer(dAtA []byte) (int, error } return len(dAtA) - i, nil } +func (m *MsgGasParams_MultiSendType) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGasParams_MultiSendType) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.MultiSendType != nil { + { + size, err := m.MultiSendType.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGashub(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *MsgGasParams_GrantAllowanceType) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGasParams_GrantAllowanceType) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.GrantAllowanceType != nil { + { + size, err := m.GrantAllowanceType.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGashub(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + return len(dAtA) - i, nil +} func (m *MsgGasParams_FixedGasParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -739,14 +858,38 @@ func (m *MsgGasParams_FixedType) Size() (n int) { } return n } -func (m *MsgGasParams_DynamicType) Size() (n int) { +func (m *MsgGasParams_GrantType) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GrantType != nil { + l = m.GrantType.Size() + n += 1 + l + sovGashub(uint64(l)) + } + return n +} +func (m *MsgGasParams_MultiSendType) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.DynamicType != nil { - l = m.DynamicType.Size() + if m.MultiSendType != nil { + l = m.MultiSendType.Size() + n += 1 + l + sovGashub(uint64(l)) + } + return n +} +func (m *MsgGasParams_GrantAllowanceType) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GrantAllowanceType != nil { + l = m.GrantAllowanceType.Size() n += 1 + l + sovGashub(uint64(l)) } return n @@ -1004,7 +1147,77 @@ func (m *MsgGasParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DynamicType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GrantType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGashub + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGashub + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MsgGasParams_DynamicGasParams{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.GasParams = &MsgGasParams_GrantType{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MultiSendType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGashub + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGashub + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MsgGasParams_DynamicGasParams{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.GasParams = &MsgGasParams_MultiSendType{v} + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GrantAllowanceType", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1035,7 +1248,7 @@ func (m *MsgGasParams) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.GasParams = &MsgGasParams_DynamicType{v} + m.GasParams = &MsgGasParams_GrantAllowanceType{v} iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 927cef5731..9ca73d49c3 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -33,13 +33,10 @@ func NewMsgGasParamsWithFixedGas(msgTypeUrl string, gas uint64) *MsgGasParams { } // NewMsgGasParamsWithDynamicGas creates a new MsgGasParams object with dynamic gas -func NewMsgGasParamsWithDynamicGas(msgTypeUrl string, gasFixed, gasPerItem uint64) *MsgGasParams { +func NewMsgGasParamsWithDynamicGas(msgTypeUrl string, msgGasParams isMsgGasParams_GasParams) *MsgGasParams { return &MsgGasParams{ MsgTypeUrl: msgTypeUrl, - GasParams: &MsgGasParams_DynamicType{DynamicType: &MsgGasParams_DynamicGasParams{ - FixedGas: gasFixed, - GasPerItem: gasPerItem, - }}, + GasParams: msgGasParams, } } @@ -109,9 +106,33 @@ func DefaultParams() Params { NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeposit", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgWithdraw", 1e5), NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDisableRefund", 1e5), - NewMsgGasParamsWithDynamicGas("/cosmos.authz.v1beta1.MsgGrant", 1e5, 1e5), - NewMsgGasParamsWithDynamicGas("/cosmos.bank.v1beta1.MsgMultiSend", 1e5, 1e5), - NewMsgGasParamsWithDynamicGas("/cosmos.feegrant.v1beta1.MsgGrantAllowance", 1e5, 1e5), + NewMsgGasParamsWithDynamicGas( + "/cosmos.authz.v1beta1.MsgGrant", + &MsgGasParams_GrantType{ + GrantType: &MsgGasParams_DynamicGasParams{ + FixedGas: 1e5, + GasPerItem: 1e5, + }, + }, + ), + NewMsgGasParamsWithDynamicGas( + "/cosmos.bank.v1beta1.MsgMultiSend", + &MsgGasParams_MultiSendType{ + MultiSendType: &MsgGasParams_DynamicGasParams{ + FixedGas: 1e5, + GasPerItem: 1e5, + }, + }, + ), + NewMsgGasParamsWithDynamicGas( + "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + &MsgGasParams_GrantAllowanceType{ + GrantAllowanceType: &MsgGasParams_DynamicGasParams{ + FixedGas: 1e5, + GasPerItem: 1e5, + }, + }, + ), } return Params{ MaxTxSize: DefaultMaxTxSize, @@ -166,8 +187,16 @@ func validateMsgGasParams(i interface{}) error { if p.FixedType.FixedGas == 0 { return fmt.Errorf("invalid gas. cannot be zero") } - case *MsgGasParams_DynamicType: - if p.DynamicType.FixedGas == 0 || p.DynamicType.GasPerItem == 0 { + case *MsgGasParams_GrantType: + if p.GrantType.FixedGas == 0 || p.GrantType.GasPerItem == 0 { + return fmt.Errorf("invalid gas. cannot be zero") + } + case *MsgGasParams_MultiSendType: + if p.MultiSendType.FixedGas == 0 || p.MultiSendType.GasPerItem == 0 { + return fmt.Errorf("invalid gas. cannot be zero") + } + case *MsgGasParams_GrantAllowanceType: + if p.GrantAllowanceType.FixedGas == 0 || p.GrantAllowanceType.GasPerItem == 0 { return fmt.Errorf("invalid gas. cannot be zero") } default: From 9d0aed5ef8b3eda9ad47c987de276c0b163ab4ac Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 16 Feb 2023 16:41:54 +0800 Subject: [PATCH 10/13] fix some review comments --- client/tx/tx.go | 3 ++ proto/cosmos/gashub/v1alpha1/tx.proto | 2 +- x/gashub/keeper/genesis.go | 30 ++++-------- x/gashub/keeper/keeper.go | 2 +- x/gashub/keeper/msg_server.go | 50 +++++++++++--------- x/gashub/keeper/params.go | 4 +- x/gashub/types/gas_calculator.go | 20 ++++++++ x/gashub/types/msg.go | 2 +- x/gashub/types/params.go | 6 +-- x/gashub/types/tx.pb.go | 67 ++++++++++++++------------- 10 files changed, 102 insertions(+), 84 deletions(-) diff --git a/client/tx/tx.go b/client/tx/tx.go index eae408878c..de3db2ad4c 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -81,6 +81,9 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error { if err != nil { return err } + if parsedGasPrices == nil { + return fmt.Errorf("empty gas prices") + } // we only accept one type coin gasPrice := parsedGasPrices[0] diff --git a/proto/cosmos/gashub/v1alpha1/tx.proto b/proto/cosmos/gashub/v1alpha1/tx.proto index 456b685e6a..cceb2b773a 100644 --- a/proto/cosmos/gashub/v1alpha1/tx.proto +++ b/proto/cosmos/gashub/v1alpha1/tx.proto @@ -23,7 +23,7 @@ message MsgUpdateMsgGasParams { option (gogoproto.goproto_getters) = false; string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - MsgGasParams new_params = 2; + repeated MsgGasParams new_params_set = 2; } // MsgUpdateMsgGasParamsResponse defines the Msg/UpdateMsgGasParams response type. diff --git a/x/gashub/keeper/genesis.go b/x/gashub/keeper/genesis.go index fe7b988776..b976960535 100644 --- a/x/gashub/keeper/genesis.go +++ b/x/gashub/keeper/genesis.go @@ -12,7 +12,7 @@ func (ghk Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { ghk.SetParams(ctx, data.Params) // init gas calculators from genesis data - registerGasCalculators(data.Params) + registerAllGasCalculators(data.Params) } // ExportGenesis returns a GenesisState for a given context and keeper @@ -22,40 +22,28 @@ func (ghk Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return types.NewGenesisState(params) } -func registerGasCalculators(params types.Params) { +func registerAllGasCalculators(params types.Params) { msgGasParamsSet := params.GetMsgGasParamsSet() for _, gasParams := range msgGasParamsSet { - err := registerGasCalculator(gasParams) + err := registerSingleGasCalculator(gasParams) if err != nil { panic(err) } } } -func registerGasCalculator(gasParams *types.MsgGasParams) error { - msgType := gasParams.GetMsgTypeUrl() +func registerSingleGasCalculator(gasParams *types.MsgGasParams) error { + msgTypeUrl := gasParams.GetMsgTypeUrl() switch gasParams.GasParams.(type) { case *types.MsgGasParams_FixedType: - types.RegisterCalculatorGen(msgType, func(params types.Params) types.GasCalculator { - msgGasParamsSet := params.GetMsgGasParamsSet() - for _, gasParams := range msgGasParamsSet { - if gasParams.GetMsgTypeUrl() == msgType { - p := gasParams.GetFixedType() - if p == nil { - panic(fmt.Errorf("get msg gas params failed for %s", msgType)) - } - return types.FixedGasCalculator(p.FixedGas) - } - } - panic(fmt.Sprintf("no params for %s", msgType)) - }) + types.RegisterCalculatorGen(msgTypeUrl, types.FixedGasCalculatorGen(msgTypeUrl)) case *types.MsgGasParams_GrantType: - types.RegisterCalculatorGen(msgType, types.MsgGrantGasCalculatorGen) + types.RegisterCalculatorGen(msgTypeUrl, types.MsgGrantGasCalculatorGen) case *types.MsgGasParams_MultiSendType: - types.RegisterCalculatorGen(msgType, types.MsgMultiSendGasCalculatorGen) + types.RegisterCalculatorGen(msgTypeUrl, types.MsgMultiSendGasCalculatorGen) case *types.MsgGasParams_GrantAllowanceType: - types.RegisterCalculatorGen(msgType, types.MsgGrantAllowanceGasCalculatorGen) + types.RegisterCalculatorGen(msgTypeUrl, types.MsgGrantAllowanceGasCalculatorGen) default: return fmt.Errorf("unknown gas params type") } diff --git a/x/gashub/keeper/keeper.go b/x/gashub/keeper/keeper.go index f441391616..414701fb8d 100644 --- a/x/gashub/keeper/keeper.go +++ b/x/gashub/keeper/keeper.go @@ -44,5 +44,5 @@ func (ghk Keeper) GetCodec() codec.BinaryCodec { return ghk.cdc } func (ghk Keeper) RegisterGasCalculators(ctx sdk.Context) { params := ghk.GetParams(ctx) - registerGasCalculators(params) + registerAllGasCalculators(params) } diff --git a/x/gashub/keeper/msg_server.go b/x/gashub/keeper/msg_server.go index f46e3a6f8c..8ba2f374f6 100644 --- a/x/gashub/keeper/msg_server.go +++ b/x/gashub/keeper/msg_server.go @@ -31,38 +31,42 @@ func (k msgServer) UpdateMsgGasParams(goCtx context.Context, msg *types.MsgUpdat } params := k.GetParams(ctx) - newMsgGasParams := msg.NewParams - msgGasParamsSet := params.MsgGasParamsSet - typeUrl := msg.NewParams.MsgTypeUrl + newMsgGasParamsSet := msg.NewParamsSet + for _, newParams := range newMsgGasParamsSet { + if err := types.ValidateMsgGasParams(newParams); err != nil { + return nil, err + } + + typeUrl := newParams.MsgTypeUrl - fromValue := "" - for idx, msgGasParams := range msgGasParamsSet { - if msgGasParams.MsgTypeUrl == typeUrl { - fromValue = msgGasParams.String() - msgGasParamsSet[idx] = newMsgGasParams - break + fromValue := "" + for idx, msgGasParams := range msgGasParamsSet { + if msgGasParams.MsgTypeUrl == typeUrl { + fromValue = msgGasParams.String() + msgGasParamsSet[idx] = newParams + break + } + } + if fromValue == "" { + params.MsgGasParamsSet = append(params.MsgGasParamsSet, newParams) } - } - // for new msg gas type, add it to params and register gas calculator - if fromValue == "" { - params.MsgGasParamsSet = append(params.MsgGasParamsSet, newMsgGasParams) - err := registerGasCalculator(newMsgGasParams) - if err != nil { + // register gas calculator + if err := registerSingleGasCalculator(newParams); err != nil { return nil, err } + + ctx.EventManager().EmitTypedEvent( + &types.EventUpdateMsgGasParams{ + MsgTypeUrl: newParams.MsgTypeUrl, + FromValue: fromValue, + ToValue: newParams.String(), + }, + ) } k.SetParams(ctx, params) - ctx.EventManager().EmitTypedEvent( - &types.EventUpdateMsgGasParams{ - MsgTypeUrl: msg.NewParams.MsgTypeUrl, - FromValue: fromValue, - ToValue: newMsgGasParams.String(), - }, - ) - return &types.MsgUpdateMsgGasParamsResponse{}, nil } diff --git a/x/gashub/keeper/params.go b/x/gashub/keeper/params.go index 8e1066a990..99ba584a42 100644 --- a/x/gashub/keeper/params.go +++ b/x/gashub/keeper/params.go @@ -5,12 +5,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/gashub/types" ) -// SetParams sets the auth module's parameters. +// SetParams sets the gashub module's parameters. func (ghk Keeper) SetParams(ctx sdk.Context, params types.Params) { ghk.paramSubspace.SetParamSet(ctx, ¶ms) } -// GetParams gets the auth module's parameters. +// GetParams gets the gashub module's parameters. func (ghk Keeper) GetParams(ctx sdk.Context) (params types.Params) { ghk.paramSubspace.GetParamSet(ctx, ¶ms) return diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 4d26491f75..90d6e54b83 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -25,6 +25,10 @@ func RegisterCalculatorGen(msgType string, feeCalcGen GasCalculatorGenerator) { calculatorsGen[msgType] = feeCalcGen } +func EmptyCalculatorsGen() { + +} + func GetGasCalculatorGen(msgType string) GasCalculatorGenerator { return calculatorsGen[msgType] } @@ -38,6 +42,22 @@ func FixedGasCalculator(amount uint64) GasCalculator { } } +func FixedGasCalculatorGen(msgTypeUrl string) GasCalculatorGenerator { + return func(params Params) GasCalculator { + msgGasParamsSet := params.GetMsgGasParamsSet() + for _, gasParams := range msgGasParamsSet { + if gasParams.GetMsgTypeUrl() == msgTypeUrl { + p := gasParams.GetFixedType() + if p == nil { + panic(fmt.Errorf("get msg gas params failed for %s", msgTypeUrl)) + } + return FixedGasCalculator(p.FixedGas) + } + } + panic(fmt.Sprintf("no params for %s", msgTypeUrl)) + } +} + func GrantCalculator(fixedGas, gasPerItem uint64) GasCalculator { return func(msg types.Msg) (uint64, error) { if fixedGas == 0 || gasPerItem == 0 { diff --git a/x/gashub/types/msg.go b/x/gashub/types/msg.go index 7339e32aad..97827d39be 100644 --- a/x/gashub/types/msg.go +++ b/x/gashub/types/msg.go @@ -36,7 +36,7 @@ func (msg MsgUpdateMsgGasParams) ValidateBasic() error { return sdkerrors.ErrInvalidAddress.Wrapf("invalid sender address: %s", err) } - if err := validateMsgGasParams(msg.NewParams); err != nil { + if err := ValidateMsgGasParams(msg.NewParams); err != nil { return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid msg gas params: %s", err) } diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 9ca73d49c3..88b76d52aa 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -62,7 +62,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), - paramtypes.NewParamSetPair(KeyMsgGasParamsSet, &p.MsgGasParamsSet, validateMsgGasParams), + paramtypes.NewParamSetPair(KeyMsgGasParamsSet, &p.MsgGasParamsSet, ValidateMsgGasParams), } } @@ -173,7 +173,7 @@ func validateMinGasPerByte(i interface{}) error { return nil } -func validateMsgGasParams(i interface{}) error { +func ValidateMsgGasParams(i interface{}) error { v, ok := i.([]*MsgGasParams) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -215,7 +215,7 @@ func (p Params) Validate() error { if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { return err } - if err := validateMsgGasParams(p.MsgGasParamsSet); err != nil { + if err := ValidateMsgGasParams(p.MsgGasParamsSet); err != nil { return err } diff --git a/x/gashub/types/tx.pb.go b/x/gashub/types/tx.pb.go index 8441afbad9..1cdcb356e8 100644 --- a/x/gashub/types/tx.pb.go +++ b/x/gashub/types/tx.pb.go @@ -32,8 +32,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgUpdateMsgGasParams represents a message to update msg gas params. type MsgUpdateMsgGasParams struct { - From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` - NewParams *MsgGasParams `protobuf:"bytes,2,opt,name=new_params,json=newParams,proto3" json:"new_params,omitempty"` + From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + NewParamsSet []*MsgGasParams `protobuf:"bytes,2,rep,name=new_params_set,json=newParamsSet,proto3" json:"new_params_set,omitempty"` } func (m *MsgUpdateMsgGasParams) Reset() { *m = MsgUpdateMsgGasParams{} } @@ -114,28 +114,29 @@ func init() { func init() { proto.RegisterFile("cosmos/gashub/v1alpha1/tx.proto", fileDescriptor_08053c9491c72816) } var fileDescriptor_08053c9491c72816 = []byte{ - // 331 bytes of a gzipped FileDescriptorProto + // 338 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0x28, 0xd0, 0x83, 0x28, 0xd0, 0x83, 0x29, 0x90,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3, 0x8a, 0x53, 0x8d, 0x1a, 0x19, + 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0xaa, 0xb8, 0x84, 0xb0, 0xf8, 0x46, 0x17, 0x8f, 0x3b, 0x30, + 0x95, 0x4b, 0x99, 0x92, 0xa4, 0x1c, 0xe6, 0x06, 0x27, 0xd7, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, + 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, + 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4e, 0xcf, 0x2c, 0x01, 0x19, 0x94, 0x9c, 0x9f, 0x0b, 0x8d, 0x19, + 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x01, 0x8b, 0xd8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, + 0x36, 0x70, 0xdc, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x35, 0x45, 0x6b, 0x45, 0x02, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -240,17 +241,19 @@ func (m *MsgUpdateMsgGasParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.NewParams != nil { - { - size, err := m.NewParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.NewParamsSet) > 0 { + for iNdEx := len(m.NewParamsSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.NewParamsSet[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 } if len(m.From) > 0 { i -= len(m.From) @@ -306,9 +309,11 @@ func (m *MsgUpdateMsgGasParams) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.NewParams != nil { - l = m.NewParams.Size() - n += 1 + l + sovTx(uint64(l)) + if len(m.NewParamsSet) > 0 { + for _, e := range m.NewParamsSet { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } } return n } @@ -391,7 +396,7 @@ func (m *MsgUpdateMsgGasParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NewParamsSet", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -418,10 +423,8 @@ func (m *MsgUpdateMsgGasParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.NewParams == nil { - m.NewParams = &MsgGasParams{} - } - if err := m.NewParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.NewParamsSet = append(m.NewParamsSet, &MsgGasParams{}) + if err := m.NewParamsSet[len(m.NewParamsSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From 4dd949e49c21a762266e3ee4103b65452596de66 Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 16 Feb 2023 17:31:23 +0800 Subject: [PATCH 11/13] fix: wrong usage of ValidateMsgGasParams --- x/gashub/keeper/msg_server.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/x/gashub/keeper/msg_server.go b/x/gashub/keeper/msg_server.go index 8ba2f374f6..ba28aaffae 100644 --- a/x/gashub/keeper/msg_server.go +++ b/x/gashub/keeper/msg_server.go @@ -33,11 +33,10 @@ func (k msgServer) UpdateMsgGasParams(goCtx context.Context, msg *types.MsgUpdat params := k.GetParams(ctx) msgGasParamsSet := params.MsgGasParamsSet newMsgGasParamsSet := msg.NewParamsSet + if err := types.ValidateMsgGasParams(newMsgGasParamsSet); err != nil { + return nil, err + } for _, newParams := range newMsgGasParamsSet { - if err := types.ValidateMsgGasParams(newParams); err != nil { - return nil, err - } - typeUrl := newParams.MsgTypeUrl fromValue := "" From 4bcd30e83f54e19c4d47e857d063df354168e16b Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 16 Feb 2023 17:40:47 +0800 Subject: [PATCH 12/13] fix build error --- x/gashub/types/msg.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/gashub/types/msg.go b/x/gashub/types/msg.go index 97827d39be..9f6d8c9ec1 100644 --- a/x/gashub/types/msg.go +++ b/x/gashub/types/msg.go @@ -17,10 +17,10 @@ var _ sdk.Msg = &MsgUpdateMsgGasParams{} // MsgUpdateMsgGasParams - construct a msg to update msg gas params. // //nolint:interfacer -func NewMsgUpdateMsgGasParams(from sdk.AccAddress, msgGasParams *MsgGasParams) *MsgUpdateMsgGasParams { +func NewMsgUpdateMsgGasParams(from sdk.AccAddress, msgGasParamsSet []*MsgGasParams) *MsgUpdateMsgGasParams { return &MsgUpdateMsgGasParams{ - From: from.String(), - NewParams: msgGasParams, + From: from.String(), + NewParamsSet: msgGasParamsSet, } } @@ -36,7 +36,7 @@ func (msg MsgUpdateMsgGasParams) ValidateBasic() error { return sdkerrors.ErrInvalidAddress.Wrapf("invalid sender address: %s", err) } - if err := ValidateMsgGasParams(msg.NewParams); err != nil { + if err := ValidateMsgGasParams(msg.NewParamsSet); err != nil { return errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid msg gas params: %s", err) } From 68c169ff4fe54df4030b263e1fc5c85d231f6688 Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 16 Feb 2023 17:46:02 +0800 Subject: [PATCH 13/13] fix lint issues --- x/gashub/types/gas_calculator.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 90d6e54b83..a9902312c4 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -25,10 +25,6 @@ func RegisterCalculatorGen(msgType string, feeCalcGen GasCalculatorGenerator) { calculatorsGen[msgType] = feeCalcGen } -func EmptyCalculatorsGen() { - -} - func GetGasCalculatorGen(msgType string) GasCalculatorGenerator { return calculatorsGen[msgType] }