Unexpected Behaviour Hex-Encoding Negative `BigInt`s
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rust
- Lĩnh vực
- api, blockchain
Hướng nghiên cứu
Bắt đầu bằng việc đọc triển khai của typeConversions.bigIntToHex trong HostExports và hành vi của num::BigInt::to_bytes_be. So sánh tài liệu tham chiếu về mã hóa go-ethereum với ba hành vi được đề xuất đối với các giá trị âm, sau đó xác định chính sách nào có thể chấp nhận được mà không làm hỏng khả năng tương thích của các hàm host. Hoàn tất khi hành vi và các ảnh hưởng đến khả năng tương thích đã được quyết định và được bao quát bởi các bài kiểm thử hoặc tài liệu liên quan.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I would like to report some behaviour that seems unexpected to me.
What is the current behavior?
Encoding a negative BigInt value will return the hex of its absolute value. So -42 will be encoded as 0x2a.
What is the expected behavior?
Looking into the code, it looks like num::BigInt::to_bytes_be returns the big-endian bytes for its absolute value. This causes typeConversions.bigIntToHex to encode absolute values of its BigInt parameter.
This is a bit unexpected to me, and I would have expected either:
- To sign prefix the hex value (so
42becomes0x2aand-42becomes-0x2a). This is more inline with hownum::BigIntwould hex-format values. - To hex encode the value in 2's compliment notation. (so
42becomes0x2aand-42becomes0xd6). In looking at the code, this encoding implementation requires no leading 0s in the hex representation. This would mean that with 2's compliment, there would be multiple numbers with the same hex representation (for example255would be0xffand-1would also be0xff). - Disallow hex-encoding negative big integers. From the documentation for the
typeConversions.bigIntToHeximplementation in theHostExports, it mentionsgo-ethereumencoding rules as the reference. By those rules, hex marshalling for negative numbers is explicitly prohibited, so following that here would also make sense:Negative integers are not supported at this time. Attempting to marshal them will return an error. Values larger than 256bits are rejected by Unmarshal but will be marshaled without error.
Unfortunately, all of these suggestions would be breaking changes (which I imagine should be avoided for subgraph host function implementations).
- Ngôn ngữ chính
- Rust
- Star
- 3.2k
- Fork
- 1.1k
- Merge trung bình
- 4 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
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 graphprotocol/graph-node
-
current: include emits an all-null bucket for dimensionless aggregations, nulling the whole response Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
graphprotocol/graph-node#6719 ·
-
RUSTSEC-2026-0194: Quadratic run time when checking a start tag for duplicate attribute names Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
graphprotocol/graph-node#6673 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
graphprotocol/graph-node#6650 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
graphprotocol/graph-node#6722 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
graphprotocol/graph-node#6721 ·
Tất cả issue của graphprotocol/graph-node
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100