CBOR: Plutus data encodings change on re-encode, breaking the script data hash and the transaction id
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
- #635 來自 @Kshot3000 —— 已關閉,未合併
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 68/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
- 領域
- blockchain
研究方向
Start in packages/evolution/src/CBOR.ts, focusing on encodeArraySync, encodeMapSync, the BoundedBytes branch, and encodeUintSync; also review #575 before changing chunk handling. Add regression coverage for the six listed witness and inline datum encodings, the controls, and builder-made data, with byte-identical round-trips and unchanged body hashes as the completion criteria.
由索引模型根據 Issue 內容生成。
描述
Summary
Six encodings of Plutus data that the ledger accepts come back from Transaction.fromCBORHex then Transaction.toCBORHex in different bytes, with nothing changed:
| Received | Written back | Value |
|---|---|---|
d8799fff |
d87980 |
constructor 0, empty indefinite list |
bfff |
a0 |
empty indefinite map |
d8799800 |
d87980 |
empty list, 2-byte length header |
c24101 |
01 |
1 as a bignum |
5803cccccc |
43cccccc |
3 bytes, 2-byte length header |
5f4201024103ff |
43010203 |
bytes in chunks |
The ledger keeps the original bytes of every datum and redeemer and hashes those:
- plutus
Data.hsL215-230 and L245-283 decode all six forms: indefinite and definite lists and maps, bignums throughdecodeBoundedBigInteger, and chunked bytes throughdecodeBoundedBytesIndef. - cardano-ledger
Plutus/Data.hsL95:newtype Data era = MkData (MemoBytes (PlutusData era)). Alonzo/Tx.hsL318-321: the script integrity hash is taken overoriginalBytesof the redeemers and datums.
So a changed witness datum or redeemer fails with PPViewHashesDontMatch, and a changed inline datum changes the body and the transaction id.
Affected
packages/evolution/src/CBOR.ts
encodeArraySync(L1314) andencodeMapSync(L1371): the empty fast paths return80anda0before the captured format is read- the
BoundedBytesbranch (L962-968) callsencodeBoundedBytesSyncwith no format, so header width and chunking are dropped encodeUintSync(L983-995) emits tag 2 only above 2^64-1 and honours only auintformat, so a captured tag 2 or 3 node is ignored
Fix
Give each of these paths the captured format, and use it only when it still fits the value:
- read the format before the empty fast paths
- pass the format to the bounded bytes encoder: keep the header width, and keep the chunk layout only when the chunk sizes add up to the value's length and none is over 64 bytes
- when the captured node is tag 2 or 3, write the value as that bignum
Land this with or after #575 (stale chunk sizes). Passing the format into the bounded bytes encoder without that guard would carry the stale-chunk corruption into datums.
Regression test
Oracle is the node; CML agrees on every case below.
- given: each encoding above as a witness datum (
a1 04 d90102 81 [datum]) and as an inline datum ([1, #6.24(bytes)]) - before fix: the bytes change in both places; for the inline datum the body hash changes
- after fix: byte-identical in both places
- control:
d8799f01ffand a correctly chunked 65-byte value already round-trip and must stay unchanged; a builder-made datum is unchanged
Devnet, raw submission through Ogmios:
- all six as inline datums: original accepted; after
addVKeyWitnessesHex, rejected with 3100 invalid signatures d8799fffas a witness datum, with a datum-hash output and the script data hash in the body: original accepted; afteraddVKeyWitnessesHex, rejected with 3113 script integrity hash mismatch
Must FAIL on main today and PASS after the fix.
Reference
#235 (fixed in #236) covered non-empty indefinite lists in redeemers; these are the cases it did not reach. Related: #530 (bignum chunking above 64 bytes), #395 (Data map default), #397 (duplicate keys in Data maps).
- 主要語言
- TypeScript
- 星號
- 22
- 分支
- 34
- 平均合併
- 16 小時 53 分鐘
- 30 天內合併 PR
- 10
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
IntersectMBO/evolution-sdk 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
IntersectMBO/evolution-sdk#696 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 79/100
IntersectMBO/evolution-sdk#694 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
IntersectMBO/evolution-sdk#559 ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
IntersectMBO/evolution-sdk#557 ·
維護者通常 1 天內回覆
-
RewardAccount: validate header type bits and bech32 prefix可能重新可做 關聯的 PR 已關閉且未合併。 未關閉enhancement external-review
難度 2/5 1-3 小時 新手友好度 84/100
IntersectMBO/evolution-sdk#456 · 1 則留言 ·
維護者通常 1 天內回覆
查看 IntersectMBO/evolution-sdk 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
triage: failed
難度 2/5 1-3 小時 新手友好度 68/100
oxc-project/tsrs#1277 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
ardia-browser/ardia#6798 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
enhancement from-app needs-triage
難度 2/5 1-3 小時 新手友好度 68/100
nightly-labs/openbot#23943 ·
維護者通常 1 天內回覆