dapphub / dapptools

Dapp, Seth, Hevm, and more

Home Page:https://dapp.tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

example how to use source maps

dadaphl opened this issue · comments

Hello,

i'm trying to use the interactive debugger in hevm. Contracts are compiled with truffle compile. Unfortunately I can not figure out how to set the source maps. I have tried like this

export ETH_RPC_URL=http://localhost:8545
export TXHASH=0x219cb5cca5708daa6c485c0688be6bbe6933cdea5fc802d3654c743452bbddf3
hevm exec --caller $(seth tx $TXHASH from) --address $(seth tx $TXHASH to) --calldata $(seth tx $TXHASH input) --rpc $ETH_RPC_URL --block $(($(seth tx $TXHASH blockNumber)-1)) --gas $(seth tx $TXHASH gas) --debug --json-file ./build/contracts/Contract.json 

I always get <no source map> in the debugger. I also can't seem to find it in the documentation.
I'd appreciate an example how to compile the contracts so I can debug a tx on chain with source code mapping.

Thank you

commented

hevm expects at least the following components in the solc output json:

  • metadata
  • evm.bytecode
  • evm.deployedBytecode
  • abi
  • storageLayout
  • evm.bytecode.sourceMap
  • evm.bytecode.linkReferences
  • evm.bytecode.generatedSources
  • evm.deployedBytecode.sourceMap
  • evm.deployedBytecode.linkReferences
  • evm.deployedBytecode.generatedSources
  • evm.deployedBytecode.immutableReference

I'm not familiar with truffle usage, but I suspect that the sourcemaps are not included in the output from truffle compile?

@d-xo can you add source maps when you download them from etherscan using bundle-source? It seems that I'm only able to use one file with compilation output atm, not multiple? Do you have a suggestion on how one can merge compilation output with the bundlesource to create a bigger sourcemap in this case?

commented

seth bundle-source should produce json files containing sourcemaps. Currently it only produces json output for one contract (this may have been produced from multiple source files if the multiple source option in etherscan was used). If you want to merge the output from multiple contracts I would suggest using jq to manually merge the json objects (e.g. https://stackoverflow.com/questions/19529688/how-to-merge-2-json-objects-from-2-files-using-jq).