forked from ethereum/evmlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecadd.py
39 lines (32 loc) · 830 Bytes
/
ecadd.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
"""
"""
#!/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 ecadd
"""
p = c.Program()
p.call(0x7bc9,0x06,0)
p.op(c.GAS)
return p.bytecode()
def main():
g = genesis.Genesis()
g.setConfigMetropolis()
(geth_g, parity_g) = g.export()
geth = vm.GethVM("/home/martin/go/src/github.com/ethereum/go-ethereum/build/bin/evm")
outp = geth.execute(code = generateCall(), genesis = geth_g, json=True)
prev = 0
for l in outp:
obj = json.loads(l)
if 'gas' in obj.keys():
g = int(obj['gas'],16)
print(l)
print("Gas: %d (delta: %d)" % (g, (g-prev)))
prev = g
if __name__ == '__main__':
main()