Skip to content

Commit

Permalink
temporary-store: don't require package store to be in an Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Jul 8, 2022
1 parent 2ec4309 commit 655940e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 2 additions & 3 deletions crates/sui-adapter/src/temporary_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use move_core_types::account_address::AccountAddress;
use move_core_types::language_storage::{ModuleId, StructTag};
use move_core_types::resolver::{ModuleResolver, ResourceResolver};
use std::collections::{BTreeMap, HashSet};
use std::sync::Arc;
use sui_types::base_types::{
ObjectDigest, ObjectID, ObjectRef, SequenceNumber, SuiAddress, TransactionDigest,
};
Expand All @@ -32,7 +31,7 @@ pub struct AuthorityTemporaryStore<S> {
// The backing store for retrieving Move packages onchain.
// When executing a Move call, the dependent packages are not going to be
// in the input objects. They will be feteched from the backing store.
package_store: Arc<S>,
package_store: S,
tx_digest: TransactionDigest,
objects: BTreeMap<ObjectID, Object>,
mutable_inputs: Vec<ObjectRef>, // Inputs that are mutable
Expand All @@ -50,7 +49,7 @@ impl<S> AuthorityTemporaryStore<S> {
/// Creates a new store associated with an authority store, and populates it with
/// initial objects.
pub fn new(
package_store: Arc<S>,
package_store: S,
input_objects: InputObjects,
tx_digest: TransactionDigest,
) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ impl AuthorityState {
certificate: &CertifiedTransaction,
transaction_digest: TransactionDigest,
) -> SuiResult<(
AuthorityTemporaryStore<AuthorityStore>,
AuthorityTemporaryStore<Arc<AuthorityStore>>,
SignedTransactionEffects,
)> {
let (gas_status, input_objects) = transaction_input_checker::check_transaction_input(
Expand Down Expand Up @@ -1368,7 +1368,7 @@ impl AuthorityState {
#[instrument(name = "commit_certificate", level = "debug", skip_all)]
pub(crate) async fn commit_certificate(
&self,
temporary_store: AuthorityTemporaryStore<AuthorityStore>,
temporary_store: AuthorityTemporaryStore<Arc<AuthorityStore>>,
certificate: &CertifiedTransaction,
signed_effects: &SignedTransactionEffects,
) -> SuiResult {
Expand Down
12 changes: 12 additions & 0 deletions crates/sui-types/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ pub trait Storage {
pub trait BackingPackageStore {
fn get_package(&self, package_id: &ObjectID) -> SuiResult<Option<Object>>;
}

impl<S: BackingPackageStore> BackingPackageStore for std::sync::Arc<S> {
fn get_package(&self, package_id: &ObjectID) -> SuiResult<Option<Object>> {
BackingPackageStore::get_package(self.as_ref(), package_id)
}
}

impl<S: BackingPackageStore> BackingPackageStore for &S {
fn get_package(&self, package_id: &ObjectID) -> SuiResult<Option<Object>> {
BackingPackageStore::get_package(*self, package_id)
}
}

0 comments on commit 655940e

Please sign in to comment.