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

refactor(iota-types): Remove trait ParentSync #3799

Merged
merged 4 commits into from
Oct 31, 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
11 changes: 1 addition & 10 deletions crates/iota-core/src/execution_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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<Option<ObjectRef>> {
ObjectCacheRead::get_latest_object_ref_or_tombstone(self, object_id)
}
}
};
}

Expand Down
37 changes: 2 additions & 35 deletions crates/iota-replay/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Option<ObjectRef>> {
fn inner(self_: &LocalExec, object_id: ObjectID) -> IotaResult<Option<ObjectRef>> {
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 {
miker83z marked this conversation as resolved.
Show resolved Hide resolved
object_id,
result: res.clone(),
},
);
res
}
}

impl ResourceResolver for LocalExec {
type Error = IotaError;

Expand Down
4 changes: 0 additions & 4 deletions crates/iota-replay/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ pub enum ExecutionStoreEvent {
child: ObjectID,
result: IotaResult<Option<Object>>,
},
ParentSyncStoreGetLatestParentEntryRef {
object_id: ObjectID,
result: IotaResult<Option<ObjectRef>>,
},
ResourceResolverGetResource {
address: AccountAddress,
typ: StructTag,
Expand Down
13 changes: 2 additions & 11 deletions crates/iota-single-node-benchmark/src/mock_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -170,15 +170,6 @@ impl GetModule for InMemoryObjectStore {
}
}

impl ParentSync for InMemoryObjectStore {
fn get_latest_parent_entry_ref_deprecated(
&self,
_object_id: ObjectID,
) -> IotaResult<Option<ObjectRef>> {
unreachable!()
}
}

impl GetSharedLocks for InMemoryObjectStore {
fn get_shared_locks(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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<Option<iota_types::base_types::ObjectRef>> {
panic!("Never called in newer protocol versions")
}
}

impl ObjectStore for PersistedStoreInnerReadOnlyWrapper {
fn get_object(
&self,
Expand Down
15 changes: 3 additions & 12 deletions crates/iota-types/src/in_memory_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -87,15 +87,6 @@ impl ChildObjectResolver for InMemoryStorage {
}
}

impl ParentSync for InMemoryStorage {
fn get_latest_parent_entry_ref_deprecated(
&self,
_object_id: ObjectID,
) -> IotaResult<Option<ObjectRef>> {
unreachable!("Should not be called for InMemoryStorage as it's deprecated.")
}
}

impl ModuleResolver for InMemoryStorage {
type Error = IotaError;

Expand Down
45 changes: 3 additions & 42 deletions crates/iota-types/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ pub enum ObjectChange {
Delete(DeleteKindWithOldVersion),
}

pub trait StorageView: Storage + ParentSync + ChildObjectResolver {}
impl<T: Storage + ParentSync + ChildObjectResolver> StorageView for T {}
pub trait StorageView: Storage + ChildObjectResolver {}
impl<T: Storage + ChildObjectResolver> 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
Expand Down Expand Up @@ -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<Option<ObjectRef>>;
}

impl<S: ParentSync> ParentSync for std::sync::Arc<S> {
fn get_latest_parent_entry_ref_deprecated(
&self,
object_id: ObjectID,
) -> IotaResult<Option<ObjectRef>> {
ParentSync::get_latest_parent_entry_ref_deprecated(self.as_ref(), object_id)
}
}

impl<S: ParentSync> ParentSync for &S {
fn get_latest_parent_entry_ref_deprecated(
&self,
object_id: ObjectID,
) -> IotaResult<Option<ObjectRef>> {
ParentSync::get_latest_parent_entry_ref_deprecated(*self, object_id)
}
}

impl<S: ParentSync> ParentSync for &mut S {
fn get_latest_parent_entry_ref_deprecated(
&self,
object_id: ObjectID,
) -> IotaResult<Option<ObjectRef>> {
ParentSync::get_latest_parent_entry_ref_deprecated(*self, object_id)
}
}

impl<S: ChildObjectResolver> ChildObjectResolver for std::sync::Arc<S> {
fn read_child_object(
&self,
Expand Down Expand Up @@ -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;
}

Expand All @@ -600,7 +562,6 @@ where
T: BackingPackageStore,
T: ChildObjectResolver,
T: ObjectStore,
T: ParentSync,
{
fn as_object_store(&self) -> &dyn ObjectStore {
self
Expand Down
13 changes: 2 additions & 11 deletions crates/simulacrum/src/store/in_mem_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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<Option<iota_types::base_types::ObjectRef>> {
panic!("Never called in newer protocol versions")
}
}

#[derive(Debug)]
pub struct KeyStore {
validator_keys: BTreeMap<AuthorityName, AuthorityKeyPair>,
Expand Down
7 changes: 2 additions & 5 deletions crates/simulacrum/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use iota_types::{
VerifiedCheckpoint,
},
object::Object,
storage::{BackingStore, ChildObjectResolver, ParentSync},
storage::{BackingStore, ChildObjectResolver},
transaction::{
InputObjectKind, InputObjects, ObjectReadResult, ReceivingObjectReadResult,
ReceivingObjects, VerifiedTransaction,
Expand All @@ -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());
Expand Down
11 changes: 1 addition & 10 deletions iota-execution/latest/iota-adapter/src/temporary_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use iota_types::{
object::{Data, Object, Owner},
storage::{
BackingPackageStore, BackingStore, ChildObjectResolver, DenyListResult, PackageObject,
ParentSync, Storage,
Storage,
},
transaction::InputObjects,
};
Expand Down Expand Up @@ -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<Option<ObjectRef>> {
unreachable!("Never called in newer protocol versions")
}
}
11 changes: 1 addition & 10 deletions iota-execution/v0/iota-adapter/src/temporary_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use iota_types::{
object::{Data, Object, Owner},
storage::{
BackingPackageStore, BackingStore, ChildObjectResolver, DenyListResult, PackageObject,
ParentSync, Storage,
Storage,
},
transaction::InputObjects,
};
Expand Down Expand Up @@ -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<Option<ObjectRef>> {
unreachable!("Never called in newer protocol versions")
}
}
Loading