Data: reject duplicate map keys on decode and make datum hashing byte faithful
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- data
調査の方向性
packages/evolution/src/Data.ts の L74/L88 付近にある map のデコードロジックと、L908-915 付近にある toDatumHash から始めます。Transaction.ts にある CBORFormat の WeakMap メモ化パターンを読み、その後、重複キーのデコードと、デコードされた非 canonical datum のハッシュ計算に対するリグレッションカバレッジを追加します。重複キーが暗黙的に統合されることがなく、デコードされた datum のハッシュが元のバイト列が利用可能な場合にそれを使用すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Two issues with Plutus Data. (1) A Data map is modelled as a JS Map, which collapses duplicate primitive keys (last value wins). On chain a Data map is an association list that keeps every pair and resolves lookups first wins, so decoding a duplicate key map silently drops entries and can disagree with a validator. (2) toDatumHash re-encodes the decoded value and hashes that rather than hashing the bytes the datum came from, so a datum that arrived in a non canonical encoding produces a hash the node never computed.
Affected
packages/evolution/src/Data.ts map modelled as globalThis.Map (L74, L88)
packages/evolution/src/Data.ts toDatumHash (L908-915, re-encodes via toCBORBytes)
on chain semantics: IntersectMBO/plutus PlutusCore/Data.hs (Map [(Data,Data)], decodeMap keeps all pairs)
ledger hashes original memoized bytes: cardano-ledger Plutus/Data.hs
Fix
(1) Reject duplicate keys when decoding a Data map (fail closed) so silent data loss cannot happen; this keeps the ergonomic Map type. (2) Make datum hashing byte faithful for decoded datums by hashing the original source bytes, reusing the CBORFormat WeakMap memo pattern already used for Transaction (commit a0de4afa, Transaction.ts) so a decoded datum re-hashes to its original bytes. Bare integer top level datums cannot be WeakMap keyed and fall back to re-encode.
Regression test
- dup keys: Data.fromCBORHex("a200010002") currently decodes to a size 1 map dropping the first pair; after fix it is rejected (or preserved, per chosen approach), never silently collapsed
- datum hash: decode a datum that was created with a non canonical encoding, then toDatumHash must equal blake2b256 over the original bytes (the on chain hash), not over a re-encode
Must FAIL on main today and PASS after the fix.
Reference
Report 10
- 主要言語
- TypeScript
- スター
- 22
- フォーク
- 31
- 平均マージ
- 3日 19分
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
IntersectMBO/evolution-sdk のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
IntersectMBO/evolution-sdk#579 ·
メンテナーはふだん 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 日以内に返信
-
dependencies good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 93/100
IntersectMBO/evolution-sdk#541 ·
メンテナーはふだん 1 日以内に返信
-
bug external-review
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
IntersectMBO/evolution-sdk#530 ·
メンテナーはふだん 1 日以内に返信
IntersectMBO/evolution-sdk の issue をすべて見る
似ている issue
-
area/core status/need-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
google-gemini/gemini-cli#29602 ·
メンテナーはふだん 1 日以内に返信
-
area: backend enhancement priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
snapotter-hq/SnapOtter#1879 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Tencent/BrowserSkill#390 ·
メンテナーはふだん 1 日以内に返信
-
good first issue status: needs triaging type: bug version: 2.0
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
medusajs/medusa#17094 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信