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

Debug OOG txs sent to precompiles #3376

Merged
merged 2 commits into from Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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