Skip to content

Commit

Permalink
A few gateway fixes (MystenLabs#3488)
Browse files Browse the repository at this point in the history
* [gateway] Do not initialize lock for shared object

* [gateway] No need to redownload framework again and again
  • Loading branch information
lxfind authored Jul 26, 2022
1 parent 4230348 commit 88940ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/sui-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,17 @@ impl<S: Eq + Serialize + for<'de> Deserialize<'de>> SuiDataStore<S> {
&(object.owner, object_ref.0),
&ObjectInfo::new(&object_ref, object),
)?;
// Only initialize lock for owned objects.
// TODO: Skip this for quasi-shared objects.
self.lock_service
.initialize_locks(&[object_ref], false /* is_force_reset */)
.await?;
}

// Update the parent
self.parent_sync
.insert(&object_ref, &object.previous_transaction)?;

self.lock_service
.initialize_locks(&[object_ref], false /* is_force_reset */)
.await?;

Ok(())
}

Expand Down
7 changes: 7 additions & 0 deletions crates/sui-core/src/gateway_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ where
/// And when it's out-of-dated in the rare case, we need to be able to understand the error
/// returned from validators and update the object locally so that the wallet can retry.
async fn get_object_internal(&self, object_id: &ObjectID) -> SuiResult<Object> {
if let Ok(Some(o)) = self.store.get_object(object_id) {
if o.is_immutable() {
// If an object is immutable, it can never be mutated and hence is guaranteed to
// be up-to-date. No need to download from validators.
return Ok(o);
}
}
let object = self
.download_object_from_authorities(*object_id)
.await?
Expand Down

0 comments on commit 88940ee

Please sign in to comment.