From ca5282ad59f94173d2111b2de94302e7b2df48a2 Mon Sep 17 00:00:00 2001 From: jkrvivian Date: Wed, 30 Oct 2024 21:53:00 +0800 Subject: [PATCH 1/2] refactor(iota-types): Remove trait ParentSync --- crates/iota-core/src/execution_cache.rs | 11 +---- crates/iota-replay/src/replay.rs | 37 +-------------- .../src/mock_storage.rs | 13 +----- .../src/simulator_persisted_store.rs | 13 +----- crates/iota-types/src/in_memory_storage.rs | 15 ++----- crates/iota-types/src/storage/mod.rs | 45 ++----------------- crates/simulacrum/src/store/in_mem_store.rs | 13 +----- crates/simulacrum/src/store/mod.rs | 7 +-- .../iota-adapter/src/temporary_store.rs | 11 +---- .../v0/iota-adapter/src/temporary_store.rs | 11 +---- 10 files changed, 19 insertions(+), 157 deletions(-) diff --git a/crates/iota-core/src/execution_cache.rs b/crates/iota-core/src/execution_cache.rs index ee795648f53..e9d885485ed 100644 --- a/crates/iota-core/src/execution_cache.rs +++ b/crates/iota-core/src/execution_cache.rs @@ -17,7 +17,7 @@ use iota_types::{ object::{Object, Owner}, storage::{ BackingPackageStore, BackingStore, ChildObjectResolver, InputKey, MarkerValue, ObjectKey, - ObjectOrTombstone, ObjectStore, PackageObject, ParentSync, + ObjectOrTombstone, ObjectStore, PackageObject, error::{Error as StorageError, Result as StorageResult}, }, transaction::{VerifiedSignedTransaction, VerifiedTransaction}, @@ -819,15 +819,6 @@ macro_rules! implement_storage_traits { ObjectCacheRead::get_package_object(self, package_id) } } - - impl ParentSync for $implementor { - fn get_latest_parent_entry_ref_deprecated( - &self, - object_id: ObjectID, - ) -> IotaResult> { - ObjectCacheRead::get_latest_object_ref_or_tombstone(self, object_id) - } - } }; } diff --git a/crates/iota-replay/src/replay.rs b/crates/iota-replay/src/replay.rs index d5048ca2589..858f1cc0f8f 100644 --- a/crates/iota-replay/src/replay.rs +++ b/crates/iota-replay/src/replay.rs @@ -32,8 +32,8 @@ use iota_types::{ metrics::LimitsMetrics, object::{Data, Object, Owner}, storage::{ - BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, ParentSync, - get_module, get_module_by_id, + BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, get_module, + get_module_by_id, }, transaction::{ CheckedInputObjects, InputObjectKind, InputObjects, ObjectReadResult, ObjectReadResultKind, @@ -1970,39 +1970,6 @@ impl ChildObjectResolver for LocalExec { } } -impl ParentSync for LocalExec { - /// The objects here much already exist in the store because we downloaded - /// them earlier No download from network - fn get_latest_parent_entry_ref_deprecated( - &self, - object_id: ObjectID, - ) -> IotaResult> { - fn inner(self_: &LocalExec, object_id: ObjectID) -> IotaResult> { - if let Some(v) = self_ - .storage - .live_objects_store - .lock() - .expect("Can't lock") - .get(&object_id) - { - return Ok(Some(v.compute_object_reference())); - } - Ok(None) - } - let res = inner(self, object_id); - self.exec_store_events - .lock() - .expect("Unable to lock events list") - .push( - ExecutionStoreEvent::ParentSyncStoreGetLatestParentEntryRef { - object_id, - result: res.clone(), - }, - ); - res - } -} - impl ResourceResolver for LocalExec { type Error = IotaError; diff --git a/crates/iota-single-node-benchmark/src/mock_storage.rs b/crates/iota-single-node-benchmark/src/mock_storage.rs index c0ff1624cfc..e5740a903d8 100644 --- a/crates/iota-single-node-benchmark/src/mock_storage.rs +++ b/crates/iota-single-node-benchmark/src/mock_storage.rs @@ -9,13 +9,13 @@ use std::{ use iota_storage::package_object_cache::PackageObjectCache; use iota_types::{ - base_types::{EpochId, ObjectID, ObjectRef, SequenceNumber, VersionNumber}, + base_types::{EpochId, ObjectID, SequenceNumber, VersionNumber}, error::{IotaError, IotaResult}, inner_temporary_store::InnerTemporaryStore, object::{Object, Owner}, storage::{ BackingPackageStore, ChildObjectResolver, GetSharedLocks, ObjectStore, PackageObject, - ParentSync, get_module_by_id, + get_module_by_id, }, transaction::{InputObjectKind, InputObjects, ObjectReadResult, TransactionKey}, }; @@ -170,15 +170,6 @@ impl GetModule for InMemoryObjectStore { } } -impl ParentSync for InMemoryObjectStore { - fn get_latest_parent_entry_ref_deprecated( - &self, - _object_id: ObjectID, - ) -> IotaResult> { - unreachable!() - } -} - impl GetSharedLocks for InMemoryObjectStore { fn get_shared_locks( &self, diff --git a/crates/iota-transactional-test-runner/src/simulator_persisted_store.rs b/crates/iota-transactional-test-runner/src/simulator_persisted_store.rs index 073afb43ed9..d5282dd11bc 100644 --- a/crates/iota-transactional-test-runner/src/simulator_persisted_store.rs +++ b/crates/iota-transactional-test-runner/src/simulator_persisted_store.rs @@ -20,8 +20,8 @@ use iota_types::{ }, object::{Object, Owner}, storage::{ - BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, ParentSync, - ReadStore, RestStateReader, load_package_object_from_object_store, + BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, ReadStore, + RestStateReader, load_package_object_from_object_store, }, transaction::VerifiedTransaction, }; @@ -517,15 +517,6 @@ impl ObjectStore for PersistedStore { } } -impl ParentSync for PersistedStore { - fn get_latest_parent_entry_ref_deprecated( - &self, - _object_id: ObjectID, - ) -> iota_types::error::IotaResult> { - panic!("Never called in newer protocol versions") - } -} - impl ObjectStore for PersistedStoreInnerReadOnlyWrapper { fn get_object( &self, diff --git a/crates/iota-types/src/in_memory_storage.rs b/crates/iota-types/src/in_memory_storage.rs index a0632a46109..a06b711d4e6 100644 --- a/crates/iota-types/src/in_memory_storage.rs +++ b/crates/iota-types/src/in_memory_storage.rs @@ -10,14 +10,14 @@ use move_bytecode_utils::module_cache::GetModule; use move_core_types::{language_storage::ModuleId, resolver::ModuleResolver}; use crate::{ - base_types::{ObjectID, ObjectRef, SequenceNumber, VersionNumber}, + base_types::{ObjectID, SequenceNumber, VersionNumber}, committee::EpochId, error::{IotaError, IotaResult}, inner_temporary_store::WrittenObjects, object::{Object, Owner}, storage::{ - BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, ParentSync, - get_module, get_module_by_id, load_package_object_from_object_store, + BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, get_module, + get_module_by_id, load_package_object_from_object_store, }, transaction::{ InputObjectKind, InputObjects, ObjectReadResult, Transaction, TransactionDataAPI, @@ -87,15 +87,6 @@ impl ChildObjectResolver for InMemoryStorage { } } -impl ParentSync for InMemoryStorage { - fn get_latest_parent_entry_ref_deprecated( - &self, - _object_id: ObjectID, - ) -> IotaResult> { - unreachable!("Should not be called for InMemoryStorage as it's deprecated.") - } -} - impl ModuleResolver for InMemoryStorage { type Error = IotaError; diff --git a/crates/iota-types/src/storage/mod.rs b/crates/iota-types/src/storage/mod.rs index ae5fa86124f..e685f91d39f 100644 --- a/crates/iota-types/src/storage/mod.rs +++ b/crates/iota-types/src/storage/mod.rs @@ -160,8 +160,8 @@ pub enum ObjectChange { Delete(DeleteKindWithOldVersion), } -pub trait StorageView: Storage + ParentSync + ChildObjectResolver {} -impl StorageView for T {} +pub trait StorageView: Storage + ChildObjectResolver {} +impl StorageView for T {} /// An abstraction of the (possibly distributed) store for objects. This /// API only allows for the retrieval of objects, not any state changes @@ -382,42 +382,6 @@ impl BackingPackageStore for PostExecutionPackageResolver { } } -pub trait ParentSync { - /// This function is only called by older protocol versions. - /// It creates an explicit dependency to tombstones, which is not desired. - fn get_latest_parent_entry_ref_deprecated( - &self, - object_id: ObjectID, - ) -> IotaResult>; -} - -impl ParentSync for std::sync::Arc { - fn get_latest_parent_entry_ref_deprecated( - &self, - object_id: ObjectID, - ) -> IotaResult> { - ParentSync::get_latest_parent_entry_ref_deprecated(self.as_ref(), object_id) - } -} - -impl ParentSync for &S { - fn get_latest_parent_entry_ref_deprecated( - &self, - object_id: ObjectID, - ) -> IotaResult> { - ParentSync::get_latest_parent_entry_ref_deprecated(*self, object_id) - } -} - -impl ParentSync for &mut S { - fn get_latest_parent_entry_ref_deprecated( - &self, - object_id: ObjectID, - ) -> IotaResult> { - ParentSync::get_latest_parent_entry_ref_deprecated(*self, object_id) - } -} - impl ChildObjectResolver for std::sync::Arc { fn read_child_object( &self, @@ -589,9 +553,7 @@ impl Display for DeleteKind { } } -pub trait BackingStore: - BackingPackageStore + ChildObjectResolver + ObjectStore + ParentSync -{ +pub trait BackingStore: BackingPackageStore + ChildObjectResolver + ObjectStore { fn as_object_store(&self) -> &dyn ObjectStore; } @@ -600,7 +562,6 @@ where T: BackingPackageStore, T: ChildObjectResolver, T: ObjectStore, - T: ParentSync, { fn as_object_store(&self) -> &dyn ObjectStore { self diff --git a/crates/simulacrum/src/store/in_mem_store.rs b/crates/simulacrum/src/store/in_mem_store.rs index e704f797259..cd05dc3e8a4 100644 --- a/crates/simulacrum/src/store/in_mem_store.rs +++ b/crates/simulacrum/src/store/in_mem_store.rs @@ -18,8 +18,8 @@ use iota_types::{ }, object::{Object, Owner}, storage::{ - BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, ParentSync, - get_module, load_package_object_from_object_store, + BackingPackageStore, ChildObjectResolver, ObjectStore, PackageObject, get_module, + load_package_object_from_object_store, }, transaction::VerifiedTransaction, }; @@ -326,15 +326,6 @@ impl ObjectStore for InMemoryStore { } } -impl ParentSync for InMemoryStore { - fn get_latest_parent_entry_ref_deprecated( - &self, - _object_id: ObjectID, - ) -> iota_types::error::IotaResult> { - panic!("Never called in newer protocol versions") - } -} - #[derive(Debug)] pub struct KeyStore { validator_keys: BTreeMap, diff --git a/crates/simulacrum/src/store/mod.rs b/crates/simulacrum/src/store/mod.rs index b6a2b92fc7f..0da62903796 100644 --- a/crates/simulacrum/src/store/mod.rs +++ b/crates/simulacrum/src/store/mod.rs @@ -16,7 +16,7 @@ use iota_types::{ VerifiedCheckpoint, }, object::Object, - storage::{BackingStore, ChildObjectResolver, ParentSync}, + storage::{BackingStore, ChildObjectResolver}, transaction::{ InputObjectKind, InputObjects, ObjectReadResult, ReceivingObjectReadResult, ReceivingObjects, VerifiedTransaction, @@ -25,10 +25,7 @@ use iota_types::{ pub mod in_mem_store; pub trait SimulatorStore: - iota_types::storage::BackingPackageStore - + iota_types::storage::ObjectStore - + ParentSync - + ChildObjectResolver + iota_types::storage::BackingPackageStore + iota_types::storage::ObjectStore + ChildObjectResolver { fn init_with_genesis(&mut self, genesis: &genesis::Genesis) { self.insert_checkpoint(genesis.checkpoint()); diff --git a/iota-execution/latest/iota-adapter/src/temporary_store.rs b/iota-execution/latest/iota-adapter/src/temporary_store.rs index 1f35ae0fcf2..10f5a7304f5 100644 --- a/iota-execution/latest/iota-adapter/src/temporary_store.rs +++ b/iota-execution/latest/iota-adapter/src/temporary_store.rs @@ -29,7 +29,7 @@ use iota_types::{ object::{Data, Object, Owner}, storage::{ BackingPackageStore, BackingStore, ChildObjectResolver, DenyListResult, PackageObject, - ParentSync, Storage, + Storage, }, transaction::InputObjects, }; @@ -1139,12 +1139,3 @@ impl<'backing> ResourceResolver for TemporaryStore<'backing> { } } } - -impl<'backing> ParentSync for TemporaryStore<'backing> { - fn get_latest_parent_entry_ref_deprecated( - &self, - _object_id: ObjectID, - ) -> IotaResult> { - unreachable!("Never called in newer protocol versions") - } -} diff --git a/iota-execution/v0/iota-adapter/src/temporary_store.rs b/iota-execution/v0/iota-adapter/src/temporary_store.rs index 1f35ae0fcf2..10f5a7304f5 100644 --- a/iota-execution/v0/iota-adapter/src/temporary_store.rs +++ b/iota-execution/v0/iota-adapter/src/temporary_store.rs @@ -29,7 +29,7 @@ use iota_types::{ object::{Data, Object, Owner}, storage::{ BackingPackageStore, BackingStore, ChildObjectResolver, DenyListResult, PackageObject, - ParentSync, Storage, + Storage, }, transaction::InputObjects, }; @@ -1139,12 +1139,3 @@ impl<'backing> ResourceResolver for TemporaryStore<'backing> { } } } - -impl<'backing> ParentSync for TemporaryStore<'backing> { - fn get_latest_parent_entry_ref_deprecated( - &self, - _object_id: ObjectID, - ) -> IotaResult> { - unreachable!("Never called in newer protocol versions") - } -} From d05dd0f37d21c954d87f61fe8090ad9680be2dbb Mon Sep 17 00:00:00 2001 From: muXxer Date: Wed, 30 Oct 2024 18:21:03 +0100 Subject: [PATCH 2/2] fix(node): remove unused `ParentSyncStoreGetLatestParentEntryRef` --- crates/iota-replay/src/types.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/iota-replay/src/types.rs b/crates/iota-replay/src/types.rs index 11ca9df050c..993868020a6 100644 --- a/crates/iota-replay/src/types.rs +++ b/crates/iota-replay/src/types.rs @@ -276,10 +276,6 @@ pub enum ExecutionStoreEvent { child: ObjectID, result: IotaResult>, }, - ParentSyncStoreGetLatestParentEntryRef { - object_id: ObjectID, - result: IotaResult>, - }, ResourceResolverGetResource { address: AccountAddress, typ: StructTag,