-
Notifications
You must be signed in to change notification settings - Fork 11.5k
graphql-alt: Epoch #21997
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
amnn
wants to merge
2
commits into
amnn/gql-vis
Choose a base branch
from
amnn/gql-epoch
base: amnn/gql-vis
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
graphql-alt: Epoch #21997
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
28 changes: 28 additions & 0 deletions
28
crates/sui-indexer-alt-e2e-tests/tests/graphql/checkpoints/epoch.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,28 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --protocol-version 70 --accounts A --simulator | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-epoch | ||
|
||
//# create-checkpoint | ||
|
||
//# create-checkpoint | ||
|
||
//# advance-epoch | ||
|
||
//# create-checkpoint | ||
|
||
//# run-graphql | ||
{ | ||
c0: checkpoint(sequenceNumber: 0) { epoch { epochId } } | ||
c1: checkpoint(sequenceNumber: 1) { epoch { epochId } } | ||
c2: checkpoint(sequenceNumber: 2) { epoch { epochId } } | ||
c3: checkpoint(sequenceNumber: 3) { epoch { epochId } } | ||
c4: checkpoint(sequenceNumber: 4) { epoch { epochId } } | ||
c5: checkpoint(sequenceNumber: 5) { epoch { epochId } } | ||
c6: checkpoint(sequenceNumber: 6) { epoch { epochId } } | ||
c7: checkpoint(sequenceNumber: 7) { epoch { epochId } } | ||
} |
74 changes: 74 additions & 0 deletions
74
crates/sui-indexer-alt-e2e-tests/tests/graphql/checkpoints/epoch.snap
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,74 @@ | ||
--- | ||
source: external-crates/move/crates/move-transactional-test-runner/src/framework.rs | ||
--- | ||
processed 8 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1, line 6: | ||
//# create-checkpoint | ||
Checkpoint created: 1 | ||
|
||
task 2, line 8: | ||
//# advance-epoch | ||
Epoch advanced: 0 | ||
|
||
task 3, line 10: | ||
//# create-checkpoint | ||
Checkpoint created: 3 | ||
|
||
task 4, line 12: | ||
//# create-checkpoint | ||
Checkpoint created: 4 | ||
|
||
task 5, line 14: | ||
//# advance-epoch | ||
Epoch advanced: 1 | ||
|
||
task 6, line 16: | ||
//# create-checkpoint | ||
Checkpoint created: 6 | ||
|
||
task 7, lines 18-28: | ||
//# run-graphql | ||
Response: { | ||
"data": { | ||
"c0": { | ||
"epoch": { | ||
"epochId": 0 | ||
} | ||
}, | ||
"c1": { | ||
"epoch": { | ||
"epochId": 0 | ||
} | ||
}, | ||
"c2": { | ||
"epoch": { | ||
"epochId": 0 | ||
} | ||
}, | ||
"c3": { | ||
"epoch": { | ||
"epochId": 1 | ||
} | ||
}, | ||
"c4": { | ||
"epoch": { | ||
"epochId": 1 | ||
} | ||
}, | ||
"c5": { | ||
"epoch": { | ||
"epochId": 1 | ||
} | ||
}, | ||
"c6": { | ||
"epoch": { | ||
"epochId": 2 | ||
} | ||
}, | ||
"c7": null | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
crates/sui-indexer-alt-e2e-tests/tests/graphql/epochs/query.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,46 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --protocol-version 70 --accounts A --simulator | ||
|
||
//# advance-clock --duration-ns 123000000 | ||
|
||
//# advance-epoch | ||
|
||
//# advance-clock --duration-ns 321000000 | ||
|
||
//# advance-epoch | ||
|
||
//# advance-epoch | ||
|
||
//# run-graphql | ||
{ | ||
e0: epoch(epochId: 0) { ...E } | ||
e1: epoch(epochId: 1) { ...E } | ||
e2: epoch(epochId: 2) { ...E } | ||
|
||
# This epoch doesn't exist yet | ||
e3: epoch(epochId: 3) { ...E } | ||
} | ||
|
||
fragment E on Epoch { | ||
epochId | ||
referenceGasPrice | ||
startTimestamp | ||
endTimestamp | ||
} | ||
|
||
//# run-graphql | ||
{ # This checkpoint is half way through the epoch, so the epoch should return | ||
# its starting information, but not its ending information. | ||
checkpoint(sequenceNumber: 2) { | ||
query { | ||
epoch(epochId: 1) { | ||
epochId | ||
referenceGasPrice | ||
startTimestamp | ||
endTimestamp | ||
} | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
crates/sui-indexer-alt-e2e-tests/tests/graphql/epochs/query.snap
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,62 @@ | ||
--- | ||
source: external-crates/move/crates/move-transactional-test-runner/src/framework.rs | ||
--- | ||
processed 8 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 2, line 8: | ||
//# advance-epoch | ||
Epoch advanced: 0 | ||
|
||
task 4, line 12: | ||
//# advance-epoch | ||
Epoch advanced: 1 | ||
|
||
task 5, line 14: | ||
//# advance-epoch | ||
Epoch advanced: 2 | ||
|
||
task 6, lines 16-31: | ||
//# run-graphql | ||
Response: { | ||
"data": { | ||
"e0": { | ||
"epochId": 0, | ||
"referenceGasPrice": "1000", | ||
"startTimestamp": "1970-01-01T00:00:00Z", | ||
"endTimestamp": "1970-01-01T00:00:00.123Z" | ||
}, | ||
"e1": { | ||
"epochId": 1, | ||
"referenceGasPrice": "1000", | ||
"startTimestamp": "1970-01-01T00:00:00.123Z", | ||
"endTimestamp": "1970-01-01T00:00:00.444Z" | ||
}, | ||
"e2": { | ||
"epochId": 2, | ||
"referenceGasPrice": "1000", | ||
"startTimestamp": "1970-01-01T00:00:00.444Z", | ||
"endTimestamp": null | ||
}, | ||
"e3": null | ||
} | ||
} | ||
|
||
task 7, lines 33-46: | ||
//# run-graphql | ||
Response: { | ||
"data": { | ||
"checkpoint": { | ||
"query": { | ||
"epoch": { | ||
"epochId": 1, | ||
"referenceGasPrice": "1000", | ||
"startTimestamp": "1970-01-01T00:00:00.123Z", | ||
"endTimestamp": null | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,6 +11,7 @@ use super::{ | |||||
scalars::{digest::Digest, sui_address::SuiAddress, uint53::UInt53}, | ||||||
types::{ | ||||||
checkpoint::Checkpoint, | ||||||
epoch::Epoch, | ||||||
move_package::{self, MovePackage, PackageKey}, | ||||||
object::{self, Object, ObjectKey}, | ||||||
service_config::ServiceConfig, | ||||||
|
@@ -50,6 +51,14 @@ impl Query { | |||||
Ok(Checkpoint::with_sequence_number(scope, sequence_number)) | ||||||
} | ||||||
|
||||||
/// Fetch an epoch by its ID. | ||||||
/// | ||||||
/// Returns `null` if the epoch does not exist yet, or was pruned. | ||||||
async fn epoch(&self, ctx: &Context<'_>, epoch_id: UInt53) -> Result<Option<Epoch>, RpcError> { | ||||||
let scope = self.scope(ctx)?; | ||||||
Epoch::fetch(ctx, scope, epoch_id).await | ||||||
} | ||||||
|
||||||
/// Fetch checkpoints by their sequence numbers. | ||||||
/// | ||||||
/// Returns a list of checkpoints that is guaranteed to be the same length as `keys`. If a checkpoint in `keys` could not be found in the store, its corresponding entry in the result will be `null`. This could be because the checkpoint does not exist yet, or because it was pruned. | ||||||
|
@@ -65,6 +74,22 @@ impl Query { | |||||
.collect()) | ||||||
} | ||||||
|
||||||
/// Fetch epochs by their IDs. | ||||||
/// | ||||||
/// Returns a list of epochs that is guarnateed to be the same length as `keys`. If an epoch in `keys` could not be found in the store, its corresponding entry in the result will be `null`. This could be because the epocch does not exist yet, or because it was pruned. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
async fn multi_get_epochs( | ||||||
&self, | ||||||
ctx: &Context<'_>, | ||||||
keys: Vec<UInt53>, | ||||||
) -> Result<Vec<Option<Epoch>>, RpcError> { | ||||||
let scope = self.scope(ctx)?; | ||||||
let epochs = keys | ||||||
.into_iter() | ||||||
.map(|k| Epoch::fetch(ctx, scope.clone(), k)); | ||||||
|
||||||
try_join_all(epochs).await | ||||||
} | ||||||
|
||||||
/// Fetch objects by their keys. | ||||||
/// | ||||||
/// Returns a list of objects that is guaranteed to be the same length as `keys`. If an object in `keys` could not be found in the store, its corresponding entry in the result will be `null`. This could be because the object never existed, or because it was pruned. | ||||||
|
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.
wheres c7 coming from?
e0
c0: init
c1: L6
c2: L8 advance-epoch
e1
c3 L10
c4 L12
c5 L14 advance epoch
and then c6 from L16