Skip to content

fix: canonicalize tx hash in GetPcUniversalTxKey#267

Merged
0xNilesh merged 1 commit into
audit-fixesfrom
fix/pc-utx-key-canonicalize-txhash
Jun 17, 2026
Merged

fix: canonicalize tx hash in GetPcUniversalTxKey#267
0xNilesh merged 1 commit into
audit-fixesfrom
fix/pc-utx-key-canonicalize-txhash

Conversation

@0xNilesh

Copy link
Copy Markdown
Member

What

GetPcUniversalTxKey (the Push-origin / outbound UTX id) now canonicalizes its tx hash via LenientCanonicalizeTxHash, mirroring GetInboundUniversalTxKey. It also trims pcCaip.

Why

pc.TxHash is always assigned from receipt.Hash (*evmtypes.MsgEthereumTxResponse), which go-ethereum emits as 0x+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 populated pc.TxHash from a non-lowercase / non-0x source 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 key
  • TestPcUniversalTxKey_DistinctInputsDiverge — different tx hash and different pc_caip diverge (scoping)
  • TestPcUniversalTxKey_Recipe — pins the sha256(pcCaip : canonical(txHash)) formula

go test ./x/uexecutor/types/ passes (full package, no regressions).

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.
@0xNilesh
0xNilesh merged commit 5c6bf13 into audit-fixes Jun 17, 2026
6 of 7 checks passed
@Aman035
Aman035 deleted the fix/pc-utx-key-canonicalize-txhash branch July 8, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant