fix: canonicalize tx hash in GetPcUniversalTxKey#267
Merged
Conversation
Makes the Push-origin UTX id robust by contract (mirrors GetInboundUniversalTxKey, normalizes case/0x); no behavior change for real EVM receipt hashes. Adds Pc UTX key tests.
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.
What
GetPcUniversalTxKey(the Push-origin / outbound UTX id) now canonicalizes its tx hash viaLenientCanonicalizeTxHash, mirroringGetInboundUniversalTxKey. It also trimspcCaip.Why
pc.TxHashis always assigned fromreceipt.Hash(*evmtypes.MsgEthereumTxResponse), which go-ethereum emits as0x+lowercase — so today the key is already canonical. But that was true by convention, not by contract: the read path (GetUniversalTx) is an exact-key lookup with no normalization, so any future call site that ever populatedpc.TxHashfrom a non-lowercase / non-0xsource would silently produce a divergent UTX id (mismatching what an off-chain client like the SDK computes).This makes the Push-origin UTX id robust by contract, consistent with the inbound path which already canonicalizes. No behavior change for real inputs — lowercase EVM receipt hashes canonicalize to themselves, so existing ids are unchanged.
Tests (
x/uexecutor/types/keys_canonical_test.go)TestPcUniversalTxKey_CanonicalizesEvmTxHash— uppercase /0X/ no-0x/ whitespace-padded variants of the same hash all converge to one keyTestPcUniversalTxKey_DistinctInputsDiverge— different tx hash and differentpc_caipdiverge (scoping)TestPcUniversalTxKey_Recipe— pins thesha256(pcCaip : canonical(txHash))formulago test ./x/uexecutor/types/passes (full package, no regressions).