Skip to content

Commit

Permalink
[GraphQL/MovePackage] Paginate by checkpoint
Browse files Browse the repository at this point in the history
## Description

Adds a query, `Query.packages` for fetching all packages that were
introduced within a given checkpoint range. Useful for fetching
package contents in bulk, to do local analyses.

## Test plan

New E2E tests:

```
sui$ cargo nextest run -p sui-graphql-e2e-tests \
  --features pg_integration                     \
  -- packages/versioning
```

Also tested for performance against a large read replica (the query
planner quotes a high estimate for the query but the actual results do
not take very long to run because queries on many sub-partitions are
eliminated).
  • Loading branch information
amnn committed Aug 19, 2024
1 parent 9dd08f0 commit 70899b2
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 22 deletions.
204 changes: 192 additions & 12 deletions crates/sui-graphql-e2e-tests/tests/packages/versioning.exp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 14 tasks
processed 15 tasks

init:
A: object(0,0)
Expand All @@ -13,7 +13,7 @@ task 2, line 11:
//# create-checkpoint
Checkpoint created: 1

task 3, lines 13-21:
task 3, lines 13-28:
//# run-graphql
Response: {
"data": {
Expand All @@ -28,21 +28,45 @@ Response: {
]
}
}
},
"packages": {
"nodes": [
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000001",
"version": 1
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000002",
"version": 1
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000003",
"version": 1
},
{
"address": "0x000000000000000000000000000000000000000000000000000000000000dee9",
"version": 1
},
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
}
]
}
}
}

task 4, lines 23-27:
task 4, lines 30-34:
//# upgrade --package P0 --upgrade-capability 1,1 --sender A
created: object(4,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5251600, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 5, line 29:
task 5, line 36:
//# create-checkpoint
Checkpoint created: 2

task 6, lines 31-39:
task 6, lines 38-53:
//# run-graphql
Response: {
"data": {
Expand All @@ -60,21 +84,49 @@ Response: {
]
}
}
},
"packages": {
"nodes": [
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000001",
"version": 1
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000002",
"version": 1
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000003",
"version": 1
},
{
"address": "0x000000000000000000000000000000000000000000000000000000000000dee9",
"version": 1
},
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
}
]
}
}
}

task 7, lines 41-46:
task 7, lines 55-60:
//# upgrade --package P1 --upgrade-capability 1,1 --sender A
created: object(7,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5426400, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 8, line 48:
task 8, line 62:
//# create-checkpoint
Checkpoint created: 3

task 9, lines 50-58:
task 9, lines 64-79:
//# run-graphql
Response: {
"data": {
Expand All @@ -95,11 +147,43 @@ Response: {
]
}
}
},
"packages": {
"nodes": [
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000001",
"version": 1
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000002",
"version": 1
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000003",
"version": 1
},
{
"address": "0x000000000000000000000000000000000000000000000000000000000000dee9",
"version": 1
},
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
},
{
"address": "0x0eae57b7a07b0548b1f6b0c309f0692828ff994e9159b541334b25582980631c",
"version": 3
}
]
}
}
}

task 10, lines 60-97:
task 10, lines 81-118:
//# run-graphql
Response: {
"data": {
Expand Down Expand Up @@ -199,7 +283,7 @@ Response: {
}
}

task 11, lines 99-136:
task 11, lines 120-157:
//# run-graphql
Response: {
"data": {
Expand Down Expand Up @@ -290,7 +374,7 @@ Response: {
}
}

task 12, lines 138-193:
task 12, lines 159-214:
//# run-graphql
Response: {
"data": {
Expand Down Expand Up @@ -429,7 +513,7 @@ Response: {
}
}

task 13, lines 195-223:
task 13, lines 216-244:
//# run-graphql
Response: {
"data": {
Expand All @@ -441,3 +525,99 @@ Response: {
"v4": null
}
}

task 14, lines 246-277:
//# run-graphql
Response: {
"data": {
"before": {
"nodes": [
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000001",
"version": 1,
"previousTransactionBlock": {
"effects": {
"checkpoint": {
"sequenceNumber": 0
}
}
}
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000002",
"version": 1,
"previousTransactionBlock": {
"effects": {
"checkpoint": {
"sequenceNumber": 0
}
}
}
},
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000003",
"version": 1,
"previousTransactionBlock": {
"effects": {
"checkpoint": {
"sequenceNumber": 0
}
}
}
},
{
"address": "0x000000000000000000000000000000000000000000000000000000000000dee9",
"version": 1,
"previousTransactionBlock": {
"effects": {
"checkpoint": {
"sequenceNumber": 0
}
}
}
}
]
},
"after": {
"nodes": [
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2,
"previousTransactionBlock": {
"effects": {
"checkpoint": {
"sequenceNumber": 2
}
}
}
},
{
"address": "0x0eae57b7a07b0548b1f6b0c309f0692828ff994e9159b541334b25582980631c",
"version": 3,
"previousTransactionBlock": {
"effects": {
"checkpoint": {
"sequenceNumber": 3
}
}
}
}
]
},
"between": {
"nodes": [
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2,
"previousTransactionBlock": {
"effects": {
"checkpoint": {
"sequenceNumber": 2
}
}
}
}
]
}
}
}
54 changes: 54 additions & 0 deletions crates/sui-graphql-e2e-tests/tests/packages/versioning.move
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ module P0::m {
functions { nodes { name } }
}
}

packages(first: 10) {
nodes {
address
version
}
}
}

//# upgrade --package P0 --upgrade-capability 1,1 --sender A
Expand All @@ -36,6 +43,13 @@ module P1::m {
functions { nodes { name } }
}
}

packages(first: 10) {
nodes {
address
version
}
}
}

//# upgrade --package P1 --upgrade-capability 1,1 --sender A
Expand All @@ -55,6 +69,13 @@ module P2::m {
functions { nodes { name } }
}
}

packages(first: 10) {
nodes {
address
version
}
}
}

//# run-graphql
Expand Down Expand Up @@ -221,3 +242,36 @@ module P2::m {
}
}
}

//# run-graphql
{ # Querying packages with checkpoint bounds
before: packages(first: 10, filter: { beforeCheckpoint: 1 }) {
nodes {
address
version
previousTransactionBlock {
effects { checkpoint { sequenceNumber } }
}
}
}

after: packages(first: 10, filter: { afterCheckpoint: 1 }) {
nodes {
address
version
previousTransactionBlock {
effects { checkpoint { sequenceNumber } }
}
}
}

between: packages(first: 10, filter: { afterCheckpoint: 1, beforeCheckpoint: 3 }) {
nodes {
address
version
previousTransactionBlock {
effects { checkpoint { sequenceNumber } }
}
}
}
}
Loading

0 comments on commit 70899b2

Please sign in to comment.