Skip to content

Commit

Permalink
rpcdaemon: fix state access in eth_estimateGas (#1967)
Browse files Browse the repository at this point in the history
  • Loading branch information
lupin012 authored Apr 15, 2024
1 parent 85e4fd0 commit 0d71288
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion silkworm/rpc/core/estimate_gas_oracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ Task<intx::uint256> EstimateGasOracle::estimate_gas(const Call& call, const silk
auto this_executor = co_await boost::asio::this_coro::executor;
auto exec_result = co_await async_task(workers_.executor(), [&]() -> ExecutionResult {
auto state = transaction_.create_state(this_executor, tx_database_, storage_, block_number);
EVMExecutor executor{config_, workers_, state};

ExecutionResult result{evmc_status_code::EVMC_SUCCESS};
silkworm::Transaction transaction{call.to_transaction()};
while (lo + 1 < hi) {
EVMExecutor executor{config_, workers_, state};
auto mid = (hi + lo) / 2;
transaction.gas_limit = mid;

Expand All @@ -102,6 +102,7 @@ Task<intx::uint256> EstimateGasOracle::estimate_gas(const Call& call, const silk
}

if (hi == cap) {
EVMExecutor executor{config_, workers_, state};
transaction.gas_limit = hi;
result = try_execution(executor, block, transaction);
SILK_DEBUG << "HI == cap tested again with " << (result.error_code == evmc_status_code::EVMC_SUCCESS ? "succeed" : "failed");
Expand Down

0 comments on commit 0d71288

Please sign in to comment.