Skip to content

Commit

Permalink
[main][GraphQL] Fix pruning compatibility issues (#18862)
Browse files Browse the repository at this point in the history
## 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:
  • Loading branch information
amnn authored Jul 30, 2024
1 parent de9d14f commit 3053ad9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 3 additions & 4 deletions crates/sui-graphql-rpc/src/types/protocol_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -90,7 +90,7 @@ impl ProtocolConfigs {

impl ProtocolConfigs {
pub(crate) async fn query(db: &Db, protocol_version: Option<u64>) -> Result<Self, Error> {
use checkpoints::dsl as c;
use chain_identifier::dsl as c;
use epochs::dsl as e;

let (latest_version, digest_bytes): (i64, Option<Vec<u8>>) = db
Expand All @@ -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())
Expand Down
3 changes: 0 additions & 3 deletions crates/sui-indexer/src/schema/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3053ad9

Please sign in to comment.