Skip to content

Commit

Permalink
Minor cleanup in acquire_shared_locks_from_effects (#16527)
Browse files Browse the repository at this point in the history
## Description 

Minor nits including renaming variables, cleanup types and remove link
overrides.

## Test Plan 

CI

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
lxfind authored Mar 5, 2024
1 parent 5f1ba74 commit debcc9d
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ impl AuthorityPerEpochStore {
// successfully for each affected object id.
async fn get_or_init_next_object_versions(
&self,
objects_to_init: impl Iterator<Item = (ObjectID, SequenceNumber)> + Clone,
objects_to_init: &[(ObjectID, SequenceNumber)],
cache_reader: &dyn ExecutionCacheRead,
) -> SuiResult<HashMap<ObjectID, SequenceNumber>> {
let mut ret: HashMap<_, _>;
Expand All @@ -1328,16 +1328,16 @@ impl AuthorityPerEpochStore {
let tables = self.tables()?;
let mut db_transaction = tables.next_shared_object_versions.transaction()?;

let ids = objects_to_init.clone().map(|(id, _)| id);
let ids: Vec<_> = objects_to_init.iter().map(|(id, _)| *id).collect();

let next_versions = db_transaction
.multi_get(&self.tables()?.next_shared_object_versions, ids.clone())?;

let uninitialized_objects: Vec<(ObjectID, SequenceNumber)> = next_versions
.iter()
.zip(objects_to_init.clone())
.zip(objects_to_init)
.filter_map(|(next_version, id_and_version)| match next_version {
None => Some(id_and_version),
None => Some(*id_and_version),
Some(_) => None,
})
.collect();
Expand Down Expand Up @@ -1385,28 +1385,18 @@ impl AuthorityPerEpochStore {

async fn set_assigned_shared_object_versions(
&self,
certificate: &VerifiedExecutableTransaction,
tx_digest: &TransactionDigest,
init_shared_versions: &[(ObjectID, SequenceNumber)],
assigned_versions: &Vec<(ObjectID, SequenceNumber)>,
cache_reader: &dyn ExecutionCacheRead,
) -> SuiResult {
let tx_digest = certificate.digest();

debug!(
?tx_digest,
?assigned_versions,
"set_assigned_shared_object_versions"
);

#[allow(clippy::needless_collect)]
let shared_input_objects: Vec<_> = certificate
.data()
.transaction_data()
.kind()
.shared_input_objects()
.map(SharedInputObject::into_id_and_version)
.collect();

self.get_or_init_next_object_versions(shared_input_objects.into_iter(), cache_reader)
self.get_or_init_next_object_versions(init_shared_versions, cache_reader)
.await?;
self.tables()?
.assigned_shared_object_versions
Expand Down Expand Up @@ -1525,13 +1515,19 @@ impl AuthorityPerEpochStore {
effects: &TransactionEffects,
cache_reader: &dyn ExecutionCacheRead,
) -> SuiResult {
let init_shared_versions: Vec<_> = certificate
.shared_input_objects()
.map(SharedInputObject::into_id_and_version)
.collect();
let assigned_versions: Vec<_> = effects
.input_shared_objects()
.into_iter()
.map(|iso| iso.id_and_version())
.collect();
self.set_assigned_shared_object_versions(
certificate,
&effects
.input_shared_objects()
.into_iter()
.map(|iso| iso.id_and_version())
.collect(),
certificate.digest(),
&init_shared_versions,
&assigned_versions,
cache_reader,
)
.await
Expand Down Expand Up @@ -2473,11 +2469,8 @@ impl AuthorityPerEpochStore {
shared_input_objects
};

self.get_or_init_next_object_versions(
unique_shared_input_objects.into_iter(),
cache_reader,
)
.await?
self.get_or_init_next_object_versions(&unique_shared_input_objects, cache_reader)
.await?
};

let mut deferred_txns: BTreeMap<DeferralKey, Vec<VerifiedSequencedConsensusTransaction>> =
Expand Down

0 comments on commit debcc9d

Please sign in to comment.