diff --git a/docs/userguides/testing.md b/docs/userguides/testing.md index 0b03743048..2d6a67ee69 100644 --- a/docs/userguides/testing.md +++ b/docs/userguides/testing.md @@ -558,12 +558,6 @@ At the end of test suite, you will see tables such as: changeOnStatus 2 23827 45739 34783 34783 getSecret 1 24564 24564 24564 24564 - Transferring ETH Gas - - Method Times called Min. Max. Mean Median - ─────────────────────────────────────────────────────── - to:test0 2 2400 9100 5750 5750 - TestContract Gas Method Times called Min. Max. Mean Median diff --git a/docs/userguides/trace.md b/docs/userguides/trace.md index 57e873da22..dd8461243c 100644 --- a/docs/userguides/trace.md +++ b/docs/userguides/trace.md @@ -53,6 +53,24 @@ DSProxy.execute(_target=LoanShifterTaker, _data=0x35..0000) -> "" [1421947 gas] ) [6057 gas] ``` +Similarly, you can use the provider directly to get a trace. +This is useful if you want to interact with the trace or change some parameters for creating the trace. + +```python +from ape import chain + +# Change the `debug_traceTransaction` parameter dictionary +trace = chain.provider.get_transaction_trace( + "0x...", debug_trace_transaction_parameters={"enableMemory": False} +) + +# You can still print the pretty call-trace (as we did in the example above) +print(trace) + +# Interact with low-level logs for deeper analysis. +struct_logs = trace.get_raw_frames() +``` + ## Tracing Calls Some network providers trace calls in addition to transactions. diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 19dac65e26..adad54e7fc 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -856,7 +856,7 @@ def _enrich_calltree(self, call: Dict, **kwargs) -> Dict: depth = call.get("depth", 0) if depth == 0 and address in self.account_manager: - call["contract_id"] = "Transferring ETH" + call["contract_id"] = f"__{self.fee_token_symbol}_transfer__" else: call["contract_id"] = self._enrich_contract_id(call["contract_id"], **kwargs) diff --git a/src/ape_ethereum/trace.py b/src/ape_ethereum/trace.py index f9a8c9917d..1eb824c1ff 100644 --- a/src/ape_ethereum/trace.py +++ b/src/ape_ethereum/trace.py @@ -179,15 +179,13 @@ def get_gas_report(self, exclude: Optional[Sequence[ContractFunctionPath]] = Non tx = self.transaction # Enrich transfers. - if ( - call.get("contract_id", "").startswith("Transferring ") - and tx.get("to") is not None - and tx["to"] in self.account_manager - ): + contract_id = call.get("contract_id", "") + is_transfer = contract_id.startswith("__") and contract_id.endswith("transfer__") + if is_transfer and tx.get("to") is not None and tx["to"] in self.account_manager: receiver_id = self.account_manager[tx["to"]].alias or tx["to"] call["method_id"] = f"to:{receiver_id}" - elif call.get("contract_id", "").startswith("Transferring ") and (receiver := tx.get("to")): + elif is_transfer and (receiver := tx.get("to")): call["method_id"] = f"to:{receiver}" exclusions = exclude or [] diff --git a/tests/functional/test_trace.py b/tests/functional/test_trace.py index 515d69508d..d6f95c3719 100644 --- a/tests/functional/test_trace.py +++ b/tests/functional/test_trace.py @@ -45,7 +45,7 @@ def test_get_gas_report_transfer(gas_tracker, sender, receiver): tx = sender.transfer(receiver, 0) trace = tx.trace actual = trace.get_gas_report() - expected = {"Transferring ETH": {"to:TEST::2": [tx.gas_used]}} + expected = {"__ETH_transfer__": {"to:TEST::2": [tx.gas_used]}} assert actual == expected