Provide general-purpose wide arithmetic (128-bit) API
- Langage dominant
- Python
- Étoiles
- 288
- Forks
- 138
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
## 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
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.