test: reproduce secp256r1 fee payer is_signer mismatch (swig-ts#107)#139
Open
tracy-codes wants to merge 1 commit intomainfrom
Open
test: reproduce secp256r1 fee payer is_signer mismatch (swig-ts#107)#139tracy-codes wants to merge 1 commit intomainfrom
tracy-codes wants to merge 1 commit intomainfrom
Conversation
…ig-ts#107) Add tests that reproduce the issue where secp256r1 SignV2 transactions fail with PermissionDeniedSecp256r1InvalidMessageHash (0xbd2) when a transfer destination is the fee payer. Root cause: the Solana runtime marks the fee payer as is_signer=true on all AccountInfos, but the client SDK computes the message hash with is_signer=false when the payer appears only as a transfer destination. This causes the keccak hash to mismatch between client and program. Tests added: - test_secp256r1_multi_transfer_with_fee_payer_destination_v2: reproduces #107 - test_secp256r1_multi_transfer_to_different_recipients_v2: control (passes) - test_secp256r1_multi_transfer_fee_payer_dest_with_signer_fix_v2: confirms fix - test_secp256r1_separate_sign_v2_with_fee_payer_destination_v2: separate ixs
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.
Summary
is_signerflag mismatch between client and on-chain message hash computation when the fee payer is also a transfer destinationis_signer=truebefore hash computation)Root Cause
When the fee payer appears as a destination in a
system_instruction::transfer, the client-sidecompact_instructionsadds it withis_signer=false. However, the Solana runtime always marks the fee payer asis_signer=trueon allAccountInfos. Thecompute_message_hashinsecp256r1.rshashes theAccountsPayload(which includesis_signer), so the hashes diverge, resulting inPermissionDeniedSecp256r1InvalidMessageHash(0xbd2).Tests Added
test_secp256r1_multi_transfer_with_fee_payer_destination_v2test_secp256r1_multi_transfer_to_different_recipients_v2test_secp256r1_multi_transfer_fee_payer_dest_with_signer_fix_v2test_secp256r1_separate_sign_v2_with_fee_payer_destination_v2Fix Required (in swig-ts)
The TS SDK must ensure that the fee payer is marked as
isSigner=truein the accounts list before computing the message hash for secp256r1 (and secp256k1) signing.