Closed nrryuya closed 5 years ago
Fow now, the code can't be deployed due to the excess of the code size: eth.exceptions.OutOfGas: Contract code size exceeds EIP170 limit of 24577. Got code of size: 55782
The size of the Solidity implementation is 6713 with Remix IDE.
The size of the code of big integer arithmetic is around 30000...
For analysis.
Apparently, there are a tremendous number of mstore
and mload
in the LLL.
def _convertBytesArrayToUInt256List(_inp: bytes[256]) -> uint256[8]:
has a sequence of 231 of mload
.
[mload, 320],
[mload, 352],
[mload, 384],
[mload, 416],
[mload, 448],
[mload, 480],
[mload, 512],
[mload, 544],
[mload, 576],
[mload, 608],
[mload, 640],
[mload, 672],
# Continuing...
The code below in Line 225 is compiled to a complicated LLL
multiplicationResult = _primes[4 * i] * _primes[4 * i + 1] * _primes[4 * i + 2] * _primes[4 * i + 3]
@nrryuya Yes we really need to have some discussion about what we can do here to reduce bytecode size, I don't think pass by reference is a secure paradigm (as always happy to be convinced otherwise). However as suggested by @charles-cooper we can looking in supporting "final" or immutable structs.
References
This is based on The Matter Inc.'s implementation in Solidity. (gist)
Other references of big integer arithmetic