forked from ethereum/evmlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbigmodexp.py
48 lines (37 loc) · 1.13 KB
/
bigmodexp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
"""
#!/usr/bin/env python
import json
import tempfile, os
from evmlab import compiler as c
from evmlab import vm
from evmlab import genesis
def generateCall():
"""
Makes a call to modexp
"""
p = c.Program()
p.mstore(0x3,0xff2a1e53 )
p.delegatecall(0x11ecd01b,0x5,0x0,0x60)
p.op(c.STOP)
return p.bytecode()
def main():
g = genesis.Genesis()
g.setConfigMetropolis()
(geth_g, parity_g) = g.export()
print(parity_g)
geth = vm.GethVM("/home/martin/go/src/github.com/ethereum/go-ethereum/build/bin/evm")
par = vm.ParityVM(executable="holiman/std-parityvm", docker=True)
print("Bytecode: ")
print(generateCall())
g_out = geth.execute(code = generateCall(), genesis = geth_g, json=True, gas=0xFFFF, memory=True)
p_out = par.execute(code = generateCall(), genesis = parity_g, json=True, gas=0xFFFF, memory=True)
l = len(g_out)
if len(p_out) < l:
l = len(p_out)
for i in range(0,l):
print(g_out[i])
print("g:" + vm.toText(json.loads(g_out[i])))
print("p:" + vm.toText(json.loads(p_out[i])))
if __name__ == '__main__':
main()