Skip to content

Commit

Permalink
rpcdaemon: fix account state in debug_accountAt (#1893)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sixtysixter authored Mar 11, 2024
1 parent 13d0b98 commit 65b0504
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rpc-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions silkworm/rpc/commands/debug_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Task<void> 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();
Expand All @@ -324,7 +324,7 @@ Task<void> DebugRpcApi::handle_debug_account_at(const nlohmann::json& request, n

EVMExecutor executor{*chain_config_ptr, workers_, state};

uint64_t index = std::min(static_cast<uint64_t>(transactions.size()), tx_index + 1);
uint64_t index = std::min(static_cast<uint64_t>(transactions.size()), tx_index);
for (uint64_t idx{0}; idx < index; idx++) {
rpc::Transaction txn{transactions[idx]};
executor.call(block, txn);
Expand Down
7 changes: 4 additions & 3 deletions silkworm/rpc/core/evm_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<AnalysisCacheService>(workers_);
EVM evm{block, ibs_state_, config_};
Expand Down

0 comments on commit 65b0504

Please sign in to comment.