diff --git a/include/evm_runtime/config_wrapper.hpp b/include/evm_runtime/config_wrapper.hpp index 205467ed..36711156 100644 --- a/include/evm_runtime/config_wrapper.hpp +++ b/include/evm_runtime/config_wrapper.hpp @@ -66,6 +66,9 @@ struct config_wrapper { eosio::symbol get_token_symbol() const; uint64_t get_minimum_natively_representable() const; + void set_ingress_gas_limit(uint64_t gas_limit); + uint64_t get_ingress_gas_limit() const; + private: void set_queue_front_block(uint32_t block_num); diff --git a/include/evm_runtime/evm_contract.hpp b/include/evm_runtime/evm_contract.hpp index b01b979b..23ba801c 100644 --- a/include/evm_runtime/evm_contract.hpp +++ b/include/evm_runtime/evm_contract.hpp @@ -90,6 +90,7 @@ class [[eosio::contract]] evm_contract : public contract [[eosio::action]] void setgasparam(uint64_t gas_txnewaccount, uint64_t gas_newaccount, uint64_t gas_txcreate, uint64_t gas_codedeposit, uint64_t gas_sset); [[eosio::action]] void setgasprices(const gas_prices_type& prices); + [[eosio::action]] void setgaslimit(uint64_t ingress_gas_limit); // Events [[eosio::action]] void evmtx(eosio::ignore event){ diff --git a/include/evm_runtime/tables.hpp b/include/evm_runtime/tables.hpp index 8bd30290..b7ad581d 100644 --- a/include/evm_runtime/tables.hpp +++ b/include/evm_runtime/tables.hpp @@ -269,9 +269,10 @@ struct [[eosio::table]] [[eosio::contract("evm_contract")]] config binary_extension consensus_parameter; binary_extension token_contract; // <- default(unset) means eosio.token binary_extension queue_front_block; + binary_extension ingress_gas_limit; binary_extension gas_prices; - EOSLIB_SERIALIZE(config, (version)(chainid)(genesis_time)(ingress_bridge_fee)(gas_price)(miner_cut)(status)(evm_version)(consensus_parameter)(token_contract)(queue_front_block)(gas_prices)); + EOSLIB_SERIALIZE(config, (version)(chainid)(genesis_time)(ingress_bridge_fee)(gas_price)(miner_cut)(status)(evm_version)(consensus_parameter)(token_contract)(queue_front_block)(ingress_gas_limit)(gas_prices)); }; struct [[eosio::table]] [[eosio::contract("evm_contract")]] price_queue diff --git a/src/actions.cpp b/src/actions.cpp index 4dcd2fb0..db50ea5b 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -667,7 +667,7 @@ void evm_contract::handle_evm_transfer(eosio::asset quantity, const std::string& value *= intx::uint256(_config->get_minimum_natively_representable()); auto calculate_gas_limit = [&](const evmc::address& destination) -> int64_t { - int64_t gas_limit = 21000; + int64_t gas_limit = _config->get_ingress_gas_limit(); account_table accounts(get_self(), get_self().value); auto inx = accounts.get_index<"by.address"_n>(); @@ -916,4 +916,8 @@ void evm_contract::setgasprices(const gas_prices_type& prices) { } } +void evm_contract::setgaslimit(uint64_t ingress_gas_limit) { + _config->set_ingress_gas_limit(ingress_gas_limit); +} + } //evm_runtime diff --git a/src/config_wrapper.cpp b/src/config_wrapper.cpp index fafe96f8..ae9879e0 100644 --- a/src/config_wrapper.cpp +++ b/src/config_wrapper.cpp @@ -27,6 +27,9 @@ config_wrapper::config_wrapper(eosio::name self) : _self(self), _config(self, se if (!_cached_config.gas_prices.has_value()) { _cached_config.gas_prices = gas_prices_type{}; } + if (!_cached_config.ingress_gas_limit.has_value()) { + _cached_config.ingress_gas_limit = 21000; + } } config_wrapper::~config_wrapper() { @@ -395,4 +398,13 @@ bool config_wrapper::check_gas_overflow(uint64_t gas_txcreate, uint64_t gas_code return true; } +void config_wrapper::set_ingress_gas_limit(uint64_t gas_limit) { + _cached_config.ingress_gas_limit = gas_limit; + set_dirty(); +} + +uint64_t config_wrapper::get_ingress_gas_limit() const { + return *_cached_config.ingress_gas_limit; +} + } //namespace evm_runtime diff --git a/tests/basic_evm_tester.cpp b/tests/basic_evm_tester.cpp index e05a0c75..1fe61460 100644 --- a/tests/basic_evm_tester.cpp +++ b/tests/basic_evm_tester.cpp @@ -103,6 +103,11 @@ namespace fc { namespace raw { fc::raw::unpack(ds, queue_front_block); tmp.queue_front_block.emplace(queue_front_block); } + if(ds.remaining()) { + uint64_t ingress_gas_limit; + fc::raw::unpack(ds, ingress_gas_limit); + tmp.ingress_gas_limit.emplace(ingress_gas_limit); + } if(ds.remaining()) { evm_test::gas_prices_type prices; fc::raw::unpack(ds, prices); diff --git a/tests/basic_evm_tester.hpp b/tests/basic_evm_tester.hpp index 481ede80..cdf3b80d 100644 --- a/tests/basic_evm_tester.hpp +++ b/tests/basic_evm_tester.hpp @@ -118,6 +118,7 @@ struct config_table_row std::optional consensus_parameter; std::optional token_contract; std::optional queue_front_block; + std::optional ingress_gas_limit; std::optional gas_prices; };