CBOR: repeated map keys are silently collapsed, where the ledger either rejects them or keeps every pair
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- data
調査の方向性
Start in packages/evolution/src/CBOR.ts at decodeMapAt and the captured-format map encoder; trace the transaction body, metadata-label, and metadatum paths. Run the regression cases through Transaction.fromCBORHex and compare re-encoded bytes, including controls and the multi-assets, withdrawals, and mint cases. Done means ledger-record and Map duplicates fail with a key-naming error while metadatum pairs round-trip byte-identically.
索引モデルが issue の本文から書いたものです。
説明
Summary
The CBOR map decoder stores entries in a JS Map, so a repeated key keeps only its last value, and no error is raised. On re-encode the captured key order replays every key, so the output repeats the last value:
body a4 ... 02 00 02 0a → a4 ... 02 0a 02 0a (fee 0 lost)
label a2 00 01 00 02 → a2 00 02 00 02 ({0: 1} lost)
datum a2 01 01 01 02 → a2 01 02 01 02 ({1: 1} lost)
The ledger treats repeated keys in two different ways, so a single rule at the CBOR layer cannot be right:
| Where | Ledger | SDK today | Should |
|---|---|---|---|
| transaction body, witness set | reject: SparseKeyed decoders fail on a repeated field (Coders.hs L565-569, duplicateKey L634-640; Conway/TxBody.hs L183, Alonzo/TxWits.hs L609) |
accepts, rewrites | reject on decode |
metadata labels and other Map fields |
reject from protocol version 9: decodeMap uses decodeMapLikeEnforceNoDuplicates (Decoder.hs L748-753, L785-789) |
accepts, rewrites | reject on decode |
| metadatum map values | keep every pair: Metadatum Map is a list of pairs (Metadata.hs L161-172) |
drops the earlier pair | keep every pair |
| Plutus data maps | keep every pair: Map [(Data, Data)] (plutus Data.hs L44, L277-283) |
drops the earlier pair | tracked in #397 |
Affected
packages/evolution/src/CBOR.ts
decodeMapAt(L1973-2035):map.set(k, v)overwrites a repeated key; the capturedkeyOrderstill records both- map encode with a captured format (L1496-1525) replays every
keyOrderentry, each with the surviving value
Every schema built on this decoder inherits the behavior. Tested here: the transaction body, metadata labels and metadatum values. Multi-assets, withdrawals and mint go through the same ledger decodeMap, but were not tested, so the fix should add one case for each.
Fix
Decide per schema, following the ledger:
- ledger records and
Mapfields: reject a repeated key when decoding, with an error that names the key - metadatum map values: keep every pair in order, so decode then encode returns the same pairs
The Plutus data side is #397, and it needs the same answer as metadatum values. The devnet accepted {1: 1, 1: 2} as an inline datum and rejected the SDK's rewrite with 3100, so rejecting on decode would refuse valid on-chain datums.
Regression test
Oracle is the node.
- body
a4 00 [inputs] 01 [outputs] 02 00 02 0a: before fix, decodes and re-encodes as02 0a 02 0a; after fix,Transaction.fromCBORHexfails with a duplicate key error - metadata
a2 00 01 00 02(label 0 twice): same, rejected after fix - metadatum
a1 00 a2 01 01 01 02: before fix, written back asa1 00 a2 01 02 01 02; after fix, byte-identical - control: maps without repeated keys are unchanged
Devnet, raw submission through Ogmios:
- body with the fee key twice: node rejects as malformed; the SDK decodes it
- metadata with label 0 twice: node rejects as malformed; the SDK decodes it
- metadatum
{1: 1, 1: 2}under label 0: original accepted; afteraddVKeyWitnessesHex, rejected with 3107 metadata hash mismatch
Must FAIL on main today and PASS after the fix.
Reference
#397 covers the Plutus data side. #531 asks for rejecting repeated keys on decode before the signing fix hashes original bytes.
- 主要言語
- TypeScript
- スター
- 22
- フォーク
- 35
- 平均マージ
- 19時間 56分
- マージ済み PR(30日)
- 58
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
IntersectMBO/evolution-sdk のほかの issue
-
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 日以内に返信
-
dependabot: remove stale @types/bip39 entries対応中かも @Kshot3000 が 5 日前に担当しました。 オープンdependencies good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 93/100
IntersectMBO/evolution-sdk#541 ·
メンテナーはふだん 1 日以内に返信
-
txBuilder: committee cert redeemers are never resolved to a certificate index対応中かも @Kshot3000 が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
IntersectMBO/evolution-sdk#518 ·
メンテナーはふだん 1 日以内に返信
IntersectMBO/evolution-sdk の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
mobile-next/mobile-mcp#526 ·
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 1/5 1時間未満 初心者へのやさしさ 73/100
redhat-developer/rhdh-plugin-export-overlays#4470 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
anthropics/anthropic-sdk-typescript#1273 ·
メンテナーはふだん 10 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
CopilotKit/OpenBot#815 ·
メンテナーはふだん 1 日以内に返信