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

test(zk): cheatcode usage in zkVm #539

Merged
merged 4 commits into from
Aug 22, 2024
Merged

test(zk): cheatcode usage in zkVm #539

merged 4 commits into from
Aug 22, 2024

Conversation

Karrq
Copy link
Contributor

@Karrq Karrq commented Aug 21, 2024

Motivation

Cheatcodes are not supported in zkVm, but there are no tests that display this limitation

Solution

Provide a test case which shows this limitation and also potential pattern to avoid a given contract from being executed in zkVm and thus circumvent this limtation


function getZkBalance(Vm vm, address target) public view returns (uint256) {
vm.zkVm(true);
getNonce(vm, target);
Copy link
Contributor

Choose a reason for hiding this comment

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

so this gets executed in evm even though the vm.zkVm(true) is before this, and it would only run things in zkVm if a CALL happens from that point on right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Partially correct: in this instance, getNonce is an internal call, thus the VM is not switched before executing it, but if any call happens inside it (or we access storage translated data) then yes, it will use zkVM

@Karrq Karrq merged commit 41760f0 into main Aug 22, 2024
11 checks passed
@Karrq Karrq deleted the tests/zkvm-cheatcodes branch August 22, 2024 09:18
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