hardhat 2.13.0-dev.4 → 2.13.1

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.
Files changed (117) hide show
  1. package/internal/cli/bootstrap.js +0 -0
  2. package/internal/cli/cli.js +0 -0
  3. package/internal/constants.d.ts.map +1 -1
  4. package/internal/constants.js +1 -0
  5. package/internal/constants.js.map +1 -1
  6. package/internal/core/jsonrpc/types/output/block.d.ts +24 -0
  7. package/internal/core/jsonrpc/types/output/block.d.ts.map +1 -1
  8. package/internal/core/jsonrpc/types/output/block.js +8 -0
  9. package/internal/core/jsonrpc/types/output/block.js.map +1 -1
  10. package/internal/hardhat-network/provider/BlockchainBase.d.ts +1 -1
  11. package/internal/hardhat-network/provider/BlockchainBase.d.ts.map +1 -1
  12. package/internal/hardhat-network/provider/BlockchainBase.js +16 -9
  13. package/internal/hardhat-network/provider/BlockchainBase.js.map +1 -1
  14. package/internal/hardhat-network/provider/TxPool.d.ts.map +1 -1
  15. package/internal/hardhat-network/provider/TxPool.js +1 -0
  16. package/internal/hardhat-network/provider/TxPool.js.map +1 -1
  17. package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts +1 -1
  18. package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
  19. package/internal/hardhat-network/provider/fork/ForkBlockchain.js +24 -14
  20. package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
  21. package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts.map +1 -1
  22. package/internal/hardhat-network/provider/fork/rpcToBlockData.js +2 -0
  23. package/internal/hardhat-network/provider/fork/rpcToBlockData.js.map +1 -1
  24. package/internal/hardhat-network/provider/modules/eth.d.ts +1 -0
  25. package/internal/hardhat-network/provider/modules/eth.d.ts.map +1 -1
  26. package/internal/hardhat-network/provider/modules/eth.js +28 -3
  27. package/internal/hardhat-network/provider/modules/eth.js.map +1 -1
  28. package/internal/hardhat-network/provider/node.d.ts +1 -0
  29. package/internal/hardhat-network/provider/node.d.ts.map +1 -1
  30. package/internal/hardhat-network/provider/node.js +38 -16
  31. package/internal/hardhat-network/provider/node.js.map +1 -1
  32. package/internal/hardhat-network/provider/output.d.ts +8 -0
  33. package/internal/hardhat-network/provider/output.d.ts.map +1 -1
  34. package/internal/hardhat-network/provider/output.js +9 -0
  35. package/internal/hardhat-network/provider/output.js.map +1 -1
  36. package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +1 -1
  37. package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
  38. package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +1 -1
  39. package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
  40. package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +1 -1
  41. package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
  42. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts.map +1 -1
  43. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +5 -1
  44. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
  45. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts.map +1 -1
  46. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +5 -1
  47. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
  48. package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +1 -1
  49. package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +1 -1
  50. package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js +1 -1
  51. package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js.map +1 -1
  52. package/internal/solidity/resolver.d.ts.map +1 -1
  53. package/internal/solidity/resolver.js +18 -2
  54. package/internal/solidity/resolver.js.map +1 -1
  55. package/internal/util/hardforks.d.ts +2 -1
  56. package/internal/util/hardforks.d.ts.map +1 -1
  57. package/internal/util/hardforks.js +2 -0
  58. package/internal/util/hardforks.js.map +1 -1
  59. package/package.json +11 -11
  60. package/src/internal/constants.ts +1 -0
  61. package/src/internal/core/jsonrpc/types/output/block.ts +12 -0
  62. package/src/internal/hardhat-network/provider/BlockchainBase.ts +19 -10
  63. package/src/internal/hardhat-network/provider/TxPool.ts +1 -0
  64. package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +28 -18
  65. package/src/internal/hardhat-network/provider/fork/rpcToBlockData.ts +2 -0
  66. package/src/internal/hardhat-network/provider/modules/eth.ts +40 -3
  67. package/src/internal/hardhat-network/provider/node.ts +36 -14
  68. package/src/internal/hardhat-network/provider/output.ts +20 -0
  69. package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +1 -1
  70. package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +1 -1
  71. package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +1 -1
  72. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.ts +5 -1
  73. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.ts +5 -1
  74. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.ts +1 -1
  75. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.ts +1 -1
  76. package/src/internal/solidity/resolver.ts +25 -6
  77. package/src/internal/util/hardforks.ts +2 -0
  78. package/internal/hardhat-network/provider/RethnetState.d.ts +0 -27
  79. package/internal/hardhat-network/provider/RethnetState.d.ts.map +0 -1
  80. package/internal/hardhat-network/provider/RethnetState.js +0 -89
  81. package/internal/hardhat-network/provider/RethnetState.js.map +0 -1
  82. package/internal/hardhat-network/provider/utils/bloom.d.ts +0 -32
  83. package/internal/hardhat-network/provider/utils/bloom.d.ts.map +0 -1
  84. package/internal/hardhat-network/provider/utils/bloom.js +0 -79
  85. package/internal/hardhat-network/provider/utils/bloom.js.map +0 -1
  86. package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts +0 -12
  87. package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts.map +0 -1
  88. package/internal/hardhat-network/provider/utils/convertToRethnet.js +0 -162
  89. package/internal/hardhat-network/provider/utils/convertToRethnet.js.map +0 -1
  90. package/internal/hardhat-network/provider/vm/block-builder.d.ts +0 -31
  91. package/internal/hardhat-network/provider/vm/block-builder.d.ts.map +0 -1
  92. package/internal/hardhat-network/provider/vm/block-builder.js +0 -151
  93. package/internal/hardhat-network/provider/vm/block-builder.js.map +0 -1
  94. package/internal/hardhat-network/provider/vm/creation.d.ts +0 -10
  95. package/internal/hardhat-network/provider/vm/creation.d.ts.map +0 -1
  96. package/internal/hardhat-network/provider/vm/creation.js +0 -29
  97. package/internal/hardhat-network/provider/vm/creation.js.map +0 -1
  98. package/internal/hardhat-network/provider/vm/dual.d.ts +0 -44
  99. package/internal/hardhat-network/provider/vm/dual.d.ts.map +0 -1
  100. package/internal/hardhat-network/provider/vm/dual.js +0 -501
  101. package/internal/hardhat-network/provider/vm/dual.js.map +0 -1
  102. package/internal/hardhat-network/provider/vm/ethereumjs.d.ts +0 -57
  103. package/internal/hardhat-network/provider/vm/ethereumjs.d.ts.map +0 -1
  104. package/internal/hardhat-network/provider/vm/ethereumjs.js +0 -420
  105. package/internal/hardhat-network/provider/vm/ethereumjs.js.map +0 -1
  106. package/internal/hardhat-network/provider/vm/exit.d.ts +0 -23
  107. package/internal/hardhat-network/provider/vm/exit.d.ts.map +0 -1
  108. package/internal/hardhat-network/provider/vm/exit.js +0 -130
  109. package/internal/hardhat-network/provider/vm/exit.js.map +0 -1
  110. package/internal/hardhat-network/provider/vm/rethnet.d.ts +0 -100
  111. package/internal/hardhat-network/provider/vm/rethnet.d.ts.map +0 -1
  112. package/internal/hardhat-network/provider/vm/rethnet.js +0 -287
  113. package/internal/hardhat-network/provider/vm/rethnet.js.map +0 -1
  114. package/internal/hardhat-network/provider/vm/vm-adapter.d.ts +0 -53
  115. package/internal/hardhat-network/provider/vm/vm-adapter.d.ts.map +0 -1
  116. package/internal/hardhat-network/provider/vm/vm-adapter.js +0 -3
  117. package/internal/hardhat-network/provider/vm/vm-adapter.js.map +0 -1
@@ -48,9 +48,7 @@ export class ForkBlockchain
48
48
  return this._latestBlockNumber;
49
49
  }
50
50
 
51
- public async getBlock(
52
- blockHashOrNumber: Buffer | bigint
53
- ): Promise<Block | null> {
51
+ public async getBlock(blockHashOrNumber: Buffer | bigint): Promise<Block> {
54
52
  if (
55
53
  typeof blockHashOrNumber === "bigint" &&
56
54
  this._data.isReservedBlock(blockHashOrNumber)
@@ -61,11 +59,17 @@ export class ForkBlockchain
61
59
  let block: Block | undefined | null;
62
60
  if (Buffer.isBuffer(blockHashOrNumber)) {
63
61
  block = await this._getBlockByHash(blockHashOrNumber);
64
- return block ?? null;
62
+ if (block === undefined) {
63
+ throw new Error("Block not found");
64
+ }
65
+ return block;
65
66
  }
66
67
 
67
68
  block = await this._getBlockByNumber(BigInt(blockHashOrNumber));
68
- return block ?? null;
69
+ if (block === undefined) {
70
+ throw new Error("Block not found");
71
+ }
72
+ return block;
69
73
  }
70
74
 
71
75
  public async addBlock(block: Block): Promise<Block> {
@@ -131,10 +135,10 @@ export class ForkBlockchain
131
135
  if (td !== undefined) {
132
136
  return td;
133
137
  }
134
- const block = await this.getBlock(blockHash);
135
- if (block === null) {
136
- throw new Error("Block not found");
137
- }
138
+
139
+ // fetch block to check if it exists
140
+ await this.getBlock(blockHash);
141
+
138
142
  td = this._data.getTotalDifficulty(blockHash);
139
143
  if (td === undefined) {
140
144
  throw new Error("This should never happen");
@@ -232,10 +236,12 @@ export class ForkBlockchain
232
236
  if (blockNumber > this._latestBlockNumber) {
233
237
  return undefined;
234
238
  }
235
- const block = await super.getBlock(blockNumber);
236
- if (block !== null) {
239
+
240
+ try {
241
+ const block = await super.getBlock(blockNumber);
237
242
  return block;
238
- }
243
+ } catch {}
244
+
239
245
  const rpcBlock = await this._jsonRpcClient.getBlockByNumber(
240
246
  blockNumber,
241
247
  true
@@ -254,13 +260,17 @@ export class ForkBlockchain
254
260
  }
255
261
 
256
262
  const common = this._common.copy();
257
- // We set the common's hardfork to Berlin if the remote block doesn't have
258
- // EIP-1559 activated. The reason for this is that ethereumjs throws if we
259
- // have a base fee for an older hardfork, and set a default one for London.
260
- if (rpcBlock.baseFeePerGas !== undefined) {
261
- common.setHardfork("london"); // TODO: consider changing this to "latest hardfork"
262
- } else {
263
+ // We set the common's hardfork depending on the remote block fields, to
264
+ // prevent ethereumjs from throwing if unsupported fields are passed.
265
+ // We use "berlin" for pre-EIP-1559 blocks (blocks without baseFeePerGas),
266
+ // "merge" for blocks that have baseFeePerGas but not withdrawals,
267
+ // and "shanghai" for blocks with withdrawals
268
+ if (rpcBlock.baseFeePerGas === undefined) {
263
269
  common.setHardfork("berlin");
270
+ } else if (rpcBlock.withdrawals === undefined) {
271
+ common.setHardfork("merge");
272
+ } else {
273
+ common.setHardfork("shanghai");
264
274
  }
265
275
 
266
276
  // we don't include the transactions to add our own custom tx objects,
@@ -23,8 +23,10 @@ export function rpcToBlockData(rpcBlock: RpcBlockWithTransactions): BlockData {
23
23
  mixHash: rpcBlock.mixHash,
24
24
  nonce: rpcBlock.nonce,
25
25
  baseFeePerGas: rpcBlock.baseFeePerGas,
26
+ withdrawalsRoot: rpcBlock.withdrawalsRoot,
26
27
  },
27
28
  transactions: rpcBlock.transactions.map(rpcToTxData),
29
+ withdrawals: rpcBlock.withdrawals,
28
30
  // uncleHeaders are not fetched and set here as provider methods for getting them are not supported
29
31
  };
30
32
  }
@@ -86,11 +86,13 @@ import {
86
86
  import { assertHardhatNetworkInvariant } from "../utils/assertions";
87
87
  import { optional } from "../../../util/io-ts";
88
88
  import * as BigIntUtils from "../../../util/bigint";
89
+ import { HardforkName } from "../../../util/hardforks";
89
90
  import { ModulesLogger } from "./logger";
90
91
 
91
- const EIP1559_MIN_HARDFORK = "london";
92
- const ACCESS_LIST_MIN_HARDFORK = "berlin";
93
- const EIP155_MIN_HARDFORK = "spuriousDragon";
92
+ const EIP1559_MIN_HARDFORK = HardforkName.LONDON;
93
+ const ACCESS_LIST_MIN_HARDFORK = HardforkName.BERLIN;
94
+ const EIP155_MIN_HARDFORK = HardforkName.SPURIOUS_DRAGON;
95
+ const EIP3860_MIN_HARDFORK = HardforkName.SHANGHAI;
94
96
 
95
97
  /* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
96
98
  export class EthModule {
@@ -960,7 +962,10 @@ export class EthModule {
960
962
  try {
961
963
  tx = TransactionFactory.fromSerializedData(rawTx, {
962
964
  common: this._common,
965
+ disableMaxInitCodeSizeCheck: true,
963
966
  });
967
+
968
+ this._validateEip3860MaxInitCodeSize(tx.to?.toBuffer(), tx.data);
964
969
  } catch (error) {
965
970
  // This section of the code is incredibly dependant of TransactionFactory.fromSerializedData
966
971
  // AccessListEIP2930Transaction.fromSerializedTx and Transaction.fromSerializedTx
@@ -1017,6 +1022,11 @@ export class EthModule {
1017
1022
  private async _sendTransactionAction(
1018
1023
  transactionRequest: RpcTransactionRequest
1019
1024
  ): Promise<string> {
1025
+ this._validateEip3860MaxInitCodeSize(
1026
+ transactionRequest.to,
1027
+ transactionRequest.data ?? Buffer.from([])
1028
+ );
1029
+
1020
1030
  const expectedChainId = this._common.chainId();
1021
1031
  if (
1022
1032
  transactionRequest.chainId !== undefined &&
@@ -1742,6 +1752,33 @@ You can use them by running Hardhat Network with 'hardfork' ${EIP155_MIN_HARDFOR
1742
1752
  }
1743
1753
  }
1744
1754
 
1755
+ private _validateEip3860MaxInitCodeSize(
1756
+ to: Buffer | undefined,
1757
+ data: Buffer
1758
+ ) {
1759
+ if (!this._common.gteHardfork(EIP3860_MIN_HARDFORK)) {
1760
+ // this check is only relevant after shanghai
1761
+ return;
1762
+ }
1763
+
1764
+ if (to !== undefined) {
1765
+ // this check is only relevant for deployments
1766
+ return;
1767
+ }
1768
+
1769
+ if (this._node.allowUnlimitedContractSize) {
1770
+ // this check is not performed if allowUnlimitedContractSize is enabled
1771
+ return;
1772
+ }
1773
+
1774
+ const maxInitCodeSize = this._common.param("vm", "maxInitCodeSize");
1775
+ if (data.length > maxInitCodeSize) {
1776
+ throw new InvalidArgumentsError(`Trying to send a deployment transaction whose init code length is ${data.length}. The max length allowed by EIP-3860 is ${maxInitCodeSize}.
1777
+
1778
+ Enable the 'allowUnlimitedContractSize' option to allow init codes of any length.`);
1779
+ }
1780
+ }
1781
+
1745
1782
  private _validateRawTransactionHardforkRequirements(rawTx: Buffer) {
1746
1783
  if (rawTx[0] <= 0x7f && rawTx[0] !== 1 && rawTx[0] !== 2) {
1747
1784
  throw new InvalidArgumentsError(`Invalid transaction type ${rawTx[0]}.
@@ -140,7 +140,6 @@ export class HardhatNode extends EventEmitter {
140
140
  automine,
141
141
  genesisAccounts,
142
142
  blockGasLimit,
143
- allowUnlimitedContractSize,
144
143
  tracingConfig,
145
144
  minGasPrice,
146
145
  mempoolOrder,
@@ -149,6 +148,9 @@ export class HardhatNode extends EventEmitter {
149
148
  allowBlocksWithSameTimestamp,
150
149
  } = config;
151
150
 
151
+ const allowUnlimitedContractSize =
152
+ config.allowUnlimitedContractSize ?? false;
153
+
152
154
  let stateManager: StateManager;
153
155
  let blockchain: HardhatBlockchainInterface;
154
156
  let initialBlockTimeOffset: bigint | undefined;
@@ -294,6 +296,7 @@ export class HardhatNode extends EventEmitter {
294
296
  hardfork,
295
297
  hardforkActivations,
296
298
  mixHashGenerator,
299
+ allowUnlimitedContractSize,
297
300
  allowBlocksWithSameTimestamp,
298
301
  tracingConfig,
299
302
  forkNetworkId,
@@ -380,6 +383,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
380
383
  public readonly hardfork: HardforkName,
381
384
  private readonly _hardforkActivations: HardforkHistoryConfig,
382
385
  private _mixHashGenerator: RandomBufferGenerator,
386
+ public readonly allowUnlimitedContractSize: boolean,
383
387
  private _allowBlocksWithSameTimestamp: boolean,
384
388
  tracingConfig?: TracingConfig,
385
389
  private _forkNetworkId?: number,
@@ -453,13 +457,18 @@ Hardhat Network's forking functionality only works with blocks from at least spu
453
457
  if ("maxFeePerGas" in txParams) {
454
458
  tx = FeeMarketEIP1559Transaction.fromTxData(txParams, {
455
459
  common: this._vm._common,
460
+ disableMaxInitCodeSizeCheck: true,
456
461
  });
457
462
  } else if ("accessList" in txParams) {
458
463
  tx = AccessListEIP2930Transaction.fromTxData(txParams, {
459
464
  common: this._vm._common,
465
+ disableMaxInitCodeSizeCheck: true,
460
466
  });
461
467
  } else {
462
- tx = Transaction.fromTxData(txParams, { common: this._vm._common });
468
+ tx = Transaction.fromTxData(txParams, {
469
+ common: this._vm._common,
470
+ disableMaxInitCodeSizeCheck: true,
471
+ });
463
472
  }
464
473
 
465
474
  return tx.sign(pk);
@@ -889,13 +898,21 @@ Hardhat Network's forking functionality only works with blocks from at least spu
889
898
  );
890
899
  }
891
900
 
892
- const block = await this._blockchain.getBlock(blockNumberOrPending);
893
- return block ?? undefined;
901
+ try {
902
+ const block = await this._blockchain.getBlock(blockNumberOrPending);
903
+ return block;
904
+ } catch {
905
+ return undefined;
906
+ }
894
907
  }
895
908
 
896
909
  public async getBlockByHash(blockHash: Buffer): Promise<Block | undefined> {
897
- const block = await this._blockchain.getBlock(blockHash);
898
- return block ?? undefined;
910
+ try {
911
+ const block = await this._blockchain.getBlock(blockHash);
912
+ return block;
913
+ } catch {
914
+ return undefined;
915
+ }
899
916
  }
900
917
 
901
918
  public async getBlockByTransactionHash(
@@ -1402,17 +1419,13 @@ Hardhat Network's forking functionality only works with blocks from at least spu
1402
1419
  txWithCommon = new FakeSenderAccessListEIP2930Transaction(
1403
1420
  sender,
1404
1421
  tx,
1405
- {
1406
- common: vm._common,
1407
- }
1422
+ { common: vm._common }
1408
1423
  );
1409
1424
  } else if (tx.type === 2) {
1410
1425
  txWithCommon = new FakeSenderEIP1559Transaction(
1411
1426
  sender,
1412
1427
  { ...tx, gasPrice: undefined },
1413
- {
1414
- common: vm._common,
1415
- }
1428
+ { common: vm._common }
1416
1429
  );
1417
1430
  } else {
1418
1431
  throw new InternalError(
@@ -1424,10 +1437,18 @@ Hardhat Network's forking functionality only works with blocks from at least spu
1424
1437
  if (txHash.equals(hash)) {
1425
1438
  const vmDebugTracer = new VMDebugTracer(vm);
1426
1439
  return vmDebugTracer.trace(async () => {
1427
- await vm.runTx({ tx: txWithCommon, block });
1440
+ await vm.runTx({
1441
+ tx: txWithCommon,
1442
+ block,
1443
+ skipHardForkValidation: true,
1444
+ });
1428
1445
  }, config);
1429
1446
  }
1430
- await vm.runTx({ tx: txWithCommon, block });
1447
+ await vm.runTx({
1448
+ tx: txWithCommon,
1449
+ block,
1450
+ skipHardForkValidation: true,
1451
+ });
1431
1452
  }
1432
1453
  throw new TransactionExecutionError(
1433
1454
  `Unable to find a transaction in a block that contains that transaction, this should never happen`
@@ -2415,6 +2436,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
2415
2436
  skipNonce: true,
2416
2437
  skipBalance: true,
2417
2438
  skipBlockGasLimitValidation: true,
2439
+ skipHardForkValidation: true,
2418
2440
  });
2419
2441
  } finally {
2420
2442
  if (originalCommon !== undefined) {
@@ -40,6 +40,8 @@ export interface RpcBlockOutput {
40
40
  transactionsRoot: string;
41
41
  uncles: string[];
42
42
  baseFeePerGas?: string;
43
+ withdrawals?: RpcWithdrawalItem[];
44
+ withdrawalsRoot?: string;
43
45
  }
44
46
 
45
47
  export type RpcTransactionOutput =
@@ -147,6 +149,13 @@ export interface RpcDebugTraceOutput {
147
149
  structLogs: RpcStructLog[];
148
150
  }
149
151
 
152
+ export interface RpcWithdrawalItem {
153
+ index: string;
154
+ validatorIndex: string;
155
+ address: string;
156
+ amount: string;
157
+ }
158
+
150
159
  /* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
151
160
 
152
161
  export function getRpcBlock(
@@ -191,6 +200,17 @@ export function getRpcBlock(
191
200
  output.baseFeePerGas = numberToRpcQuantity(block.header.baseFeePerGas);
192
201
  }
193
202
 
203
+ if (block.header.withdrawalsRoot !== undefined) {
204
+ output.withdrawals = block.withdrawals?.map((withdrawal) => ({
205
+ index: numberToRpcQuantity(withdrawal.index),
206
+ validatorIndex: numberToRpcQuantity(withdrawal.validatorIndex),
207
+ address: bufferToRpcData(withdrawal.address.toBuffer()),
208
+ amount: numberToRpcQuantity(withdrawal.amount),
209
+ }));
210
+
211
+ output.withdrawalsRoot = bufferToRpcData(block.header.withdrawalsRoot);
212
+ }
213
+
194
214
  return output;
195
215
  }
196
216
 
@@ -134,7 +134,7 @@ export class FakeSenderAccessListEIP2930Transaction extends AccessListEIP2930Tra
134
134
  r: data.r ?? fakeSignature.r,
135
135
  s: data.s ?? fakeSignature.s,
136
136
  },
137
- { ...opts, freeze: false }
137
+ { ...opts, freeze: false, disableMaxInitCodeSizeCheck: true }
138
138
  );
139
139
 
140
140
  this.common = this._getCommon(opts?.common);
@@ -133,7 +133,7 @@ export class FakeSenderEIP1559Transaction extends FeeMarketEIP1559Transaction {
133
133
  r: data.r ?? fakeSignature.r,
134
134
  s: data.s ?? fakeSignature.s,
135
135
  },
136
- { ...opts, freeze: false }
136
+ { ...opts, freeze: false, disableMaxInitCodeSizeCheck: true }
137
137
  );
138
138
 
139
139
  this._sender = sender;
@@ -107,7 +107,7 @@ export class FakeSenderTransaction extends Transaction {
107
107
  r: data.r ?? fakeSignature.r,
108
108
  s: data.s ?? fakeSignature.s,
109
109
  },
110
- { ...opts, freeze: false }
110
+ { ...opts, freeze: false, disableMaxInitCodeSizeCheck: true }
111
111
  );
112
112
 
113
113
  this.common = this._getCommon(opts?.common);
@@ -68,7 +68,11 @@ export class ReadOnlyValidEIP1559Transaction extends FeeMarketEIP1559Transaction
68
68
  }
69
69
  );
70
70
 
71
- super(data, { freeze: false, common: fakeCommon });
71
+ super(data, {
72
+ freeze: false,
73
+ disableMaxInitCodeSizeCheck: true,
74
+ common: fakeCommon,
75
+ });
72
76
 
73
77
  this.common = fakeCommon;
74
78
  this._sender = sender;
@@ -67,7 +67,11 @@ export class ReadOnlyValidEIP2930Transaction extends AccessListEIP2930Transactio
67
67
  }
68
68
  );
69
69
 
70
- super(data, { freeze: false, common: fakeCommon });
70
+ super(data, {
71
+ freeze: false,
72
+ disableMaxInitCodeSizeCheck: true,
73
+ common: fakeCommon,
74
+ });
71
75
 
72
76
  this.common = fakeCommon;
73
77
  this._sender = sender;
@@ -56,7 +56,7 @@ export class ReadOnlyValidTransaction extends Transaction {
56
56
  private readonly _sender: Address;
57
57
 
58
58
  constructor(sender: Address, data: TxData = {}) {
59
- super(data, { freeze: false });
59
+ super(data, { freeze: false, disableMaxInitCodeSizeCheck: true });
60
60
 
61
61
  this.common = this._getCommon();
62
62
  this._sender = sender;
@@ -47,7 +47,7 @@ export class ReadOnlyValidUnknownTypeTransaction extends Transaction {
47
47
  private readonly _actualType: number;
48
48
 
49
49
  constructor(sender: Address, type: number, data: TxData = {}) {
50
- super(data, { freeze: false });
50
+ super(data, { freeze: false, disableMaxInitCodeSizeCheck: true });
51
51
 
52
52
  this.common = this._getCommon();
53
53
  this._sender = sender;
@@ -292,11 +292,30 @@ export class Resolver {
292
292
  nodeModulesPath = path.dirname(nodeModulesPath);
293
293
  }
294
294
 
295
- await this._validateSourceNameExistenceAndCasing(
296
- nodeModulesPath,
297
- sourceName,
298
- true
299
- );
295
+ let absolutePath: string;
296
+ if (path.basename(nodeModulesPath) !== NODE_MODULES) {
297
+ // this can happen in monorepos that use PnP, in those
298
+ // cases we handle resolution differently
299
+ const packageRoot = path.dirname(packageJsonPath);
300
+ const pattern = new RegExp(`^${libraryName}/?`);
301
+ const fileName = sourceName.replace(pattern, "");
302
+
303
+ await this._validateSourceNameExistenceAndCasing(
304
+ packageRoot,
305
+ // TODO: this is _not_ a source name; we should handle this scenario in
306
+ // a better way
307
+ fileName,
308
+ true
309
+ );
310
+ absolutePath = path.join(packageRoot, fileName);
311
+ } else {
312
+ await this._validateSourceNameExistenceAndCasing(
313
+ nodeModulesPath,
314
+ sourceName,
315
+ true
316
+ );
317
+ absolutePath = path.join(nodeModulesPath, sourceName);
318
+ }
300
319
 
301
320
  const packageInfo: {
302
321
  name: string;
@@ -307,7 +326,7 @@ export class Resolver {
307
326
  return this._resolveFile(
308
327
  sourceName,
309
328
  // We resolve to the real path here, as we may be resolving a linked library
310
- await getRealPath(path.join(nodeModulesPath, sourceName)),
329
+ await getRealPath(absolutePath),
311
330
  libraryName,
312
331
  libraryVersion
313
332
  );
@@ -16,6 +16,7 @@ export enum HardforkName {
16
16
  ARROW_GLACIER = "arrowGlacier",
17
17
  GRAY_GLACIER = "grayGlacier",
18
18
  MERGE = "merge",
19
+ SHANGHAI = "shanghai",
19
20
  }
20
21
 
21
22
  const HARDFORKS_ORDER: HardforkName[] = [
@@ -34,6 +35,7 @@ const HARDFORKS_ORDER: HardforkName[] = [
34
35
  HardforkName.ARROW_GLACIER,
35
36
  HardforkName.GRAY_GLACIER,
36
37
  HardforkName.MERGE,
38
+ HardforkName.SHANGHAI,
37
39
  ];
38
40
 
39
41
  export function getHardforkName(name: string): HardforkName {
@@ -1,27 +0,0 @@
1
- /// <reference types="node" />
2
- import { Address } from "@nomicfoundation/ethereumjs-util";
3
- import { StateManager, Account, Bytecode, AccountData } from "rethnet-evm";
4
- import { GenesisAccount } from "./node-types";
5
- export declare class RethnetStateManager {
6
- private _state;
7
- constructor(_state?: StateManager);
8
- static withGenesisAccounts(genesisAccounts: GenesisAccount[]): RethnetStateManager;
9
- asInner(): StateManager;
10
- accountExists(address: Address): Promise<boolean>;
11
- getAccount(address: Address): Promise<Account | null>;
12
- getAccountStorageRoot(address: Address): Promise<Buffer | null>;
13
- accountIsEmpty(address: Address): Promise<boolean>;
14
- deleteAccount(address: Address): Promise<void>;
15
- makeSnapshot(): Promise<[Buffer, boolean]>;
16
- removeSnapshot(stateRoot: Buffer): Promise<boolean>;
17
- modifyAccount(address: Address, modifyAccountFn: (balance: bigint, nonce: bigint, code: Bytecode | undefined) => Promise<AccountData>): Promise<void>;
18
- getContractCode(address: Address): Promise<Buffer>;
19
- getContractStorage(address: Address, key: Buffer): Promise<Buffer>;
20
- putContractStorage(address: Address, key: Buffer, value: Buffer): Promise<void>;
21
- checkpoint(): Promise<void>;
22
- commit(): Promise<void>;
23
- revert(): Promise<void>;
24
- getStateRoot(): Promise<Buffer>;
25
- setStateRoot(stateRoot: Buffer): Promise<void>;
26
- }
27
- //# sourceMappingURL=RethnetState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RethnetState.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/RethnetState.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAGR,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAK9C,qBAAa,mBAAmB;IAClB,OAAO,CAAC,MAAM;gBAAN,MAAM,GAAE,YAAiC;WAE/C,mBAAmB,CAC/B,eAAe,EAAE,cAAc,EAAE,GAChC,mBAAmB;IAaf,OAAO,IAAI,YAAY;IAIjB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAIrD,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI/D,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAUlD,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,YAAY,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAK1C,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,aAAa,CACxB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,CACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,QAAQ,GAAG,SAAS,KACvB,OAAO,CAAC,WAAW,CAAC,GACxB,OAAO,CAAC,IAAI,CAAC;IAIH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAclD,kBAAkB,CAC7B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC;IAOL,kBAAkB,CAC7B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAOH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5D"}
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RethnetStateManager = void 0;
4
- const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
5
- const rethnet_evm_1 = require("rethnet-evm");
6
- /* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
7
- /* eslint-disable @typescript-eslint/no-unused-vars */
8
- class RethnetStateManager {
9
- constructor(_state = new rethnet_evm_1.StateManager()) {
10
- this._state = _state;
11
- }
12
- static withGenesisAccounts(genesisAccounts) {
13
- return new RethnetStateManager(rethnet_evm_1.StateManager.withGenesisAccounts(genesisAccounts.map((account) => {
14
- return {
15
- privateKey: account.privateKey,
16
- balance: BigInt(account.balance),
17
- };
18
- })));
19
- }
20
- asInner() {
21
- return this._state;
22
- }
23
- async accountExists(address) {
24
- const account = await this._state.getAccountByAddress(address.buf);
25
- return account !== null;
26
- }
27
- async getAccount(address) {
28
- return this._state.getAccountByAddress(address.buf);
29
- }
30
- async getAccountStorageRoot(address) {
31
- return this._state.getAccountStorageRoot(address.buf);
32
- }
33
- async accountIsEmpty(address) {
34
- const account = await this._state.getAccountByAddress(address.buf);
35
- return (account === null ||
36
- (account.balance === 0n &&
37
- account.nonce === 0n &&
38
- account.code === undefined));
39
- }
40
- async deleteAccount(address) {
41
- await this._state.removeAccount(address.buf);
42
- }
43
- async makeSnapshot() {
44
- const snapshot = await this._state.makeSnapshot();
45
- return [snapshot.stateRoot, snapshot.existed];
46
- }
47
- async removeSnapshot(stateRoot) {
48
- return this._state.removeSnapshot(stateRoot);
49
- }
50
- async modifyAccount(address, modifyAccountFn) {
51
- await this._state.modifyAccount(address.buf, modifyAccountFn);
52
- }
53
- async getContractCode(address) {
54
- const account = await this._state.getAccountByAddress(address.buf);
55
- if (account === null) {
56
- return Buffer.allocUnsafe(0);
57
- }
58
- const code = account.code;
59
- if (code !== null) {
60
- return code;
61
- }
62
- return Buffer.from([]);
63
- }
64
- async getContractStorage(address, key) {
65
- const index = (0, ethereumjs_util_1.bufferToBigInt)(key);
66
- const value = await this._state.getAccountStorageSlot(address.buf, index);
67
- return (0, ethereumjs_util_1.toBuffer)(value);
68
- }
69
- async putContractStorage(address, key, value) {
70
- const index = (0, ethereumjs_util_1.bufferToBigInt)(key);
71
- const number = (0, ethereumjs_util_1.bufferToBigInt)(value);
72
- await this._state.setAccountStorageSlot(address.buf, index, number);
73
- }
74
- async checkpoint() {
75
- return this._state.checkpoint();
76
- }
77
- async commit() { }
78
- async revert() {
79
- return this._state.revert();
80
- }
81
- async getStateRoot() {
82
- return this._state.getStateRoot();
83
- }
84
- async setStateRoot(stateRoot) {
85
- return this._state.setStateRoot(stateRoot);
86
- }
87
- }
88
- exports.RethnetStateManager = RethnetStateManager;
89
- //# sourceMappingURL=RethnetState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RethnetState.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/RethnetState.ts"],"names":[],"mappings":"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"}
@@ -1,32 +0,0 @@
1
- /// <reference types="node" />
2
- export declare class Bloom {
3
- bitvector: Buffer;
4
- /**
5
- * Represents a Bloom filter.
6
- */
7
- constructor(bitvector?: Buffer);
8
- /**
9
- * Adds an element to a bit vector of a 64 byte bloom filter.
10
- * @param e - The element to add
11
- */
12
- add(e: Buffer): void;
13
- /**
14
- * Checks if an element is in the bloom.
15
- * @param e - The element to check
16
- */
17
- check(e: Buffer): boolean;
18
- /**
19
- * Checks if multiple topics are in a bloom.
20
- * @returns `true` if every topic is in the bloom
21
- */
22
- multiCheck(topics: Buffer[]): boolean;
23
- /**
24
- * Bitwise or blooms together.
25
- */
26
- or(bloom: Bloom): void;
27
- /**
28
- * Checks equality with another bloom.
29
- */
30
- equals(otherBloom: Bloom): boolean;
31
- }
32
- //# sourceMappingURL=bloom.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bloom.d.ts","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/utils/bloom.ts"],"names":[],"mappings":";AAYA,qBAAa,KAAK;IAChB,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;gBACS,SAAS,CAAC,EAAE,MAAM;IAY9B;;;OAGG;IACI,GAAG,CAAC,CAAC,EAAE,MAAM;IAapB;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAgBhC;;;OAGG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO;IAI5C;;OAEG;IACI,EAAE,CAAC,KAAK,EAAE,KAAK;IAMtB;;OAEG;IACI,MAAM,CAAC,UAAU,EAAE,KAAK,GAAG,OAAO;CAG1C"}