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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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

@@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- Compiling stuck in the browser for recursive zkprograms https://github.com/o1-labs/o1js/pull/1906
- Sort order for actions now includes the transaction sequence number and the exact account id sequence
Copy link
Member

Choose a reason for hiding this comment

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

nit: link to PR

'1',
],
],
hash: '10964420428484427410756859799314206378989718180435238943573393516522086219419',
Copy link
Member

Choose a reason for hiding this comment

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

given our history with the action sequence, I think we should seriously consider some advanced testing here - similar to the property testing we do in other places of the codebase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you describe what cases you'd like to see? The existing tests here are simply real payloads from the graphQL node, and the real output of fetchActions in a case where the actions are derived successfully. In particular, it is one of the edge cases discovered by the original reporter of the issue: #1872 (comment)

Copy link
Member

@Trivo25 Trivo25 Nov 23, 2024

Choose a reason for hiding this comment

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

hash: '3432500319723012006583645985859849032413742507994268064744704124629760504866',
},
]);
});
Copy link
Member

Choose a reason for hiding this comment

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

this is very long and makes it very hard to read, can we clean this up a little?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what you mean by clean it up? Do you mean move the payload to a JSON file and read it in?

I would push back on removing this test or trying to prune it to its most useful bits. Since it is a raw input-output from a real edge case, I think it's worth leaving in full. It's not really meant to be readable, but it will flag regressions.

Copy link
Member

Choose a reason for hiding this comment

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

I don't want to remove it but I would like to make it more readable (dedicated JSON file for the payloads, for example)

@@ -0,0 +1,1864 @@
export { mockFetchActionsResponse };
Copy link
Member

Choose a reason for hiding this comment

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

see what i wrote above; this could save us a few thousand lines here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, this is the block in which the actions are out of order by the currently-live algorithm. So if we did trim it, we should at least keep this.

      {
        blockInfo: {
          distanceFromMaxBlockHeight: 10037,
        },
        actionState: {
          actionStateOne:
            '11553781833537412187998791170094246504179739906426596650283148421062134031747',
          actionStateTwo:
            '2657110063538905863496230550574434206907731812034404344231638673775478011856',
        },
        actionData: [
          {
            accountUpdateId: '40618',
            data: [
              '7',
              '7',
              '7',
              '7',
              '7',
              '7',
              '15661593045172372274349484602975176160403678593916071611247487060653084577990',
              '0',
              '1',
            ],
            transactionInfo: {
              sequenceNumber: 4,
              zkappAccountUpdateIds: [40618, 6396, 33066],
            },
          },
          {
            accountUpdateId: '40617',
            data: [
              '3',
              '4',
              '5',
              '7',
              '6',
              '2',
              '6453147199940115032546911372596674482366995380739961315278593325733504245402',
              '0',
              '1',
            ],
            transactionInfo: {
              sequenceNumber: 5,
              zkappAccountUpdateIds: [40617, 40372, 40373],
            },
          },
          {
            accountUpdateId: '40619',
            data: [
              '3',
              '4',
              '5',
              '7',
              '6',
              '3',
              '21594276700301685638451290563121567472719745179788000956082286147863718718533',
              '1',
              '1',
            ],
            transactionInfo: {
              sequenceNumber: 6,
              zkappAccountUpdateIds: [40619, 33539, 33540],
            },
          },
          {
            accountUpdateId: '40620',
            data: [
              '3',
              '4',
              '5',
              '7',
              '6',
              '3',
              '21594276700301685638451290563121567472719745179788000956082286147863718718533',
              '1',
              '1',
            ],
            transactionInfo: {
              sequenceNumber: 7,
              zkappAccountUpdateIds: [40620, 33539, 33540],
            },
          },
        ],
      },
      ```

Copy link
Member

@Trivo25 Trivo25 Nov 23, 2024

Choose a reason for hiding this comment

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

Sorry, I meant the property testing would be benefical here too #1917 (comment)

@@ -317,7 +321,8 @@ const getActionsQuery = (
publicKey: string,
actionStates: ActionStatesStringified,
tokenId: string,
_filterOptions?: EventActionFilterOptions
_filterOptions?: EventActionFilterOptions,
retryWithoutTxInfo: boolean = false
Copy link
Member

Choose a reason for hiding this comment

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

nit: we could generalize this into the options parameter above

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.

2 participants