hardhat 2.13.0-dev.4 → 2.13.0

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 (43) hide show
  1. package/internal/cli/bootstrap.js +0 -0
  2. package/internal/cli/cli.js +0 -0
  3. package/package.json +1 -1
  4. package/internal/hardhat-network/provider/RethnetState.d.ts +0 -27
  5. package/internal/hardhat-network/provider/RethnetState.d.ts.map +0 -1
  6. package/internal/hardhat-network/provider/RethnetState.js +0 -89
  7. package/internal/hardhat-network/provider/RethnetState.js.map +0 -1
  8. package/internal/hardhat-network/provider/utils/bloom.d.ts +0 -32
  9. package/internal/hardhat-network/provider/utils/bloom.d.ts.map +0 -1
  10. package/internal/hardhat-network/provider/utils/bloom.js +0 -79
  11. package/internal/hardhat-network/provider/utils/bloom.js.map +0 -1
  12. package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts +0 -12
  13. package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts.map +0 -1
  14. package/internal/hardhat-network/provider/utils/convertToRethnet.js +0 -162
  15. package/internal/hardhat-network/provider/utils/convertToRethnet.js.map +0 -1
  16. package/internal/hardhat-network/provider/vm/block-builder.d.ts +0 -31
  17. package/internal/hardhat-network/provider/vm/block-builder.d.ts.map +0 -1
  18. package/internal/hardhat-network/provider/vm/block-builder.js +0 -151
  19. package/internal/hardhat-network/provider/vm/block-builder.js.map +0 -1
  20. package/internal/hardhat-network/provider/vm/creation.d.ts +0 -10
  21. package/internal/hardhat-network/provider/vm/creation.d.ts.map +0 -1
  22. package/internal/hardhat-network/provider/vm/creation.js +0 -29
  23. package/internal/hardhat-network/provider/vm/creation.js.map +0 -1
  24. package/internal/hardhat-network/provider/vm/dual.d.ts +0 -44
  25. package/internal/hardhat-network/provider/vm/dual.d.ts.map +0 -1
  26. package/internal/hardhat-network/provider/vm/dual.js +0 -501
  27. package/internal/hardhat-network/provider/vm/dual.js.map +0 -1
  28. package/internal/hardhat-network/provider/vm/ethereumjs.d.ts +0 -57
  29. package/internal/hardhat-network/provider/vm/ethereumjs.d.ts.map +0 -1
  30. package/internal/hardhat-network/provider/vm/ethereumjs.js +0 -420
  31. package/internal/hardhat-network/provider/vm/ethereumjs.js.map +0 -1
  32. package/internal/hardhat-network/provider/vm/exit.d.ts +0 -23
  33. package/internal/hardhat-network/provider/vm/exit.d.ts.map +0 -1
  34. package/internal/hardhat-network/provider/vm/exit.js +0 -130
  35. package/internal/hardhat-network/provider/vm/exit.js.map +0 -1
  36. package/internal/hardhat-network/provider/vm/rethnet.d.ts +0 -100
  37. package/internal/hardhat-network/provider/vm/rethnet.d.ts.map +0 -1
  38. package/internal/hardhat-network/provider/vm/rethnet.js +0 -287
  39. package/internal/hardhat-network/provider/vm/rethnet.js.map +0 -1
  40. package/internal/hardhat-network/provider/vm/vm-adapter.d.ts +0 -53
  41. package/internal/hardhat-network/provider/vm/vm-adapter.d.ts.map +0 -1
  42. package/internal/hardhat-network/provider/vm/vm-adapter.js +0 -3
  43. package/internal/hardhat-network/provider/vm/vm-adapter.js.map +0 -1
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hardhat",
3
- "version": "2.13.0-dev.4",
3
+ "version": "2.13.0",
4
4
  "author": "Nomic Labs LLC",
5
5
  "license": "MIT",
6
6
  "homepage": "https://hardhat.org",
@@ -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":";;;AAAA,sEAI0C;AAC1C,6CAA2E;AAG3E,yEAAyE;AACzE,sDAAsD;AAEtD,MAAa,mBAAmB;IAC9B,YAAoB,SAAuB,IAAI,0BAAY,EAAE;QAAzC,WAAM,GAAN,MAAM,CAAmC;IAAG,CAAC;IAE1D,MAAM,CAAC,mBAAmB,CAC/B,eAAiC;QAEjC,OAAO,IAAI,mBAAmB,CAC5B,0BAAY,CAAC,mBAAmB,CAC9B,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO;gBACL,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;aACjC,CAAC;QACJ,CAAC,CAAC,CACH,CACF,CAAC;IACJ,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,OAAgB;QACzC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnE,OAAO,OAAO,KAAK,IAAI,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,OAAgB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,OAAgB;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,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
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"}
@@ -1,79 +0,0 @@
1
- "use strict";
2
- // This code was adapted from ethereumjs and is distributed under their license: https://github.com/ethereumjs/ethereumjs-monorepo/blob/161a4029c2fc24e5d04da6ad3aab4ac3c72af0f8/packages/vm/LICENSE
3
- // For the original context see: https://github.com/ethereumjs/ethereumjs-monorepo/blob/161a4029c2fc24e5d04da6ad3aab4ac3c72af0f8/packages/vm/src/bloom/index.ts
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.Bloom = void 0;
6
- const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
7
- const keccak_1 = require("ethereum-cryptography/keccak");
8
- const errors_1 = require("../../../core/errors");
9
- /* eslint-disable no-bitwise */
10
- const BYTE_SIZE = 256;
11
- class Bloom {
12
- /**
13
- * Represents a Bloom filter.
14
- */
15
- constructor(bitvector) {
16
- if (bitvector === undefined) {
17
- this.bitvector = (0, ethereumjs_util_1.zeros)(BYTE_SIZE);
18
- }
19
- else {
20
- (0, errors_1.assertHardhatInvariant)(bitvector.length === BYTE_SIZE, "bitvectors must be 2048 bits long");
21
- this.bitvector = bitvector;
22
- }
23
- }
24
- /**
25
- * Adds an element to a bit vector of a 64 byte bloom filter.
26
- * @param e - The element to add
27
- */
28
- add(e) {
29
- e = Buffer.from((0, keccak_1.keccak256)(e));
30
- const mask = 2047; // binary 11111111111
31
- for (let i = 0; i < 3; i++) {
32
- const first2bytes = e.readUInt16BE(i * 2);
33
- const loc = mask & first2bytes;
34
- const byteLoc = loc >> 3;
35
- const bitLoc = 1 << loc % 8;
36
- this.bitvector[BYTE_SIZE - byteLoc - 1] |= bitLoc;
37
- }
38
- }
39
- /**
40
- * Checks if an element is in the bloom.
41
- * @param e - The element to check
42
- */
43
- check(e) {
44
- e = Buffer.from((0, keccak_1.keccak256)(e));
45
- const mask = 2047; // binary 11111111111
46
- let match = true;
47
- for (let i = 0; i < 3 && match; i++) {
48
- const first2bytes = e.readUInt16BE(i * 2);
49
- const loc = mask & first2bytes;
50
- const byteLoc = loc >> 3;
51
- const bitLoc = 1 << loc % 8;
52
- match = (this.bitvector[BYTE_SIZE - byteLoc - 1] & bitLoc) !== 0;
53
- }
54
- return Boolean(match);
55
- }
56
- /**
57
- * Checks if multiple topics are in a bloom.
58
- * @returns `true` if every topic is in the bloom
59
- */
60
- multiCheck(topics) {
61
- return topics.every((t) => this.check(t));
62
- }
63
- /**
64
- * Bitwise or blooms together.
65
- */
66
- or(bloom) {
67
- for (let i = 0; i <= BYTE_SIZE; i++) {
68
- this.bitvector[i] = this.bitvector[i] | bloom.bitvector[i];
69
- }
70
- }
71
- /**
72
- * Checks equality with another bloom.
73
- */
74
- equals(otherBloom) {
75
- return this.bitvector.equals(otherBloom.bitvector);
76
- }
77
- }
78
- exports.Bloom = Bloom;
79
- //# sourceMappingURL=bloom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bloom.js","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/utils/bloom.ts"],"names":[],"mappings":";AAAA,oMAAoM;AACpM,+JAA+J;;;AAE/J,sEAAyD;AACzD,yDAAyD;AAEzD,iDAA8D;AAE9D,+BAA+B;AAE/B,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAa,KAAK;IAGhB;;OAEG;IACH,YAAY,SAAkB;QAC5B,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,IAAI,CAAC,SAAS,GAAG,IAAA,uBAAK,EAAC,SAAS,CAAC,CAAC;SACnC;aAAM;YACL,IAAA,+BAAsB,EACpB,SAAS,CAAC,MAAM,KAAK,SAAS,EAC9B,mCAAmC,CACpC,CAAC;YACF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;SAC5B;IACH,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,CAAS;QAClB,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAA,kBAAS,EAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,qBAAqB;QAExC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,MAAM,WAAW,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,WAAW,CAAC;YAC/B,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,CAAC;YACzB,MAAM,MAAM,GAAG,CAAC,IAAI,GA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,SAAS,CAAC,CAAC,CAAC,CAAC;SAC5D;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAiB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CACF;AA9ED,sBA8EC"}
@@ -1,12 +0,0 @@
1
- /// <reference types="node" />
2
- import { BlockHeader as EthereumJSBlockHeader, HeaderData } from "@nomicfoundation/ethereumjs-block";
3
- import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
4
- import { BlockConfig, BlockHeader as RethnetBlockHeader, ExecutionResult, SpecId, Transaction } from "rethnet-evm";
5
- import { HardforkName } from "../../../util/hardforks";
6
- import { RunTxResult } from "../vm/vm-adapter";
7
- export declare function ethereumjsBlockHeaderToRethnet(blockHeader: EthereumJSBlockHeader): RethnetBlockHeader;
8
- export declare function ethereumsjsHardforkToRethnet(hardfork: HardforkName): SpecId;
9
- export declare function ethereumjsHeaderDataToRethnet(headerData?: HeaderData, difficulty?: bigint, prevRandao?: Buffer): BlockConfig;
10
- export declare function ethereumjsTransactionToRethnet(tx: TypedTransaction): Transaction;
11
- export declare function rethnetResultToRunTxResult(rethnetResult: ExecutionResult, blockGasUsed: bigint): RunTxResult;
12
- //# sourceMappingURL=convertToRethnet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertToRethnet.d.ts","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/utils/convertToRethnet.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,IAAI,qBAAqB,EACpC,UAAU,EACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGL,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,WAAW,EACX,WAAW,IAAI,kBAAkB,EACjC,eAAe,EAEf,MAAM,EACN,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAQvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK/C,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,qBAAqB,GACjC,kBAAkB,CAmBpB;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAsC3E;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,CAAC,EAAE,UAAU,EACvB,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,WAAW,CAgBb;AAED,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,gBAAgB,GACnB,WAAW,CA0Bb;AAaD,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,eAAe,EAC9B,YAAY,EAAE,MAAM,GACnB,WAAW,CA0Cb"}
@@ -1,162 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rethnetResultToRunTxResult = exports.ethereumjsTransactionToRethnet = exports.ethereumjsHeaderDataToRethnet = exports.ethereumsjsHardforkToRethnet = exports.ethereumjsBlockHeaderToRethnet = void 0;
4
- const ethereumjs_tx_1 = require("@nomicfoundation/ethereumjs-tx");
5
- const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
6
- const bigint_1 = require("../../../util/bigint");
7
- const hardforks_1 = require("../../../util/hardforks");
8
- const message_trace_1 = require("../../stack-traces/message-trace");
9
- const exit_1 = require("../vm/exit");
10
- const bloom_1 = require("./bloom");
11
- /* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
12
- function ethereumjsBlockHeaderToRethnet(blockHeader) {
13
- return {
14
- parentHash: blockHeader.parentHash,
15
- ommersHash: blockHeader.uncleHash,
16
- beneficiary: blockHeader.coinbase.buf,
17
- stateRoot: blockHeader.stateRoot,
18
- transactionsRoot: blockHeader.transactionsTrie,
19
- receiptsRoot: blockHeader.receiptTrie,
20
- logsBloom: blockHeader.logsBloom,
21
- difficulty: blockHeader.difficulty,
22
- number: blockHeader.number,
23
- gasLimit: blockHeader.gasLimit,
24
- gasUsed: blockHeader.gasUsed,
25
- timestamp: blockHeader.timestamp,
26
- extraData: blockHeader.extraData,
27
- mixHash: blockHeader.mixHash,
28
- nonce: BigInt(`0x${blockHeader.nonce.toString("hex")}`),
29
- baseFeePerGas: blockHeader.baseFeePerGas,
30
- };
31
- }
32
- exports.ethereumjsBlockHeaderToRethnet = ethereumjsBlockHeaderToRethnet;
33
- function ethereumsjsHardforkToRethnet(hardfork) {
34
- switch (hardfork) {
35
- case hardforks_1.HardforkName.FRONTIER:
36
- return 0 /* Frontier */;
37
- case hardforks_1.HardforkName.HOMESTEAD:
38
- return 2 /* Homestead */;
39
- case hardforks_1.HardforkName.DAO:
40
- return 3 /* DaoFork */;
41
- case hardforks_1.HardforkName.TANGERINE_WHISTLE:
42
- return 4 /* Tangerine */;
43
- case hardforks_1.HardforkName.SPURIOUS_DRAGON:
44
- return 5 /* SpuriousDragon */;
45
- case hardforks_1.HardforkName.BYZANTIUM:
46
- return 6 /* Byzantium */;
47
- case hardforks_1.HardforkName.CONSTANTINOPLE:
48
- return 7 /* Constantinople */;
49
- case hardforks_1.HardforkName.PETERSBURG:
50
- return 8 /* Petersburg */;
51
- case hardforks_1.HardforkName.ISTANBUL:
52
- return 9 /* Istanbul */;
53
- case hardforks_1.HardforkName.MUIR_GLACIER:
54
- return 10 /* MuirGlacier */;
55
- case hardforks_1.HardforkName.BERLIN:
56
- return 11 /* Berlin */;
57
- case hardforks_1.HardforkName.LONDON:
58
- return 12 /* London */;
59
- case hardforks_1.HardforkName.ARROW_GLACIER:
60
- return 13 /* ArrowGlacier */;
61
- case hardforks_1.HardforkName.GRAY_GLACIER:
62
- return 14 /* GrayGlacier */;
63
- case hardforks_1.HardforkName.MERGE:
64
- return 15 /* Merge */;
65
- default:
66
- const _exhaustiveCheck = hardfork;
67
- throw new Error(`Unknown hardfork name '${hardfork}', this shouldn't happen`);
68
- }
69
- }
70
- exports.ethereumsjsHardforkToRethnet = ethereumsjsHardforkToRethnet;
71
- function ethereumjsHeaderDataToRethnet(headerData, difficulty, prevRandao) {
72
- const coinbase = headerData?.coinbase === undefined
73
- ? undefined
74
- : (0, ethereumjs_util_1.toBuffer)(headerData.coinbase);
75
- return {
76
- number: (0, bigint_1.fromBigIntLike)(headerData?.number),
77
- coinbase,
78
- timestamp: (0, bigint_1.fromBigIntLike)(headerData?.timestamp),
79
- difficulty,
80
- prevrandao: prevRandao,
81
- basefee: (0, bigint_1.fromBigIntLike)(headerData?.baseFeePerGas),
82
- gasLimit: (0, bigint_1.fromBigIntLike)(headerData?.gasLimit),
83
- parentHash: headerData?.parentHash,
84
- };
85
- }
86
- exports.ethereumjsHeaderDataToRethnet = ethereumjsHeaderDataToRethnet;
87
- function ethereumjsTransactionToRethnet(tx) {
88
- const chainId = (_tx) => {
89
- if (_tx instanceof ethereumjs_tx_1.AccessListEIP2930Transaction) {
90
- return _tx.chainId;
91
- }
92
- else if (_tx instanceof ethereumjs_tx_1.FeeMarketEIP1559Transaction) {
93
- return _tx.chainId;
94
- }
95
- else {
96
- return undefined;
97
- }
98
- };
99
- const rethnetTx = {
100
- from: tx.getSenderAddress().toBuffer(),
101
- to: tx.to?.buf,
102
- gasLimit: tx.gasLimit,
103
- gasPrice: tx?.maxFeePerGas ?? tx.gasPrice,
104
- gasPriorityFee: tx?.maxPriorityFeePerGas,
105
- value: tx.value,
106
- nonce: tx.nonce,
107
- input: tx.data,
108
- accessList: tx?.AccessListJSON,
109
- chainId: chainId(tx),
110
- };
111
- return rethnetTx;
112
- }
113
- exports.ethereumjsTransactionToRethnet = ethereumjsTransactionToRethnet;
114
- function rethnetLogsToBloom(logs) {
115
- const bloom = new bloom_1.Bloom();
116
- for (const log of logs) {
117
- bloom.add(log.address);
118
- for (const topic of log.topics) {
119
- bloom.add(topic);
120
- }
121
- }
122
- return bloom;
123
- }
124
- function rethnetResultToRunTxResult(rethnetResult, blockGasUsed) {
125
- const createdAddress = (0, message_trace_1.isSuccessResult)(rethnetResult.result) &&
126
- (0, message_trace_1.isCreateOutput)(rethnetResult.result.output)
127
- ? rethnetResult.result.output.address
128
- : undefined;
129
- const exit = (0, message_trace_1.isSuccessResult)(rethnetResult.result)
130
- ? exit_1.Exit.fromRethnetSuccessReason(rethnetResult.result.reason)
131
- : (0, message_trace_1.isHaltResult)(rethnetResult.result)
132
- ? exit_1.Exit.fromRethnetExceptionalHalt(rethnetResult.result.reason)
133
- : new exit_1.Exit(exit_1.ExitCode.REVERT);
134
- const returnValue = (0, message_trace_1.isRevertResult)(rethnetResult.result)
135
- ? rethnetResult.result.output
136
- : (0, message_trace_1.isSuccessResult)(rethnetResult.result)
137
- ? rethnetResult.result.output.returnValue
138
- : Buffer.from([]);
139
- const bloom = (0, message_trace_1.isSuccessResult)(rethnetResult.result)
140
- ? rethnetLogsToBloom(rethnetResult.result.logs)
141
- : new bloom_1.Bloom(undefined);
142
- return {
143
- gasUsed: rethnetResult.result.gasUsed,
144
- createdAddress: createdAddress !== undefined ? new ethereumjs_util_1.Address(createdAddress) : undefined,
145
- exit,
146
- returnValue,
147
- bloom,
148
- receipt: {
149
- // Receipts have a 0 as status on error
150
- status: exit.isError() ? 0 : 1,
151
- cumulativeBlockGasUsed: blockGasUsed + rethnetResult.result.gasUsed,
152
- bitvector: bloom.bitvector,
153
- logs: (0, message_trace_1.isSuccessResult)(rethnetResult.result)
154
- ? rethnetResult.result.logs.map((log) => {
155
- return [log.address, log.topics, log.data];
156
- })
157
- : [],
158
- },
159
- };
160
- }
161
- exports.rethnetResultToRunTxResult = rethnetResultToRunTxResult;
162
- //# sourceMappingURL=convertToRethnet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertToRethnet.js","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/utils/convertToRethnet.ts"],"names":[],"mappings":";;;AAIA,kEAIwC;AACxC,sEAAqE;AASrE,iDAAsD;AACtD,uDAAuD;AACvD,oEAK0C;AAC1C,qCAA4C;AAE5C,mCAAgC;AAEhC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,CAAC,OAAO;YACnE,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,IAAI,EAAE,IAAA,+BAAe,EAAC,aAAa,CAAC,MAAM,CAAC;gBACzC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;oBACpC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC7C,CAAC,CAAC;gBACJ,CAAC,CAAC,EAAE;SACP;KACF,CAAC;AACJ,CAAC;AA7CD,gEA6CC"}
@@ -1,31 +0,0 @@
1
- import type { Common } from "@nomicfoundation/ethereumjs-common";
2
- import { Block, HeaderData } from "@nomicfoundation/ethereumjs-block";
3
- import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
4
- import { Address } from "@nomicfoundation/ethereumjs-util";
5
- import { RunTxResult, VMAdapter } from "./vm-adapter";
6
- declare type Reward = [address: Address, reward: bigint];
7
- export interface BuildBlockOpts {
8
- parentBlock: Block;
9
- headerData?: HeaderData;
10
- }
11
- export declare class BlockBuilder {
12
- private _vm;
13
- private _common;
14
- private _opts;
15
- private _state;
16
- private _gasUsed;
17
- private _transactions;
18
- private _transactionResults;
19
- constructor(_vm: VMAdapter, _common: Common, _opts: BuildBlockOpts);
20
- startBlock(): Promise<void>;
21
- getGasUsed(): bigint;
22
- addTransaction(tx: TypedTransaction): Promise<RunTxResult>;
23
- addRewards(rewards: Reward[]): Promise<void>;
24
- seal(): Promise<Block>;
25
- revert(): Promise<void>;
26
- private _getTransactionsTrie;
27
- private _getReceiptsTrie;
28
- private _getLogsBloom;
29
- }
30
- export {};
31
- //# sourceMappingURL=block-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"block-builder.d.ts","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/vm/block-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,OAAO,EAIR,MAAM,kCAAkC,CAAC;AAS1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAItD,aAAK,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAcD,qBAAa,YAAY;IAOrB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,KAAK;IARf,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,mBAAmB,CAAqB;gBAGtC,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,cAAc;IAGlB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,UAAU,IAAI,MAAM;IAId,cAAc,CAAC,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;IAyC1D,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5C,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC;IAoDtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;YAWtB,oBAAoB;YAQpB,gBAAgB;IAU9B,OAAO,CAAC,aAAa;CAQtB"}
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlockBuilder = void 0;
4
- const ethereumjs_block_1 = require("@nomicfoundation/ethereumjs-block");
5
- const ethereumjs_rlp_1 = require("@nomicfoundation/ethereumjs-rlp");
6
- const ethereumjs_trie_1 = require("@nomicfoundation/ethereumjs-trie");
7
- const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
8
- const bigint_1 = require("../../../util/bigint");
9
- const bloom_1 = require("../utils/bloom");
10
- class BlockBuilder {
11
- constructor(_vm, _common, _opts) {
12
- this._vm = _vm;
13
- this._common = _common;
14
- this._opts = _opts;
15
- this._state = "ready";
16
- this._gasUsed = 0n;
17
- this._transactions = [];
18
- this._transactionResults = [];
19
- }
20
- async startBlock() {
21
- await this._vm.startBlock();
22
- this._state = "started";
23
- }
24
- getGasUsed() {
25
- return this._gasUsed;
26
- }
27
- async addTransaction(tx) {
28
- if (this._state !== "started") {
29
- throw new Error(`BlockBuilder.addTransaction cannot be used in state ${this._state}`);
30
- }
31
- const blockGasLimit = (0, bigint_1.fromBigIntLike)(this._opts.headerData?.gasLimit) ?? 1000000n;
32
- const blockGasRemaining = blockGasLimit - this._gasUsed;
33
- if (tx.gasLimit > blockGasRemaining) {
34
- throw new Error("tx has a higher gas limit than the remaining gas in the block");
35
- }
36
- const header = {
37
- ...this._opts.headerData,
38
- gasUsed: this._gasUsed,
39
- };
40
- if (header.number === undefined) {
41
- header.number = this._opts.parentBlock.header.number + 1n;
42
- }
43
- const blockData = { header, transactions: this._transactions };
44
- const block = ethereumjs_block_1.Block.fromBlockData(blockData, {
45
- common: this._common,
46
- skipConsensusFormatValidation: true,
47
- calcDifficultyFromHeader: this._opts.parentBlock.header,
48
- });
49
- const [result] = await this._vm.runTxInBlock(tx, block);
50
- this._transactions.push(tx);
51
- this._transactionResults.push(result);
52
- this._gasUsed += result.gasUsed;
53
- return result;
54
- }
55
- async addRewards(rewards) {
56
- if (this._state !== "started") {
57
- throw new Error(`BlockBuilder.addRewards cannot be used in state ${this._state}`);
58
- }
59
- await this._vm.addBlockRewards(rewards);
60
- this._state = "rewarded";
61
- }
62
- async seal() {
63
- if (this._state !== "rewarded") {
64
- throw new Error(`BlockBuilder.seal cannot be used in state ${this._state}`);
65
- }
66
- const stateRoot = await this._vm.getStateRoot();
67
- const transactionsTrie = await this._getTransactionsTrie();
68
- const receiptTrie = await this._getReceiptsTrie();
69
- const logsBloom = this._getLogsBloom();
70
- const gasUsed = this._gasUsed;
71
- const timestamp = this._opts.headerData?.timestamp ?? Math.round(Date.now() / 1000);
72
- const headerData = {
73
- ...this._opts.headerData,
74
- stateRoot,
75
- transactionsTrie,
76
- receiptTrie,
77
- logsBloom,
78
- gasUsed,
79
- timestamp,
80
- };
81
- const blockData = {
82
- header: {
83
- ...headerData,
84
- parentHash: this._opts.headerData?.parentHash ?? this._opts.parentBlock.hash(),
85
- number: this._opts.headerData?.number ??
86
- this._opts.parentBlock.header.number + BigInt(1),
87
- gasLimit: this._opts.headerData?.gasLimit ??
88
- this._opts.parentBlock.header.gasLimit,
89
- },
90
- transactions: this._transactions,
91
- };
92
- const block = ethereumjs_block_1.Block.fromBlockData(blockData, {
93
- common: this._common,
94
- skipConsensusFormatValidation: true,
95
- calcDifficultyFromHeader: this._opts.parentBlock.header,
96
- });
97
- await this._vm.sealBlock();
98
- this._state = "sealed";
99
- return block;
100
- }
101
- async revert() {
102
- if (this._state !== "started" && this._state !== "rewarded") {
103
- throw new Error(`BlockBuilder.revert cannot be used in state ${this._state}`);
104
- }
105
- await this._vm.revertBlock();
106
- this._state = "reverted";
107
- }
108
- async _getTransactionsTrie() {
109
- const trie = new ethereumjs_trie_1.Trie();
110
- for (const [i, tx] of this._transactions.entries()) {
111
- await trie.put(Buffer.from(ethereumjs_rlp_1.RLP.encode(i)), tx.serialize());
112
- }
113
- return trie.root();
114
- }
115
- async _getReceiptsTrie() {
116
- const receiptTrie = new ethereumjs_trie_1.Trie();
117
- for (const [i, txResult] of this._transactionResults.entries()) {
118
- const tx = this._transactions[i];
119
- const encodedReceipt = encodeReceipt(txResult.receipt, tx.type);
120
- await receiptTrie.put(Buffer.from(ethereumjs_rlp_1.RLP.encode(i)), encodedReceipt);
121
- }
122
- return receiptTrie.root();
123
- }
124
- _getLogsBloom() {
125
- const bloom = new bloom_1.Bloom();
126
- for (const txResult of this._transactionResults) {
127
- // Combine blooms via bitwise OR
128
- bloom.or(txResult.bloom);
129
- }
130
- return bloom.bitvector;
131
- }
132
- }
133
- exports.BlockBuilder = BlockBuilder;
134
- function encodeReceipt(receipt, txType) {
135
- const encoded = Buffer.from(ethereumjs_rlp_1.RLP.encode((0, ethereumjs_util_1.bufArrToArr)([
136
- receipt.stateRoot ??
137
- (receipt.status === 0
138
- ? Buffer.from([])
139
- : Buffer.from("01", "hex")),
140
- (0, ethereumjs_util_1.bigIntToBuffer)(receipt.cumulativeBlockGasUsed),
141
- receipt.bitvector,
142
- receipt.logs,
143
- ])));
144
- if (txType === 0) {
145
- return encoded;
146
- }
147
- // Serialize receipt according to EIP-2718:
148
- // `typed-receipt = tx-type || receipt-data`
149
- return Buffer.concat([(0, ethereumjs_util_1.intToBuffer)(txType), encoded]);
150
- }
151
- //# sourceMappingURL=block-builder.js.map