print_symbolic_trace
Documentation for eth_defi.trace.print_symbolic_trace function.
- print_symbolic_trace(contract_registry, calltree)[source]
Print a symbolic trace of an Ethereum transaction.
Contracts by name
Functions by name
Notes about tracing:
Currently only works with Anvil backend and if steps_trace=True
Transaction must have its gas parameter set, otherwise transaction is never broadcasted because it fails in estimate gas phase
Example output:
E AssertionError: Transaction failed: AttributeDict({'hash': HexBytes('0xaa70b2f76ad9f32f7c722390535d5a806b4d815f3d8d460e5d18cdba3b1c8c2d'), 'nonce': 2, 'blockHash': HexBytes('0x1d2a1d36185bebb373639e1eb4ddbe9f7f3347fa6dd7bcbbe5e5905fe6a1f4ed'), 'blockNumber': 3, 'transactionIndex': 0, 'from': '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'to': '0x5FbDB2315678afecb367f032d93F642f64180aa3', 'value': 0, 'gasPrice': 768647811, 'gas': 500000, 'input': '0x25ad8c83000000000000000000000000e7f1725e7734ce288f8367e1bb143e90bb3f0512', 'v': 1, 'r': HexBytes('0x43336f08be93aec7ecf456c724d3c29c6cebc589ab3fe6199ee783a627bbcda8'), 's': HexBytes('0x74002a6cdd84b81932e36ac0725591460b09eaaa6b0dd615c0c5d43171467c8a'), 'type': 2, 'accessList': [], 'maxPriorityFeePerGas': 0, 'maxFeePerGas': 1768647811, 'chainId': 31337}) E Revert reason: execution reverted: Big bada boom E Solidity stack trace: E CALL: RevertTest.revert2(second=0xe7f1725e7734ce288f8367e1bb143e90bb3f0512) [3284 gas] E └── CALL: RevertTest2.boom() [230 gas]
See also
eth_defi.anvil.launch_anvil()
.
Usage example:
reverter = deploy_contract(web3, "RevertTest.json", deployer) tx_hash = reverter.functions.revert1().transact({"from": deployer, "gas": 500_000}) receipt = web3.eth.wait_for_transaction_receipt(tx_hash) assert receipt["status"] == 0 # Tx failed # Get the debug trace from the node and transform it to a list of call items trace_data = trace_evm_transaction(web3, tx_hash) # Transform the list of call items to a human-readable output, # use ABI data from deployed contracts to enrich the output trace_output = print_symbolic_trace(get_or_create_contract_registry(web3), trace_data) assert trace_output == 'CALL: [reverted] RevertTest.<revert1> [500000 gas]'
- Parameters
contract_registry (Dict[str, web3.contract.contract.Contract]) –
The registered contracts for which we have symbolic information available.
See
eth_defi.deploy.deploy_contract()
for registering. All contracts deployed using this function should be registered by default.calltree (evm_trace.base.CallTreeNode) –
Call tree output.
From
trace_evm_transaction()
.
- Returns
Unicode print output