From 0714237d3b15d7dd6d5666516ff6258c7e90eb48 Mon Sep 17 00:00:00 2001 From: Domen Grabec Date: Tue, 19 Dec 2023 13:17:11 +0100 Subject: [PATCH] include return data in transaction trace even when the function signature is not available --- brownie/network/transaction.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index 2f9738f45..73ac8e6c8 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -920,6 +920,20 @@ def _expand_trace(self) -> None: last["address"], trace[i]["stack"][-2][-40:], trace[i]["stack"][-3] ) + # If the function signature is not available for decoding return data attach + # the encoded data. + # If the function signature is available this will be overridden by setting + # `return_value` a few lines below. + if trace[i]["depth"] and opcode == "RETURN": + subcall: dict = next( + i for i in self._subcalls[::-1] if i["to"] == last["address"] # type: ignore + ) + + if opcode == "RETURN": + returndata = _get_memory(trace[i], -1) + if returndata.hex() not in ("", "0x"): + subcall["returndata"] = returndata.hex() + try: pc = last["pc_map"][trace[i]["pc"]] except (KeyError, TypeError):