Skip to content

Commit

Permalink
use base_fee_per_gas
Browse files Browse the repository at this point in the history
  • Loading branch information
taokayan committed Apr 16, 2024
1 parent 14342cc commit ccc5242
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions include/evm_runtime/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ namespace evm_runtime {
struct evmtx_v0 {
uint64_t eos_evm_version;
bytes rlptx;

EOSLIB_SERIALIZE(evmtx_v0, (eos_evm_version)(rlptx));
uint64_t base_fee_per_gas;

EOSLIB_SERIALIZE(evmtx_v0, (eos_evm_version)(rlptx)(base_fee_per_gas));
};

using evmtx_type = std::variant<evmtx_v0>;
Expand Down
2 changes: 1 addition & 1 deletion silkworm
18 changes: 15 additions & 3 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,14 @@ void evm_contract::exec(const exec_input& input, const std::optional<exec_callba
eosevm::block_mapping bm(_config->get_genesis_time().sec_since_epoch());

Block block;

auto evm_version = _config->get_evm_version();
std::optional<uint64_t> base_fee_per_gas;
if (evm_version >= 1) {
base_fee_per_gas = _config->get_gas_price();
}
eosevm::prepare_block_header(block.header, bm, get_self().value,
bm.timestamp_to_evm_block_num(eosio::current_time_point().time_since_epoch().count()), _config->get_evm_version());
bm.timestamp_to_evm_block_num(eosio::current_time_point().time_since_epoch().count()), evm_version, base_fee_per_gas);

evm_runtime::state state{get_self(), get_self(), true};
IntraBlockState ibstate{state};
Expand Down Expand Up @@ -448,8 +454,14 @@ void evm_contract::process_tx(const runtime_config& rc, eosio::name miner, const
eosevm::block_mapping bm(_config->get_genesis_time().sec_since_epoch());

Block block;

std::optional<uint64_t> base_fee_per_gas;
if (current_version >= 1) {
base_fee_per_gas = _config->get_gas_price();
}

eosevm::prepare_block_header(block.header, bm, get_self().value,
bm.timestamp_to_evm_block_num(eosio::current_time_point().time_since_epoch().count()), current_version);
bm.timestamp_to_evm_block_num(eosio::current_time_point().time_since_epoch().count()), current_version, base_fee_per_gas);

silkworm::protocol::TrustRuleSet engine{*found_chain_config->second};

Expand Down Expand Up @@ -490,7 +502,7 @@ void evm_contract::process_tx(const runtime_config& rc, eosio::name miner, const
}

if (current_version >= 1) {
auto event = evmtx_type{evmtx_v0{current_version, txn.get_rlptx()}};
auto event = evmtx_type{evmtx_v0{current_version, txn.get_rlptx(), *base_fee_per_gas}};
action(std::vector<permission_level>{}, get_self(), "evmtx"_n, event)
.send();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/basic_evm_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace evm_test {
struct evmtx_v0 {
uint64_t eos_evm_version;
bytes rlptx;
uint64_t base_fee_per_gas;
};

using evmtx_type = std::variant<evmtx_v0>;
Expand Down Expand Up @@ -195,7 +196,7 @@ FC_REFLECT(evm_test::message_receiver, (account)(handler)(min_fee)(flags));
FC_REFLECT(evm_test::bridge_message_v0, (receiver)(sender)(timestamp)(value)(data));
FC_REFLECT(evm_test::gcstore, (id)(storage_id));
FC_REFLECT(evm_test::account_code, (id)(ref_count)(code)(code_hash));
FC_REFLECT(evm_test::evmtx_v0, (eos_evm_version)(rlptx));
FC_REFLECT(evm_test::evmtx_v0, (eos_evm_version)(rlptx)(base_fee_per_gas));

namespace evm_test {
class evm_eoa
Expand Down

0 comments on commit ccc5242

Please sign in to comment.