Last active
September 25, 2019 16:20
-
-
Save jacqueswww/a0f36ec0b10757198afa1e6154891a94 to your computer and use it in GitHub Desktop.
Pretty Damn awful, PyEVM Virtual Machine debugger. Using a custom opdcode set in Vyper ;)
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
def debug_opcode(computation): | |
print('YOUR ARE HERE!') | |
import ipdb; ipdb.set_trace() | |
import evm | |
from evm.vm.opcode import as_opcode | |
from vyper.opcodes import opcodes as vyper_opcodes | |
from evm.vm.forks.byzantium.computation import ByzantiumComputation | |
opcodes = ByzantiumComputation.opcodes.copy() | |
opcodes[vyper_opcodes['DEBUG'][0]] = as_opcode( | |
logic_fn=debug_opcode, | |
mnemonic="DEBUG", | |
gas_cost=0 | |
) | |
setattr(evm.vm.forks.byzantium.computation.ByzantiumComputation, 'opcodes', opcodes) |
Checkout https://github.com/status-im/vyper-debug, has a vyper-run
command wich one can use to run a contract.
One just places vdb
in the contract to create a breakpoint.
This works only with Vyper? I use PyEVM to test Solidity contracts. Looks like your snipped is related only to PyEVM, and not Vyper. Maybe combination of your snippet with inline assembler with this instruction could work?
Yes this is for vyper, for solidity checkout https://github.com/iamdefinitelyahuman/brownie - has pretty good debugger that uses PyEVM underlying.
The above snippet uses a custom opcode that the vyper compiler injects into the bytecode - which was a quick hack, in favour of using the program counter.
Thanks for replies. I will check it out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use it in contracts?