Closed xavier-romero closed 3 days ago
The issue raises when storing the result, because it's different from what is returned by Executor though. Looking at current source code:
var (
baseLen = new(big.Int).SetBytes(getData(input, 0, 32)).Uint64()
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
modLen = new(big.Int).SetBytes(getData(input, 64, 32)).Uint64()
)
if len(input) > 96 {
input = input[96:]
} else {
input = input[:0]
}
If the input for modexp is missing the params 4, 5 and 6 (base, exp and mod) then the first 3 params (baseLen, expLen and modLen) are resused as if they also were base, exp and mod, generating a whole different result. I managed to successfully get through the test with the modifications in this PR: https://github.com/0xPolygonHermez/cdk-erigon/pull/1468 Since I'm a total GO n00b and my understanding of the whole thing is very limited, it could be a totally wrong approach, get it just as a PoC on how it's fixed.
Another change required.
Confirmed with @xavier-romero this issue is resolved.
Another Modex issue was found and is captured in issue #1484
This is the minimal contract that I've been able to create to show the issue.
The issue raises when storing the result, because it's different from what is returned by Executor though.