fix: set signatureChainId in recover_user_from_user_signed_action - #312
Open
massimiliano1991 wants to merge 1 commit into
Open
Conversation
sign_user_signed_action sets both signatureChainId and hyperliquidChain on the action, but recover_user_from_user_signed_action only set hyperliquidChain. Since user_signed_payload reads action["signatureChainId"], recovering the signer from a freshly reconstructed action raised KeyError: 'signatureChainId'. Set signatureChainId symmetrically with sign_user_signed_action, and add a sign -> recover round-trip regression test (the function had no coverage).
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
recover_user_from_user_signed_actionis the inverse ofsign_user_signed_action, but the two are asymmetric:sign_user_signed_actionsets bothsignatureChainIdandhyperliquidChainon the action before building the EIP-712 payload.recover_user_from_user_signed_actionsets onlyhyperliquidChain.Because
user_signed_payloadreadsaction["signatureChainId"], recovering the signer from a freshly reconstructed action — the normal case for a verifier that never calledsign_user_signed_actionon that dict — raisesKeyError: 'signatureChainId'.Reproduction
Fix
Set
signatureChainIdinrecover_user_from_user_signed_actionsymmetrically withsign_user_signed_action. Added a sign → recover round-trip regression test (mainnet + testnet) that asserts the recovered address equals the signer — the function previously had no test coverage, which is why this slipped through.pytest tests/signing_test.pypasses (14 tests).Note on #267
This is orthogonal to #267 (which makes
signatureChainIdconfigurable insign_user_signed_action). The fix here matches currentmaster, wheresign_user_signed_actionhardcodes0x66eee. If #267 lands, the recover side should stay in sync — ideally both sign and recover would share a single helper for the default so they can't drift apart again.