Skip to content

Commit

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

Introduce two new queries: `Query.packageVersions` and
`MovePackage.versions` for iterating over all the different versions
of a given package.

This kind of query is useful for understanding package history.

These were introduced as a separate query, instead of having a single
query for iterating over packages that could optionally take a
checkpoint bounds or version bounds because of how system packages
interact with the `packages` table:

Because system packages are updated in-place, they only have one row
in the `packages` table. This makes sense for paginating packages in
bulk (e.g. by checkpoint) where the primary aim is to get a snapshot
of the packages available at a certain point in time, but doesn't work
for answering package version queries for system packages, and it
prevents us from creating a combined query. A combined query would
also allow someone to create a filter that bounds checkpoints and
versions, but doesn't bound the package itself (or would require us to
prevent that combination), which is complicated to implement
efficiently and not particularly useful.

## Test plan

New E2E tests:

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

+ Testing against a read replica to make sure system package tests
work well, and performance is reasonable.
  • Loading branch information
amnn committed May 13, 2024
1 parent d1c9a77 commit 2a46ffd
Show file tree
Hide file tree
Showing 6 changed files with 553 additions and 23 deletions.
215 changes: 202 additions & 13 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 15 tasks
processed 17 tasks

init:
A: object(0,0)
Expand All @@ -11,7 +11,7 @@ gas summary: computation_cost: 1000000, storage_cost: 5076800, storage_rebate:
task 2 'create-checkpoint'. lines 11-11:
Checkpoint created: 1

task 3 'run-graphql'. lines 13-28:
task 3 'run-graphql'. lines 13-50:
Response: {
"data": {
"latestPackage": {
Expand All @@ -24,6 +24,35 @@ Response: {
}
]
}
},
"versions": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
}
]
}
},
"firstPackage": {
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1,
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
},
"versions": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
}
]
}
},
"packages": {
Expand Down Expand Up @@ -53,15 +82,15 @@ Response: {
}
}

task 4 'upgrade'. lines 30-34:
task 4 'upgrade'. lines 52-56:
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 'create-checkpoint'. lines 36-36:
task 5 'create-checkpoint'. lines 58-58:
Checkpoint created: 2

task 6 'run-graphql'. lines 38-53:
task 6 'run-graphql'. lines 60-97:
Response: {
"data": {
"latestPackage": {
Expand All @@ -77,6 +106,43 @@ Response: {
}
]
}
},
"versions": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
}
]
}
},
"firstPackage": {
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1,
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
},
"versions": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
}
]
}
},
"packages": {
Expand Down Expand Up @@ -110,15 +176,15 @@ Response: {
}
}

task 7 'upgrade'. lines 55-60:
task 7 'upgrade'. lines 99-104:
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 'create-checkpoint'. lines 62-62:
task 8 'create-checkpoint'. lines 106-106:
Checkpoint created: 3

task 9 'run-graphql'. lines 64-79:
task 9 'run-graphql'. lines 108-145:
Response: {
"data": {
"latestPackage": {
Expand All @@ -137,6 +203,51 @@ Response: {
}
]
}
},
"versions": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
},
{
"address": "0x0eae57b7a07b0548b1f6b0c309f0692828ff994e9159b541334b25582980631c",
"version": 3
}
]
}
},
"firstPackage": {
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1,
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
},
"versions": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
},
{
"address": "0x0eae57b7a07b0548b1f6b0c309f0692828ff994e9159b541334b25582980631c",
"version": 3
}
]
}
},
"packages": {
Expand Down Expand Up @@ -174,7 +285,7 @@ Response: {
}
}

task 10 'run-graphql'. lines 81-118:
task 10 'run-graphql'. lines 147-184:
Response: {
"data": {
"v1": {
Expand Down Expand Up @@ -273,7 +384,7 @@ Response: {
}
}

task 11 'run-graphql'. lines 120-157:
task 11 'run-graphql'. lines 186-223:
Response: {
"data": {
"v1_from_p1": {
Expand Down Expand Up @@ -363,7 +474,7 @@ Response: {
}
}

task 12 'run-graphql'. lines 159-214:
task 12 'run-graphql'. lines 225-280:
Response: {
"data": {
"v1": {
Expand Down Expand Up @@ -501,7 +612,7 @@ Response: {
}
}

task 13 'run-graphql'. lines 216-244:
task 13 'run-graphql'. lines 282-310:
Response: {
"data": {
"v0": null,
Expand All @@ -513,7 +624,7 @@ Response: {
}
}

task 14 'run-graphql'. lines 246-277:
task 14 'run-graphql'. lines 312-343:
Response: {
"data": {
"before": {
Expand Down Expand Up @@ -607,3 +718,81 @@ Response: {
}
}
}

task 15 'run-graphql'. lines 345-378:
Response: {
"data": {
"packageVersions": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
},
{
"address": "0x0eae57b7a07b0548b1f6b0c309f0692828ff994e9159b541334b25582980631c",
"version": 3
}
]
},
"after": {
"nodes": [
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
},
{
"address": "0x0eae57b7a07b0548b1f6b0c309f0692828ff994e9159b541334b25582980631c",
"version": 3
}
]
},
"before": {
"nodes": [
{
"address": "0x175ae86f2df1eb652d57fbe9e44c7f2d67870d2b6776a4356f30930221b63b88",
"version": 1
},
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
}
]
},
"between": {
"nodes": [
{
"address": "0x351bc614b36f0f522a64334e4c278d4bfe200234958870c084e0a005f041d681",
"version": 2
}
]
}
}
}

task 16 'run-graphql'. lines 380-398:
Response: {
"data": {
"packageVersions": {
"nodes": [
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000001",
"version": 1
}
]
},
"package": {
"versions": {
"nodes": [
{
"address": "0x0000000000000000000000000000000000000000000000000000000000000001",
"version": 1
}
]
}
}
}
}
Loading

0 comments on commit 2a46ffd

Please sign in to comment.