AVM icon indicating copy to clipboard operation
AVM copied to clipboard

BigInteger check should throw not assert

Open fulldecent opened this issue 6 years ago • 2 comments

https://github.com/aionnetwork/AVM/blob/master/org.aion.avm.userlib/src/org/aion/avm/userlib/AionBuffer.java#L388

Because BigIntegers are possible to get to this point which are large.

It also says

// BigInteger instances can't be larger than 32-bytes, in AVM.

If this is true I'm wrong, please reference proof for that statement

fulldecent avatar Aug 09 '19 22:08 fulldecent

This is a restriction imposed by AVM, specifically: https://github.com/aionnetwork/AVM/blob/764e6195d6131d539eb46333d830d3a1f81edd2f/org.aion.avm.rt/src/s/java/math/BigInteger.java#L392

In standard Java, these are unbounded, but the limit is imposed by the AVM to constrain the effort expended for constant cost.

jeff-aion avatar Aug 16 '19 21:08 jeff-aion

Ah, so the Aion BigInteger implementation shadows java.math.BigInteger.

What is the primary documentation I should cite for that?

Can I get a BigInteger.MAX_VALUE and BigInteger.MIN_VALUE?

Is BigInteger.MAX_VALUE.add(BigInteger.ONE) undefined? Is that documented?

Right now AIP-040 was expecting BigInteger.MAX_VALUE == 2^256 but that is not the case.

This is where I checked for documentation

Screen Shot 2019-08-16 at 21 13 38

fulldecent avatar Aug 16 '19 21:08 fulldecent