Skip to content

fix(cbor): match byte-string map keys when replaying a decoded map - #608

Merged
solidsnakedev merged 3 commits into
mainfrom
fix/data-map-bytes-key
Oct 7, 2026
Merged

solidsnakedev merged 3 commits into
mainfrom
fix/data-map-bytes-key

Conversation

@solidsnakedev

Copy link
Copy Markdown
Collaborator

A decoded transaction rewrote witness datums and redeemers that contain a Plutus data map with byte-string keys. Transaction.fromCBORHex then toCBORHex, and Transaction.addVKeyWitnessesHex, turned d8799fa141019f0102ffff into d8799fa14101820102ff, so the node rejected the witnessed transaction with a script data hash mismatch (3113). When the encoder replays a decoded map, it looks up each captured key in the map. The captured key decodes as a plain byte array, while the same key in a data map is a BoundedBytes node, so the lookup never matched. The encoder then treated the key as new and dropped the captured format of its value.

The replay now compares keys with every BoundedBytes node unwrapped to its bytes, at any depth, so list and constructor keys that contain byte strings match too. Each captured key takes the first matching entry that no earlier key took, so a repeated byte key keeps its own value. Fresh encodings do not go through this path, so their bytes stay the same.

Part of #576, see #576 (comment).

@solidsnakedev
solidsnakedev merged commit 04c4ec3 into main Oct 7, 2026
9 checks passed
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