From 3053ad99496f832d5a13ff51b33be55f3e359052 Mon Sep 17 00:00:00 2001 From: Ashok Menon Date: Tue, 30 Jul 2024 21:18:12 +0100 Subject: [PATCH] [main][GraphQL] Fix pruning compatibility issues (#18862) ## Description Two further fixes to get GraphQL working with pruned databases. Cherry-pick of #18860 **into main**. ## Test plan Tested by deploying this version of the service against a pruned DB, and ensuring the following query executed successfully: ```graphql query { chainIdentifier protocolConfig(protocolVersion: 10) { featureFlags { key value } } } ``` --- ## 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: - [x] GraphQL: Adds support for running GraphQL against a pruned version of the service. - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --- crates/sui-graphql-rpc/src/types/protocol_config.rs | 7 +++---- crates/sui-indexer/src/schema/pg.rs | 3 --- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/sui-graphql-rpc/src/types/protocol_config.rs b/crates/sui-graphql-rpc/src/types/protocol_config.rs index 9a10021d529cf..ce60c22892d39 100644 --- a/crates/sui-graphql-rpc/src/types/protocol_config.rs +++ b/crates/sui-graphql-rpc/src/types/protocol_config.rs @@ -3,7 +3,7 @@ use async_graphql::*; use diesel::{ExpressionMethods, QueryDsl}; -use sui_indexer::schema::{checkpoints, epochs}; +use sui_indexer::schema::{chain_identifier, epochs}; use sui_protocol_config::{ProtocolConfig as NativeProtocolConfig, ProtocolVersion}; use crate::{ @@ -90,7 +90,7 @@ impl ProtocolConfigs { impl ProtocolConfigs { pub(crate) async fn query(db: &Db, protocol_version: Option) -> Result { - use checkpoints::dsl as c; + use chain_identifier::dsl as c; use epochs::dsl as e; let (latest_version, digest_bytes): (i64, Option>) = db @@ -99,9 +99,8 @@ impl ProtocolConfigs { e::epochs .select(( e::protocol_version, - c::checkpoints + c::chain_identifier .select(c::checkpoint_digest) - .filter(c::sequence_number.eq(0)) .single_value(), )) .order_by(e::epoch.desc()) diff --git a/crates/sui-indexer/src/schema/pg.rs b/crates/sui-indexer/src/schema/pg.rs index 322ad8b6a030a..564f7cd721343 100644 --- a/crates/sui-indexer/src/schema/pg.rs +++ b/crates/sui-indexer/src/schema/pg.rs @@ -296,14 +296,11 @@ macro_rules! for_all_tables { display, epochs, events, - events_partition_0, objects, objects_history, - objects_history_partition_0, objects_snapshot, packages, transactions, - transactions_partition_0, tx_calls, tx_changed_objects, tx_digests,