Skip to content

Commit

Permalink
remove type and cp columns from events
Browse files Browse the repository at this point in the history
  • Loading branch information
emmazzz committed Jun 22, 2024
1 parent f9a5e88 commit 134dd68
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 56 deletions.
21 changes: 0 additions & 21 deletions crates/sui-graphql-rpc/src/types/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,6 @@ impl Event {
page.paginate_query::<StoredEvent, _, _, _>(conn, checkpoint_viewed_at, move || {
let mut query = events::dsl::events.into_boxed();

// Bound events by the provided `checkpoint_viewed_at`. From EXPLAIN
// ANALYZE, using the checkpoint sequence number directly instead of
// translating into a transaction sequence number bound is more efficient.
query = query.filter(
events::dsl::checkpoint_sequence_number.le(checkpoint_viewed_at as i64),
);

// The transactions table doesn't have an index on the senders column, so use
// `tx_senders`.
if let Some(sender) = &filter.sender {
Expand Down Expand Up @@ -205,16 +198,6 @@ impl Event {
query = module.apply(query, events::dsl::package, events::dsl::module);
}

if let Some(type_) = &filter.event_type {
query = type_.apply(
query,
events::dsl::event_type,
events::dsl::event_type_package,
events::dsl::event_type_module,
events::dsl::event_type_name,
);
}

query
})
})
Expand Down Expand Up @@ -257,7 +240,6 @@ impl Event {
tx_sequence_number: stored_tx.tx_sequence_number,
event_sequence_number: idx as i64,
transaction_digest: stored_tx.transaction_digest.clone(),
checkpoint_sequence_number: stored_tx.checkpoint_sequence_number,
#[cfg(feature = "postgres-feature")]
senders: vec![Some(native_event.sender.to_vec())],
#[cfg(feature = "mysql-feature")]
Expand All @@ -268,9 +250,6 @@ impl Event {
event_type: native_event
.type_
.to_canonical_string(/* with_prefix */ true),
event_type_package: native_event.type_.address.to_vec(),
event_type_module: native_event.type_.module.to_string(),
event_type_name: native_event.type_.name.to_string(),
bcs: native_event.contents.clone(),
timestamp_ms: stored_tx.timestamp_ms,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CREATE TABLE events
tx_sequence_number BIGINT NOT NULL,
event_sequence_number BIGINT NOT NULL,
transaction_digest bytea NOT NULL,
checkpoint_sequence_number bigint NOT NULL,
-- array of SuiAddress in bytes. All signers of the transaction.
senders bytea[] NOT NULL,
-- bytes of the entry package ID. Notice that the package and module here
Expand All @@ -15,11 +14,7 @@ CREATE TABLE events
module text NOT NULL,
-- StructTag in Display format, fully qualified including type parameters
event_type text NOT NULL,
-- Components of the StructTag of the event type: package, module,
-- name (name of the struct, without type parameters)
event_type_package bytea NOT NULL,
event_type_module text NOT NULL,
event_type_name text NOT NULL,

-- timestamp of the checkpoint when the event was emitted
timestamp_ms BIGINT NOT NULL,
-- bcs of the Event contents (Event.contents)
Expand All @@ -30,5 +25,3 @@ CREATE TABLE events_partition_0 PARTITION OF events FOR VALUES FROM (0) TO (MAXV
CREATE INDEX events_package ON events (package, tx_sequence_number, event_sequence_number);
CREATE INDEX events_package_module ON events (package, module, tx_sequence_number, event_sequence_number);
CREATE INDEX events_event_type ON events (event_type text_pattern_ops, tx_sequence_number, event_sequence_number);
CREATE INDEX events_type_package_module_name ON events (event_type_package, event_type_module, event_type_name, tx_sequence_number, event_sequence_number);
CREATE INDEX events_checkpoint_sequence_number ON events (checkpoint_sequence_number);
16 changes: 0 additions & 16 deletions crates/sui-indexer/src/models/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ pub struct StoredEvent {
#[diesel(sql_type = diesel::sql_types::Binary)]
pub transaction_digest: Vec<u8>,

#[diesel(sql_type = diesel::sql_types::BigInt)]
pub checkpoint_sequence_number: i64,

#[cfg(feature = "postgres-feature")]
#[diesel(sql_type = diesel::sql_types::Array<diesel::sql_types::Nullable<diesel::pg::sql_types::Bytea>>)]
pub senders: Vec<Option<Vec<u8>>>,
Expand All @@ -52,15 +49,6 @@ pub struct StoredEvent {
#[diesel(sql_type = diesel::sql_types::Text)]
pub event_type: String,

#[diesel(sql_type = diesel::sql_types::Binary)]
pub event_type_package: Vec<u8>,

#[diesel(sql_type = diesel::sql_types::Text)]
pub event_type_module: String,

#[diesel(sql_type = diesel::sql_types::Text)]
pub event_type_name: String,

#[diesel(sql_type = diesel::sql_types::BigInt)]
pub timestamp_ms: i64,

Expand All @@ -81,7 +69,6 @@ impl From<IndexedEvent> for StoredEvent {
tx_sequence_number: event.tx_sequence_number as i64,
event_sequence_number: event.event_sequence_number as i64,
transaction_digest: event.transaction_digest.into_inner().to_vec(),
checkpoint_sequence_number: event.checkpoint_sequence_number as i64,
#[cfg(feature = "postgres-feature")]
senders: event
.senders
Expand All @@ -94,9 +81,6 @@ impl From<IndexedEvent> for StoredEvent {
package: event.package.to_vec(),
module: event.module.clone(),
event_type: event.event_type.clone(),
event_type_package: event.event_type_package.to_vec(),
event_type_module: event.event_type_module.clone(),
event_type_name: event.event_type_name.clone(),
bcs: event.bcs.clone(),
timestamp_ms: event.timestamp_ms as i64,
}
Expand Down
8 changes: 0 additions & 8 deletions crates/sui-indexer/src/schema/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,10 @@ diesel::table! {
tx_sequence_number -> Int8,
event_sequence_number -> Int8,
transaction_digest -> Bytea,
checkpoint_sequence_number -> Int8,
senders -> Array<Nullable<Bytea>>,
package -> Bytea,
module -> Text,
event_type -> Text,
event_type_package -> Bytea,
event_type_module -> Text,
event_type_name -> Text,
timestamp_ms -> Int8,
bcs -> Bytea,
}
Expand All @@ -149,14 +145,10 @@ diesel::table! {
tx_sequence_number -> Int8,
event_sequence_number -> Int8,
transaction_digest -> Bytea,
checkpoint_sequence_number -> Int8,
senders -> Array<Nullable<Bytea>>,
package -> Bytea,
module -> Text,
event_type -> Text,
event_type_package -> Bytea,
event_type_module -> Text,
event_type_name -> Text,
timestamp_ms -> Int8,
bcs -> Bytea,
}
Expand Down
3 changes: 0 additions & 3 deletions crates/sui-indexer/tests/ingestion_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ mod ingestion_tests {
db_event.event_type,
event_type_tag.to_canonical_string(true)
);
assert_eq!(db_event.event_type_package, SUI_SYSTEM_PACKAGE_ID.to_vec());
assert_eq!(db_event.event_type_module, "sui_system_state_inner");
assert_eq!(db_event.event_type_name, "SystemEpochInfoEvent");
Ok(())
}

Expand Down

0 comments on commit 134dd68

Please sign in to comment.