Skip to content

Commit

Permalink
Check price queue is empty when switching to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
elmato committed Aug 7, 2024
1 parent 867ce30 commit 86f48e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/config_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ uint64_t config_wrapper::get_evm_version_and_maybe_promote() {

void config_wrapper::set_evm_version(uint64_t new_version) {
eosio::check(new_version <= eosevm::max_eos_evm_version, "Unsupported version");
eosio::check(new_version != 3 || _cached_config.queue_front_block.value() == 0, "price queue must be empty");
auto current_version = get_evm_version_and_maybe_promote();
eosio::check(new_version > current_version, "new version must be greater than the active one");
_cached_config.evm_version->update([&](auto& v) {
Expand Down
23 changes: 18 additions & 5 deletions tests/gas_fee_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,6 @@ try {
auto cfg = get_config();
BOOST_CHECK_EQUAL(cfg.queue_front_block.value(), 0);

eosevm::block_mapping bm(cfg.genesis_time.sec_since_epoch());

setversion(3, evm_account_name);
produce_blocks(2);

const auto one_gwei = 1'000'000'000ull;
const auto ten_gwei = 10'000'000'000ull;

Expand All @@ -434,6 +429,24 @@ try {
transfer_token("alice"_n, evm_account_name, make_asset(1), evm_account_name.to_string());
};

eosevm::block_mapping bm(cfg.genesis_time.sec_since_epoch());

setversion(2, evm_account_name);
produce_blocks(2);

// Price queue must be empty before switching to v3
setfeeparams({.gas_price = ten_gwei});
BOOST_REQUIRE_EXCEPTION(setversion(3, evm_account_name),
eosio_assert_message_exception,
eosio_assert_message_is("price queue must be empty"));
produce_blocks(400);
trigger_prices_queue_processing();
cfg = get_config();
BOOST_CHECK_EQUAL(cfg.queue_front_block.value(), 0);

setversion(3, evm_account_name);
produce_blocks(2);

// Queue change of gas_prices to overhead_price=10Gwei storage_price=1Gwei
setgasprices({.overhead_price = ten_gwei, .storage_price = one_gwei});
auto t1 = (control->pending_block_time()+fc::seconds(prices_queue_grace_period)).time_since_epoch().count();
Expand Down

0 comments on commit 86f48e5

Please sign in to comment.