-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(graphql): add root object version for dynamic field queries (#17934)
## Description Adds the following attribute to `sui_graphql_rpc::types::object::Object`: ```rust /// Optional root parent object version if this is a dynamic field. /// /// This enables consistent dynamic field reads in the case of chained dynamic object fields, /// e.g., `Parent -> DOF1 -> DOF2`. In such cases, the object versions may end up like /// `Parent >= DOF1, DOF2` but `DOF1 < DOF2`. Thus, database queries for dynamic fields must /// bound the object versions by the version of the root object of the tree. /// /// Essentially, lamport timestamps of objects are updated for all top-level mutable objects /// provided as inputs to a transaction as well as any mutated dynamic child objects. However, /// any dynamic child objects that were loaded but not actually mutated don't end up having /// their versions updated. root_version: Option<u64>, ``` I tried making sure that this attribute is set correctly wherever an `Object` is created. There's one scenario which still isn't covered: if the GQL query is rooted at a DOF, something like ```graphql query DynamicFields($parent: SuiAddress!, $version: Int, $after: String) { object(address: $parent, version: $version) { dynamicFields(/* ... */) { // ... } } } ``` where `$parent` is a DOF's object id, then the server has no way to know the root object's version. Instead, we will use the rooting object's version, even if it is a nested child object. ## Test plan New tests `immutable_dof.move` and `nested_dof.move`. --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [x] GraphQL: - [ ] CLI: - [ ] Rust SDK: --------- Co-authored-by: Ashok Menon <amenon94@gmail.com> Co-authored-by: Will Yang <willyang@mystenlabs.com>
- Loading branch information
1 parent
0489999
commit 25335da
Showing
16 changed files
with
1,171 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 204 additions & 0 deletions
204
crates/sui-graphql-e2e-tests/tests/consistency/dynamic_fields/immutable_dof.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
processed 17 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 20-68: | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 8770400, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 70-70: | ||
created: object(2,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 3 'run'. lines 72-72: | ||
created: object(3,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2295200, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 4 'run'. lines 74-74: | ||
created: object(4,0) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2295200, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 5 'run'. lines 76-76: | ||
created: object(5,0) | ||
mutated: object(0,0), object(2,0), object(3,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 6064800, storage_rebate: 3573900, non_refundable_storage_fee: 36100 | ||
|
||
task 6 'run'. lines 78-78: | ||
created: object(6,0) | ||
mutated: object(0,0), object(2,0), object(4,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 6064800, storage_rebate: 3573900, non_refundable_storage_fee: 36100 | ||
|
||
task 7 'run'. lines 80-80: | ||
mutated: object(0,0), object(2,0), object(3,0) | ||
deleted: object(5,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 3610000, storage_rebate: 6004152, non_refundable_storage_fee: 60648 | ||
|
||
task 8 'create-checkpoint'. lines 82-82: | ||
Checkpoint created: 1 | ||
|
||
task 9 'run-graphql'. lines 84-114: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"dynamicFields": { | ||
"nodes": [ | ||
{ | ||
"value": { | ||
"address": "0x6b7e8ee3f855e9c484caf53b5fef5fe958d7266d8a3a12577f4a17830e213983", | ||
"version": 5, | ||
"contents": { | ||
"json": { | ||
"id": "0x6b7e8ee3f855e9c484caf53b5fef5fe958d7266d8a3a12577f4a17830e213983", | ||
"count": "0" | ||
} | ||
}, | ||
"dynamicFields": { | ||
"nodes": [] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
||
task 10 'run-graphql'. lines 116-146: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"dynamicFields": { | ||
"nodes": [ | ||
{ | ||
"value": { | ||
"address": "0x6b7e8ee3f855e9c484caf53b5fef5fe958d7266d8a3a12577f4a17830e213983", | ||
"version": 5, | ||
"contents": { | ||
"json": { | ||
"id": "0x6b7e8ee3f855e9c484caf53b5fef5fe958d7266d8a3a12577f4a17830e213983", | ||
"count": "0" | ||
} | ||
}, | ||
"dynamicFields": { | ||
"nodes": [ | ||
{ | ||
"value": { | ||
"address": "0x4198a12c0cd01da21a6cd35cc5e986d855c532676233d004105dbaa77bdfda77", | ||
"version": 6, | ||
"contents": { | ||
"json": { | ||
"id": "0x4198a12c0cd01da21a6cd35cc5e986d855c532676233d004105dbaa77bdfda77", | ||
"count": "0" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
||
task 11 'run-graphql'. lines 148-178: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"dynamicFields": { | ||
"nodes": [] | ||
} | ||
} | ||
} | ||
} | ||
|
||
task 12 'run-graphql'. lines 180-210: | ||
Response: { | ||
"data": { | ||
"object": null | ||
} | ||
} | ||
|
||
task 13 'run-graphql'. lines 212-239: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"owner": { | ||
"parent": { | ||
"address": "0x14c69bfdef30d74f3cb7e305aead3f5d2558ca8d4a32c96b01936c7cfbb36af0" | ||
} | ||
}, | ||
"dynamicFields": { | ||
"nodes": [] | ||
} | ||
} | ||
} | ||
} | ||
|
||
task 14 'run-graphql'. lines 241-258: | ||
Response: { | ||
"data": { | ||
"object": null | ||
} | ||
} | ||
|
||
task 15 'run-graphql'. lines 260-287: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"owner": { | ||
"_": null | ||
}, | ||
"dynamicFields": { | ||
"nodes": [ | ||
{ | ||
"value": { | ||
"address": "0x4198a12c0cd01da21a6cd35cc5e986d855c532676233d004105dbaa77bdfda77", | ||
"version": 6, | ||
"contents": { | ||
"json": { | ||
"id": "0x4198a12c0cd01da21a6cd35cc5e986d855c532676233d004105dbaa77bdfda77", | ||
"count": "0" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
||
task 16 'run-graphql'. lines 289-316: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"owner": { | ||
"_": null | ||
}, | ||
"dynamicFields": { | ||
"nodes": [ | ||
{ | ||
"value": { | ||
"address": "0x4198a12c0cd01da21a6cd35cc5e986d855c532676233d004105dbaa77bdfda77", | ||
"version": 6, | ||
"contents": { | ||
"json": { | ||
"id": "0x4198a12c0cd01da21a6cd35cc5e986d855c532676233d004105dbaa77bdfda77", | ||
"count": "0" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.