-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[gql] Graphql transactions queries can handle db with pruning enabled #19237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wlmyng
wants to merge
8
commits into
main
Choose a base branch
from
gql/compatible-with-pruning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c5a0b6c
this impl should be correct but txbounds expects a right-open interva…
wlmyng 1808bb5
tests around how transactions will work with pruning
wlmyng a07d377
track min unpruned cp in watermark task, simplify txbounds::query imp…
wlmyng 0ad253c
i think we should return an error when people query for data that is …
wlmyng 76daaee
cleanup
wlmyng 8e94e48
clippy
wlmyng 4ddfb4d
please clippy
wlmyng 7e72b73
address comments. makes me think ... i suppose even though the waterm…
wlmyng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
428 changes: 428 additions & 0 deletions
428
crates/sui-graphql-e2e-tests/tests/pruning/transactions.exp
Large diffs are not rendered by default.
Oops, something went wrong.
331 changes: 331 additions & 0 deletions
331
crates/sui-graphql-e2e-tests/tests/pruning/transactions.move
This file contains hidden or 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,331 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --protocol-version 51 --addresses Test=0x0 --accounts A --simulator --epochs-to-keep 2 | ||
|
||
//# publish | ||
module Test::M1 { | ||
use sui::coin::Coin; | ||
|
||
public struct Object has key, store { | ||
id: UID, | ||
value: u64, | ||
} | ||
|
||
fun foo<T: key, T2: drop>(_p1: u64, value1: T, _value2: &Coin<T2>, _p2: u64): T { | ||
value1 | ||
} | ||
|
||
public entry fun create(value: u64, recipient: address, ctx: &mut TxContext) { | ||
transfer::public_transfer( | ||
Object { id: object::new(ctx), value }, | ||
recipient | ||
) | ||
} | ||
} | ||
|
||
//# run Test::M1::create --sender A --args 0 @A | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-epoch | ||
|
||
//# run Test::M1::create --sender A --args 1 @A | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-epoch | ||
|
||
//# run Test::M1::create --sender A --args 2 @A | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-epoch | ||
|
||
//# run Test::M1::create --sender A --args 3 @A | ||
|
||
//# create-checkpoint | ||
|
||
//# run-graphql --wait-for-checkpoint-pruned 4 | ||
# The smallest unpruned epoch is 2, starting with checkpoint sequence number 5 | ||
# When a range is not specified, transactions queries should return results starting from the smallest unpruned tx | ||
{ | ||
epoch { | ||
epochId | ||
} | ||
checkpoints { | ||
nodes { | ||
epoch { | ||
epochId | ||
} | ||
sequenceNumber | ||
} | ||
} | ||
unfiltered: transactionBlocks { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
transactionBlocks(filter: { signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --wait-for-checkpoint-pruned 4 | ||
# In the absence of an upper bound, graphql sets the upper bound to `checkpoint_viewed_at`'s max tx + 1 (right-open interval) | ||
{ | ||
transactionBlocks(filter: { afterCheckpoint: 5 signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --wait-for-checkpoint-pruned 4 | ||
# In the absence of a lower bound, graphql sets the lower bound to the smallest unpruned checkpoint's min tx | ||
{ | ||
transactionBlocks(filter: { beforeCheckpoint: 7 signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
//# run-graphql --wait-for-checkpoint-pruned 4 | ||
# If the caller tries to fetch data outside of the unpruned range, they should receive an error | ||
{ | ||
transactionBlocks(filter: { atCheckpoint: 0 signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --wait-for-checkpoint-pruned 4 | ||
# Empty response if caller tries to fetch data beyond the available upper bound | ||
{ | ||
transactionBlocks(filter: { atCheckpoint: 10 signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
//# run-graphql | ||
# Mirror from the back | ||
{ | ||
transactionBlocks(last: 10 filter: { signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# Mirror from the back | ||
{ | ||
transactionBlocks(last: 10 filter: { afterCheckpoint: 5 signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql | ||
# Mirror from the back | ||
{ | ||
transactionBlocks(last: 10 filter: { beforeCheckpoint: 7 signAddress: "@{A}" }) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --cursors {"c":7,"t":6,"i":false} | ||
# The first tx after pruning has seq num 6. | ||
# When viewed at checkpoint 7, there are two more txs that follow it. | ||
{ | ||
transactionBlocks(after: "@{cursor_0}") { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --cursors {"c":7,"t":0,"i":false} | ||
# Data is pruned and no longer available | ||
{ | ||
transactionBlocks(after: "@{cursor_0}") { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --cursors {"c":7,"t":0,"i":true} | ||
# Data is pruned and no longer available | ||
{ | ||
transactionBlocks(after: "@{cursor_0}") { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --cursors {"c":7,"t":0,"i":true} | ||
# Data is pruned and no longer available | ||
{ | ||
transactionBlocks(scanLimit: 10000 after: "@{cursor_0}") { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasPreviousPage | ||
hasNextPage | ||
} | ||
nodes { | ||
digest | ||
effects { | ||
checkpoint { | ||
sequenceNumber | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we record
hi_tx
as well? It would seem to be symmetric and we do need to use that for the transaction queries.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we care about the transaction upperbound for whatever the checkpoint upperbound is, so it doesn't really help to track
hi_tx
here.