Skip to content

Commit

Permalink
Skip chain-id enforcing in testtx action
Browse files Browse the repository at this point in the history
  • Loading branch information
elmato committed Jul 11, 2023
1 parent 51dcbe1 commit 2e6be43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contract/include/evm_runtime/evm_contract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class [[eosio::contract]] evm_contract : public contract
check((_config.get().status & static_cast<uint32_t>(status_flags::frozen)) == 0, "contract is frozen");
}

silkworm::Receipt execute_tx(eosio::name miner, silkworm::Block& block, silkworm::Transaction& tx, silkworm::ExecutionProcessor& ep);
silkworm::Receipt execute_tx(eosio::name miner, silkworm::Block& block, silkworm::Transaction& tx, silkworm::ExecutionProcessor& ep, bool enforce_chain_id);

uint64_t get_and_increment_nonce(const name owner);

Expand Down
8 changes: 4 additions & 4 deletions contract/src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void check_result( ValidationResult r, const Transaction& txn, const char* desc
eosio::check( false, std::move(err_msg));
}

Receipt evm_contract::execute_tx( eosio::name miner, Block& block, Transaction& tx, silkworm::ExecutionProcessor& ep ) {
Receipt evm_contract::execute_tx( eosio::name miner, Block& block, Transaction& tx, silkworm::ExecutionProcessor& ep, bool enforce_chain_id) {
//when being called as an inline action, clutch in allowance for reserved addresses & signatures by setting from_self=true
const bool from_self = get_sender() == get_self();

Expand Down Expand Up @@ -244,7 +244,7 @@ Receipt evm_contract::execute_tx( eosio::name miner, Block& block, Transaction&
else if(is_reserved_address(*tx.from))
check(from_self, "bridge signature used outside of bridge transaction");

if(!from_self) {
if(enforce_chain_id && !from_self) {
check(tx.chain_id.has_value(), "tx without chain-id");
}

Expand Down Expand Up @@ -406,7 +406,7 @@ void evm_contract::pushtx( eosio::name miner, const bytes& rlptx ) {
check(tx.max_priority_fee_per_gas == tx.max_fee_per_gas, "max_priority_fee_per_gas must be equal to max_fee_per_gas");
check(tx.max_fee_per_gas >= current_config.gas_price, "gas price is too low");

auto receipt = execute_tx(miner, block, tx, ep);
auto receipt = execute_tx(miner, block, tx, ep, true);

engine.finalize(ep.state(), ep.evm().block(), ep.evm().revision());
ep.state().write_to_db(ep.evm().block().header.number);
Expand Down Expand Up @@ -573,7 +573,7 @@ bool evm_contract::gc(uint32_t max) {
ByteView bv{(const uint8_t*)orlptx->data(), orlptx->size()};
eosio::check(rlp::decode(bv,tx) == DecodingResult::kOk && bv.empty(), "unable to decode transaction");

execute_tx(eosio::name{}, block, tx, ep);
execute_tx(eosio::name{}, block, tx, ep, false);
}
engine.finalize(ep.state(), ep.evm().block(), ep.evm().revision());
ep.state().write_to_db(ep.evm().block().header.number);
Expand Down

0 comments on commit 2e6be43

Please sign in to comment.