From b1fca43d1ee7eee0a9a6af10dbd2584026cc665c Mon Sep 17 00:00:00 2001 From: sh-cha Date: Thu, 23 May 2024 19:03:03 +0900 Subject: [PATCH] delete contract query limit config --- x/evm/config/config.go | 13 ------------- x/evm/keeper/keeper.go | 4 ---- x/evm/keeper/query_server.go | 2 -- 3 files changed, 19 deletions(-) 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 {