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 Cooperative Storage #211

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Conversation

hayesgm
Copy link
Contributor

@hayesgm hayesgm commented Sep 11, 2024

This patch adds back cooperative storage, which simply isolates each read and write call in QuarkScript to pulling the active nonce and isolating storage keys on that value.

Notes:

  • This is cooperative. A malicious script is free to change any stored data.
  • After a nested quark operation, the nonce value is cleared and thus will not be properly read. We raise an error in this case.

This patch adds back cooperative storage, which simply isolates each `read` and `write` call in `QuarkScript` to pulling the active nonce and isolating storage keys on that value.

Notes:
  * This is cooperative. A malicious script is free to change any stored data.
  * After a nested quark operation, the nonce value is cleared and thus will not be properly read. We raise an error in this case.
src/quark-core/src/QuarkScript.sol Outdated Show resolved Hide resolved
@kevincheng96
Copy link
Collaborator

kevincheng96 commented Sep 11, 2024

  • After a nested quark operation, the nonce value is cleared and thus will not be properly read. We raise an error in this case.

An alternative approach to address this would be to, in the wallet, cache the current activeNonce and set it back to this value after the callcode. Not saying we should do this, but in a tstore world this is basically free and would remove this weird edge case. It's basically what we used to do in the QuarkStateManager.

Copy link
Collaborator

@kevincheng96 kevincheng96 left a comment

Choose a reason for hiding this comment

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

LGTM

This patch fixes the function names of and tests replaying multi-quark
operations. By and large, nothing changed and this works out of the box
more or less for free, but we want to make sure we test the behavior to
ensure there's no gotchas and that storage is correct, etc. So far, so
good.
@hayesgm
Copy link
Contributor Author

hayesgm commented Sep 12, 2024

  • After a nested quark operation, the nonce value is cleared and thus will not be properly read. We raise an error in this case.

An alternative approach to address this would be to, in the wallet, cache the current activeNonce and set it back to this value after the callcode. Not saying we should do this, but in a tstore world this is basically free and would remove this weird edge case. It's basically what we used to do in the QuarkStateManager.

Yeah, though scripts could also cache it themselves. Mostly here I want the scripts to be written pretty seamlessly, but they are free for more complex behaviors if they want to handle nested calls.

@hayesgm hayesgm merged commit e0fea10 into hayesgm/library-values Sep 12, 2024
1 of 4 checks passed
@hayesgm hayesgm deleted the hayesgm/cooperative-storage branch September 12, 2024 23:02
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.

3 participants