Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,9 @@ Receipt evm_contract::execute_tx(const runtime_config& rc, eosio::name miner, Bl
// Bridge transfers can generate such txs.
uint64_t tx_gas_used = receipt.cumulative_gas_used; // Only transaction in the "block" so cumulative_gas_used is the tx gas_used.
auto s = get_statistics();
if (_config->get_evm_version() >= 1) {
intx::uint512 gas_fee = intx::uint256(tx_gas_used) * ep.evm().block().header.base_fee_per_gas.value();
auto current_ver = _config->get_evm_version();
if ( current_ver >= 1) {
intx::uint512 gas_fee = current_ver == 3 ? res.overhead_fee+res.storage_fee : intx::uint256(tx_gas_used) * ep.evm().block().header.base_fee_per_gas.value();
check(gas_fee < std::numeric_limits<intx::uint256>::max(), "too much gas");
s.gas_fee_income += static_cast<intx::uint256>(gas_fee);
} else {
Expand Down
26 changes: 25 additions & 1 deletion tests/statistics_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ try {

// Set version 1
setversion(1, evm_account_name);

produce_blocks(3);

// Fund evm1 address with 10.0000 EOS / trigger version change and sets miner_cut to 0
Expand Down Expand Up @@ -209,6 +208,31 @@ try {
// 0.0063 + 0.0063 = 0.0126
const auto s2 = get_statistics();
BOOST_REQUIRE(s2.gas_fee_income == (balance_and_dust{make_asset(126), 0ULL}));

// Set version 3
setgasprices({.overhead_price=80*silkworm::kGiga, .storage_price=80*silkworm::kGiga});
setversion(3, evm_account_name);
produce_blocks(3);

// Fund evm1 address with 10.0000 EOS / trigger version change
transfer_token("alice"_n, evm_account_name, make_asset(10'0000), evm1.address_0x());

tx = generate_tx(evm2.address, 1);
tx.type = silkworm::TransactionType::kDynamicFee;
tx.max_priority_fee_per_gas = 0;
tx.max_fee_per_gas = base_gas_price + inclusion_price;

evm1.sign(tx);
pushtx(tx, miner_account);

//0.00105 + 0
BOOST_REQUIRE(vault_balance(miner_account) == (balance_and_dust{make_asset(10), 50'000'000'000'000ULL}));

// Gas fee statistics
// 0.0126 + 0.00168 = 0.01428
const auto s3 = get_statistics();

BOOST_REQUIRE(s3.gas_fee_income == (balance_and_dust{make_asset(142), 80'000'000'000'000ULL}));
}
FC_LOG_AND_RETHROW()

Expand Down