Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update gashub default params #118

Merged
merged 5 commits into from
Mar 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update: gashub default params and delete default gas calculator
pythonberg1997 committed Mar 8, 2023
commit f11e131034555d2dae4b89ed18450eaf9753f8f8
3 changes: 1 addition & 2 deletions x/auth/ante/ante_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ante_test

import (
"encoding/json"
"errors"
"fmt"
"strings"
@@ -1101,7 +1100,7 @@ func (suite *AnteTestSuite) TestAnteHandlerReCheck() {

tx, err = suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID())
suite.Require().NoError(err)
txBytes, err := json.Marshal(tx)
txBytes, err := suite.clientCtx.TxConfig.TxEncoder()(tx)
suite.Require().Nil(err, "Error marshalling tx: %v", err)
suite.ctx = suite.ctx.WithTxBytes(txBytes)

4 changes: 2 additions & 2 deletions x/auth/ante/msg_gas_test.go
Original file line number Diff line number Diff line change
@@ -47,8 +47,8 @@ func (suite *AnteTestSuite) TestMsgGas() {
expectedGas uint64
}
testCases := []testCase{
{"MsgSend", msgSend, 100000},
{"MsgMultiSend", msgMultiSend, 400000},
{"MsgSend", msgSend, 12000},
{"MsgMultiSend", msgMultiSend, 32000},
}
for _, tc := range testCases {
suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test
75 changes: 75 additions & 0 deletions x/gashub/simulation/params_test.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ import (
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/gashub/simulation"
"github.com/cosmos/cosmos-sdk/x/gashub/types"
"fmt"
)

func TestParamChanges(t *testing.T) {
@@ -33,3 +35,76 @@ func TestParamChanges(t *testing.T) {
require.Equal(t, expected[i].subspace, p.Subspace())
}
}

func TestMsgUrl(t *testing.T) {
defaultMsgGasParamsSet := []*types.MsgGasParams{
types.NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgExec", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgRevoke", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.bank.v1beta1.MsgSend", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgFundCommunityPool", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.feegrant.v1beta1.MsgRevokeAllowance", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgDeposit", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgSubmitProposal", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVote", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVoteWeighted", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.oracle.v1.MsgClaim", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgUnjail", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgBeginRedelegate", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCreateValidator", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgDelegate", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgEditValidator", 12e3),
types.NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgUndelegate", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.bridge.MsgTransferOut", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgDeposit", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgEditStorageProvider", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCopyObject", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateBucket", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateGroup", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateObject", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteBucket", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteGroup", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgLeaveGroup", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgRejectSealObject", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgSealObject", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgUpdateGroupMember", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreatePaymentAccount", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeposit", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgWithdraw", 12e3),
types.NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDisableRefund", 12e3),
owen-reorg marked this conversation as resolved.
Show resolved Hide resolved
types.NewMsgGasParamsWithDynamicGas(
"/cosmos.authz.v1beta1.MsgGrant",
&types.MsgGasParams_GrantType{
GrantType: &types.MsgGasParams_DynamicGasParams{
FixedGas: 8e3,
GasPerItem: 8e3,
},
},
),
types.NewMsgGasParamsWithDynamicGas(
"/cosmos.bank.v1beta1.MsgMultiSend",
&types.MsgGasParams_MultiSendType{
MultiSendType: &types.MsgGasParams_DynamicGasParams{
FixedGas: 8e3,
GasPerItem: 8e3,
},
},
),
types.NewMsgGasParamsWithDynamicGas(
"/cosmos.feegrant.v1beta1.MsgGrantAllowance",
&types.MsgGasParams_GrantAllowanceType{
GrantAllowanceType: &types.MsgGasParams_DynamicGasParams{
FixedGas: 8e3,
GasPerItem: 8e3,
},
},
),
}

for _, param := range defaultMsgGasParamsSet {
fmt.Println(param.MsgTypeUrl)
}
}
9 changes: 1 addition & 8 deletions x/gashub/types/gas_calculator.go
Original file line number Diff line number Diff line change
@@ -26,14 +26,7 @@ func RegisterCalculatorGen(msgType string, feeCalcGen GasCalculatorGenerator) {
}

func GetGasCalculatorGen(msgType string) GasCalculatorGenerator {
res, ok := calculatorsGen[msgType]
// todo: this is a temporary default fee, remove this after all msg types are registered
if !ok {
res = func(params Params) GasCalculator {
return FixedGasCalculator(1e5)
}
}
return res
return calculatorsGen[msgType]
}

func FixedGasCalculator(amount uint64) GasCalculator {
87 changes: 43 additions & 44 deletions x/gashub/types/params.go
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import (

// Default parameter values
const (
DefaultMaxTxSize uint64 = 1024
DefaultMaxTxSize uint64 = 32 * 1024 // 32kb
DefaultMinGasPerByte uint64 = 5
)

@@ -69,67 +69,66 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
// DefaultParams returns a default set of parameters.
func DefaultParams() Params {
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.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.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),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreatePaymentAccount", 1e5),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeposit", 1e5),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgWithdraw", 1e5),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDisableRefund", 1e5),
NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgExec", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.authz.v1beta1.MsgRevoke", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.bank.v1beta1.MsgSend", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.feegrant.v1beta1.MsgRevokeAllowance", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgDeposit", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgSubmitProposal", 2e8),
NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVote", 2e7),
NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVoteWeighted", 2e7),
NewMsgGasParamsWithFixedGas("/cosmos.oracle.v1.MsgClaim", 1e3),
NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgUnjail", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgBeginRedelegate", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCreateValidator", 2e8),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgDelegate", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgEditValidator", 2e7),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgUndelegate", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.bridge.MsgTransferOut", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgDeposit", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.sp.MsgEditStorageProvider", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCopyObject", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateBucket", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateGroup", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreateObject", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteBucket", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeleteGroup", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgLeaveGroup", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgRejectSealObject", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgSealObject", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgUpdateGroupMember", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgCreatePaymentAccount", 12e3),
owen-reorg marked this conversation as resolved.
Show resolved Hide resolved
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDeposit", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgWithdraw", 12e3),
NewMsgGasParamsWithFixedGas("/bnbchain.greenfield.storage.MsgDisableRefund", 12e3),
NewMsgGasParamsWithDynamicGas(
"/cosmos.authz.v1beta1.MsgGrant",
&MsgGasParams_GrantType{
GrantType: &MsgGasParams_DynamicGasParams{
FixedGas: 1e5,
GasPerItem: 1e5,
FixedGas: 8e3,
GasPerItem: 8e3,
},
},
),
NewMsgGasParamsWithDynamicGas(
"/cosmos.bank.v1beta1.MsgMultiSend",
&MsgGasParams_MultiSendType{
MultiSendType: &MsgGasParams_DynamicGasParams{
FixedGas: 1e5,
GasPerItem: 1e5,
FixedGas: 8e3,
GasPerItem: 8e3,
},
},
),
NewMsgGasParamsWithDynamicGas(
"/cosmos.feegrant.v1beta1.MsgGrantAllowance",
&MsgGasParams_GrantAllowanceType{
GrantAllowanceType: &MsgGasParams_DynamicGasParams{
FixedGas: 1e5,
GasPerItem: 1e5,
FixedGas: 8e3,
GasPerItem: 8e3,
},
},
),