diff --git a/crates/sui-indexer-alt/migrations/2024-10-27-150938_sum_obj_types/up.sql b/crates/sui-indexer-alt/migrations/2024-10-27-150938_sum_obj_types/up.sql index a2ea3ca54b396..4658689f7823a 100644 --- a/crates/sui-indexer-alt/migrations/2024-10-27-150938_sum_obj_types/up.sql +++ b/crates/sui-indexer-alt/migrations/2024-10-27-150938_sum_obj_types/up.sql @@ -17,11 +17,6 @@ CREATE TABLE IF NOT EXISTS sum_obj_types -- another object (kind 2), which relates to dynamic fields, and an object -- that is owned by another object's address (kind 1), which relates to -- transfer-to-object. - -- - -- Warning: This column may look similar to the concept of "ObjectOwner" - -- but is NOT the same. For purposes of determining owner_kind, ConsensusV2 - -- objects are mapped onto the variants described above based on their - -- authenticator. owner_kind SMALLINT NOT NULL, -- The address for address-owned objects, and the parent object for -- object-owned objects. diff --git a/crates/sui-indexer-alt/migrations/2024-10-28-144002_sum_coin_balances/up.sql b/crates/sui-indexer-alt/migrations/2024-10-28-144002_sum_coin_balances/up.sql index 84894c295d0c9..dbd93cc74539c 100644 --- a/crates/sui-indexer-alt/migrations/2024-10-28-144002_sum_coin_balances/up.sql +++ b/crates/sui-indexer-alt/migrations/2024-10-28-144002_sum_coin_balances/up.sql @@ -6,7 +6,8 @@ CREATE TABLE IF NOT EXISTS sum_coin_balances ( object_id BYTEA PRIMARY KEY, object_version BIGINT NOT NULL, - -- The address that owns this version of the coin. + -- The address that owns this version of the coin (it is guaranteed to be + -- address-owned). owner_id BYTEA NOT NULL, -- The type of the coin, as a BCS-serialized `TypeTag`. This is only the -- marker type, and not the full object type (e.g. `0x0...02::sui::SUI`). diff --git a/crates/sui-indexer-alt/migrations/2024-11-25-211949_obj_info/up.sql b/crates/sui-indexer-alt/migrations/2024-11-25-211949_obj_info/up.sql index a9153bc2634bc..e04214a8e2cba 100644 --- a/crates/sui-indexer-alt/migrations/2024-11-25-211949_obj_info/up.sql +++ b/crates/sui-indexer-alt/migrations/2024-11-25-211949_obj_info/up.sql @@ -21,11 +21,6 @@ CREATE TABLE IF NOT EXISTS obj_info -- another object (kind 2), which relates to dynamic fields, and an object -- that is owned by another object's address (kind 1), which relates to -- transfer-to-object. - -- - -- Warning: This column may look similar to the concept of "ObjectOwner" - -- but is NOT the same. For purposes of determining owner_kind, ConsensusV2 - -- objects are mapped onto the variants described above based on their - -- authenticator. owner_kind SMALLINT, -- The address for address-owned objects, and the parent object for -- object-owned objects. diff --git a/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/down.sql b/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/down.sql deleted file mode 100644 index fca9bf58a75d7..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/down.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE sum_coin_balances -DROP COLUMN owner_kind; - -ALTER TABLE wal_coin_balances -DROP COLUMN owner_kind; diff --git a/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/metadata.toml b/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/metadata.toml deleted file mode 100644 index 79e9221c1f2a4..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/metadata.toml +++ /dev/null @@ -1 +0,0 @@ -run_in_transaction = false diff --git a/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/up.sql b/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/up.sql deleted file mode 100644 index 814f30833efe8..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-02-185822_add_coin_balance_owner_kind/up.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE sum_coin_balances -ADD COLUMN coin_owner_kind SMALLINT NOT NULL DEFAULT 1; - -ALTER TABLE wal_coin_balances -ADD COLUMN coin_owner_kind SMALLINT; -UPDATE wal_coin_balances SET coin_owner_kind = 1 WHERE owner_id IS NOT NULL; diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/down.sql b/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/down.sql deleted file mode 100644 index c5113e3fb4646..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE INDEX CONCURRENTLY IF NOT EXISTS sum_coin_balances_owner_type -ON sum_coin_balances (owner_id, coin_type, coin_balance, object_id, object_version); diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/metadata.toml b/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/metadata.toml deleted file mode 100644 index 79e9221c1f2a4..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/metadata.toml +++ /dev/null @@ -1 +0,0 @@ -run_in_transaction = false diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/up.sql b/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/up.sql deleted file mode 100644 index fe1a5d5403c98..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-153042_add_coin_balance_owner_kind_indexes/up.sql +++ /dev/null @@ -1 +0,0 @@ -DROP INDEX CONCURRENTLY IF EXISTS sum_coin_balances_owner_type; diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/down.sql b/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/down.sql deleted file mode 100644 index 101b35951452e..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP INDEX CONCURRENTLY IF EXISTS sum_coin_balances_owner_kind_owner_id_type; diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/metadata.toml b/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/metadata.toml deleted file mode 100644 index 79e9221c1f2a4..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/metadata.toml +++ /dev/null @@ -1 +0,0 @@ -run_in_transaction = false diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/up.sql b/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/up.sql deleted file mode 100644 index 4523c74ea17cf..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162242_add_coin_balance_owner_kind_indexes/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE INDEX CONCURRENTLY IF NOT EXISTS sum_coin_balances_owner_kind_owner_id_type -ON sum_coin_balances (coin_owner_kind, owner_id, coin_type, coin_balance, object_id, object_version); diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/down.sql b/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/down.sql deleted file mode 100644 index 481c41dfe8c36..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE INDEX CONCURRENTLY IF NOT EXISTS wal_coin_balances_owner_type -ON wal_coin_balances (owner_id, coin_type, coin_balance, object_id, object_version); diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/metadata.toml b/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/metadata.toml deleted file mode 100644 index 79e9221c1f2a4..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/metadata.toml +++ /dev/null @@ -1 +0,0 @@ -run_in_transaction = false diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/up.sql b/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/up.sql deleted file mode 100644 index 43423e3f1a602..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162243_add_coin_balance_owner_kind_indexes/up.sql +++ /dev/null @@ -1 +0,0 @@ -DROP INDEX CONCURRENTLY IF EXISTS wal_coin_balances_owner_type; diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/down.sql b/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/down.sql deleted file mode 100644 index 4ce679e9d2d3f..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP INDEX CONCURRENTLY IF EXISTS wal_coin_balances_owner_kind_owner_id_type; diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/metadata.toml b/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/metadata.toml deleted file mode 100644 index 79e9221c1f2a4..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/metadata.toml +++ /dev/null @@ -1 +0,0 @@ -run_in_transaction = false diff --git a/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/up.sql b/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/up.sql deleted file mode 100644 index 3a22bc1459c87..0000000000000 --- a/crates/sui-indexer-alt/migrations/2024-12-05-162244_add_coin_balance_owner_kind_indexes/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE INDEX CONCURRENTLY IF NOT EXISTS wal_coin_balances_owner_kind_owner_id_type -ON wal_coin_balances (coin_owner_kind, owner_id, coin_type, coin_balance, object_id, object_version); diff --git a/crates/sui-indexer-alt/src/handlers/sum_coin_balances.rs b/crates/sui-indexer-alt/src/handlers/sum_coin_balances.rs index 1409e590e2561..be196f04b7b86 100644 --- a/crates/sui-indexer-alt/src/handlers/sum_coin_balances.rs +++ b/crates/sui-indexer-alt/src/handlers/sum_coin_balances.rs @@ -21,7 +21,7 @@ use sui_types::{ }; use crate::{ - models::objects::{StoredCoinOwnerKind, StoredObjectUpdate, StoredSumCoinBalance}, + models::objects::{StoredObjectUpdate, StoredSumCoinBalance}, schema::sum_coin_balances, }; @@ -98,17 +98,9 @@ impl Processor for SumCoinBalances { continue; }; - // Coin balance only tracks address-owned or ConsensusV2 objects - let (coin_owner_kind, owner_id) = match object.owner() { - Owner::AddressOwner(owner_id) => (StoredCoinOwnerKind::Fastpath, owner_id), - // ConsensusV2 objects are treated as address-owned for now in indexers. - // This will need to be updated if additional Authenticators are added. - Owner::ConsensusV2 { authenticator, .. } => ( - StoredCoinOwnerKind::Consensus, - authenticator.as_single_owner(), - ), - - Owner::Immutable | Owner::ObjectOwner(_) | Owner::Shared { .. } => continue, + // Coin balance only tracks address-owned objects + let Owner::AddressOwner(owner_id) = object.owner() else { + continue; }; let Some(coin) = object.as_coin_maybe() else { @@ -131,7 +123,6 @@ impl Processor for SumCoinBalances { owner_id: owner_id.to_vec(), coin_type: coin_type.clone(), coin_balance: coin.balance.value() as i64, - coin_owner_kind, }), }); } @@ -181,8 +172,6 @@ impl Handler for SumCoinBalances { sum_coin_balances::owner_id.eq(excluded(sum_coin_balances::owner_id)), sum_coin_balances::coin_balance .eq(excluded(sum_coin_balances::coin_balance)), - sum_coin_balances::coin_owner_kind - .eq(excluded(sum_coin_balances::coin_owner_kind)), )) .execute(conn), ), diff --git a/crates/sui-indexer-alt/src/handlers/sum_obj_types.rs b/crates/sui-indexer-alt/src/handlers/sum_obj_types.rs index ec736e38ef1fa..21264c2a54070 100644 --- a/crates/sui-indexer-alt/src/handlers/sum_obj_types.rs +++ b/crates/sui-indexer-alt/src/handlers/sum_obj_types.rs @@ -98,9 +98,8 @@ impl Processor for SumObjTypes { Owner::ObjectOwner(_) => StoredOwnerKind::Object, Owner::Shared { .. } => StoredOwnerKind::Shared, Owner::Immutable => StoredOwnerKind::Immutable, - // ConsensusV2 objects are treated as address-owned for now in indexers. - // This will need to be updated if additional Authenticators are added. - Owner::ConsensusV2 { .. } => StoredOwnerKind::Address, + // TODO: Implement support for ConsensusV2 objects. + Owner::ConsensusV2 { .. } => todo!(), }, owner_id: match object.owner() { diff --git a/crates/sui-indexer-alt/src/handlers/wal_coin_balances.rs b/crates/sui-indexer-alt/src/handlers/wal_coin_balances.rs index 2f89d2fa8656e..ebc28dd8f5672 100644 --- a/crates/sui-indexer-alt/src/handlers/wal_coin_balances.rs +++ b/crates/sui-indexer-alt/src/handlers/wal_coin_balances.rs @@ -49,8 +49,6 @@ impl Handler for WalCoinBalances { coin_balance: value.update.as_ref().map(|o| o.coin_balance), cp_sequence_number: value.cp_sequence_number as i64, - - coin_owner_kind: value.update.as_ref().map(|o| o.coin_owner_kind), }) .collect(); diff --git a/crates/sui-indexer-alt/src/models/objects.rs b/crates/sui-indexer-alt/src/models/objects.rs index 7f1096a8f8fe8..d1007b835c16c 100644 --- a/crates/sui-indexer-alt/src/models/objects.rs +++ b/crates/sui-indexer-alt/src/models/objects.rs @@ -51,14 +51,6 @@ pub enum StoredOwnerKind { Shared = 3, } -#[derive(AsExpression, FromSqlRow, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[diesel(sql_type = SmallInt)] -#[repr(i16)] -pub enum StoredCoinOwnerKind { - Fastpath = 0, - Consensus = 1, -} - #[derive(Insertable, Debug, Clone, FieldCount)] #[diesel(table_name = sum_coin_balances, primary_key(object_id))] pub struct StoredSumCoinBalance { @@ -67,7 +59,6 @@ pub struct StoredSumCoinBalance { pub owner_id: Vec, pub coin_type: Vec, pub coin_balance: i64, - pub coin_owner_kind: StoredCoinOwnerKind, } #[derive(Insertable, Debug, Clone, FieldCount)] @@ -92,7 +83,6 @@ pub struct StoredWalCoinBalance { pub coin_type: Option>, pub coin_balance: Option, pub cp_sequence_number: i64, - pub coin_owner_kind: Option, } #[derive(Insertable, Debug, Clone)] @@ -143,31 +133,6 @@ where } } -impl serialize::ToSql for StoredCoinOwnerKind -where - i16: serialize::ToSql, -{ - fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, DB>) -> serialize::Result { - match self { - StoredCoinOwnerKind::Fastpath => 0.to_sql(out), - StoredCoinOwnerKind::Consensus => 1.to_sql(out), - } - } -} - -impl deserialize::FromSql for StoredCoinOwnerKind -where - i16: deserialize::FromSql, -{ - fn from_sql(raw: DB::RawValue<'_>) -> deserialize::Result { - Ok(match i16::from_sql(raw)? { - 0 => StoredCoinOwnerKind::Fastpath, - 1 => StoredCoinOwnerKind::Consensus, - o => return Err(format!("Unexpected StoredCoinOwnerKind: {o}").into()), - }) - } -} - #[derive(Insertable, Debug, Clone, FieldCount)] #[diesel(table_name = obj_info, primary_key(object_id, cp_sequence_number))] pub struct StoredObjInfo { diff --git a/crates/sui-indexer-alt/src/schema.rs b/crates/sui-indexer-alt/src/schema.rs index 9b933f1bd9208..c519fb4192d6f 100644 --- a/crates/sui-indexer-alt/src/schema.rs +++ b/crates/sui-indexer-alt/src/schema.rs @@ -132,7 +132,6 @@ diesel::table! { owner_id -> Bytea, coin_type -> Bytea, coin_balance -> Int8, - coin_owner_kind -> Int2, } } @@ -223,7 +222,6 @@ diesel::table! { coin_type -> Nullable, coin_balance -> Nullable, cp_sequence_number -> Int8, - coin_owner_kind -> Nullable, } }