Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GraphQL] Remove "Live" ObjectKind, rename "Historical" to "Indexed" #17313

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ task 4 'run-graphql'. lines 62-75:
Response: {
"data": {
"object": {
"status": "HISTORICAL",
"status": "INDEXED",
"version": 3,
"asMoveObject": {
"contents": {
Expand All @@ -45,7 +45,7 @@ task 7 'run-graphql'. lines 81-107:
Response: {
"data": {
"latest_version": {
"status": "HISTORICAL",
"status": "INDEXED",
"version": 4,
"asMoveObject": {
"contents": {
Expand All @@ -57,7 +57,7 @@ Response: {
}
},
"previous_version": {
"status": "HISTORICAL",
"status": "INDEXED",
"version": 3,
"asMoveObject": {
"contents": {
Expand Down Expand Up @@ -89,7 +89,7 @@ Response: {
"asMoveObject": null
},
"previous_version": {
"status": "HISTORICAL",
"status": "INDEXED",
"version": 4,
"asMoveObject": {
"contents": {
Expand All @@ -116,7 +116,7 @@ task 13 'run-graphql'. lines 145-183:
Response: {
"data": {
"latest_unwrapped": {
"status": "HISTORICAL",
"status": "INDEXED",
"version": 6,
"asMoveObject": {
"contents": {
Expand All @@ -133,7 +133,7 @@ Response: {
"asMoveObject": null
},
"first_version": {
"status": "HISTORICAL",
"status": "INDEXED",
"version": 3,
"asMoveObject": {
"contents": {
Expand Down Expand Up @@ -181,7 +181,7 @@ task 19 'run-graphql'. lines 221-259:
Response: {
"data": {
"object_within_available_range": {
"status": "HISTORICAL",
"status": "INDEXED",
"version": 6,
"asMoveObject": {
"contents": {
Expand Down
12 changes: 4 additions & 8 deletions crates/sui-graphql-rpc/schema/current_progress_schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2490,18 +2490,14 @@ input ObjectKey {

enum ObjectKind {
"""
The object is loaded from serialized data, such as the contents of a transaction.
The object is loaded from serialized data, such as the contents of a transaction that hasn't
been indexed yet.
"""
NOT_INDEXED
"""
The object is currently live and is not deleted or wrapped.
The object is fetched from the index.
"""
LIVE
"""
The object is referenced at some version, and thus is fetched from the snapshot or
historical objects table.
"""
HISTORICAL
INDEXED
"""
The object is deleted or wrapped and only partial information can be loaded from the
indexer.
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-graphql-rpc/src/types/dynamic_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl TryFrom<MoveObject> for DynamicField {
let super_ = &stored.super_;

let (df_object_id, df_kind) = match &super_.kind {
ObjectKind::Historical(_, stored) => stored
ObjectKind::Indexed(_, stored) => stored
.df_object_id
.as_ref()
.map(|id| (id, stored.df_kind))
Expand Down
27 changes: 13 additions & 14 deletions crates/sui-graphql-rpc/src/types/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ pub(crate) struct ObjectImpl<'o>(pub &'o Object);
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub(crate) enum ObjectKind {
/// An object loaded from serialized data, such as the contents of a transaction.
/// An object loaded from serialized data, such as the contents of a transaction that hasn't
/// been indexed yet.
NotIndexed(NativeObject),
/// An object fetched from the snapshot or historical objects table.
Historical(NativeObject, StoredHistoryObject),
/// An object fetched from the index.
Indexed(NativeObject, StoredHistoryObject),
/// The object is wrapped or deleted and only partial information can be loaded from the
/// indexer.
WrappedOrDeleted(StoredDeletedHistoryObject),
Expand All @@ -72,13 +73,11 @@ pub(crate) enum ObjectKind {
#[derive(Enum, Copy, Clone, Eq, PartialEq, Debug)]
#[graphql(name = "ObjectKind")]
pub enum ObjectStatus {
/// The object is loaded from serialized data, such as the contents of a transaction.
/// The object is loaded from serialized data, such as the contents of a transaction that hasn't
/// been indexed yet.
NotIndexed,
/// The object is currently live and is not deleted or wrapped.
Live,
/// The object is referenced at some version, and thus is fetched from the snapshot or
/// historical objects table.
Historical,
/// The object is fetched from the index.
Indexed,
/// The object is deleted or wrapped and only partial information can be loaded from the
/// indexer.
WrappedOrDeleted,
Expand Down Expand Up @@ -606,7 +605,7 @@ impl ObjectImpl<'_> {
// WrappedOrDeleted objects are also read from the historical objects table, and they do
// not have a serialized object, so the column is also nullable for stored historical
// objects.
K::Historical(_, stored) => stored.serialized_object.as_ref().map(Base64::from),
K::Indexed(_, stored) => stored.serialized_object.as_ref().map(Base64::from),

K::NotIndexed(native) => {
let bytes = bcs::to_bytes(native)
Expand Down Expand Up @@ -672,7 +671,7 @@ impl Object {
use ObjectKind as K;

match &self.kind {
K::NotIndexed(native) | K::Historical(native, _) => Some(native),
K::NotIndexed(native) | K::Indexed(native, _) => Some(native),
K::WrappedOrDeleted(_) => None,
}
}
Expand All @@ -681,7 +680,7 @@ impl Object {
use ObjectKind as K;

match &self.kind {
K::NotIndexed(native) | K::Historical(native, _) => native.version().value(),
K::NotIndexed(native) | K::Indexed(native, _) => native.version().value(),
K::WrappedOrDeleted(stored) => stored.object_version as u64,
}
}
Expand Down Expand Up @@ -1003,7 +1002,7 @@ impl Object {

Ok(Self {
address,
kind: ObjectKind::Historical(native_object, history_object),
kind: ObjectKind::Indexed(native_object, history_object),
checkpoint_viewed_at,
})
}
Expand Down Expand Up @@ -1266,7 +1265,7 @@ impl From<&ObjectKind> for ObjectStatus {
fn from(kind: &ObjectKind) -> Self {
match kind {
ObjectKind::NotIndexed(_) => ObjectStatus::NotIndexed,
ObjectKind::Historical(_, _) => ObjectStatus::Historical,
ObjectKind::Indexed(_, _) => ObjectStatus::Indexed,
ObjectKind::WrappedOrDeleted(_) => ObjectStatus::WrappedOrDeleted,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2494,18 +2494,14 @@ input ObjectKey {

enum ObjectKind {
"""
The object is loaded from serialized data, such as the contents of a transaction.
The object is loaded from serialized data, such as the contents of a transaction that hasn't
been indexed yet.
"""
NOT_INDEXED
"""
The object is currently live and is not deleted or wrapped.
The object is fetched from the index.
"""
LIVE
"""
The object is referenced at some version, and thus is fetched from the snapshot or
historical objects table.
"""
HISTORICAL
INDEXED
"""
The object is deleted or wrapped and only partial information can be loaded from the
indexer.
Expand Down Expand Up @@ -4179,3 +4175,4 @@ schema {
query: Query
mutation: Mutation
}

Loading