Skip to content

Commit

Permalink
[GraphQL] paginate activeValidators and reportRecords (MystenLabs#15933)
Browse files Browse the repository at this point in the history
## Description 

`activeValidators` and `reportRecords` may result in long arrays of
results so we need to paginate them.

## Test Plan 

Added to existing tests.

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### 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
  • Loading branch information
emmazzz authored Jan 29, 2024
1 parent 9f94fb6 commit 6128863
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 116 deletions.
24 changes: 13 additions & 11 deletions crates/sui-graphql-e2e-tests/tests/call/simple.exp
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,20 @@ Response: {
}
}

task 20 'run-graphql'. lines 154-168:
task 20 'run-graphql'. lines 154-170:
Response: {
"data": {
"epoch": {
"validatorSet": {
"activeValidators": [
{
"address": {
"address": "0xa7b032703878aa74c3126935789fd1d4d7e111d5911b09247d6963061c312b5a"
"activeValidators": {
"nodes": [
{
"address": {
"address": "0xa7b032703878aa74c3126935789fd1d4d7e111d5911b09247d6963061c312b5a"
}
}
}
]
]
}
}
},
"address": {
Expand All @@ -240,7 +242,7 @@ Response: {
}
}

task 21 'run-graphql'. lines 170-176:
task 21 'run-graphql'. lines 172-178:
Response: {
"data": {
"epoch": {
Expand All @@ -249,17 +251,17 @@ Response: {
}
}

task 22 'run'. lines 178-178:
task 22 'run'. lines 180-180:
created: object(22,0)
mutated: object(0,1)
gas summary: computation_cost: 999000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 23 'run'. lines 180-180:
task 23 'run'. lines 182-182:
created: object(23,0)
mutated: object(0,1)
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 24 'run'. lines 182-182:
task 24 'run'. lines 184-184:
created: object(24,0)
mutated: object(0,1)
gas summary: computation_cost: 235000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880
6 changes: 4 additions & 2 deletions crates/sui-graphql-e2e-tests/tests/call/simple.move
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ module Test::M1 {
epoch {
validatorSet {
activeValidators {
address {
address
nodes {
address {
address
}
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions crates/sui-graphql-e2e-tests/tests/epoch/epoch.exp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ Checkpoint created: 5
task 9 'advance-epoch'. lines 31-32:
Epoch advanced: 2

task 10 'run-graphql'. lines 33-47:
task 10 'run-graphql'. lines 33-52:
Response: {
"data": {
"epoch": {
"validatorSet": {
"totalStake": "20000010002000000"
"totalStake": "20000010002000000",
"activeValidators": {
"nodes": [
{
"name": "validator-0"
}
]
}
},
"totalGasFees": "1000000",
"totalStakeRewards": "1000000",
Expand Down
5 changes: 5 additions & 0 deletions crates/sui-graphql-e2e-tests/tests/epoch/epoch.move
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
epoch(id: 2) {
validatorSet {
totalStake
activeValidators {
nodes {
name
}
}
}
totalGasFees
totalStakeRewards
Expand Down
69 changes: 38 additions & 31 deletions crates/sui-graphql-e2e-tests/tests/validator/validator.exp
Original file line number Diff line number Diff line change
Expand Up @@ -40,114 +40,121 @@ Checkpoint created: 3
task 9 'advance-epoch'. lines 53-53:
Epoch advanced: 1

task 10 'run-graphql'. lines 55-65:
task 10 'run-graphql'. lines 55-67:
Response: {
"data": {
"epoch": {
"validatorSet": {
"activeValidators": [
{
"apy": 1,
"name": "validator-0"
}
]
"activeValidators": {
"nodes": [
{
"apy": 1,
"name": "validator-0"
}
]
}
}
}
}
}

task 11 'run'. lines 67-67:
task 11 'run'. lines 69-69:
created: object(11,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 12 'run'. lines 69-69:
task 12 'run'. lines 71-71:
created: object(12,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 13 'run'. lines 71-71:
task 13 'run'. lines 73-73:
created: object(13,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 14 'run'. lines 73-73:
task 14 'run'. lines 75-75:
created: object(14,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 15 'run'. lines 75-75:
task 15 'run'. lines 77-77:
created: object(15,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 16 'run'. lines 77-77:
task 16 'run'. lines 79-79:
created: object(16,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 17 'run'. lines 79-79:
task 17 'run'. lines 81-81:
created: object(17,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 18 'run'. lines 81-81:
task 18 'run'. lines 83-83:
created: object(18,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 19 'run'. lines 83-83:
task 19 'run'. lines 85-85:
created: object(19,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 20 'run'. lines 85-85:
task 20 'run'. lines 87-87:
created: object(20,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 21 'run'. lines 87-87:
task 21 'run'. lines 89-89:
created: object(21,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 22 'run'. lines 89-89:
task 22 'run'. lines 91-91:
created: object(22,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 23 'run'. lines 91-91:
task 23 'run'. lines 93-93:
created: object(23,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 24 'run'. lines 93-93:
task 24 'run'. lines 95-95:
created: object(24,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 25 'run'. lines 95-95:
task 25 'run'. lines 97-97:
created: object(25,0)
mutated: object(0,0)
gas summary: computation_cost: 1441000000, storage_cost: 1932269600, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 26 'create-checkpoint'. lines 97-97:
task 26 'create-checkpoint'. lines 99-99:
Checkpoint created: 5

task 27 'advance-epoch'. lines 99-101:
task 27 'advance-epoch'. lines 101-103:
Epoch advanced: 2

task 28 'run-graphql'. lines 103-113:
task 28 'run-graphql'. lines 105-122:
Response: {
"data": {
"epoch": {
"validatorSet": {
"activeValidators": [
{
"apy": 2,
"name": "validator-0"
}
]
"activeValidators": {
"nodes": [
{
"apy": 2,
"name": "validator-0",
"reportRecords": {
"nodes": []
}
}
]
}
}
}
}
Expand Down
21 changes: 15 additions & 6 deletions crates/sui-graphql-e2e-tests/tests/validator/validator.move
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ module P0::m {
};
v
}

public entry fun new(ctx: &mut TxContext){
let id = object::new(ctx);
let w = weight();
sui::transfer::public_transfer(
Big { id, weight: w },
Big { id, weight: w },
sender(ctx)
)
}
Expand All @@ -57,8 +57,10 @@ module P0::m {
epoch(id: 1) {
validatorSet {
activeValidators {
apy
name
nodes {
apy
name
}
}
}
}
Expand Down Expand Up @@ -105,8 +107,15 @@ module P0::m {
epoch(id: 2) {
validatorSet {
activeValidators {
apy
name
nodes {
apy
name
reportRecords {
nodes {
address
}
}
}
}
}
}
Expand Down
56 changes: 30 additions & 26 deletions crates/sui-graphql-rpc/docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,30 +519,32 @@
> inactivePoolsSize
> validatorCandidatesSize
> activeValidators {
> name
> description
> imageUrl
> projectUrl
> exchangeRates {
> storageRebate
> bcs
> hasPublicTransfer
> nodes {
> name
> description
> imageUrl
> projectUrl
> exchangeRates {
> storageRebate
> bcs
> hasPublicTransfer
> }
> exchangeRatesSize
> stakingPoolActivationEpoch
> stakingPoolSuiBalance
> rewardsPool
> poolTokenBalance
> pendingStake
> pendingTotalSuiWithdraw
> pendingPoolTokenWithdraw
> votingPower
> gasPrice
> commissionRate
> nextEpochStake
> nextEpochGasPrice
> nextEpochCommissionRate
> atRisk
> }
> exchangeRatesSize
> stakingPoolActivationEpoch
> stakingPoolSuiBalance
> rewardsPool
> poolTokenBalance
> pendingStake
> pendingTotalSuiWithdraw
> pendingPoolTokenWithdraw
> votingPower
> gasPrice
> commissionRate
> nextEpochStake
> nextEpochGasPrice
> nextEpochCommissionRate
> atRisk
> }
> }
> }
Expand Down Expand Up @@ -1217,9 +1219,11 @@
> referenceGasPrice
> validatorSet {
> activeValidators {
> name
> description
> exchangeRatesSize
> nodes {
> name
> description
> exchangeRatesSize
> }
> }
> totalStake
> }
Expand Down
Loading

0 comments on commit 6128863

Please sign in to comment.