algorand / algorand/pyteal

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

Offen
#246 3 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @PabloLION Auf GitHub ansehen
new-feature-request Team Scytale
Vorherrschende Sprache
Python
Sterne
288
Forks
138
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.