hardhat 2.22.11 → 2.22.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internal/hardhat-network/provider/provider.d.ts +2 -3
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +5 -19
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/return-data.d.ts +2 -15
- package/internal/hardhat-network/provider/return-data.d.ts.map +1 -1
- package/internal/hardhat-network/provider/return-data.js +2 -50
- package/internal/hardhat-network/provider/return-data.js.map +1 -1
- package/internal/hardhat-network/provider/vm/exit.d.ts +2 -20
- package/internal/hardhat-network/provider/vm/exit.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/exit.js +3 -78
- package/internal/hardhat-network/provider/vm/exit.js.map +1 -1
- package/internal/hardhat-network/stack-traces/compiler-to-model.d.ts +2 -3
- package/internal/hardhat-network/stack-traces/compiler-to-model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/compiler-to-model.js +2 -351
- package/internal/hardhat-network/stack-traces/compiler-to-model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.d.ts +2 -7
- package/internal/hardhat-network/stack-traces/debug.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +3 -143
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/library-utils.d.ts +2 -11
- package/internal/hardhat-network/stack-traces/library-utils.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/library-utils.js +3 -61
- package/internal/hardhat-network/stack-traces/library-utils.js.map +1 -1
- package/internal/hardhat-network/stack-traces/logger.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/logger.js +0 -221
- package/internal/hardhat-network/stack-traces/logger.js.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts +2 -51
- package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.js +0 -46
- package/internal/hardhat-network/stack-traces/message-trace.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +58 -53
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +4 -155
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.js +12 -37
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts +2 -13
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +2 -162
- package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.d.ts +4 -15
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.js +6 -70
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts +2 -19
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.js +3 -150
- package/internal/hardhat-network/stack-traces/vm-tracer.js.map +1 -1
- package/package.json +2 -2
- package/src/internal/hardhat-network/provider/provider.ts +11 -24
- package/src/internal/hardhat-network/provider/return-data.ts +5 -73
- package/src/internal/hardhat-network/provider/vm/exit.ts +4 -92
- package/src/internal/hardhat-network/stack-traces/compiler-to-model.ts +5 -697
- package/src/internal/hardhat-network/stack-traces/debug.ts +5 -218
- package/src/internal/hardhat-network/stack-traces/library-utils.ts +5 -90
- package/src/internal/hardhat-network/stack-traces/logger.ts +0 -221
- package/src/internal/hardhat-network/stack-traces/message-trace.ts +5 -122
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +16 -15
- package/src/internal/hardhat-network/stack-traces/solidity-stack-trace.ts +83 -186
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +5 -253
- package/src/internal/hardhat-network/stack-traces/vm-trace-decoder.ts +15 -108
- package/src/internal/hardhat-network/stack-traces/vm-tracer.ts +5 -206
- package/internal/hardhat-network/stack-traces/contracts-identifier.d.ts +0 -15
- package/internal/hardhat-network/stack-traces/contracts-identifier.d.ts.map +0 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.js +0 -166
- package/internal/hardhat-network/stack-traces/contracts-identifier.js.map +0 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts +0 -85
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +0 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +0 -1168
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +0 -1
- package/internal/hardhat-network/stack-traces/mapped-inlined-internal-functions-heuristics.d.ts +0 -24
- package/internal/hardhat-network/stack-traces/mapped-inlined-internal-functions-heuristics.d.ts.map +0 -1
- package/internal/hardhat-network/stack-traces/mapped-inlined-internal-functions-heuristics.js +0 -116
- package/internal/hardhat-network/stack-traces/mapped-inlined-internal-functions-heuristics.js.map +0 -1
- package/internal/hardhat-network/stack-traces/model.d.ts +0 -140
- package/internal/hardhat-network/stack-traces/model.d.ts.map +0 -1
- package/internal/hardhat-network/stack-traces/model.js +0 -328
- package/internal/hardhat-network/stack-traces/model.js.map +0 -1
- package/internal/hardhat-network/stack-traces/opcodes.d.ts +0 -266
- package/internal/hardhat-network/stack-traces/opcodes.d.ts.map +0 -1
- package/internal/hardhat-network/stack-traces/opcodes.js +0 -320
- package/internal/hardhat-network/stack-traces/opcodes.js.map +0 -1
- package/internal/hardhat-network/stack-traces/source-maps.d.ts +0 -13
- package/internal/hardhat-network/stack-traces/source-maps.d.ts.map +0 -1
- package/internal/hardhat-network/stack-traces/source-maps.js +0 -106
- package/internal/hardhat-network/stack-traces/source-maps.js.map +0 -1
- package/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +0 -235
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +0 -1845
- package/src/internal/hardhat-network/stack-traces/mapped-inlined-internal-functions-heuristics.ts +0 -163
- package/src/internal/hardhat-network/stack-traces/model.ts +0 -409
- package/src/internal/hardhat-network/stack-traces/opcodes.ts +0 -344
- package/src/internal/hardhat-network/stack-traces/source-maps.ts +0 -167
|
@@ -1,154 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VMTracer = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const message_trace_1 = require("./message-trace");
|
|
8
|
-
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
9
|
-
const DUMMY_RETURN_DATA = Buffer.from([]);
|
|
10
|
-
const DUMMY_GAS_USED = 0n;
|
|
11
|
-
/**
|
|
12
|
-
* Consumes the incoming VM trace events, until an error occurs, to keep track
|
|
13
|
-
* of the last top level message trace/error.
|
|
14
|
-
*/
|
|
15
|
-
class VMTracer {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.tracingSteps = [];
|
|
18
|
-
this._messageTraces = [];
|
|
19
|
-
// TODO: temporarily hardcoded to remove the need of using ethereumjs' common and evm here
|
|
20
|
-
this._maxPrecompileNumber = 10;
|
|
21
|
-
}
|
|
22
|
-
getLastTopLevelMessageTrace() {
|
|
23
|
-
return this._messageTraces[0];
|
|
24
|
-
}
|
|
25
|
-
getLastError() {
|
|
26
|
-
return this._lastError;
|
|
27
|
-
}
|
|
28
|
-
_shouldKeepTracing() {
|
|
29
|
-
return this._lastError === undefined;
|
|
30
|
-
}
|
|
31
|
-
addBeforeMessage(message) {
|
|
32
|
-
if (!this._shouldKeepTracing()) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
let trace;
|
|
37
|
-
if (message.depth === 0) {
|
|
38
|
-
this._messageTraces = [];
|
|
39
|
-
this.tracingSteps = [];
|
|
40
|
-
}
|
|
41
|
-
if (message.to === undefined) {
|
|
42
|
-
const createTrace = {
|
|
43
|
-
code: message.data,
|
|
44
|
-
steps: [],
|
|
45
|
-
value: message.value,
|
|
46
|
-
exit: new exit_1.Exit(exit_1.ExitCode.SUCCESS),
|
|
47
|
-
returnData: DUMMY_RETURN_DATA,
|
|
48
|
-
numberOfSubtraces: 0,
|
|
49
|
-
depth: message.depth,
|
|
50
|
-
deployedContract: undefined,
|
|
51
|
-
gasUsed: DUMMY_GAS_USED,
|
|
52
|
-
};
|
|
53
|
-
trace = createTrace;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const toAsBigInt = (0, ethereumjs_util_1.bytesToBigInt)(message.to);
|
|
57
|
-
if (toAsBigInt > 0 && toAsBigInt <= this._maxPrecompileNumber) {
|
|
58
|
-
const precompileTrace = {
|
|
59
|
-
precompile: Number(toAsBigInt),
|
|
60
|
-
calldata: message.data,
|
|
61
|
-
value: message.value,
|
|
62
|
-
exit: new exit_1.Exit(exit_1.ExitCode.SUCCESS),
|
|
63
|
-
returnData: DUMMY_RETURN_DATA,
|
|
64
|
-
depth: message.depth,
|
|
65
|
-
gasUsed: DUMMY_GAS_USED,
|
|
66
|
-
};
|
|
67
|
-
trace = precompileTrace;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
const codeAddress = message.codeAddress;
|
|
71
|
-
// if we enter here, then `to` is not undefined, therefore
|
|
72
|
-
// `codeAddress` and `code` should be defined
|
|
73
|
-
(0, errors_1.assertHardhatInvariant)(codeAddress !== undefined, "codeAddress should be defined");
|
|
74
|
-
(0, errors_1.assertHardhatInvariant)(message.code !== undefined, "code should be defined");
|
|
75
|
-
const callTrace = {
|
|
76
|
-
code: message.code,
|
|
77
|
-
calldata: message.data,
|
|
78
|
-
steps: [],
|
|
79
|
-
value: message.value,
|
|
80
|
-
exit: new exit_1.Exit(exit_1.ExitCode.SUCCESS),
|
|
81
|
-
returnData: DUMMY_RETURN_DATA,
|
|
82
|
-
address: message.to,
|
|
83
|
-
numberOfSubtraces: 0,
|
|
84
|
-
depth: message.depth,
|
|
85
|
-
gasUsed: DUMMY_GAS_USED,
|
|
86
|
-
codeAddress,
|
|
87
|
-
};
|
|
88
|
-
trace = callTrace;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (this._messageTraces.length > 0) {
|
|
92
|
-
const parentTrace = this._messageTraces[this._messageTraces.length - 1];
|
|
93
|
-
if ((0, message_trace_1.isPrecompileTrace)(parentTrace)) {
|
|
94
|
-
throw new Error("This should not happen: message execution started while a precompile was executing");
|
|
95
|
-
}
|
|
96
|
-
parentTrace.steps.push(trace);
|
|
97
|
-
parentTrace.numberOfSubtraces += 1;
|
|
98
|
-
}
|
|
99
|
-
this._messageTraces.push(trace);
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
this._lastError = error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
addStep(step) {
|
|
106
|
-
if (!this._shouldKeepTracing()) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
this.tracingSteps.push(step);
|
|
110
|
-
try {
|
|
111
|
-
const trace = this._messageTraces[this._messageTraces.length - 1];
|
|
112
|
-
if ((0, message_trace_1.isPrecompileTrace)(trace)) {
|
|
113
|
-
throw new Error("This should not happen: step event fired while a precompile was executing");
|
|
114
|
-
}
|
|
115
|
-
trace.steps.push({ pc: Number(step.pc) });
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
this._lastError = error;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
addAfterMessage(result) {
|
|
122
|
-
if (!this._shouldKeepTracing()) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
const trace = this._messageTraces[this._messageTraces.length - 1];
|
|
127
|
-
trace.gasUsed = result.result.gasUsed;
|
|
128
|
-
const executionResult = result.result;
|
|
129
|
-
if ((0, message_trace_1.isSuccessResult)(executionResult)) {
|
|
130
|
-
trace.exit = exit_1.Exit.fromEdrSuccessReason(executionResult.reason);
|
|
131
|
-
trace.returnData = executionResult.output.returnValue;
|
|
132
|
-
if ((0, message_trace_1.isCreateTrace)(trace)) {
|
|
133
|
-
trace.deployedContract = executionResult.output.address;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if ((0, message_trace_1.isHaltResult)(executionResult)) {
|
|
137
|
-
trace.exit = exit_1.Exit.fromEdrExceptionalHalt(executionResult.reason);
|
|
138
|
-
trace.returnData = Buffer.from([]);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
trace.exit = new exit_1.Exit(exit_1.ExitCode.REVERT);
|
|
142
|
-
trace.returnData = executionResult.output;
|
|
143
|
-
}
|
|
144
|
-
if (this._messageTraces.length > 1) {
|
|
145
|
-
this._messageTraces.pop();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
this._lastError = error;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
exports.VMTracer = VMTracer;
|
|
4
|
+
const napi_rs_1 = require("../../../common/napi-rs");
|
|
5
|
+
const { VmTracer } = (0, napi_rs_1.requireNapiRsModule)("@nomicfoundation/edr");
|
|
6
|
+
exports.VMTracer = VmTracer;
|
|
154
7
|
//# sourceMappingURL=vm-tracer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vm-tracer.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/vm-tracer.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"vm-tracer.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/vm-tracer.ts"],"names":[],"mappings":";;;AAAA,qDAA8D;AAE9D,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,6BAAmB,EACtC,sBAAsB,CACkB,CAAC;AAEtB,4BAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hardhat",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.13",
|
|
4
4
|
"author": "Nomic Labs LLC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://hardhat.org",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@ethersproject/abi": "^5.1.2",
|
|
87
87
|
"@metamask/eth-sig-util": "^4.0.0",
|
|
88
|
-
"@nomicfoundation/edr": "^0.
|
|
88
|
+
"@nomicfoundation/edr": "^0.6.3",
|
|
89
89
|
"@nomicfoundation/ethereumjs-common": "4.0.4",
|
|
90
90
|
"@nomicfoundation/ethereumjs-tx": "5.0.4",
|
|
91
91
|
"@nomicfoundation/ethereumjs-util": "9.0.4",
|
|
@@ -11,6 +11,8 @@ import type {
|
|
|
11
11
|
import type {
|
|
12
12
|
EdrContext,
|
|
13
13
|
Provider as EdrProviderT,
|
|
14
|
+
VmTraceDecoder as VmTraceDecoderT,
|
|
15
|
+
VMTracer as VMTracerT,
|
|
14
16
|
RawTrace,
|
|
15
17
|
Response,
|
|
16
18
|
SubscriptionEvent,
|
|
@@ -42,7 +44,6 @@ import { isErrorResponse } from "../../core/providers/http";
|
|
|
42
44
|
import { getHardforkName } from "../../util/hardforks";
|
|
43
45
|
import { createModelsAndDecodeBytecodes } from "../stack-traces/compiler-to-model";
|
|
44
46
|
import { ConsoleLogger } from "../stack-traces/consoleLogger";
|
|
45
|
-
import { ContractsIdentifier } from "../stack-traces/contracts-identifier";
|
|
46
47
|
import {
|
|
47
48
|
VmTraceDecoder,
|
|
48
49
|
initializeVmTraceDecoder,
|
|
@@ -167,7 +168,7 @@ export class EdrProviderWrapper
|
|
|
167
168
|
private _callOverrideCallback?: CallOverrideCallback;
|
|
168
169
|
|
|
169
170
|
/** Used for internal stack trace tests. */
|
|
170
|
-
private _vmTracer?:
|
|
171
|
+
private _vmTracer?: VMTracerT;
|
|
171
172
|
|
|
172
173
|
private constructor(
|
|
173
174
|
private readonly _provider: EdrProviderT,
|
|
@@ -175,7 +176,7 @@ export class EdrProviderWrapper
|
|
|
175
176
|
private readonly _node: {
|
|
176
177
|
_vm: MinimalEthereumJsVm;
|
|
177
178
|
},
|
|
178
|
-
private readonly _vmTraceDecoder:
|
|
179
|
+
private readonly _vmTraceDecoder: VmTraceDecoderT,
|
|
179
180
|
// The common configuration for EthereumJS VM is not used by EDR, but tests expect it as part of the provider.
|
|
180
181
|
private readonly _common: Common,
|
|
181
182
|
tracingConfig?: TracingConfig
|
|
@@ -221,8 +222,7 @@ export class EdrProviderWrapper
|
|
|
221
222
|
const printLineFn = loggerConfig.printLineFn ?? printLine;
|
|
222
223
|
const replaceLastLineFn = loggerConfig.replaceLastLineFn ?? replaceLastLine;
|
|
223
224
|
|
|
224
|
-
const
|
|
225
|
-
const vmTraceDecoder = new VmTraceDecoder(contractsIdentifier);
|
|
225
|
+
const vmTraceDecoder = new VmTraceDecoder();
|
|
226
226
|
|
|
227
227
|
const hardforkName = getHardforkName(config.hardfork);
|
|
228
228
|
|
|
@@ -368,6 +368,9 @@ export class EdrProviderWrapper
|
|
|
368
368
|
if (needsTraces) {
|
|
369
369
|
const rawTraces = responseObject.traces;
|
|
370
370
|
for (const rawTrace of rawTraces) {
|
|
371
|
+
this._vmTracer?.observe(rawTrace);
|
|
372
|
+
|
|
373
|
+
// For other consumers in JS we need to marshall the entire trace over FFI
|
|
371
374
|
const trace = rawTrace.trace();
|
|
372
375
|
|
|
373
376
|
// beforeTx event
|
|
@@ -384,8 +387,6 @@ export class EdrProviderWrapper
|
|
|
384
387
|
edrTracingStepToMinimalInterpreterStep(traceItem)
|
|
385
388
|
);
|
|
386
389
|
}
|
|
387
|
-
|
|
388
|
-
this._vmTracer?.addStep(traceItem);
|
|
389
390
|
}
|
|
390
391
|
// afterMessage event
|
|
391
392
|
else if ("executionResult" in traceItem) {
|
|
@@ -395,8 +396,6 @@ export class EdrProviderWrapper
|
|
|
395
396
|
edrTracingMessageResultToMinimalEVMResult(traceItem)
|
|
396
397
|
);
|
|
397
398
|
}
|
|
398
|
-
|
|
399
|
-
this._vmTracer?.addAfterMessage(traceItem.executionResult);
|
|
400
399
|
}
|
|
401
400
|
// beforeMessage event
|
|
402
401
|
else {
|
|
@@ -406,8 +405,6 @@ export class EdrProviderWrapper
|
|
|
406
405
|
edrTracingMessageToMinimalMessage(traceItem)
|
|
407
406
|
);
|
|
408
407
|
}
|
|
409
|
-
|
|
410
|
-
this._vmTracer?.addBeforeMessage(traceItem);
|
|
411
408
|
}
|
|
412
409
|
}
|
|
413
410
|
|
|
@@ -474,7 +471,7 @@ export class EdrProviderWrapper
|
|
|
474
471
|
*
|
|
475
472
|
* Used for internal stack traces integration tests.
|
|
476
473
|
*/
|
|
477
|
-
public setVmTracer(vmTracer?:
|
|
474
|
+
public setVmTracer(vmTracer?: VMTracerT) {
|
|
478
475
|
this._vmTracer = vmTracer;
|
|
479
476
|
}
|
|
480
477
|
|
|
@@ -552,7 +549,7 @@ export class EdrProviderWrapper
|
|
|
552
549
|
);
|
|
553
550
|
|
|
554
551
|
log(
|
|
555
|
-
"
|
|
552
|
+
"VmTraceDecoder failed to be updated. Please report this to help us improve Hardhat.\n",
|
|
556
553
|
error
|
|
557
554
|
);
|
|
558
555
|
|
|
@@ -578,17 +575,7 @@ export class EdrProviderWrapper
|
|
|
578
575
|
rawTrace: RawTrace
|
|
579
576
|
): Promise<SolidityStackTrace | undefined> {
|
|
580
577
|
const vmTracer = new VMTracer();
|
|
581
|
-
|
|
582
|
-
const trace = rawTrace.trace();
|
|
583
|
-
for (const traceItem of trace) {
|
|
584
|
-
if ("pc" in traceItem) {
|
|
585
|
-
vmTracer.addStep(traceItem);
|
|
586
|
-
} else if ("executionResult" in traceItem) {
|
|
587
|
-
vmTracer.addAfterMessage(traceItem.executionResult);
|
|
588
|
-
} else {
|
|
589
|
-
vmTracer.addBeforeMessage(traceItem);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
578
|
+
vmTracer.observe(rawTrace);
|
|
592
579
|
|
|
593
580
|
let vmTrace = vmTracer.getLastTopLevelMessageTrace();
|
|
594
581
|
const vmTracerError = vmTracer.getLastError();
|
|
@@ -1,75 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { assertHardhatInvariant } from "../../core/errors";
|
|
1
|
+
import { requireNapiRsModule } from "../../../common/napi-rs";
|
|
3
2
|
|
|
4
|
-
const {
|
|
3
|
+
const { ReturnData } = requireNapiRsModule(
|
|
4
|
+
"@nomicfoundation/edr"
|
|
5
|
+
) as typeof import("@nomicfoundation/edr");
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
const ERROR_SELECTOR = "08c379a0";
|
|
8
|
-
// selector of Panic(uint256)
|
|
9
|
-
const PANIC_SELECTOR = "4e487b71";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Represents the returnData of a transaction, whose contents are unknown.
|
|
13
|
-
*/
|
|
14
|
-
export class ReturnData {
|
|
15
|
-
private _selector: string | undefined;
|
|
16
|
-
|
|
17
|
-
constructor(public value: Uint8Array) {
|
|
18
|
-
if (value.length >= 4) {
|
|
19
|
-
this._selector = Buffer.from(value.slice(0, 4)).toString("hex");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public isEmpty(): boolean {
|
|
24
|
-
return this.value.length === 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public matchesSelector(selector: Uint8Array): boolean {
|
|
28
|
-
if (this._selector === undefined) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return this._selector === Buffer.from(selector).toString("hex");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public isErrorReturnData(): boolean {
|
|
36
|
-
return this._selector === ERROR_SELECTOR;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public isPanicReturnData(): boolean {
|
|
40
|
-
return this._selector === PANIC_SELECTOR;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public decodeError(): string {
|
|
44
|
-
if (this.isEmpty()) {
|
|
45
|
-
return "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
assertHardhatInvariant(
|
|
49
|
-
this._selector === ERROR_SELECTOR,
|
|
50
|
-
"Expected return data to be a Error(string)"
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const [decodedError] = rawDecode(["string"], this.value.slice(4)) as [
|
|
54
|
-
string
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
return decodedError;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public decodePanic(): bigint {
|
|
61
|
-
assertHardhatInvariant(
|
|
62
|
-
this._selector === PANIC_SELECTOR,
|
|
63
|
-
"Expected return data to be a Panic(uint256)"
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
// we are assuming that panic codes are smaller than Number.MAX_SAFE_INTEGER
|
|
67
|
-
const errorCode = bytesToBigInt(this.value.slice(4));
|
|
68
|
-
|
|
69
|
-
return errorCode;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public getSelector(): string | undefined {
|
|
73
|
-
return this._selector;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
7
|
+
export { ReturnData };
|
|
@@ -1,95 +1,7 @@
|
|
|
1
|
-
import type { ExceptionalHalt, SuccessReason } from "@nomicfoundation/edr";
|
|
2
|
-
|
|
3
1
|
import { requireNapiRsModule } from "../../../../common/napi-rs";
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
OUT_OF_GAS,
|
|
9
|
-
INTERNAL_ERROR,
|
|
10
|
-
INVALID_OPCODE,
|
|
11
|
-
STACK_UNDERFLOW,
|
|
12
|
-
CODESIZE_EXCEEDS_MAXIMUM,
|
|
13
|
-
CREATE_COLLISION,
|
|
14
|
-
STATIC_STATE_CHANGE,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Exit {
|
|
18
|
-
public static fromEdrSuccessReason(reason: SuccessReason): Exit {
|
|
19
|
-
const { SuccessReason } = requireNapiRsModule(
|
|
20
|
-
"@nomicfoundation/edr"
|
|
21
|
-
) as typeof import("@nomicfoundation/edr");
|
|
22
|
-
|
|
23
|
-
switch (reason) {
|
|
24
|
-
case SuccessReason.Stop:
|
|
25
|
-
case SuccessReason.Return:
|
|
26
|
-
case SuccessReason.SelfDestruct:
|
|
27
|
-
case SuccessReason.EofReturnContract:
|
|
28
|
-
return new Exit(ExitCode.SUCCESS);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const _exhaustiveCheck: never = reason;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public static fromEdrExceptionalHalt(halt: ExceptionalHalt): Exit {
|
|
35
|
-
const { ExceptionalHalt } = requireNapiRsModule(
|
|
36
|
-
"@nomicfoundation/edr"
|
|
37
|
-
) as typeof import("@nomicfoundation/edr");
|
|
38
|
-
|
|
39
|
-
switch (halt) {
|
|
40
|
-
case ExceptionalHalt.OutOfGas:
|
|
41
|
-
return new Exit(ExitCode.OUT_OF_GAS);
|
|
42
|
-
|
|
43
|
-
case ExceptionalHalt.OpcodeNotFound:
|
|
44
|
-
case ExceptionalHalt.InvalidFEOpcode:
|
|
45
|
-
// Returned when an opcode is not implemented for the hardfork
|
|
46
|
-
case ExceptionalHalt.NotActivated:
|
|
47
|
-
return new Exit(ExitCode.INVALID_OPCODE);
|
|
48
|
-
|
|
49
|
-
case ExceptionalHalt.StackUnderflow:
|
|
50
|
-
return new Exit(ExitCode.STACK_UNDERFLOW);
|
|
51
|
-
|
|
52
|
-
case ExceptionalHalt.CreateCollision:
|
|
53
|
-
return new Exit(ExitCode.CREATE_COLLISION);
|
|
54
|
-
|
|
55
|
-
case ExceptionalHalt.CreateContractSizeLimit:
|
|
56
|
-
return new Exit(ExitCode.CODESIZE_EXCEEDS_MAXIMUM);
|
|
57
|
-
|
|
58
|
-
default: {
|
|
59
|
-
// eslint-disable-next-line @nomicfoundation/hardhat-internal-rules/only-hardhat-error
|
|
60
|
-
throw new Error(`Unmatched EDR exceptional halt: ${halt}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
constructor(public kind: ExitCode) {}
|
|
66
|
-
|
|
67
|
-
public isError(): boolean {
|
|
68
|
-
return this.kind !== ExitCode.SUCCESS;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public getReason(): string {
|
|
72
|
-
switch (this.kind) {
|
|
73
|
-
case ExitCode.SUCCESS:
|
|
74
|
-
return "Success";
|
|
75
|
-
case ExitCode.REVERT:
|
|
76
|
-
return "Reverted";
|
|
77
|
-
case ExitCode.OUT_OF_GAS:
|
|
78
|
-
return "Out of gas";
|
|
79
|
-
case ExitCode.INTERNAL_ERROR:
|
|
80
|
-
return "Internal error";
|
|
81
|
-
case ExitCode.INVALID_OPCODE:
|
|
82
|
-
return "Invalid opcode";
|
|
83
|
-
case ExitCode.STACK_UNDERFLOW:
|
|
84
|
-
return "Stack underflow";
|
|
85
|
-
case ExitCode.CODESIZE_EXCEEDS_MAXIMUM:
|
|
86
|
-
return "Codesize exceeds maximum";
|
|
87
|
-
case ExitCode.CREATE_COLLISION:
|
|
88
|
-
return "Create collision";
|
|
89
|
-
case ExitCode.STATIC_STATE_CHANGE:
|
|
90
|
-
return "Static state change";
|
|
91
|
-
}
|
|
3
|
+
const { ExitCode } = requireNapiRsModule(
|
|
4
|
+
"@nomicfoundation/edr"
|
|
5
|
+
) as typeof import("@nomicfoundation/edr");
|
|
92
6
|
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
}
|
|
7
|
+
export { ExitCode };
|