fix: clear dst1 to zero#110
Open
0xVolosnikov wants to merge 1 commit into
Open
Conversation
23c56ae to
8032292
Compare
Before executing each opcode, zk_evm clears the decoded dst1 register and, after execution, leaves it at zero unless the instruction produced a second output (see zksync-protocol#222). vm2 previously left dst1 untouched, so an instruction with a "dirty" non-r0 dst1 field, or one that panics before writing dst1 (UMA read with increment), could leave dst1 in a different state than zk_evm. A panic caught by a near-call frame does not reset registers, so the divergence is observable. Mirror zk_evm's behavior: - Store the dst1 register for every opcode during decoding (it already fits in the destination register slot of Arguments). - Track whether the second output was written (Mul/Div and UMA reads with increment) via a transient State flag. - In full_boilerplate, after the business logic runs, clear dst1 to zero unless it was written. The clear happens after the primary output so that a dst0/dst1 alias resolves to zero, and after pre-execution panics have already returned, matching zk_evm's opcode masking. Bump the zk_evm pin to a commit that includes the matching reference fix, and add regression tests for the alias and UMA-increment-panic cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8032292 to
54bb064
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Mirrors zk_evm's mechanism
zk_evm pin
Bumped zk_evm/zkevm_opcode_defs/zk_evm_abstractions to ac58f328 (v0.153.12)