Skip to content

Commit

Permalink
[GraphQL/ProtocolConfig] chain_identifier
Browse files Browse the repository at this point in the history
## Description

Read the genesis digest from the `chain_identifier` table, instead of
`checkpoints`, because it may not exist there (if the underlying table
is pruned).

## Test plan

Run the service, and test the following query.

```graphql
query {
  protocolConfig(protocolVersion: 10) {
    featureFlags {
      key
      value
    }
  }
}
```
  • Loading branch information
amnn committed Jul 30, 2024
1 parent 1eaa1ea commit f7408a0
Showing 1 changed file with 3 additions and 4 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 @@ -88,7 +88,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 @@ -97,9 +97,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

0 comments on commit f7408a0

Please sign in to comment.