Skip to content

Commit

Permalink
temporary-store: rename AuthorityTemporaryStore -> TemporaryStore
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Jul 8, 2022
1 parent 655940e commit d322947
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 31 deletions.
18 changes: 8 additions & 10 deletions crates/sui-adapter/src/temporary_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub type InnerTemporaryStore = (
Vec<Event>,
);

pub struct AuthorityTemporaryStore<S> {
pub struct TemporaryStore<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.
Expand All @@ -45,7 +45,7 @@ pub struct AuthorityTemporaryStore<S> {
created_object_ids: HashSet<ObjectID>,
}

impl<S> AuthorityTemporaryStore<S> {
impl<S> TemporaryStore<S> {
/// Creates a new store associated with an authority store, and populates it with
/// initial objects.
pub fn new(
Expand Down Expand Up @@ -283,7 +283,7 @@ impl<S> AuthorityTemporaryStore<S> {
}
}

impl<S> Storage for AuthorityTemporaryStore<S> {
impl<S> Storage for TemporaryStore<S> {
/// Resets any mutations and deletions recorded in the store.
fn reset(&mut self) {
self.written.clear();
Expand All @@ -305,11 +305,9 @@ impl<S> Storage for AuthorityTemporaryStore<S> {
self.created_object_ids = ids;
}

/*
Invariant: A key assumption of the write-delete logic
is that an entry is not both added and deleted by the
caller.
*/
// Invariant: A key assumption of the write-delete logic
// is that an entry is not both added and deleted by the
// caller.

fn write_object(&mut self, mut object: Object) {
// there should be no write after delete
Expand Down Expand Up @@ -354,7 +352,7 @@ impl<S> Storage for AuthorityTemporaryStore<S> {
}
}

impl<S: BackingPackageStore> ModuleResolver for AuthorityTemporaryStore<S> {
impl<S: BackingPackageStore> ModuleResolver for TemporaryStore<S> {
type Error = SuiError;
fn get_module(&self, module_id: &ModuleId) -> Result<Option<Vec<u8>>, Self::Error> {
let package_id = &ObjectID::from(*module_id.address());
Expand Down Expand Up @@ -383,7 +381,7 @@ impl<S: BackingPackageStore> ModuleResolver for AuthorityTemporaryStore<S> {
}
}

impl<S> ResourceResolver for AuthorityTemporaryStore<S> {
impl<S> ResourceResolver for TemporaryStore<S> {
type Error = SuiError;

fn get_resource(
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub mod move_integration_tests;
#[path = "unit_tests/gas_tests.rs"]
mod gas_tests;

pub use sui_adapter::temporary_store::AuthorityTemporaryStore;
pub use sui_adapter::temporary_store::TemporaryStore;

mod authority_store;
pub use authority_store::{
Expand Down Expand Up @@ -581,7 +581,7 @@ impl AuthorityState {
certificate: &CertifiedTransaction,
transaction_digest: TransactionDigest,
) -> SuiResult<(
AuthorityTemporaryStore<Arc<AuthorityStore>>,
TemporaryStore<Arc<AuthorityStore>>,
SignedTransactionEffects,
)> {
let (gas_status, input_objects) = transaction_input_checker::check_transaction_input(
Expand Down Expand Up @@ -620,7 +620,7 @@ impl AuthorityState {

let transaction_dependencies = input_objects.transaction_dependencies();
let mut temporary_store =
AuthorityTemporaryStore::new(self.database.clone(), input_objects, transaction_digest);
TemporaryStore::new(self.database.clone(), input_objects, transaction_digest);
let (effects, _execution_error) = execution_engine::execute_transaction_to_effects(
shared_object_refs,
&mut temporary_store,
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<Arc<AuthorityStore>>,
temporary_store: TemporaryStore<Arc<AuthorityStore>>,
certificate: &CertifiedTransaction,
signed_effects: &SignedTransactionEffects,
) -> SuiResult {
Expand Down
14 changes: 7 additions & 7 deletions crates/sui-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ impl<S: Eq + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
/// version, and then writes locks, objects, certificates, parents atomically.
pub async fn update_state<BackingPackageStore>(
&self,
temporary_store: AuthorityTemporaryStore<BackingPackageStore>,
temporary_store: TemporaryStore<BackingPackageStore>,
certificate: &CertifiedTransaction,
proposed_seq: TxSequenceNumber,
effects: &TransactionEffectsEnvelope<S>,
Expand Down Expand Up @@ -694,7 +694,7 @@ impl<S: Eq + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
/// Persist temporary storage to DB for genesis modules
pub async fn update_objects_state_for_genesis<BackingPackageStore>(
&self,
temporary_store: AuthorityTemporaryStore<BackingPackageStore>,
temporary_store: TemporaryStore<BackingPackageStore>,
transaction_digest: TransactionDigest,
) -> Result<(), SuiError> {
debug_assert_eq!(transaction_digest, TransactionDigest::genesis());
Expand Down Expand Up @@ -723,7 +723,7 @@ impl<S: Eq + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
) -> SuiResult {
let transaction_digest = certificate.digest();
let mut temporary_store =
AuthorityTemporaryStore::new(Arc::new(&self), input_objects, *transaction_digest);
TemporaryStore::new(Arc::new(&self), input_objects, *transaction_digest);
for (_, object) in mutated_objects {
temporary_store.write_object(object);
}
Expand Down Expand Up @@ -756,7 +756,7 @@ impl<S: Eq + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
async fn sequence_tx<BackingPackageStore>(
&self,
write_batch: DBBatch,
temporary_store: AuthorityTemporaryStore<BackingPackageStore>,
temporary_store: TemporaryStore<BackingPackageStore>,
transaction_digest: &TransactionDigest,
proposed_seq: TxSequenceNumber,
effects: &TransactionEffectsEnvelope<S>,
Expand Down Expand Up @@ -805,7 +805,7 @@ impl<S: Eq + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
async fn batch_update_objects<BackingPackageStore>(
&self,
mut write_batch: DBBatch,
temporary_store: AuthorityTemporaryStore<BackingPackageStore>,
temporary_store: TemporaryStore<BackingPackageStore>,
transaction_digest: TransactionDigest,
update_type: UpdateType,
) -> SuiResult<Option<TxSequenceNumber>> {
Expand Down Expand Up @@ -1480,7 +1480,7 @@ pub async fn store_package_and_init_modules_for_genesis<

debug_assert!(ctx.digest() == TransactionDigest::genesis());
let mut temporary_store =
AuthorityTemporaryStore::new(store.clone(), InputObjects::new(filtered), ctx.digest());
TemporaryStore::new(store.clone(), InputObjects::new(filtered), ctx.digest());
let package_id = ObjectID::from(*modules[0].self_id().address());
let natives = native_functions.clone();
let mut gas_status = SuiGasStatus::new_unmetered();
Expand Down Expand Up @@ -1511,7 +1511,7 @@ pub async fn generate_genesis_system_object<S: Eq + Serialize + for<'de> Deseria
) -> SuiResult {
let genesis_digest = genesis_ctx.digest();
let mut temporary_store =
AuthorityTemporaryStore::new(store.clone(), InputObjects::new(vec![]), genesis_digest);
TemporaryStore::new(store.clone(), InputObjects::new(vec![]), genesis_digest);
let mut pubkeys = Vec::new();
for name in committee.names() {
pubkeys.push(committee.public_key(name)?.to_bytes().to_vec());
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-core/src/epoch/tests/reconfiguration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use sui_types::{

use crate::gateway_state::GatewayMetrics;
use crate::{
authority::AuthorityTemporaryStore, authority_active::ActiveAuthority,
authority::TemporaryStore, authority_active::ActiveAuthority,
authority_aggregator::authority_aggregator_tests::init_local_authorities,
checkpoints::CheckpointLocals, epoch::reconfiguration::CHECKPOINT_COUNT_PER_EPOCH,
execution_engine,
Expand Down Expand Up @@ -128,7 +128,7 @@ async fn test_start_epoch_change() {
// Test that for certificates that have finished execution and is about to write effects,
// they will also fail to get a ticket for the commit.
let tx_digest = *transaction.digest();
let mut temporary_store = AuthorityTemporaryStore::new(
let mut temporary_store = TemporaryStore::new(
state.database.clone(),
InputObjects::new(
transaction
Expand Down
12 changes: 6 additions & 6 deletions crates/sui-core/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use move_core_types::ident_str;
use move_core_types::identifier::Identifier;
use std::{collections::BTreeSet, sync::Arc};

use crate::authority::AuthorityTemporaryStore;
use crate::authority::TemporaryStore;
use move_core_types::language_storage::ModuleId;
use move_vm_runtime::{move_vm::MoveVM, native_functions::NativeFunctionTable};
use sui_adapter::adapter;
Expand Down Expand Up @@ -33,7 +33,7 @@ use tracing::{debug, instrument, trace};
#[instrument(name = "tx_execute_to_effects", level = "debug", skip_all)]
pub fn execute_transaction_to_effects<S: BackingPackageStore>(
shared_object_refs: Vec<ObjectRef>,
temporary_store: &mut AuthorityTemporaryStore<S>,
temporary_store: &mut TemporaryStore<S>,
transaction_data: TransactionData,
transaction_digest: TransactionDigest,
mut transaction_dependencies: BTreeSet<TransactionDigest>,
Expand Down Expand Up @@ -85,7 +85,7 @@ pub fn execute_transaction_to_effects<S: BackingPackageStore>(
}

fn charge_gas_for_object_read<S>(
temporary_store: &AuthorityTemporaryStore<S>,
temporary_store: &TemporaryStore<S>,
gas_status: &mut SuiGasStatus,
) -> Result<(), ExecutionError> {
// Charge gas for reading all objects from the DB.
Expand All @@ -101,7 +101,7 @@ fn charge_gas_for_object_read<S>(

#[instrument(name = "tx_execute", level = "debug", skip_all)]
fn execute_transaction<S: BackingPackageStore>(
temporary_store: &mut AuthorityTemporaryStore<S>,
temporary_store: &mut TemporaryStore<S>,
transaction_data: TransactionData,
gas_object_id: ObjectID,
tx_ctx: &mut TxContext,
Expand Down Expand Up @@ -242,7 +242,7 @@ fn execute_transaction<S: BackingPackageStore>(
}

fn transfer_object<S>(
temporary_store: &mut AuthorityTemporaryStore<S>,
temporary_store: &mut TemporaryStore<S>,
mut object: Object,
sender: SuiAddress,
recipient: SuiAddress,
Expand Down Expand Up @@ -270,7 +270,7 @@ fn transfer_object<S>(
/// We make sure that the gas object's version is not incremented after this function call, because
/// when we charge gas later, its version will be officially incremented.
fn transfer_sui<S>(
temporary_store: &mut AuthorityTemporaryStore<S>,
temporary_store: &mut TemporaryStore<S>,
mut object: Object,
recipient: SuiAddress,
amount: Option<u64>,
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use std::{
sync::Arc,
};
use sui_adapter::{adapter::new_move_vm, genesis};
use sui_core::{authority::AuthorityTemporaryStore, execution_engine};
use sui_core::{authority::TemporaryStore, execution_engine};
use sui_framework::DEFAULT_FRAMEWORK_PATH;
use sui_types::{
base_types::{
Expand Down Expand Up @@ -470,7 +470,7 @@ impl<'a> SuiTestAdapter<'a> {
let transaction_dependencies = input_objects.transaction_dependencies();
let shared_object_refs: Vec<_> = input_objects.filter_shared_objects();
let mut temporary_store =
AuthorityTemporaryStore::new(self.storage.clone(), input_objects, transaction_digest);
TemporaryStore::new(self.storage.clone(), input_objects, transaction_digest);
let (
TransactionEffects {
status,
Expand Down

0 comments on commit d322947

Please sign in to comment.