Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example how to use source maps #888

Open
dadaphl opened this issue Dec 14, 2021 · 3 comments
Open

example how to use source maps #888

dadaphl opened this issue Dec 14, 2021 · 3 comments

Comments

@dadaphl
Copy link

dadaphl commented Dec 14, 2021

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

@d-xo
Copy link
Contributor

d-xo commented Jan 8, 2022

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?

@jekkos
Copy link

jekkos commented Jan 9, 2022

@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?

@d-xo
Copy link
Contributor

d-xo commented Jan 10, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants