Skip to content

Commit

Permalink
update: gashub default params and delete default gas calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Mar 8, 2023
1 parent 68ac309 commit eec0a39
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 56 deletions.
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"
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions x/auth/ante/msg_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions x/gashub/types/gas_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
88 changes: 44 additions & 44 deletions x/gashub/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

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

Expand Down Expand Up @@ -69,67 +69,67 @@ 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.MsgFundCommunityPool", 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", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVote", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.gov.v1.MsgVoteWeighted", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.oracle.v1.MsgClaim", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.slashing.v1beta1.MsgUnjail", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgBeginRedelegate", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgCreateValidator", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgDelegate", 12e3),
NewMsgGasParamsWithFixedGas("/cosmos.staking.v1beta1.MsgEditValidator", 12e3),
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),
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,
},
},
),
Expand Down

0 comments on commit eec0a39

Please sign in to comment.