You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
Calling MUL with large operands will cause the VM to perform large computations that could prevent it from making progress.
Expected behavior
MUL should have a relatively constant cost in computation to reflect its gas cost.
How to reproduce
Consider calling the following contract:
defMain():
a=10whileTrue:
a=a*a
24 iterations of this loop takes about 30 seconds for me to execute and costs ~0.5 gas.
This is an operation with relatively low gas cost but with a high computational cost.
It could possibly be used as a an inexpensive vehicle to cause VMs to be busy performing large computations.
A similar contract that only performs a busy loop consumes around 500 gas.
Current behavior
Calling
MUL
with large operands will cause the VM to perform large computations that could prevent it from making progress.Expected behavior
MUL
should have a relatively constant cost in computation to reflect its gas cost.How to reproduce
Consider calling the following contract:
24 iterations of this loop takes about 30 seconds for me to execute and costs ~0.5 gas.
This is an operation with relatively low gas cost but with a high computational cost.
It could possibly be used as a an inexpensive vehicle to cause VMs to be busy performing large computations.
A similar contract that only performs a busy loop consumes around 500 gas.
This works because integers are arbitrarily large bignums, that has a variable cost for multiplication that depends on their size. And the multiplication is currently performed regardless of operand sizes.
A solution could be to limit numeric types to 32 bytes, as neo does.
Your environment
Not applicable
The text was updated successfully, but these errors were encountered: