From 65b0504fc3fce74b5c0ab897c4144a5a42369818 Mon Sep 17 00:00:00 2001 From: Sixtysixter <20945591+Sixtysixter@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:48:46 +0100 Subject: [PATCH] rpcdaemon: fix account state in debug_accountAt (#1893) --- .github/workflows/rpc-integration-tests.yml | 2 +- silkworm/rpc/commands/debug_api.cpp | 4 ++-- silkworm/rpc/core/evm_executor.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rpc-integration-tests.yml b/.github/workflows/rpc-integration-tests.yml index ef67b84c96..c3c832a961 100644 --- a/.github/workflows/rpc-integration-tests.yml +++ b/.github/workflows/rpc-integration-tests.yml @@ -26,7 +26,7 @@ jobs: - name: Checkout RPC Tests Repository & Install Requirements run: | rm -rf ${{runner.workspace}}/rpc-tests - git -c advice.detachedHead=false clone --depth 1 --branch v0.4.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests + git -c advice.detachedHead=false clone --depth 1 --branch v0.5.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests cd ${{runner.workspace}}/rpc-tests pip3 install -r requirements.txt diff --git a/silkworm/rpc/commands/debug_api.cpp b/silkworm/rpc/commands/debug_api.cpp index 8fe983c825..7dd470f21c 100644 --- a/silkworm/rpc/commands/debug_api.cpp +++ b/silkworm/rpc/commands/debug_api.cpp @@ -306,7 +306,7 @@ Task DebugRpcApi::handle_debug_account_at(const nlohmann::json& request, n } const auto& block = block_with_hash->block; - auto block_number = block.header.number - 1; + auto block_number = block.header.number; const auto& transactions = block.transactions; SILK_DEBUG << "Block number: " << block_number << " #tnx: " << transactions.size(); @@ -324,7 +324,7 @@ Task DebugRpcApi::handle_debug_account_at(const nlohmann::json& request, n EVMExecutor executor{*chain_config_ptr, workers_, state}; - uint64_t index = std::min(static_cast(transactions.size()), tx_index + 1); + uint64_t index = std::min(static_cast(transactions.size()), tx_index); for (uint64_t idx{0}; idx < index; idx++) { rpc::Transaction txn{transactions[idx]}; executor.call(block, txn); diff --git a/silkworm/rpc/core/evm_executor.cpp b/silkworm/rpc/core/evm_executor.cpp index 59ca71cd38..443fcf6f88 100644 --- a/silkworm/rpc/core/evm_executor.cpp +++ b/silkworm/rpc/core/evm_executor.cpp @@ -168,11 +168,12 @@ uint64_t EVMExecutor::refund_gas(const EVM& evm, const silkworm::Transaction& tx 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 = gas_refund < max_refund ? gas_refund : max_refund; // min + 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; @@ -218,8 +219,8 @@ ExecutionResult EVMExecutor::call( const Tracers& tracers, bool refund, bool gas_bailout) { - SILK_DEBUG << "EVMExecutor::call: " << block.header.number << " gasLimit: " << txn.gas_limit << " refund: " << refund << " gasBailout: " << gas_bailout; - SILK_DEBUG << "EVMExecutor::call: transaction: " << &txn; + SILK_DEBUG << "EVMExecutor::call: blockNumber: " << block.header.number << " gasLimit: " << txn.gas_limit << " refund: " << refund << " gasBailout: " << gas_bailout; + SILK_DEBUG << "EVMExecutor::call: transaction: " << rpc::Transaction{txn}; auto& svc = use_service(workers_); EVM evm{block, ibs_state_, config_};