Skip to content

Commit

Permalink
Implement ConsensusV2 object handling in sui-execution (MystenLabs#20445
Browse files Browse the repository at this point in the history
)

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
aschran authored Dec 2, 2024
1 parent f66f5ea commit 5bc14df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions crates/sui-types/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ pub enum Authenticator {

impl Authenticator {
pub fn as_single_owner(&self) -> &SuiAddress {
// NOTE: Existing callers are written assuming that only singly-owned
// ConsensusV2 objects exist. If additional Authenticator variants are
// added, do not simply panic here. Instead, change the return type of
// this function and update callers accordingly.
match self {
Self::SingleOwner(address) => address,
}
Expand Down
4 changes: 1 addition & 3 deletions sui-execution/latest/sui-adapter/src/temporary_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl<'backing> TemporaryStore<'backing> {
assert!(sender == a, "Input object must be owned by sender");
Some(id)
}
Owner::Shared { .. } => Some(id),
Owner::Shared { .. } | Owner::ConsensusV2 { .. } => Some(id),
Owner::Immutable => {
// object is authenticated, but it cannot own other objects,
// so we should not add it to `authenticated_objs`
Expand All @@ -559,8 +559,6 @@ impl<'backing> TemporaryStore<'backing> {
"Input objects must be address owned, shared, consensus, or immutable"
)
}
// TODO: Implement support for ConsensusV2 objects.
Owner::ConsensusV2 { .. } => todo!(),
}
})
.filter(|id| {
Expand Down
21 changes: 17 additions & 4 deletions sui-execution/latest/sui-move-natives/src/test_scenario.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,17 @@ pub fn end_transaction(
.or_default()
.insert(id);
}
// TODO: Implement support for ConsensusV2 objects.
Owner::ConsensusV2 { .. } => todo!(),
Owner::ConsensusV2 { authenticator, .. } => {
// Treat ConsensusV2 objects the same as address-owned for now. This will have
// to be revisited when other Authenticators are added.
inventories
.address_inventories
.entry(*authenticator.as_single_owner())
.or_default()
.entry(ty)
.or_default()
.insert(id);
}
}
}

Expand Down Expand Up @@ -833,8 +842,12 @@ fn transaction_effects(
Owner::ObjectOwner(o) => transferred_to_object.push((pack_id(id), pack_id(o))),
Owner::Shared { .. } => shared.push(id),
Owner::Immutable => frozen.push(id),
// TODO: Implement support for ConsensusV2 objects.
Owner::ConsensusV2 { .. } => todo!(),
// Treat ConsensusV2 objects the same as address-owned for now. This will have
// to be revisited when other Authenticators are added.
Owner::ConsensusV2 { authenticator, .. } => transferred_to_account.push((
pack_id(id),
Value::address((*authenticator.as_single_owner()).into()),
)),
}
}

Expand Down

0 comments on commit 5bc14df

Please sign in to comment.