Fix: Missing discriminator for instructions without parameters#52
Open
t0mpl wants to merge 1 commit intogagliardetto:mainfrom
Open
Fix: Missing discriminator for instructions without parameters#52t0mpl wants to merge 1 commit intogagliardetto:mainfrom
t0mpl wants to merge 1 commit intogagliardetto:mainfrom
Conversation
6 tasks
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.
Problem:
Instructions with no parameters were being generated with nil instruction data instead of including their 8-byte discriminator. This caused InstructionFallbackNotFound errors when calling these instructions on-chain.
The generator was only creating the buffer and writing the discriminator when len(instruction.Args) > 0. Instructions like cancel_order, force_void, initialize_market_factory, etc. would fail because Anchor always expects the discriminator, even for parameter-less instructions.
Solution:
Refactored the instruction generation logic to always:
Create the buffer and encoder
Write the instruction discriminator
Encode parameters only when they exist
The buffer is now always passed to NewInstruction() instead of conditionally passing nil.
Changes:
Modified generator/instructions.go to move discriminator encoding outside the parameter check
All instructions now include their discriminator in the instruction data
Parameter encoding remains conditional