diff --git a/silkworm/execution/local_state.cpp b/silkworm/execution/local_state.cpp index 3fb04dafcc..6f7b4857d4 100644 --- a/silkworm/execution/local_state.cpp +++ b/silkworm/execution/local_state.cpp @@ -39,7 +39,7 @@ std::optional LocalState::read_account(const evmc::address& address) co return std::move(result->value); } } else { - // historical request on *txn_id timestamp + // TODO(canepat) historical AccountsDomainGetAsOfQuery on *txn_id timestamp } return std::nullopt; } @@ -57,7 +57,7 @@ ByteView LocalState::read_code(const evmc::address& address, const evmc::bytes32 return result->value; } } else { - // historical request on *txn_id timestamp + // TODO(canepat) historical CodeDomainGetAsOfQuery on *txn_id timestamp } return ByteView{}; } @@ -77,7 +77,7 @@ evmc::bytes32 LocalState::read_storage( return result->value; } } else { - // historical request on *txn_id timestamp + // TODO(canepat) historical StorageDomainGetAsOfQuery on *txn_id timestamp } return {}; } @@ -112,48 +112,4 @@ std::optional LocalState::canonical_hash(BlockNum block_num) cons return data_model().read_canonical_header_hash(block_num); } -void LocalState::update_account( - const evmc::address& address, - std::optional initial, - std::optional current) { - /* should be managed request on Latest(txn_id == nullopt) and historical (txn_id != nullopt) */ - - Step current_step = Step::from_txn_id(*txn_id_); - if (current) { - AccountsDomainPutQuery query{tx_, data_store_.state_db().accounts_domain()}; - query.exec(address, *current, *txn_id_, initial, current_step); - } else { - AccountsDomainDeleteQuery query{tx_, data_store_.state_db().accounts_domain()}; - query.exec(address, *txn_id_, initial, current_step); - } -} - -void LocalState::update_account_code( - const evmc::address& address, - uint64_t /*incarnation*/, - const evmc::bytes32& /*code_hash*/, - ByteView code) { - /* should be managed request on Latest(txn_id == nullopt) and historical (txn_id != nullopt) */ - - Step current_step = Step::from_txn_id(*txn_id_); - CodeDomainPutQuery query{tx_, data_store_.state_db().code_domain()}; - std::optional initial_code = read_code(address, evmc::bytes32{}); - if (initial_code && initial_code->empty()) - initial_code = std::nullopt; - query.exec(address, code, *txn_id_, initial_code, current_step); -} - -void LocalState::update_storage( - const evmc::address& address, - uint64_t /*incarnation*/, - const evmc::bytes32& location, - const evmc::bytes32& initial, - const evmc::bytes32& current) { - /* should be managed request on Latest(txn_id == nullopt) and historical (txn_id != nullopt) */ - - Step current_step = Step::from_txn_id(*txn_id_); - StorageDomainPutQuery query{tx_, data_store_.state_db().storage_domain()}; - query.exec({address, location}, current, *txn_id_, initial, current_step); -} - } // namespace silkworm::execution diff --git a/silkworm/execution/local_state.hpp b/silkworm/execution/local_state.hpp index 7933deedf3..0e6fe43be3 100644 --- a/silkworm/execution/local_state.hpp +++ b/silkworm/execution/local_state.hpp @@ -38,7 +38,7 @@ class LocalState : public State { db::DataStoreRef data_store) : txn_id_{txn_id}, data_store_{std::move(data_store)}, - tx_{data_store_.chaindata.access_rw().start_rw_tx()} {} + tx_{data_store_.chaindata.access_ro().start_ro_tx()} {} std::optional read_account(const evmc::address& address) const noexcept override; @@ -73,22 +73,22 @@ class LocalState : public State { void begin_block(BlockNum /*block_num*/, size_t /*updated_accounts_count*/) override {} void update_account( - const evmc::address& address, - std::optional initial, - std::optional current) override; + const evmc::address& /*address*/, + std::optional /*initial*/, + std::optional /*current*/) override {} void update_account_code( - const evmc::address& address, - uint64_t incarnation, - const evmc::bytes32& code_hash, - ByteView code) override; + const evmc::address& /*address*/, + uint64_t /*incarnation*/, + const evmc::bytes32& /*code_hash*/, + ByteView /*code*/) override {} void update_storage( - const evmc::address& address, - uint64_t incarnation, - const evmc::bytes32& location, - const evmc::bytes32& initial, - const evmc::bytes32& current) override; + const evmc::address& /*address*/, + uint64_t /*incarnation*/, + const evmc::bytes32& /*location*/, + const evmc::bytes32& /*initial*/, + const evmc::bytes32& /*current*/) override {} void unwind_state_changes(BlockNum /*block_num*/) override {} @@ -99,7 +99,7 @@ class LocalState : public State { std::optional txn_id_; db::DataStoreRef data_store_; - mutable datastore::kvdb::RWTxnManaged tx_; + mutable datastore::kvdb::ROTxnManaged tx_; }; } // namespace silkworm::execution