Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcdaemon: fix data storage access in local state #2221

Merged
merged 4 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rpc-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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.35.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v0.36.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
cd ${{runner.workspace}}/rpc-tests
pip3 install -r requirements.txt

Expand Down
8 changes: 4 additions & 4 deletions silkworm/db/state/local_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ uint64_t LocalState::previous_incarnation(const evmc::address& /*address*/) cons
}

std::optional<BlockHeader> LocalState::read_header(BlockNum block_number, const evmc::bytes32& block_hash) const noexcept {
return db::read_header(txn_, block_number, block_hash);
return data_model_.read_header(block_number, block_hash);
}

bool LocalState::read_body(BlockNum block_number, const evmc::bytes32& block_hash, BlockBody& out) const noexcept {
return db::read_body(txn_, block_hash, block_number, out);
return data_model_.read_body(block_hash, block_number, out);
}

std::optional<intx::uint256> LocalState::total_difficulty(BlockNum block_number, const evmc::bytes32& block_hash) const noexcept {
return db::read_total_difficulty(txn_, block_number, block_hash);
return data_model_.read_total_difficulty(block_number, block_hash);
}

evmc::bytes32 LocalState::state_root_hash() const {
Expand All @@ -68,7 +68,7 @@ BlockNum LocalState::current_canonical_block() const {

std::optional<evmc::bytes32> LocalState::canonical_hash(BlockNum block_number) const {
// This method should not be called by EVM::execute
return db::read_canonical_hash(txn_, block_number);
return data_model_.read_canonical_hash(block_number);
}

} // namespace silkworm::db::state
3 changes: 2 additions & 1 deletion silkworm/db/state/local_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace silkworm::db::state {
class LocalState : public State {
public:
explicit LocalState(BlockNum block_number, mdbx::env chaindata_env)
: block_number_{block_number}, txn_{std::move(chaindata_env)} {}
: block_number_{block_number}, txn_{std::move(chaindata_env)}, data_model_{txn_} {}

std::optional<Account> read_account(const evmc::address& address) const noexcept override;

Expand Down Expand Up @@ -91,6 +91,7 @@ class LocalState : public State {
private:
BlockNum block_number_;
mutable db::ROTxnManaged txn_;
db::DataModel data_model_;
};

} // namespace silkworm::db::state
4 changes: 4 additions & 0 deletions silkworm/rpc/core/evm_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,10 @@ Task<TraceDeployResult> TraceCallExecutor::trace_deploy_transaction(const silkwo
co_return deploy_result;
}

Task<TraceCallResult> TraceCallExecutor::trace_transaction(const silkworm::Block& block, const rpc::Transaction& transaction, const TraceConfig& config) {
return execute(block.header.number - 1, block, transaction, gsl::narrow<int32_t>(transaction.transaction_index), config);
}

Task<std::vector<Trace>> TraceCallExecutor::trace_transaction(const BlockWithHash& block_with_hash, const rpc::Transaction& transaction) {
std::vector<Trace> traces;

Expand Down
4 changes: 1 addition & 3 deletions silkworm/rpc/core/evm_trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,8 @@ class TraceCallExecutor {
Task<std::vector<TraceCallResult>> trace_block_transactions(const silkworm::Block& block, const TraceConfig& config);
Task<TraceCallResult> trace_call(const silkworm::Block& block, const Call& call, const TraceConfig& config);
Task<TraceManyCallResult> trace_calls(const silkworm::Block& block, const std::vector<TraceCall>& calls);
Task<TraceCallResult> trace_transaction(const silkworm::Block& block, const rpc::Transaction& transaction, const TraceConfig& config) {
return execute(block.header.number - 1, block, transaction, gsl::narrow<int32_t>(transaction.transaction_index), config);
}
Task<TraceDeployResult> trace_deploy_transaction(const silkworm::Block& block, const evmc::address& contract_address);
Task<TraceCallResult> trace_transaction(const silkworm::Block& block, const rpc::Transaction& transaction, const TraceConfig& config);
Task<std::vector<Trace>> trace_transaction(const silkworm::BlockWithHash& block, const rpc::Transaction& transaction);
Task<TraceEntriesResult> trace_transaction_entries(const TransactionWithBlock& transaction_with_block);
Task<std::string> trace_transaction_error(const TransactionWithBlock& transaction_with_block);
Expand Down
Loading