diff --git a/silkworm/rpc/core/evm_executor.cpp b/silkworm/rpc/core/evm_executor.cpp index 394c047ce5..ae5d7f271d 100644 --- a/silkworm/rpc/core/evm_executor.cpp +++ b/silkworm/rpc/core/evm_executor.cpp @@ -163,24 +163,6 @@ std::string EVMExecutor::get_error_message(int64_t error_code, const Bytes& erro return error_message; } -uint64_t EVMExecutor::refund_gas(const EVM& evm, const silkworm::Transaction& txn, uint64_t gas_left, uint64_t gas_refund) { - const evmc_revision rev{evm.revision()}; - const uint64_t max_refund_quotient{rev >= EVMC_LONDON ? protocol::kMaxRefundQuotientLondon - : protocol::kMaxRefundQuotientFrontier}; - const uint64_t max_refund{(txn.gas_limit - gas_left) / max_refund_quotient}; - const uint64_t refund = std::min(gas_refund, max_refund); - gas_left += refund; - - const intx::uint256 base_fee_per_gas{evm.block().header.base_fee_per_gas.value_or(0)}; - SILK_DEBUG << "EVMExecutor::refund_gas txn.max_fee_per_gas: " << txn.max_fee_per_gas << " base_fee_per_gas: " << base_fee_per_gas; - - const intx::uint256 effective_gas_price{txn.max_fee_per_gas >= base_fee_per_gas ? txn.effective_gas_price(base_fee_per_gas) - : txn.max_priority_fee_per_gas}; - SILK_DEBUG << "EVMExecutor::refund_gas effective_gas_price: " << effective_gas_price; - ibs_state_.add_to_balance(*txn.sender(), gas_left * effective_gas_price); - return gas_left; -} - void EVMExecutor::call_first_n(const silkworm::Block& block, const uint64_t n, const Tracers& tracers, bool refund, bool gas_bailout) { for (size_t idx = 0; idx < block.transactions.size() && idx < n; idx++) { const auto& txn = block.transactions.at(idx); @@ -190,47 +172,6 @@ void EVMExecutor::call_first_n(const silkworm::Block& block, const uint64_t n, c void EVMExecutor::reset() { execution_processor_.reset(); - // execution_processor_.get_ibs_state().clear_journal_and_substate(); -} - -std::optional EVMExecutor::pre_check(const EVM& evm, const silkworm::Transaction& txn, - const intx::uint256& base_fee_per_gas, const intx::uint128& g0) { - const evmc_revision rev{evm.revision()}; - - if (rev >= EVMC_LONDON) { - if (txn.max_fee_per_gas > 0 || txn.max_priority_fee_per_gas > 0) { - if (txn.max_fee_per_gas < txn.max_priority_fee_per_gas) { - std::string from = address_to_hex(*txn.sender()); - std::string error = "tip higher than fee cap: address " + from + ", tip: " + intx::to_string(txn.max_priority_fee_per_gas) + " gasFeeCap: " + - intx::to_string(txn.max_fee_per_gas); - return PreCheckResult{error, PreCheckErrorCode::kTipHigherThanFeeCap}; - } - - if (txn.max_fee_per_gas < base_fee_per_gas) { - const std::string from = address_to_hex(*txn.sender()); - std::string error = "fee cap less than block base fee: address " + from + ", gasFeeCap: " + - intx::to_string(txn.max_fee_per_gas) + " baseFee: " + intx::to_string(base_fee_per_gas); - return PreCheckResult{error, PreCheckErrorCode::kFeeCapLessThanBlockFeePerGas}; - } - } - } else { - if (txn.type != silkworm::TransactionType::kLegacy && txn.type != silkworm::TransactionType::kAccessList) { - return PreCheckResult{"eip-1559 transactions require london", PreCheckErrorCode::kIsNotLondon}; - } - } - - if (rev >= EVMC_CANCUN) { - if (!evm.block().header.excess_blob_gas) { - std::string error = "internal failure: Cancun is active but ExcessBlobGas is nil"; - return PreCheckResult{error, PreCheckErrorCode::kInternalError}; - } - } - - if (txn.gas_limit < g0) { - std::string error = "intrinsic gas too low: have " + std::to_string(txn.gas_limit) + ", want " + intx::to_string(g0); - return PreCheckResult{error, PreCheckErrorCode::kIntrinsicGasTooLow}; - } - return std::nullopt; } ExecutionResult convert_validated_precheck(const ValidationResult& result, const Block& block, const silkworm::Transaction& txn, const EVM& evm) { diff --git a/silkworm/rpc/core/evm_executor.hpp b/silkworm/rpc/core/evm_executor.hpp index 0b53306bea..f042be2ea2 100644 --- a/silkworm/rpc/core/evm_executor.hpp +++ b/silkworm/rpc/core/evm_executor.hpp @@ -107,7 +107,6 @@ class EVMExecutor { : config_(config), workers_{workers}, state_{std::move(state)}, - ibs_state_{*state_}, rule_set_{protocol::rule_set_factory(config)}, execution_processor_{block, *rule_set_, *state_, config} { SILKWORM_ASSERT(rule_set_); @@ -140,12 +139,9 @@ class EVMExecutor { }; static std::optional pre_check(const EVM& evm, const silkworm::Transaction& txn, const intx::uint256& base_fee_per_gas, const intx::uint128& g0); - uint64_t refund_gas(const EVM& evm, const silkworm::Transaction& txn, uint64_t gas_left, uint64_t gas_refund); - const silkworm::ChainConfig& config_; WorkerPool& workers_; std::shared_ptr state_; - IntraBlockState ibs_state_; protocol::RuleSetPtr rule_set_; ExecutionProcessor execution_processor_; };