From 117392887130702f8b79527ed6ef0cfc9c75b8ea Mon Sep 17 00:00:00 2001 From: Hoon <48665813+sh-cha@users.noreply.github.com> Date: Fri, 24 May 2024 13:50:26 +0900 Subject: [PATCH] delete contract query limit config (#20) * delete contract query limit config * default 3,000,000 --- cmd/minitiad/config.go | 1 + x/evm/config/config.go | 13 ------------- x/evm/keeper/keeper.go | 4 ---- x/evm/keeper/query_server.go | 2 -- 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/cmd/minitiad/config.go b/cmd/minitiad/config.go index 569069f..7968d03 100644 --- a/cmd/minitiad/config.go +++ b/cmd/minitiad/config.go @@ -40,6 +40,7 @@ func initAppConfig() (string, interface{}) { // // In simapp, we set the min gas prices to 0. srvCfg.MinGasPrices = fmt.Sprintf("0%s", types.BaseDenom) + srvCfg.QueryGasLimit = 3000000 // Enable API and unsafe CORS (CORS allowed from any host) srvCfg.API.Enable = true diff --git a/x/evm/config/config.go b/x/evm/config/config.go index fa9b85f..ddf6edd 100644 --- a/x/evm/config/config.go +++ b/x/evm/config/config.go @@ -7,28 +7,22 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" ) -// DefaultContractQueryGasLimit - default max query gas for external query -const DefaultContractQueryGasLimit = uint64(3_000_000) - // DefaultContractSimulationGasLimit - default max simulation gas const DefaultContractSimulationGasLimit = uint64(3_000_000) const ( flagContractSimulationGasLimit = "evm.contract-simulation-gas-limit" - flagContractQueryGasLimit = "evm.contract-query-gas-limit" ) // EVMConfig is the extra config required for evm type EVMConfig struct { ContractSimulationGasLimit uint64 `mapstructure:"contract-simulation-gas-limit"` - ContractQueryGasLimit uint64 `mapstructure:"contract-query-gas-limit"` } // DefaultEVMConfig returns the default settings for EVMConfig func DefaultEVMConfig() EVMConfig { return EVMConfig{ ContractSimulationGasLimit: DefaultContractSimulationGasLimit, - ContractQueryGasLimit: DefaultContractQueryGasLimit, } } @@ -36,14 +30,12 @@ func DefaultEVMConfig() EVMConfig { func GetConfig(appOpts servertypes.AppOptions) EVMConfig { return EVMConfig{ ContractSimulationGasLimit: cast.ToUint64(appOpts.Get(flagContractSimulationGasLimit)), - ContractQueryGasLimit: cast.ToUint64(appOpts.Get(flagContractQueryGasLimit)), } } // AddConfigFlags implements servertypes.EVMConfigFlags interface. func AddConfigFlags(startCmd *cobra.Command) { startCmd.Flags().Uint64(flagContractSimulationGasLimit, DefaultContractSimulationGasLimit, "Set the max simulation gas for evm contract execution") - startCmd.Flags().Uint64(flagContractQueryGasLimit, DefaultContractQueryGasLimit, "Set the max gas that can be spent on executing a query with a Move contract") } // DefaultConfigTemplate default config template for evm @@ -56,9 +48,4 @@ const DefaultConfigTemplate = ` # The maximum gas amount can be used in a tx simulation call. contract-simulation-gas-limit = "{{ .EVMConfig.ContractSimulationGasLimit }}" - -# The maximum gas amount can be spent for contract query. -# The contract query will invoke contract execution vm, -# so we need to restrict the max usage to prevent DoS attack -contract-query-gas-limit = "{{ .EVMConfig.ContractQueryGasLimit }}" ` diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 1cecb95..514cde6 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -75,10 +75,6 @@ func NewKeeper( evmConfig.ContractSimulationGasLimit = evmconfig.DefaultContractSimulationGasLimit } - if evmConfig.ContractQueryGasLimit == 0 { - evmConfig.ContractQueryGasLimit = evmconfig.DefaultContractQueryGasLimit - } - k := &Keeper{ ac: ac, cdc: cdc, diff --git a/x/evm/keeper/query_server.go b/x/evm/keeper/query_server.go index 56e2171..28c250c 100644 --- a/x/evm/keeper/query_server.go +++ b/x/evm/keeper/query_server.go @@ -6,7 +6,6 @@ import ( "strings" errorsmod "cosmossdk.io/errors" - storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -34,7 +33,6 @@ func (qs *queryServerImpl) Call(ctx context.Context, req *types.QueryCallRequest }() sdkCtx := sdk.UnwrapSDKContext(ctx) - sdkCtx = sdkCtx.WithGasMeter(storetypes.NewGasMeter(qs.config.ContractQueryGasLimit)) sender, err := qs.ac.StringToBytes(req.Sender) if err != nil {