Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
BlinkyStitt committed Sep 10, 2021
1 parent 27fa5c7 commit 856c0da
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions brownie/network/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,28 +658,27 @@ def _get_trace(self) -> None:
self._modified_state = False
return

# different nodes return their values in slightly different formats. its really fun to handle

# check to see if need to fix the values on the stack
# different nodes return slightly different formats. its really fun to handle
# geth/nethermind returns unprefixed and with 0-padding for stack and memory
# erigon returns 0x-prefixed and without padding (but their memory values are like geth)
fix_stack = False
for step in trace:
if not step["stack"]:
continue
check = step["stack"][0]
if not (len(check) == 64 and check.isnumeric()):
if not isinstance(check, str):
break
if check.startswith("0x"):
fix_stack = True
break

fix_gas = isinstance(trace[0]["gas"], str)

if fix_stack or fix_gas:
for step in trace:
# for stack values, we need 32 bytes (64 characters) without the 0x prefix
# geth/nethermind returns unprefixed and with padding
# erigon returns 0x-prefixed and without padding (but their memory values are like geth)
if fix_stack:
# for stack values, we need 32 bytes (64 chars) without the 0x prefix
step["stack"] = [HexBytes(s).hex()[2:].zfill(64) for s in step["stack"]]

if fix_gas:
# handle traces where numeric values are returned as hex (Nethermind)
step["gas"] = int(step["gas"], 16)
Expand Down

0 comments on commit 856c0da

Please sign in to comment.