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

Add endActionState and fromActionState to fetchActions #828

Merged
merged 7 commits into from
Apr 5, 2023

Conversation

MartinMinkov
Copy link
Contributor

@MartinMinkov MartinMinkov commented Apr 4, 2023

Description

🔗 Resolves #802

This PR introduces fromActionState and endActionState parameters to the fetchActions function in SnarkyJS. This enhancement allows us to fetch only the necessary actions to compute the latest actions state, instead of retrieving the entire actions history of a zkApp as done previously.

With these improvements, we no longer need to start from an empty action state and apply hashes to derive the current action state by analyzing each block from the beginning of a zkApp's history. Instead, we can utilize the new actionStateTwo field returned by the Archive Node API. As actionStateTwo represents the second latest action state calculated, it serves as a safe starting point for deriving the most recent action state. We can now apply AccountUpdates to the actionStateTwo value to compute the current action state.

Furthermore, users can now provide a fromActionState parameter to the Archive Node API, which will return actions only after the specified action state. This feature offers a filtering option in SnarkyJS that was previously unavailable.

Please note that this PR relies on o1-labs/Archive-Node-API#71.

@MartinMinkov MartinMinkov marked this pull request as ready for review April 4, 2023 23:12
Copy link
Collaborator

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

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

Mostly looks good, although I would change the 'actionHash' terminology to 'actionState', and make sure the local and remote Mina interfaces are consistent.

A general comment is that we don't have good test coverage for getActions. Ideally, there'd be a unit test which confirms expected behavior on LocalBlockchain (for cases like multiple actions in an account update / in a block / computing action states from multiple blocks with actions). Plus a manual test which confirms it with an archive node, for the time being where the Berkeley test doesn't work in CI

CHANGELOG.md Outdated Show resolved Hide resolved
src/lib/mina.ts Outdated Show resolved Hide resolved
src/lib/mina.ts Outdated Show resolved Hide resolved
src/lib/mina.ts Outdated Show resolved Hide resolved
@MartinMinkov MartinMinkov changed the title Add endActionHash and fromActionHash to fetchActions Add endActionState and fromActionState to fetchActions Apr 5, 2023
@MartinMinkov MartinMinkov merged commit 52ec32b into main Apr 5, 2023
@MartinMinkov MartinMinkov deleted the feat/actions-hash-recalculations branch April 5, 2023 20:28
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.

Allow Fetch.fetchActions to derive actionHash from any block instead of calculating from beginning
2 participants