forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gql] objects_snapshot test for availableRange-aware object history l…
…ookup (MystenLabs#15677) ## Description Expose a way to provide config values to ObjectsSnapshotProcessor to enable e2e tests around objects_snapshot. 1. Adds a SnapshotLagConfig to ObjectsSnapshotProcessor struct 2. ReaderWriterConfig for start_test_indexer_v2, reorganizes some logic on instantiating a reader or writer indexer_v2 3. RunGraphqlCommand now waits for objects_snapshot catch up in addition to the existing checkpoint catch up. snapshot.move to test querying against objects_snapshot and objects_history tables ## Test Plan snapshot.move --- 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
Showing
13 changed files
with
452 additions
and
54 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
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,96 @@ | ||
processed 17 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 11-37: | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 6171200, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 39-39: | ||
created: object(2,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 3 'create-checkpoint'. lines 41-41: | ||
Checkpoint created: 1 | ||
|
||
task 4 'run-graphql'. lines 43-56: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"status": "LIVE", | ||
"version": 3, | ||
"asMoveObject": { | ||
"contents": { | ||
"json": { | ||
"id": "0xcf27391f83c42a323595be23151f6ede95a083f451a388ff2e3e25fbbf31a7c3", | ||
"value": "0" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
task 5 'run-graphql'. lines 59-73: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"status": "HISTORICAL", | ||
"version": 3, | ||
"asMoveObject": { | ||
"contents": { | ||
"json": { | ||
"id": "0xcf27391f83c42a323595be23151f6ede95a083f451a388ff2e3e25fbbf31a7c3", | ||
"value": "0" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
task 6 'run'. lines 75-75: | ||
created: object(6,0) | ||
mutated: object(0,0) | ||
wrapped: object(2,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 2553600, storage_rebate: 1301652, non_refundable_storage_fee: 13148 | ||
|
||
task 7 'create-checkpoint'. lines 77-77: | ||
Checkpoint created: 2 | ||
|
||
task 9 'create-checkpoint'. lines 81-81: | ||
Checkpoint created: 3 | ||
|
||
task 11 'create-checkpoint'. lines 85-85: | ||
Checkpoint created: 4 | ||
|
||
task 13 'create-checkpoint'. lines 89-89: | ||
Checkpoint created: 5 | ||
|
||
task 14 'run-graphql'. lines 91-105: | ||
Response: { | ||
"data": { | ||
"object": null | ||
} | ||
} | ||
|
||
task 15 'run-graphql'. lines 108-123: | ||
Response: { | ||
"data": { | ||
"object": { | ||
"status": "WRAPPED_OR_DELETED", | ||
"version": 4, | ||
"asMoveObject": null | ||
} | ||
} | ||
} | ||
|
||
task 16 'run-graphql'. lines 125-140: | ||
Response: { | ||
"data": { | ||
"object": null | ||
} | ||
} |
140 changes: 140 additions & 0 deletions
140
crates/sui-graphql-e2e-tests/tests/objects/snapshot.move
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,140 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Objects can continue to be found on the live objects table until they are WrappedOrDeleted. From | ||
// there, the object can be fetched on the objects_history table, until it gets snapshotted into | ||
// objects_snapshot table. This test checks that we correctly fetch data from both the | ||
// objects_snapshot and objects_history tables. | ||
|
||
//# init --addresses Test=0x0 --accounts A --simulator --object-snapshot-min-checkpoint-lag 0 --object-snapshot-max-checkpoint-lag 2 | ||
|
||
//# publish | ||
module Test::M1 { | ||
use sui::object::{Self, UID}; | ||
use sui::tx_context::{Self, TxContext}; | ||
use sui::transfer; | ||
|
||
struct Object has key, store { | ||
id: UID, | ||
value: u64, | ||
} | ||
|
||
struct Wrapper has key { | ||
id: UID, | ||
o: Object | ||
} | ||
|
||
public entry fun create(value: u64, recipient: address, ctx: &mut TxContext) { | ||
transfer::public_transfer( | ||
Object { id: object::new(ctx), value }, | ||
recipient | ||
) | ||
} | ||
|
||
public entry fun wrap(o: Object, ctx: &mut TxContext) { | ||
transfer::transfer(Wrapper { id: object::new(ctx), o }, tx_context::sender(ctx)) | ||
} | ||
} | ||
|
||
//# run Test::M1::create --args 0 @A | ||
|
||
//# create-checkpoint 1 | ||
|
||
//# run-graphql | ||
{ | ||
object( | ||
address: "@{obj_2_0}" | ||
) { | ||
status | ||
version | ||
asMoveObject { | ||
contents { | ||
json | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
//# run-graphql | ||
{ | ||
object( | ||
address: "@{obj_2_0}" | ||
version: 3 | ||
) { | ||
status | ||
version | ||
asMoveObject { | ||
contents { | ||
json | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run Test::M1::wrap --sender A --args object(2,0) | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-clock --duration-ns 1 | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-clock --duration-ns 1 | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-clock --duration-ns 1 | ||
|
||
//# create-checkpoint | ||
|
||
//# run-graphql | ||
# should not exist on live objects | ||
{ | ||
object( | ||
address: "@{obj_2_0}" | ||
) { | ||
status | ||
version | ||
asMoveObject { | ||
contents { | ||
json | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
//# run-graphql | ||
# fetched from objects_snapshot | ||
{ | ||
object( | ||
address: "@{obj_2_0}" | ||
version: 4 | ||
) { | ||
status | ||
version | ||
asMoveObject { | ||
contents { | ||
json | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# should not exist in either objects_snapshot or objects_history | ||
{ | ||
object( | ||
address: "@{obj_2_0}" | ||
version: 3 | ||
) { | ||
status | ||
version | ||
asMoveObject { | ||
contents { | ||
json | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.