execution/vm: report invalid EOF stack-op operands in ErrInvalidOpCode#20529
Open
Sahil-4555 wants to merge 2 commits intoerigontech:mainfrom
Open
execution/vm: report invalid EOF stack-op operands in ErrInvalidOpCode#20529Sahil-4555 wants to merge 2 commits intoerigontech:mainfrom
Sahil-4555 wants to merge 2 commits intoerigontech:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines EOF stack-manipulation invalid-operand reporting by ensuring ErrInvalidOpCode attributes failures to the parent instruction (DUPN/SWAPN/EXCHANGE) and captures the offending immediate byte, improving diagnosability and aligning tests with the new behavior.
Changes:
- Extend
ErrInvalidOpCodeto optionally store an operand byte and include it in the error string. - Update
DUPN/SWAPN/EXCHANGEimmediate-range rejection to returnErrInvalidOpCodewith the parent opcode plus the invalid operand. - Update EIP-8024 execution tests to assert both the opcode and the invalid operand for excluded immediate ranges.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
execution/vm/instructions.go |
Return ErrInvalidOpCode tagged with the parent opcode and invalid immediate for excluded operand ranges in DUPN/SWAPN/EXCHANGE. |
execution/vm/errors.go |
Add optional operand metadata to ErrInvalidOpCode and surface it in Error() output. |
execution/vm/instructions_test.go |
Enhance tests to validate ErrInvalidOpCode includes correct opcode and operand for invalid immediates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This PR improves invalid opcode reporting for the EOF stack-manipulation instructions. For
DUPN,SWAPN, andEXCHANGE, when the immediate byte falls into an excluded range,ErrInvalidOpCodenow preserves the parent opcode that triggered the failure and also records the offending operand byte. This makes the error more accurate and easier to diagnose, since the failure is now tied to the actual instruction family instead of the raw immediate value being interpreted as the opcode.The accompanying tests were updated to match that behavior. They now verify not only that invalid low- and high-range immediates return
ErrInvalidOpCode, but also that the error contains the correct opcode (DUPN, SWAPN, or EXCHANGE) and the exact invalid operand value.