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

[Indexer] Add json serialized SuiSystemStateSummary to epochs table #19428

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Sep 18, 2024

Description

The existing system_state column is a BCS serialization of a JSON-RPC type, which is not evolvable.
This PR adds a new column that is the JSON serialization of SuiSystemStateSummary without BCS.

It also fixes two bugs along the way:

  1. We were storing the wrong version of the system state, offsetting by 1 epoch. This PR fixes it by storing the right version of the json column at the beginning of the epoch instead of at the end.
  2. We were ignoring a deserialization error and swallow it in some place. Made that throw instead.

Test plan

Added a debug assert to see that this column is populated with the correct epoch.


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:

Copy link

vercel bot commented Sep 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2024 7:03pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 19, 2024 7:03pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 19, 2024 7:03pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 19, 2024 7:03pm

Copy link
Contributor

@amnn amnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully following why we need to rename the column we currently use, instead of adding a new column it seems like this way we're more likely to break things.

@bmwill
Copy link
Contributor

bmwill commented Sep 18, 2024

Why don't we instead store the serialized JSON form instead of a BCS form? JSON is a much more evolvable format that bcs and the SystemState type is not a core data structure that has a "canonical" bcs form.

@@ -153,18 +158,15 @@ impl TryFrom<StoredEpochInfo> for EpochInfo {
fn try_from(value: StoredEpochInfo) -> Result<Self, Self::Error> {
let epoch = value.epoch as u64;
let end_of_epoch_info = (&value).into();
let system_state: Option<SuiSystemStateSummary> = bcs::from_bytes(&value.system_state)
let system_state: SuiSystemStateSummary = bcs::from_bytes(&value.system_state_deprecated)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this should not have been Option indeed.

@lxfind
Copy link
Contributor Author

lxfind commented Sep 18, 2024

Why don't we instead store the serialized JSON form instead of a BCS form? JSON is a much more evolvable format that bcs and the SystemState type is not a core data structure that has a "canonical" bcs form.

We certainly could. SuiSystemState type uses enum at the top so it should be "canonical"?

@bmwill
Copy link
Contributor

bmwill commented Sep 18, 2024

Why don't we instead store the serialized JSON form instead of a BCS form? JSON is a much more evolvable format that bcs and the SystemState type is not a core data structure that has a "canonical" bcs form.

We certainly could. SuiSystemState type uses enum at the top so it should be "canonical"?

Its just this will always be transmitted in json form, so we should just store and use the json form

@lxfind
Copy link
Contributor Author

lxfind commented Sep 18, 2024

All feedback addressed. Updated the PR description.

@lxfind lxfind changed the title [Indexer] Add bcs SuiSystemState to epochs table [Indexer] Add json serialized SuiSystemStateSummary to epochs table Sep 18, 2024
@lxfind lxfind force-pushed the indexer-epochs-add-system-state branch from 92960c1 to 8df2509 Compare September 19, 2024 19:02
@lxfind lxfind merged commit 0ae6514 into main Sep 19, 2024
46 of 48 checks passed
@lxfind lxfind deleted the indexer-epochs-add-system-state branch September 19, 2024 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants