From d3076723802a94731cb13b94779bdccd11fe8b7c Mon Sep 17 00:00:00 2001 From: Ge Gao <106119108+gegaowp@users.noreply.github.com> Date: Thu, 11 May 2023 10:51:34 -0400 Subject: [PATCH] fn: remove object IDs from transactions_to_addr index (#11314) ## Description transactions_to_addr now includes both address and object IDs. Related posts are https://mysten-labs.slack.com/archives/C04FG4Q7YJ3/p1682369162080879 https://mysten-labs.slack.com/archives/C04HS54LHUM/p1682039873458439 ## Test Plan CI test run local FN + Explorer and make sure 0x5 is not showing as address any more. --- crates/sui-storage/src/indexes.rs | 2 +- crates/sui-types/src/object.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/sui-storage/src/indexes.rs b/crates/sui-storage/src/indexes.rs index e4ce9ccec89f2..aafe5f8b8c9fb 100644 --- a/crates/sui-storage/src/indexes.rs +++ b/crates/sui-storage/src/indexes.rs @@ -482,7 +482,7 @@ impl IndexStore { &self.tables.transactions_to_addr, mutated_objects.filter_map(|(_, owner)| { owner - .get_owner_address() + .get_address_owner_address() .ok() .map(|addr| ((addr, sequence), digest)) }), diff --git a/crates/sui-types/src/object.rs b/crates/sui-types/src/object.rs index c9a67b46288ba..22f007b9c1cca 100644 --- a/crates/sui-types/src/object.rs +++ b/crates/sui-types/src/object.rs @@ -488,6 +488,19 @@ pub enum Owner { } impl Owner { + // NOTE: only return address of AddressOwner, otherwise return error, + // ObjectOwner's address is converted from object id, thus we will skip it. + pub fn get_address_owner_address(&self) -> SuiResult { + match self { + Self::AddressOwner(address) => Ok(*address), + Self::Shared { .. } | Self::Immutable | Self::ObjectOwner(_) => { + Err(SuiError::UnexpectedOwnerType) + } + } + } + + // NOTE: this function will return address of both AddressOwner and ObjectOwner, + // address of ObjectOwner is converted from object id, even though the type is SuiAddress. pub fn get_owner_address(&self) -> SuiResult { match self { Self::AddressOwner(address) | Self::ObjectOwner(address) => Ok(*address),