diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1b18fde..295d97cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,5 +92,5 @@ target_compile_options(evm_runtime PUBLIC --no-missing-ricardian-clause) if (WITH_LARGE_STACK) target_link_options(evm_runtime PUBLIC --stack-size=50000000) else() - target_link_options(evm_runtime PUBLIC --stack-size=35088) + target_link_options(evm_runtime PUBLIC --stack-size=34896) endif() diff --git a/src/config_wrapper.cpp b/src/config_wrapper.cpp index 58a86ea0..97a9e8f5 100644 --- a/src/config_wrapper.cpp +++ b/src/config_wrapper.cpp @@ -80,10 +80,25 @@ void config_wrapper::set_gas_price(uint64_t gas_price) { void config_wrapper::enqueue_gas_price(uint64_t gas_price) { price_queue_table queue(_self, _self.value); auto time = eosio::current_time_point() + eosio::seconds(grace_period_seconds); + auto time_us = time.elapsed.count(); + + auto it = queue.end(); + if( it != queue.begin()) { + --it; + eosio::check(time_us >= it->time, "internal error"); + if(it->time == time_us) { + queue.modify(*it, eosio::same_payer, [&](auto& el) { + el.price = gas_price; + }); + return; + } + } + queue.emplace(_self, [&](auto& el) { - el.time = time.elapsed.count(); + el.time = time_us; el.price = gas_price; }); + } void config_wrapper::process_price_queue() { diff --git a/tests/basic_evm_tester.hpp b/tests/basic_evm_tester.hpp index f6e783f3..91c658bc 100644 --- a/tests/basic_evm_tester.hpp +++ b/tests/basic_evm_tester.hpp @@ -1,5 +1,4 @@ #pragma once -#include #include #include #include diff --git a/tests/gas_fee_tests.cpp b/tests/gas_fee_tests.cpp index 29c58b9e..5a442db1 100644 --- a/tests/gas_fee_tests.cpp +++ b/tests/gas_fee_tests.cpp @@ -334,10 +334,20 @@ try { produce_blocks(100); - // Queue change of gas_price to 20Gwei - setfeeparams({.gas_price = 2*ten_gwei}); + // Queue change of gas_price to 30Gwei + setfeeparams({.gas_price = 3*ten_gwei}); auto t2 = control->pending_block_time()+fc::seconds(price_queue_grace_period); + q = get_price_queue(); + BOOST_CHECK_EQUAL(q.size(), 2); + BOOST_CHECK_EQUAL(q[0].time, t1.time_since_epoch().count()); + BOOST_CHECK_EQUAL(q[0].price, ten_gwei); + BOOST_CHECK_EQUAL(q[1].time, t2.time_since_epoch().count()); + BOOST_CHECK_EQUAL(q[1].price, 3*ten_gwei); + + // Overwrite queue change (same block) 20Gwei + setfeeparams({.gas_price = 2*ten_gwei}); + q = get_price_queue(); BOOST_CHECK_EQUAL(q.size(), 2); BOOST_CHECK_EQUAL(q[0].time, t1.time_since_epoch().count());