hardhat 2.22.10 → 2.22.12
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/console.sol +1 -1
- package/internal/cli/project-creation.d.ts +1 -1
- package/internal/cli/project-creation.js +1 -1
- package/internal/core/providers/lazy-initialization.d.ts.map +1 -1
- package/internal/core/providers/lazy-initialization.js +10 -10
- package/internal/core/providers/lazy-initialization.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.js +2 -1
- package/internal/hardhat-network/jsonrpc/handler.js.map +1 -1
- 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/consoleLogger.d.ts +2 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js +2 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js.map +1 -1
- package/internal/hardhat-network/stack-traces/constants.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/constants.js +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.js +596 -596
- 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/internal/solidity/compiler/solc-info.d.ts.map +1 -1
- package/internal/solidity/compiler/solc-info.js +3 -0
- package/internal/solidity/compiler/solc-info.js.map +1 -1
- package/package.json +6 -5
- package/sample-projects/javascript/contracts/Lock.sol +1 -1
- package/sample-projects/javascript/hardhat.config.js +1 -1
- package/sample-projects/javascript/ignition/modules/Lock.js +3 -0
- package/sample-projects/javascript-esm/contracts/Lock.sol +1 -1
- package/sample-projects/javascript-esm/hardhat.config.cjs +1 -1
- package/sample-projects/javascript-esm/ignition/modules/Lock.js +3 -0
- package/sample-projects/typescript/contracts/Lock.sol +1 -1
- package/sample-projects/typescript/hardhat.config.ts +1 -1
- package/sample-projects/typescript/ignition/modules/Lock.ts +3 -0
- package/sample-projects/typescript-viem/contracts/Lock.sol +1 -1
- package/sample-projects/typescript-viem/hardhat.config.ts +1 -1
- package/sample-projects/typescript-viem/ignition/modules/Lock.ts +3 -0
- package/src/internal/cli/project-creation.ts +1 -1
- package/src/internal/core/providers/lazy-initialization.ts +13 -13
- package/src/internal/hardhat-network/jsonrpc/handler.ts +2 -1
- 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/consoleLogger.ts +2 -1
- package/src/internal/hardhat-network/stack-traces/constants.ts +1 -1
- 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 +596 -596
- 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/src/internal/solidity/compiler/solc-info.ts +3 -0
- 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,235 +0,0 @@
|
|
|
1
|
-
import { bytesToHex } from "@nomicfoundation/ethereumjs-util";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
normalizeLibraryRuntimeBytecodeIfNecessary,
|
|
5
|
-
zeroOutAddresses,
|
|
6
|
-
zeroOutSlices,
|
|
7
|
-
} from "./library-utils";
|
|
8
|
-
import { Bytecode } from "./model";
|
|
9
|
-
import { getOpcodeLength, Opcode } from "./opcodes";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This class represent a somewhat special Trie of bytecodes.
|
|
13
|
-
*
|
|
14
|
-
* What makes it special is that every node has a set of all of its descendants and its depth.
|
|
15
|
-
*/
|
|
16
|
-
class BytecodeTrie {
|
|
17
|
-
public static isBytecodeTrie(o: any): o is BytecodeTrie {
|
|
18
|
-
if (o === undefined || o === null) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return "childNodes" in o;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public readonly childNodes: Map<number, BytecodeTrie> = new Map();
|
|
26
|
-
public readonly descendants: Bytecode[] = [];
|
|
27
|
-
public match?: Bytecode;
|
|
28
|
-
|
|
29
|
-
constructor(public readonly depth: number) {}
|
|
30
|
-
|
|
31
|
-
public add(bytecode: Bytecode) {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
33
|
-
let trieNode: BytecodeTrie = this;
|
|
34
|
-
for (
|
|
35
|
-
let currentCodeByte = 0;
|
|
36
|
-
currentCodeByte <= bytecode.normalizedCode.length;
|
|
37
|
-
currentCodeByte += 1
|
|
38
|
-
) {
|
|
39
|
-
if (currentCodeByte === bytecode.normalizedCode.length) {
|
|
40
|
-
// If multiple contracts with the exact same bytecode are added we keep the last of them.
|
|
41
|
-
// Note that this includes the metadata hash, so the chances of happening are pretty remote,
|
|
42
|
-
// except in super artificial cases that we have in our test suite.
|
|
43
|
-
trieNode.match = bytecode;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const byte = bytecode.normalizedCode[currentCodeByte];
|
|
48
|
-
trieNode.descendants.push(bytecode);
|
|
49
|
-
|
|
50
|
-
let childNode = trieNode.childNodes.get(byte);
|
|
51
|
-
if (childNode === undefined) {
|
|
52
|
-
childNode = new BytecodeTrie(currentCodeByte);
|
|
53
|
-
trieNode.childNodes.set(byte, childNode);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
trieNode = childNode;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Searches for a bytecode. If it's an exact match, it is returned. If there's no match, but a
|
|
62
|
-
* prefix of the code is found in the trie, the node of the longest prefix is returned. If the
|
|
63
|
-
* entire code is covered by the trie, and there's no match, we return undefined.
|
|
64
|
-
*/
|
|
65
|
-
public search(
|
|
66
|
-
code: Uint8Array,
|
|
67
|
-
currentCodeByte: number = 0
|
|
68
|
-
): Bytecode | BytecodeTrie | undefined {
|
|
69
|
-
if (currentCodeByte > code.length) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
74
|
-
let trieNode: BytecodeTrie = this;
|
|
75
|
-
for (; currentCodeByte <= code.length; currentCodeByte += 1) {
|
|
76
|
-
if (currentCodeByte === code.length) {
|
|
77
|
-
return trieNode.match;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const childNode = trieNode.childNodes.get(code[currentCodeByte]);
|
|
81
|
-
|
|
82
|
-
if (childNode === undefined) {
|
|
83
|
-
return trieNode;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
trieNode = childNode;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export class ContractsIdentifier {
|
|
92
|
-
private _trie = new BytecodeTrie(-1);
|
|
93
|
-
private _cache: Map<string, Bytecode> = new Map();
|
|
94
|
-
|
|
95
|
-
constructor(private readonly _enableCache = true) {}
|
|
96
|
-
|
|
97
|
-
public addBytecode(bytecode: Bytecode) {
|
|
98
|
-
this._trie.add(bytecode);
|
|
99
|
-
this._cache.clear();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public getBytecodeForCall(
|
|
103
|
-
code: Uint8Array,
|
|
104
|
-
isCreate: boolean
|
|
105
|
-
): Bytecode | undefined {
|
|
106
|
-
const normalizedCode = normalizeLibraryRuntimeBytecodeIfNecessary(code);
|
|
107
|
-
|
|
108
|
-
let normalizedCodeHex: string | undefined;
|
|
109
|
-
if (this._enableCache) {
|
|
110
|
-
normalizedCodeHex = bytesToHex(normalizedCode);
|
|
111
|
-
const cached = this._cache.get(normalizedCodeHex);
|
|
112
|
-
|
|
113
|
-
if (cached !== undefined) {
|
|
114
|
-
return cached;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const result = this._searchBytecode(isCreate, normalizedCode);
|
|
119
|
-
|
|
120
|
-
if (this._enableCache) {
|
|
121
|
-
if (result !== undefined) {
|
|
122
|
-
this._cache.set(normalizedCodeHex!, result);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
private _searchBytecode(
|
|
130
|
-
isCreate: boolean,
|
|
131
|
-
code: Uint8Array,
|
|
132
|
-
normalizeLibraries = true,
|
|
133
|
-
trie = this._trie,
|
|
134
|
-
firstByteToSearch = 0
|
|
135
|
-
): Bytecode | undefined {
|
|
136
|
-
const searchResult = trie.search(code, firstByteToSearch);
|
|
137
|
-
|
|
138
|
-
if (searchResult === undefined) {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (!BytecodeTrie.isBytecodeTrie(searchResult)) {
|
|
143
|
-
return searchResult;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Deployment messages have their abi-encoded arguments at the end of the bytecode.
|
|
147
|
-
//
|
|
148
|
-
// We don't know how long those arguments are, as we don't know which contract is being
|
|
149
|
-
// deployed, hence we don't know the signature of its constructor.
|
|
150
|
-
//
|
|
151
|
-
// To make things even harder, we can't trust that the user actually passed the right
|
|
152
|
-
// amount of arguments.
|
|
153
|
-
//
|
|
154
|
-
// Luckily, the chances of a complete deployment bytecode being the prefix of another one are
|
|
155
|
-
// remote. For example, most of the time it ends with its metadata hash, which will differ.
|
|
156
|
-
//
|
|
157
|
-
// We take advantage of this last observation, and just return the bytecode that exactly
|
|
158
|
-
// matched the searchResult (sub)trie that we got.
|
|
159
|
-
if (
|
|
160
|
-
isCreate &&
|
|
161
|
-
searchResult.match !== undefined &&
|
|
162
|
-
searchResult.match.isDeployment
|
|
163
|
-
) {
|
|
164
|
-
return searchResult.match;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (normalizeLibraries) {
|
|
168
|
-
for (const bytecodeWithLibraries of searchResult.descendants) {
|
|
169
|
-
if (
|
|
170
|
-
bytecodeWithLibraries.libraryAddressPositions.length === 0 &&
|
|
171
|
-
bytecodeWithLibraries.immutableReferences.length === 0
|
|
172
|
-
) {
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const normalizedLibrariesCode = zeroOutAddresses(
|
|
177
|
-
code,
|
|
178
|
-
bytecodeWithLibraries.libraryAddressPositions
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const normalizedCode = zeroOutSlices(
|
|
182
|
-
normalizedLibrariesCode,
|
|
183
|
-
bytecodeWithLibraries.immutableReferences
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const normalizedResult = this._searchBytecode(
|
|
187
|
-
isCreate,
|
|
188
|
-
normalizedCode,
|
|
189
|
-
false,
|
|
190
|
-
searchResult,
|
|
191
|
-
searchResult.depth + 1
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
if (normalizedResult !== undefined) {
|
|
195
|
-
return normalizedResult;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// If we got here we may still have the contract, but with a different metadata hash.
|
|
201
|
-
//
|
|
202
|
-
// We check if we got to match the entire executable bytecode, and are just stuck because
|
|
203
|
-
// of the metadata. If that's the case, we can assume that any descendant will be a valid
|
|
204
|
-
// Bytecode, so we just choose the most recently added one.
|
|
205
|
-
//
|
|
206
|
-
// The reason this works is because there's no chance that Solidity includes an entire
|
|
207
|
-
// bytecode (i.e. with metadata), as a prefix of another one.
|
|
208
|
-
if (
|
|
209
|
-
this._isMatchingMetadata(code, searchResult.depth) &&
|
|
210
|
-
searchResult.descendants.length > 0
|
|
211
|
-
) {
|
|
212
|
-
return searchResult.descendants[searchResult.descendants.length - 1];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return undefined;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Returns true if the lastByte is placed right when the metadata starts or after it.
|
|
220
|
-
*/
|
|
221
|
-
private _isMatchingMetadata(code: Uint8Array, lastByte: number): boolean {
|
|
222
|
-
for (let byte = 0; byte < lastByte; ) {
|
|
223
|
-
const opcode = code[byte];
|
|
224
|
-
|
|
225
|
-
// Solidity always emits REVERT INVALID right before the metadata
|
|
226
|
-
if (opcode === Opcode.REVERT && code[byte + 1] === Opcode.INVALID) {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
byte += getOpcodeLength(opcode);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
}
|