as-bignum
as-bignum copied to clipboard
Implement 128-bit types necessary for NEAR blockchain runtime
Currently different types in the library are in various stages of implementation completeness.
NEAR uses 128-bit numbers internally, therefore we need following types fully implemented:
- [ ]
u128
- [ ]
i128
- [ ]
safe.u128
- [ ]
safe.i128
Acceptance criteria:
- [ ] All types listed above implement all operations currently supported by
u128
- [ ]
safe.
types also implement overflow check for all operations which can result in overflow - [ ] Code has 100% branch coverage in tests
@MaxGraey we plan to post bounty for this on http://gitcoin.co/
I'm just wondering what operations not implemented for u128
? safe.u128
also should be fully implement. Only required full test coverage.
I'm just wondering what operations not implemented for
u128
yeah, I think this one is fully implemented (or very close), that's why I'm suggesting to use it as reference for other types
safe.u128
also should be fully implement.
There seems to be some stuff which looks like missing: https://github.com/MaxGraey/as-bignum/blob/c2c70bce55af6085d9455ca08378f07f8b04a992/assembly/integer/safe/u128.ts#L151
Only required full test coverage.
Yeah, that's the main part.
There seems to be some stuff which looks like missing:
Ah, that's could be implemented really fast. Will check this tomorrow. Iām just not sure if anyone even uses safe.u128
u128
and safe.u128
should be fully implemented. But not 100% tests coverage yet
Hi! @vgrichina, @MaxGraey
Regarding functionality required by NEAR, I'm creating the AssemblyScript version of one of the core contracts: staking-pool.
In order to complete the task, I need to be able to multiply two u128 getting the result as u256, something like:
mul(u128,u128)->u256
.
Also I need to divide two u256, something like div(u256,u256)->u256
.
operator * and / seem to be missing from type u256
Also I'm good if you @MaxGraey can complete #46, I can use that too. The formula I need to apply is exactly that: u128 * u128 / u128 -> u128
@luciotato I started implementation for u128.muldiv
here #49
@MaxGraey can we make a bounty to get this done faster (together with division problem)?
Does 3000K NEAR sound good? How long would it take? Maybe you have different estimate as you have better context.
Blockchain is live already, token traded here https://coinmarketcap.com/currencies/near-protocol/.
This already should be fixed. Check 0.2.7
version