Data: reject duplicate map keys on decode and make datum hashing byte faithful
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- data
Hướng nghiên cứu
Bắt đầu trong packages/evolution/src/Data.ts, tại logic giải mã map quanh L74/L88 và toDatumHash quanh L908-915. Đọc mẫu memoization WeakMap của CBORFormat trong Transaction.ts, sau đó thêm kiểm thử hồi quy cho việc giải mã các key trùng lặp và băm một datum không canonical đã được giải mã. Hoàn tất khi các key trùng lặp không bao giờ bị gộp một cách im lặng và hash của datum đã được giải mã sử dụng các byte ban đầu khi có sẵn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 22
- Fork
- 33
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 44
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của IntersectMBO/evolution-sdk
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
IntersectMBO/evolution-sdk#559 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
IntersectMBO/evolution-sdk#557 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dependencies good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 93/100
IntersectMBO/evolution-sdk#541 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
IntersectMBO/evolution-sdk#518 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement external-review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
IntersectMBO/evolution-sdk#456 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của IntersectMBO/evolution-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NousResearch/hermes-agent#136483 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Tool errors containing cycles or BigInt crash getErrorMessage and replace the original failureĐang mởfactory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
vercel/ai#22796 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Web chat input doesn't regain focus after a reply finishesCó thể đã có người làm @GaijinSystems đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
zeroclaw-labs/zeroclaw#11658 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
babylonlabs-io/babylon-toolkit#2711 ·
Maintainer thường phản hồi trong vòng 1 ngày