Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

Value type should be math-safe #89

Open
sinitcin opened this issue Nov 5, 2021 · 3 comments
Open

Value type should be math-safe #89

sinitcin opened this issue Nov 5, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@sinitcin
Copy link
Contributor

sinitcin commented Nov 5, 2021

The current type Value represents just wrapper around u128. We should make a type that handles overflows and underflows properly to avoid situations when we accidentally might create a vulnerability.

@altonen
Copy link
Contributor

altonen commented Nov 5, 2021

I believe there was some discussions on this topic already somewhere? I think it's worth linking here if someone remembers where that discussion took place.

@sinitcin
Copy link
Contributor Author

sinitcin commented Nov 5, 2021

I believe there was some discussions on this topic already somewhere? I think it's worth linking here if someone remembers where that discussion took place.

@iljakuklic as far as I remember you have prepared something that was related to this issue?

@iljakuklic
Copy link
Contributor

I believe there was some discussions on this topic already somewhere? I think it's worth linking here if someone remembers where that discussion took place.

@iljakuklic as far as I remember you have prepared something that was related to this issue?

I posted a very rough design sketch here #67 (comment). I also stumbled upon a trait in Substrate [1] that uses Rust's affine types to make sure you do not accidentally inflate token supply. Arithmetic operations "consume" the values so you can't use them multiple times. Not sure how exactly it is used, just noticed that the other day.

[1] https://paritytech.github.io/substrate/monthly-2021-09+1/frame_support/traits/tokens/imbalance/trait.Imbalance.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants