algorand / algorand/pyteal

Provide general-purpose wide arithmetic (128-bit) API

Đang mở
#246 3 bình luận 0 reaction 1 người được giao Được @PabloLION nhận Xem trên GitHub
new-feature-request Team Scytale
Ngôn ngữ chính
Python
Star
288
Fork
138
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## Problem

PyTeal's ergonomics for wide arithmetic opcodes (`addw`, `mulw`, `divw`, `divmodw`, `expw`) is limited. Limitation examples:
* No general-purpose way exists to confirm the result of wide arithmetic operations fits into 64 bits. While possible for PyTeal developers to implement, it'd be less error prone PyTeal provided a 1st class facility.
* Here's an example implementing the logic for a special purpose use case:
https://github.com/algorand/pyteal/blob/4594ceacb597ca6e5ae125ab81c1efc783c020c5/pyteal/ast/widemath.py#L127-L136
* No general-purpose abstraction exists for wide arithmetic operations. Consequently, PyTeal developers must hand roll abstractions (e.g. add two 128-bit ints). It feels like a common abstraction can be provided to minimize sources of error and promote application consistency.

## Solution

* Define wide arithmetic abstraction (e.g. `WideUint128`) with these APIs for 64-bit and 128-bit operations:
* \+
* \-
* \*
* /
* mod
* exp
* Consider interactions with existing abstractions (e.g. `WideRatio`).
* Update user guide docs.

Background context:
* https://github.com/algorand/pyteal/issues/101 first introduced specific abstractions like `WideRatio`.
* Subsequent iterations led to https://github.com/algorand/pyteal/pull/236. Since https://github.com/algorand/pyteal/pull/236 moves towards a general-purpose API, it motivated creating this _issue_ to reassess scope.

## Dependencies

N/A

## Urgency

TBD

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.