Skip to content

Commit

Permalink
Merge pull request #3376 from NomicFoundation/debug-tt-oog-precompile
Browse files Browse the repository at this point in the history
Debug OOG txs sent to precompiles
  • Loading branch information
fvictorio committed Nov 24, 2022
2 parents 55b2d07 + 13433f1 commit 663628a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/big-pumas-fail.md
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Fixed an edge case where Hardhat would hang if `debug_traceTransaction` was used with an OOG transaction sent to a precompile.
Expand Up @@ -222,7 +222,10 @@ export class VMDebugTracer {
);

// geth does this for some reason
if (result.execResult.exceptionError?.error === "out of gas") {
if (
rpcStructLogs.length > 0 &&
result.execResult.exceptionError?.error === "out of gas"
) {
rpcStructLogs[rpcStructLogs.length - 1].error = {};
}

Expand Down
Expand Up @@ -127,6 +127,31 @@ describe("Debug module", function () {
assertEqualTraces(trace, modifiesStateTrace);
});

it("should trace an OOG transaction sent to a precompile", async function () {
await sendDummyTransaction(this.provider, 0, {
from: DEFAULT_ACCOUNTS_ADDRESSES[1],
to: "0x0000000000000000000000000000000000000001",
}).catch(() => {});

const block = await this.provider.send("eth_getBlockByNumber", [
"latest",
false,
]);

const txHash = block.transactions[0];

const trace: RpcDebugTraceOutput = await this.provider.send(
"debug_traceTransaction",
[txHash]
);
assert.deepEqual(trace, {
gas: 21_000,
failed: true,
returnValue: "",
structLogs: [],
});
});

describe("berlin", function () {
useProvider({ hardfork: "berlin" });

Expand Down

0 comments on commit 663628a

Please sign in to comment.