Skip to content
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

Sort actions by tx sequence when available #1917

Merged
merged 10 commits into from
Jan 9, 2025

Conversation

45930
Copy link
Contributor

@45930 45930 commented Nov 22, 2024

Relates to #1872

The archive node currently in production does not expose enough information to accurately sort actions and produce an actions hash.

o1-labs/Archive-Node-API#107 is the PR to fix the archive node API, and this is the PR to update the query and sorting in o1js.

if (error) throw Error(error.statusText);
if (error) {
// retry once without querying transaction info
[response, error] = await makeGraphqlRequest<ActionQueryResponse>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than retry the query, perhaps we can set the archive node API version in the Mina.Network settings somewhere. Then we could make a different query based on which version we believe we're talking to.

For this specific example, after we get Minascan to update their version, the new query will work in nearly every case, but we ought to prepare for the case that different versions of the API could be running.

@45930 45930 marked this pull request as ready for review November 22, 2024 15:03
@45930 45930 requested review from a team as code owners November 22, 2024 15:03
@45930 45930 requested review from boray and ymekuria November 22, 2024 15:03
@45930
Copy link
Contributor Author

45930 commented Nov 22, 2024

This PR is not to be merged until after Minascan deploys the fixes in o1-labs/Archive-Node-API#107

CHANGELOG.md Outdated Show resolved Hide resolved
src/lib/mina/fetch.unit-test.ts Outdated Show resolved Hide resolved
src/lib/mina/fetch.unit-test.ts Show resolved Hide resolved
src/lib/mina/graphql.ts Outdated Show resolved Hide resolved
45930 added a commit to o1-labs/Archive-Node-API that referenced this pull request Dec 17, 2024
Fixes: #106 

This PR adds `sequenceNumber`, as well as `zkappAccountUpdateIds` to the
graphQL schema, which will expose enough information for clients to
verify the order in which actions were processed by consensus. It also
attempts to return actions in that order, and exposes the ordering spec
in a unit test.

We also overhaul the test contract and test suite to emit more random
and different values so that sequential events and actions can be
identified by their data.

I have tested this branch locally against the [sibling
branch](o1-labs/o1js#1917) in o1js.
@45930 45930 requested a review from Trivo25 January 8, 2025 21:55
});
// DEPRECATED: In case the archive node is running an out-of-date version, best guess is to sort by the account update id
// As of 2025-01-07, minascan is running a version of the node which supports `sequenceNumber` and `zkappAccountUpdateIds` fields
// We could consider removing this fallback since no other nodes are widely used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider removing this fallback since no other nodes are widely used

I would be careful with that and I don't think we should. App developers are currently incentivized to run their own services for that type of stuff, so we will never know what users are exactly using. Imo we should just keep it in there, it doesn't hurt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo we should just keep it in there, it doesn't hurt

It's a little sloppy because we will retry on any error. The archive node API responds with Error: Unknown Error: {} when this situation is hit. So we should also improve the error handling on the API side.

But I'll leave it as-is for now. The most common case will be that that the first request succeeds and this case is never hit.

src/lib/mina/fetch.ts Outdated Show resolved Hide resolved
@45930 45930 merged commit 2f4d437 into main Jan 9, 2025
29 checks passed
@45930 45930 deleted the 2024-11-actions-sort-by-tx-sequence branch January 9, 2025 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants