Skip to content

Commit 108ce43

Browse files
authored
[graphql] split out epoch fields into new sui system state type (#14163)
## Description On jsonrpc we can (only) query for latest sui system state. The initial graphql draft schema combines sui system state to the epoch struct, but since not all sui system state data are stable for the epoch, this draft proposes splitting out most of the epoch into a new sui system state type. 1. Query has new resolver latest_sui_system_state 2. validator type can now resolve operation_cap, staking_pool, and exchange_rates to move objects 3. protocol config typing is modified to take in a ProtocolConfig instead of fetching the same data source for each of its fields ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
1 parent 484f88e commit 108ce43

17 files changed

+507
-178
lines changed

crates/sui-graphql-rpc/examples/epoch/epoch.graphql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,51 @@
1111
epochId, referenceGasPrice
1212
}
1313
}
14+
15+
# Selecting all fields for epoch 100
16+
{
17+
epoch(id: 100){
18+
protocolConfigs {
19+
protocolVersion
20+
}
21+
referenceGasPrice
22+
startTimestamp
23+
endTimestamp
24+
validatorSet {
25+
totalStake
26+
pendingActiveValidatorsSize
27+
stakePoolMappingsSize
28+
inactivePoolsSize
29+
validatorCandidatesSize
30+
activeValidators {
31+
name
32+
description
33+
imageUrl
34+
projectUrl
35+
exchangeRates {
36+
asObject {
37+
storageRebate
38+
bcs
39+
kind
40+
}
41+
hasPublicTransfer
42+
}
43+
exchangeRatesSize
44+
stakingPoolActivationEpoch
45+
stakingPoolSuiBalance
46+
rewardsPool
47+
poolTokenBalance
48+
pendingStake
49+
pendingTotalSuiWithdraw
50+
pendingPoolTokenWithdraw
51+
votingPower
52+
gasPrice
53+
commissionRate
54+
nextEpochStake
55+
nextEpochGasPrice
56+
nextEpochCommissionRate
57+
atRisk
58+
}
59+
}
60+
}
61+
}

crates/sui-graphql-rpc/examples/protocol_configs/all_configs.graphql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,13 @@
5353
}
5454
}
5555
}
56+
57+
protocolConfigs {
58+
protocolVersion
59+
featureFlags {
60+
key
61+
}
62+
featureFlag(key:"advance_epoch_start_time_in_safe_mode") {
63+
value
64+
}
65+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
latestSuiSystemState {
3+
systemStateVersion
4+
referenceGasPrice
5+
startTimestamp
6+
validatorSet {
7+
totalStake
8+
pendingActiveValidatorsSize
9+
stakePoolMappingsSize
10+
inactivePoolsSize
11+
validatorCandidatesSize
12+
activeValidators {
13+
name
14+
description
15+
imageUrl
16+
projectUrl
17+
exchangeRates {
18+
asObject {
19+
storageRebate
20+
bcs
21+
kind
22+
}
23+
hasPublicTransfer
24+
}
25+
exchangeRatesSize
26+
stakingPoolActivationEpoch
27+
stakingPoolSuiBalance
28+
rewardsPool
29+
poolTokenBalance
30+
pendingStake
31+
pendingTotalSuiWithdraw
32+
pendingPoolTokenWithdraw
33+
votingPower
34+
gasPrice
35+
commissionRate
36+
nextEpochStake
37+
nextEpochGasPrice
38+
nextEpochCommissionRate
39+
atRisk
40+
}
41+
}
42+
}
43+
}

crates/sui-graphql-rpc/schema/current_progress_schema.graphql

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,11 @@ type EndOfEpochData {
172172

173173
type Epoch {
174174
epochId: Int!
175-
systemStateVersion: BigInt
176-
protocolConfigs: ProtocolConfigs
177175
referenceGasPrice: BigInt
178-
systemParameters: SystemParameters
179-
stakeSubsidy: StakeSubsidy
180176
validatorSet: ValidatorSet
181-
storageFund: StorageFund
182-
safeMode: SafeMode
183177
startTimestamp: DateTime
178+
endTimestamp: DateTime
179+
protocolConfigs: ProtocolConfigs
184180
}
185181

186182
enum ExecutionStatus {
@@ -471,9 +467,9 @@ type ProtocolConfigFeatureFlag {
471467
}
472468

473469
type ProtocolConfigs {
474-
configs: [ProtocolConfigAttr!]
475-
featureFlags: [ProtocolConfigFeatureFlag!]
476470
protocolVersion: Int!
471+
featureFlags: [ProtocolConfigFeatureFlag!]!
472+
configs: [ProtocolConfigAttr!]!
477473
config(key: String!): ProtocolConfigAttr
478474
featureFlag(key: String!): ProtocolConfigFeatureFlag
479475
}
@@ -499,6 +495,7 @@ type Query {
499495
objectConnection(first: Int, after: String, last: Int, before: String, filter: ObjectFilter): ObjectConnection
500496
protocolConfig(protocolVersion: Int): ProtocolConfigs!
501497
resolveNameServiceAddress(name: String!): Address
498+
latestSuiSystemState: SuiSystemStateSummary!
502499
}
503500

504501
type SafeMode {
@@ -578,6 +575,19 @@ type StorageFund {
578575

579576
scalar SuiAddress
580577

578+
type SuiSystemStateSummary {
579+
systemStateVersion: BigInt
580+
referenceGasPrice: BigInt
581+
systemParameters: SystemParameters
582+
stakeSubsidy: StakeSubsidy
583+
validatorSet: ValidatorSet
584+
storageFund: StorageFund
585+
safeMode: SafeMode
586+
startTimestamp: DateTime
587+
epoch: Epoch
588+
protocolConfigs: ProtocolConfigs
589+
}
590+
581591
type SystemParameters {
582592
durationMs: BigInt
583593
stakeSubsidyStartEpoch: Int
@@ -682,6 +692,11 @@ type Validator {
682692
nextEpochStake: BigInt
683693
nextEpochGasPrice: BigInt
684694
nextEpochCommissionRate: Int
695+
atRisk: Int
696+
reportRecords: [SuiAddress!]
697+
operationCap: MoveObject
698+
stakingPool: MoveObject
699+
exchangeRates: MoveObject
685700
}
686701

687702
type ValidatorCredentials {

crates/sui-graphql-rpc/schema/draft_target_schema.graphql

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,16 +444,10 @@ type DisplayEntry {
444444

445445
type Epoch {
446446
epochId: Int!
447-
systemStateVersion: Int
448447
protocolConfigs: ProtocolConfigs
449448
referenceGasPrice: BigInt
450449

451-
systemParameters: SystemParameters
452-
stakeSubsidy: StakeSubsidy
453450
validatorSet: ValidatorSet
454-
storageFund: StorageFund
455-
safeMode: SafeMode
456-
457451
startTimestamp: DateTime
458452
endTimestamp: DateTime
459453

@@ -476,10 +470,23 @@ type Epoch {
476470
): TransactionBlockConnection
477471
}
478472

473+
type SuiSystemStateSummary {
474+
epoch: Epoch
475+
protocolConfigs: ProtocolConfigs
476+
systemStateVersion: Int
477+
referenceGasPrice: BigInt
478+
479+
systemParameters: SystemParameters
480+
stakeSubsidy: StakeSubsidy
481+
validatorSet: ValidatorSet
482+
storageFund: StorageFund
483+
safeMode: SafeMode
484+
}
485+
479486
type ProtocolConfigs {
480487
protocolVersion: Int!
481-
featureFlags: [ProtocolConfigFeatureFlag]
482-
configs: [ProtocolConfigAttr]
488+
featureFlags: [ProtocolConfigFeatureFlag!]!
489+
configs: [ProtocolConfigAttr!]!
483490
config(key: String!): ProtocolConfigAttr
484491
featureFlag(key: String!): ProtocolConfigFeatureFlag
485492
}

0 commit comments

Comments
 (0)