diff --git a/include/evm_runtime/config_wrapper.hpp b/include/evm_runtime/config_wrapper.hpp index d0ab67a6..931cc019 100644 --- a/include/evm_runtime/config_wrapper.hpp +++ b/include/evm_runtime/config_wrapper.hpp @@ -58,8 +58,8 @@ struct config_wrapper { void update_consensus_parameters(eosio::asset ram_price_mb, uint64_t gas_price); void update_consensus_parameters2(std::optional gas_txnewaccount, std::optional gas_newaccount, std::optional gas_txcreate, std::optional gas_codedeposit, std::optional gas_sset); - const consensus_parameter_data_type& get_consensus_param(); - std::pair get_consensus_param_and_maybe_promote(); + consensus_parameter_data_type get_consensus_param(); + std::pair get_consensus_param_and_maybe_promote(); void set_token_contract(eosio::name token_contract); // only set during init eosio::name get_token_contract() const; diff --git a/src/actions.cpp b/src/actions.cpp index fd67e941..4dcd2fb0 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -458,7 +458,7 @@ void evm_contract::process_tx(const runtime_config& rc, eosio::name miner, const auto current_version = _config->get_evm_version_and_maybe_promote(); - std::pair gas_param_pair = _config->get_consensus_param_and_maybe_promote(); + auto gas_param_pair = _config->get_consensus_param_and_maybe_promote(); if (gas_param_pair.second) { // should not happen eosio::check(current_version >= 1, "gas param change requires evm_version >= 1"); diff --git a/src/config_wrapper.cpp b/src/config_wrapper.cpp index 274c6203..bb308bab 100644 --- a/src/config_wrapper.cpp +++ b/src/config_wrapper.cpp @@ -324,13 +324,13 @@ void config_wrapper::update_consensus_parameters2(std::optional gas_tx set_dirty(); } -const consensus_parameter_data_type& config_wrapper::get_consensus_param() { +consensus_parameter_data_type config_wrapper::get_consensus_param() { // should not happen eosio::check(_cached_config.consensus_parameter.has_value(), "consensus_parameter not exist"); return _cached_config.consensus_parameter->get_value(_cached_config.genesis_time, get_current_time()); } -std::pair config_wrapper::get_consensus_param_and_maybe_promote() { +std::pair config_wrapper::get_consensus_param_and_maybe_promote() { // should not happen eosio::check(_cached_config.consensus_parameter.has_value(), "consensus_parameter not exist"); diff --git a/tests/gas_param_tests.cpp b/tests/gas_param_tests.cpp index cd1d5ca3..53bccf1d 100644 --- a/tests/gas_param_tests.cpp +++ b/tests/gas_param_tests.cpp @@ -189,6 +189,38 @@ BOOST_FIXTURE_TEST_CASE(basic, gas_param_evm_tester) try { } FC_LOG_AND_RETHROW() +BOOST_FIXTURE_TEST_CASE(gas_param_traces, gas_param_evm_tester) try { + + init(); + + setversion(3, evm_account_name); + produce_blocks(2); + + setgasparam(1, 2, 3, 4, 2900, evm_account_name); + produce_blocks(3); + + evm_eoa evm1; + auto trace = transfer_token("alice"_n, evm_account_name, make_asset(1), evm1.address_0x()); + + BOOST_REQUIRE_EQUAL(trace->action_traces.size(), 5); + BOOST_ASSERT(trace->action_traces[0].act.name == "transfer"_n); + BOOST_ASSERT(trace->action_traces[1].act.name == "transfer"_n); + BOOST_ASSERT(trace->action_traces[2].act.name == "transfer"_n); + BOOST_ASSERT(trace->action_traces[3].act.name == "configchange"_n); + BOOST_ASSERT(trace->action_traces[4].act.name == "evmtx"_n); + + auto cp = fc::raw::unpack(trace->action_traces[3].act.data); + + std::visit([&](auto& v){ + BOOST_REQUIRE_EQUAL(v.gas_parameter.gas_txnewaccount, 1); + BOOST_REQUIRE_EQUAL(v.gas_parameter.gas_newaccount, 2); + BOOST_REQUIRE_EQUAL(v.gas_parameter.gas_txcreate, 3); + BOOST_REQUIRE_EQUAL(v.gas_parameter.gas_codedeposit, 4); + BOOST_REQUIRE_EQUAL(v.gas_parameter.gas_sset, 2900); + }, cp); + +} FC_LOG_AND_RETHROW() + BOOST_FIXTURE_TEST_CASE(gas_param_G_txnewaccount, gas_param_evm_tester) try { uint64_t suggested_gas_price = 150'000'000'000ull;