This repository has been archived by the owner on May 23, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds some tools and documentation (!`README.md) for comparing vm traces between geth and pyethapp/pyethereum.
- Loading branch information
1 parent
5ab7008
commit 8b1eca5
Showing
3 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
import json | ||
from deepdiff import DeepDiff | ||
from pprint import pprint | ||
from print_pylog import read_pythons | ||
# from __future__ import print_function | ||
|
||
|
||
def read_geth(fn): | ||
with open(fn) as f: | ||
slogs = json.load(f)['result']['structLogs'] | ||
return slogs | ||
|
||
|
||
if __name__ == '__main__': | ||
pyblocks = read_pythons() | ||
blocknum = int(sys.argv[1]) if len(sys.argv) > 1 else 1 | ||
|
||
goblock = read_geth("trace-{}.json".format(blocknum)) | ||
pprint(DeepDiff(goblock, pyblocks[blocknum])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
import json | ||
from collections import defaultdict | ||
|
||
|
||
def read_pythons(fn='pylog.jsons'): | ||
with open(fn) as f: | ||
lines = [json.loads(line) for line in f.readlines()] | ||
blocks = defaultdict(list) | ||
bnum = 0 | ||
for l in lines: | ||
if l['pc'] == 0: | ||
bnum += 1 | ||
# remove py slogging specifics: | ||
l.pop('event') | ||
l.pop('level') | ||
blocks[bnum].append(l) | ||
return blocks | ||
|
||
if __name__ == '__main__': | ||
pyblocks = read_pythons() | ||
blocknum = int(sys.argv[1]) if len(sys.argv) > 1 else 1 | ||
|
||
print json.dumps(pyblocks[blocknum], indent=2) |