hardhat 2.19.5 → 2.20.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.
- package/builtin-tasks/node.js +3 -3
- package/builtin-tasks/node.js.map +1 -1
- package/internal/cli/analytics.d.ts.map +1 -1
- package/internal/cli/analytics.js +2 -1
- package/internal/cli/analytics.js.map +1 -1
- package/internal/cli/project-creation.d.ts +1 -1
- package/internal/cli/project-creation.js +1 -1
- package/internal/constants.d.ts.map +1 -1
- package/internal/constants.js +1 -0
- package/internal/constants.js.map +1 -1
- package/internal/core/config/config-resolution.d.ts.map +1 -1
- package/internal/core/config/config-resolution.js +8 -0
- package/internal/core/config/config-resolution.js.map +1 -1
- package/internal/core/config/config-validation.d.ts.map +1 -1
- package/internal/core/config/config-validation.js +10 -0
- package/internal/core/config/config-validation.js.map +1 -1
- package/internal/core/config/default-config.d.ts.map +1 -1
- package/internal/core/config/default-config.js +11 -0
- package/internal/core/config/default-config.js.map +1 -1
- package/internal/core/jsonrpc/types/base-types.d.ts +1 -1
- package/internal/core/jsonrpc/types/base-types.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/base-types.js +7 -5
- package/internal/core/jsonrpc/types/base-types.js.map +1 -1
- package/internal/core/jsonrpc/types/input/callRequest.d.ts +2 -0
- package/internal/core/jsonrpc/types/input/callRequest.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/callRequest.js +2 -0
- package/internal/core/jsonrpc/types/input/callRequest.js.map +1 -1
- package/internal/core/jsonrpc/types/input/transactionRequest.d.ts +4 -0
- package/internal/core/jsonrpc/types/input/transactionRequest.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/transactionRequest.js +2 -0
- package/internal/core/jsonrpc/types/input/transactionRequest.js.map +1 -1
- package/internal/core/jsonrpc/types/output/block.d.ts +6 -0
- package/internal/core/jsonrpc/types/output/block.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/output/block.js +3 -0
- package/internal/core/jsonrpc/types/output/block.js.map +1 -1
- package/internal/core/providers/accounts.d.ts.map +1 -1
- package/internal/core/providers/accounts.js +10 -10
- package/internal/core/providers/accounts.js.map +1 -1
- package/internal/core/providers/util.js +2 -2
- package/internal/core/providers/util.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.d.ts +3 -3
- package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.js +9 -9
- package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.d.ts +5 -5
- package/internal/hardhat-network/provider/BlockchainData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.js +10 -10
- package/internal/hardhat-network/provider/BlockchainData.js.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts +7 -0
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.js +14 -2
- package/internal/hardhat-network/provider/HardhatBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/TxPool.d.ts +2 -3
- package/internal/hardhat-network/provider/TxPool.d.ts.map +1 -1
- package/internal/hardhat-network/provider/TxPool.js +16 -16
- package/internal/hardhat-network/provider/TxPool.js.map +1 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js +1 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js.map +1 -1
- package/internal/hardhat-network/provider/filter.d.ts +5 -6
- package/internal/hardhat-network/provider/filter.d.ts.map +1 -1
- package/internal/hardhat-network/provider/filter.js +2 -2
- package/internal/hardhat-network/provider/filter.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts +7 -0
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js +21 -4
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts +16 -9
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.js +42 -25
- package/internal/hardhat-network/provider/fork/ForkStateManager.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js +3 -0
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts +2 -2
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/base.js +4 -4
- package/internal/hardhat-network/provider/modules/base.js.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.js +16 -9
- package/internal/hardhat-network/provider/modules/eth.js.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.d.ts +1 -1
- package/internal/hardhat-network/provider/modules/logger.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.js +17 -17
- package/internal/hardhat-network/provider/modules/logger.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +17 -13
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +6 -2
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +148 -79
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/output.d.ts +3 -0
- package/internal/hardhat-network/provider/output.d.ts.map +1 -1
- package/internal/hardhat-network/provider/output.js +23 -9
- package/internal/hardhat-network/provider/output.js.map +1 -1
- package/internal/hardhat-network/provider/return-data.d.ts +3 -4
- package/internal/hardhat-network/provider/return-data.d.ts.map +1 -1
- package/internal/hardhat-network/provider/return-data.js +4 -3
- package/internal/hardhat-network/provider/return-data.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts +8 -10
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +9 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts +8 -10
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +9 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts +9 -10
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +6 -7
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts +5 -6
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts +4 -5
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts +7 -8
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +2 -2
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts +7 -8
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js +2 -2
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts +4 -5
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeAccount.js +1 -1
- package/internal/hardhat-network/provider/utils/makeAccount.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.js +5 -3
- package/internal/hardhat-network/provider/utils/makeCommon.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +2 -2
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +15 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.js +2 -2
- package/internal/hardhat-network/provider/utils/makeStateTrie.js.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +1 -3
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +6 -2
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
- package/internal/hardhat-network/provider/utils/random.d.ts +3 -3
- package/internal/hardhat-network/provider/utils/random.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/random.js +2 -2
- package/internal/hardhat-network/provider/utils/random.js.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js +42 -44
- 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/contracts-identifier.js +1 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.js.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +12 -12
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +5 -4
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/library-utils.d.ts +4 -4
- package/internal/hardhat-network/stack-traces/library-utils.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/library-utils.js.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts +8 -9
- package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.d.ts +5 -5
- package/internal/hardhat-network/stack-traces/model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +5 -5
- package/internal/hardhat-network/stack-traces/model.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 +3 -3
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +2 -3
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +3 -2
- package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +34 -28
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts +1 -2
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.js +9 -9
- package/internal/hardhat-network/stack-traces/vm-tracer.js.map +1 -1
- package/internal/solidity/compiler/downloader.d.ts.map +1 -1
- package/internal/solidity/compiler/downloader.js +2 -2
- package/internal/solidity/compiler/downloader.js.map +1 -1
- package/internal/solidity/compiler/solc-info.d.ts.map +1 -1
- package/internal/solidity/compiler/solc-info.js +1 -0
- package/internal/solidity/compiler/solc-info.js.map +1 -1
- package/internal/util/abi-helpers.d.ts +2 -3
- package/internal/util/abi-helpers.d.ts.map +1 -1
- package/internal/util/abi-helpers.js.map +1 -1
- package/internal/util/bigint.d.ts +1 -2
- package/internal/util/bigint.d.ts.map +1 -1
- package/internal/util/bigint.js +2 -2
- package/internal/util/bigint.js.map +1 -1
- package/internal/util/hardforks.d.ts +2 -1
- package/internal/util/hardforks.d.ts.map +1 -1
- package/internal/util/hardforks.js +2 -0
- package/internal/util/hardforks.js.map +1 -1
- package/internal/util/keccak.d.ts +1 -2
- package/internal/util/keccak.d.ts.map +1 -1
- package/internal/util/keccak.js +1 -1
- package/internal/util/keccak.js.map +1 -1
- package/package.json +12 -11
- package/sample-projects/javascript/contracts/Lock.sol +1 -1
- package/sample-projects/javascript/hardhat.config.js +1 -1
- package/sample-projects/javascript-esm/contracts/Lock.sol +1 -1
- package/sample-projects/javascript-esm/hardhat.config.cjs +1 -1
- package/sample-projects/typescript/contracts/Lock.sol +1 -1
- package/sample-projects/typescript/hardhat.config.ts +1 -1
- package/sample-projects/typescript-viem/contracts/Lock.sol +1 -1
- package/sample-projects/typescript-viem/hardhat.config.ts +1 -1
- package/src/builtin-tasks/node.ts +8 -4
- package/src/internal/cli/analytics.ts +4 -1
- package/src/internal/cli/project-creation.ts +1 -1
- package/src/internal/constants.ts +1 -0
- package/src/internal/core/config/config-resolution.ts +13 -0
- package/src/internal/core/config/config-validation.ts +19 -0
- package/src/internal/core/config/default-config.ts +11 -0
- package/src/internal/core/jsonrpc/types/base-types.ts +12 -7
- package/src/internal/core/jsonrpc/types/input/callRequest.ts +3 -0
- package/src/internal/core/jsonrpc/types/input/transactionRequest.ts +5 -1
- package/src/internal/core/jsonrpc/types/output/block.ts +3 -0
- package/src/internal/core/providers/accounts.ts +24 -13
- package/src/internal/core/providers/util.ts +2 -2
- package/src/internal/hardhat-network/jsonrpc/client.ts +7 -4
- package/src/internal/hardhat-network/provider/BlockchainData.ts +6 -6
- package/src/internal/hardhat-network/provider/HardhatBlockchain.ts +28 -3
- package/src/internal/hardhat-network/provider/TxPool.ts +19 -16
- package/src/internal/hardhat-network/provider/ethereumjs-workarounds.ts +4 -5
- package/src/internal/hardhat-network/provider/filter.ts +11 -8
- package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +40 -7
- package/src/internal/hardhat-network/provider/fork/ForkStateManager.ts +79 -39
- package/src/internal/hardhat-network/provider/fork/rpcToBlockData.ts +3 -0
- package/src/internal/hardhat-network/provider/fork/rpcToTxData.ts +2 -2
- package/src/internal/hardhat-network/provider/modules/base.ts +5 -5
- package/src/internal/hardhat-network/provider/modules/eth.ts +40 -14
- package/src/internal/hardhat-network/provider/modules/logger.ts +17 -14
- package/src/internal/hardhat-network/provider/node-types.ts +19 -12
- package/src/internal/hardhat-network/provider/node.ts +210 -86
- package/src/internal/hardhat-network/provider/output.ts +35 -8
- package/src/internal/hardhat-network/provider/return-data.ts +6 -5
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +24 -25
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +24 -25
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +27 -16
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.ts +7 -8
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.ts +6 -5
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.ts +15 -8
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.ts +15 -8
- package/src/internal/hardhat-network/provider/types/HardhatBlockchainInterface.ts +4 -4
- package/src/internal/hardhat-network/provider/utils/makeAccount.ts +2 -2
- package/src/internal/hardhat-network/provider/utils/makeCommon.ts +9 -3
- package/src/internal/hardhat-network/provider/utils/makeFakeSignature.ts +21 -7
- package/src/internal/hardhat-network/provider/utils/makeStateTrie.ts +3 -3
- package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +10 -5
- package/src/internal/hardhat-network/provider/utils/random.ts +5 -5
- package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +13 -13
- package/src/internal/hardhat-network/stack-traces/constants.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +4 -4
- package/src/internal/hardhat-network/stack-traces/debug.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +6 -5
- package/src/internal/hardhat-network/stack-traces/library-utils.ts +6 -6
- package/src/internal/hardhat-network/stack-traces/message-trace.ts +8 -8
- package/src/internal/hardhat-network/stack-traces/model.ts +5 -5
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +4 -2
- package/src/internal/hardhat-network/stack-traces/solidity-stack-trace.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +3 -2
- package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +49 -38
- package/src/internal/hardhat-network/stack-traces/vm-tracer.ts +15 -13
- package/src/internal/solidity/compiler/downloader.ts +3 -2
- package/src/internal/solidity/compiler/solc-info.ts +1 -0
- package/src/internal/util/abi-helpers.ts +2 -2
- package/src/internal/util/bigint.ts +4 -4
- package/src/internal/util/hardforks.ts +2 -0
- package/src/internal/util/keccak.ts +2 -2
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Common,
|
|
3
|
+
StateManagerInterface,
|
|
4
|
+
} from "@nomicfoundation/ethereumjs-common";
|
|
2
5
|
import {
|
|
3
6
|
TransactionFactory,
|
|
4
7
|
TypedTransaction,
|
|
5
8
|
} from "@nomicfoundation/ethereumjs-tx";
|
|
6
|
-
import { StateManager } from "@nomicfoundation/ethereumjs-statemanager";
|
|
7
9
|
import {
|
|
8
10
|
Address,
|
|
9
|
-
bufferToHex,
|
|
10
|
-
|
|
11
|
+
bytesToHex as bufferToHex,
|
|
12
|
+
equalsBytes,
|
|
13
|
+
toBytes,
|
|
11
14
|
} from "@nomicfoundation/ethereumjs-util";
|
|
12
15
|
import { List as ImmutableList, Record as ImmutableRecord } from "immutable";
|
|
13
16
|
|
|
@@ -56,7 +59,7 @@ export function deserializeTransaction(
|
|
|
56
59
|
let data;
|
|
57
60
|
if (fakeFrom !== undefined) {
|
|
58
61
|
const sender = Address.fromString(fakeFrom);
|
|
59
|
-
const serialization =
|
|
62
|
+
const serialization = toBytes(rlpSerialization);
|
|
60
63
|
|
|
61
64
|
if (tx.get("txType") === 1) {
|
|
62
65
|
data =
|
|
@@ -79,9 +82,9 @@ export function deserializeTransaction(
|
|
|
79
82
|
);
|
|
80
83
|
}
|
|
81
84
|
} else {
|
|
82
|
-
data = TransactionFactory.fromSerializedData(
|
|
85
|
+
data = TransactionFactory.fromSerializedData(toBytes(rlpSerialization), {
|
|
83
86
|
common,
|
|
84
|
-
|
|
87
|
+
allowUnlimitedInitCodeSize: true,
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
90
|
|
|
@@ -102,7 +105,7 @@ export class TxPool {
|
|
|
102
105
|
) => OrderedTransaction;
|
|
103
106
|
|
|
104
107
|
constructor(
|
|
105
|
-
private readonly _stateManager:
|
|
108
|
+
private readonly _stateManager: StateManagerInterface,
|
|
106
109
|
blockGasLimit: bigint,
|
|
107
110
|
common: Common
|
|
108
111
|
) {
|
|
@@ -282,8 +285,8 @@ export class TxPool {
|
|
|
282
285
|
const senderAccount = await this._stateManager.getAccount(
|
|
283
286
|
Address.fromString(address)
|
|
284
287
|
);
|
|
285
|
-
const senderNonce = senderAccount
|
|
286
|
-
const senderBalance = senderAccount
|
|
288
|
+
const senderNonce = senderAccount?.nonce ?? 0n;
|
|
289
|
+
const senderBalance = senderAccount?.balance ?? 0n;
|
|
287
290
|
|
|
288
291
|
let moveToQueued = false;
|
|
289
292
|
for (const tx of txs) {
|
|
@@ -320,8 +323,8 @@ export class TxPool {
|
|
|
320
323
|
const senderAccount = await this._stateManager.getAccount(
|
|
321
324
|
Address.fromString(address)
|
|
322
325
|
);
|
|
323
|
-
const senderNonce = senderAccount
|
|
324
|
-
const senderBalance = senderAccount
|
|
326
|
+
const senderNonce = senderAccount?.nonce ?? 0n;
|
|
327
|
+
const senderBalance = senderAccount?.balance ?? 0n;
|
|
325
328
|
|
|
326
329
|
for (const tx of txs) {
|
|
327
330
|
const deserializedTx = this._deserializeTransaction(tx);
|
|
@@ -446,7 +449,7 @@ export class TxPool {
|
|
|
446
449
|
}
|
|
447
450
|
|
|
448
451
|
const senderAccount = await this._stateManager.getAccount(senderAddress);
|
|
449
|
-
const senderBalance = senderAccount
|
|
452
|
+
const senderBalance = senderAccount?.balance ?? 0n;
|
|
450
453
|
|
|
451
454
|
const maxFee = "gasPrice" in tx ? tx.gasPrice : tx.maxFeePerGas;
|
|
452
455
|
const txMaxUpfrontCost = tx.gasLimit * maxFee + tx.value;
|
|
@@ -495,7 +498,7 @@ export class TxPool {
|
|
|
495
498
|
txList: SenderTransactions | undefined
|
|
496
499
|
) {
|
|
497
500
|
const existingTx = txList?.find((etx) =>
|
|
498
|
-
this._deserializeTransaction(etx).data.hash()
|
|
501
|
+
equalsBytes(this._deserializeTransaction(etx).data.hash(), tx.hash())
|
|
499
502
|
);
|
|
500
503
|
return existingTx !== undefined;
|
|
501
504
|
}
|
|
@@ -562,7 +565,7 @@ export class TxPool {
|
|
|
562
565
|
this._state = this._state.set("blockGasLimit", BigIntUtils.toHex(newLimit));
|
|
563
566
|
}
|
|
564
567
|
|
|
565
|
-
private _deleteTransactionByHash(hash:
|
|
568
|
+
private _deleteTransactionByHash(hash: Uint8Array) {
|
|
566
569
|
this._state = this._state.set(
|
|
567
570
|
"hashToTransaction",
|
|
568
571
|
this._getTransactionsByHash().delete(bufferToHex(hash))
|
|
@@ -592,7 +595,7 @@ export class TxPool {
|
|
|
592
595
|
accountAddress: Address
|
|
593
596
|
): Promise<bigint> {
|
|
594
597
|
const account = await this._stateManager.getAccount(accountAddress);
|
|
595
|
-
return account
|
|
598
|
+
return account?.nonce ?? 0n;
|
|
596
599
|
}
|
|
597
600
|
|
|
598
601
|
/**
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { TransactionFactory } from "@nomicfoundation/ethereumjs-tx";
|
|
2
|
-
import { BaseTransaction } from "@nomicfoundation/ethereumjs-tx/dist/baseTransaction";
|
|
2
|
+
import { BaseTransaction } from "@nomicfoundation/ethereumjs-tx/dist/cjs/baseTransaction";
|
|
3
3
|
import {
|
|
4
|
-
AccessListEIP2930TxData,
|
|
5
|
-
TxData,
|
|
6
4
|
TxOptions,
|
|
7
|
-
|
|
5
|
+
TypedTxData,
|
|
6
|
+
} from "@nomicfoundation/ethereumjs-tx/dist/cjs/types";
|
|
8
7
|
|
|
9
8
|
// This is a hack to prevent Block.fromBlockData from recreating our
|
|
10
9
|
// transactions and changing their types. Note fromBlockData is used
|
|
11
10
|
// by the BlockBuilder to update block it's building.
|
|
12
11
|
const previousFromTxData = TransactionFactory.fromTxData;
|
|
13
12
|
(TransactionFactory as any).fromTxData = function (
|
|
14
|
-
txData:
|
|
13
|
+
txData: TypedTxData,
|
|
15
14
|
txOptions?: TxOptions
|
|
16
15
|
) {
|
|
17
16
|
if (txData instanceof BaseTransaction) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
bytesToHex as bufferToHex,
|
|
3
|
+
toBytes,
|
|
4
|
+
} from "@nomicfoundation/ethereumjs-util";
|
|
2
5
|
import { Bloom } from "@nomicfoundation/ethereumjs-vm";
|
|
3
6
|
|
|
4
7
|
import { RpcLogOutput } from "./output";
|
|
@@ -14,8 +17,8 @@ export enum Type {
|
|
|
14
17
|
export interface FilterCriteria {
|
|
15
18
|
fromBlock: bigint;
|
|
16
19
|
toBlock: bigint;
|
|
17
|
-
addresses:
|
|
18
|
-
normalizedTopics: Array<Array<
|
|
20
|
+
addresses: Uint8Array[];
|
|
21
|
+
normalizedTopics: Array<Array<Uint8Array | null> | null>;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export interface Filter {
|
|
@@ -30,8 +33,8 @@ export interface Filter {
|
|
|
30
33
|
|
|
31
34
|
export function bloomFilter(
|
|
32
35
|
bloom: Bloom,
|
|
33
|
-
addresses:
|
|
34
|
-
normalizedTopics: Array<Array<
|
|
36
|
+
addresses: Uint8Array[],
|
|
37
|
+
normalizedTopics: Array<Array<Uint8Array | null> | null>
|
|
35
38
|
): boolean {
|
|
36
39
|
if (addresses.length > 0) {
|
|
37
40
|
let included = false;
|
|
@@ -84,7 +87,7 @@ export function filterLogs(
|
|
|
84
87
|
|
|
85
88
|
if (
|
|
86
89
|
criteria.addresses.length !== 0 &&
|
|
87
|
-
!includes(criteria.addresses,
|
|
90
|
+
!includes(criteria.addresses, toBytes(log.address))
|
|
88
91
|
) {
|
|
89
92
|
continue;
|
|
90
93
|
}
|
|
@@ -99,7 +102,7 @@ export function filterLogs(
|
|
|
99
102
|
return filteredLogs;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
export function includes(addresses:
|
|
105
|
+
export function includes(addresses: Uint8Array[], a: Uint8Array): boolean {
|
|
103
106
|
for (const address of addresses) {
|
|
104
107
|
if (Buffer.compare(address, a) === 0) {
|
|
105
108
|
return true;
|
|
@@ -110,7 +113,7 @@ export function includes(addresses: Buffer[], a: Buffer): boolean {
|
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
export function topicMatched(
|
|
113
|
-
normalizedTopics: Array<Array<
|
|
116
|
+
normalizedTopics: Array<Array<Uint8Array | null> | null>,
|
|
114
117
|
logTopics: string[]
|
|
115
118
|
): boolean {
|
|
116
119
|
for (let i = 0; i < normalizedTopics.length; i++) {
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { Block } from "@nomicfoundation/ethereumjs-block";
|
|
2
|
+
import {
|
|
3
|
+
BlockchainInterface,
|
|
4
|
+
BlockchainEvents,
|
|
5
|
+
} from "@nomicfoundation/ethereumjs-blockchain";
|
|
2
6
|
import { Common } from "@nomicfoundation/ethereumjs-common";
|
|
3
|
-
import {
|
|
4
|
-
|
|
7
|
+
import {
|
|
8
|
+
FeeMarketEIP1559TxData,
|
|
9
|
+
TypedTransaction,
|
|
10
|
+
} from "@nomicfoundation/ethereumjs-tx";
|
|
11
|
+
import {
|
|
12
|
+
Address,
|
|
13
|
+
AsyncEventEmitter,
|
|
14
|
+
equalsBytes,
|
|
15
|
+
} from "@nomicfoundation/ethereumjs-util";
|
|
5
16
|
|
|
6
|
-
import { FeeMarketEIP1559TxData } from "@nomicfoundation/ethereumjs-tx/dist/types";
|
|
7
17
|
import { RpcBlockWithTransactions } from "../../../core/jsonrpc/types/output/block";
|
|
8
18
|
import { RpcTransactionReceipt } from "../../../core/jsonrpc/types/output/receipt";
|
|
9
19
|
import { RpcTransaction } from "../../../core/jsonrpc/types/output/transaction";
|
|
@@ -35,6 +45,7 @@ export class ForkBlockchain
|
|
|
35
45
|
implements HardhatBlockchainInterface
|
|
36
46
|
{
|
|
37
47
|
private _latestBlockNumber = this._forkBlockNumber;
|
|
48
|
+
public events?: AsyncEventEmitter<BlockchainEvents> | undefined;
|
|
38
49
|
|
|
39
50
|
constructor(
|
|
40
51
|
private _jsonRpcClient: JsonRpcClient,
|
|
@@ -44,6 +55,22 @@ export class ForkBlockchain
|
|
|
44
55
|
super(common);
|
|
45
56
|
}
|
|
46
57
|
|
|
58
|
+
public getIteratorHead(_name?: string | undefined): Promise<Block> {
|
|
59
|
+
throw new Error("Method not implemented.");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public setIteratorHead(_tag: string, _headHash: Uint8Array): Promise<void> {
|
|
63
|
+
throw new Error("Method not implemented.");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public getCanonicalHeadBlock(): Promise<Block> {
|
|
67
|
+
throw new Error("Method not implemented.");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public shallowCopy(): BlockchainInterface {
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
47
74
|
public getLatestBlockNumber(): bigint {
|
|
48
75
|
return this._latestBlockNumber;
|
|
49
76
|
}
|
|
@@ -87,7 +114,7 @@ export class ForkBlockchain
|
|
|
87
114
|
// Thus, we avoid this check for the first block after the fork.
|
|
88
115
|
if (blockNumber > this._forkBlockNumber + 1n) {
|
|
89
116
|
const parent = await this.getLatestBlock();
|
|
90
|
-
if (!block.header.parentHash
|
|
117
|
+
if (!equalsBytes(block.header.parentHash, parent.hash())) {
|
|
91
118
|
throw new Error("Invalid parent hash");
|
|
92
119
|
}
|
|
93
120
|
}
|
|
@@ -118,7 +145,10 @@ export class ForkBlockchain
|
|
|
118
145
|
public deleteLaterBlocks(block: Block): void {
|
|
119
146
|
const blockNumber = block.header.number;
|
|
120
147
|
const savedBlock = this._data.getBlockByNumber(blockNumber);
|
|
121
|
-
if (
|
|
148
|
+
if (
|
|
149
|
+
savedBlock === undefined ||
|
|
150
|
+
!equalsBytes(savedBlock.hash(), block.hash())
|
|
151
|
+
) {
|
|
122
152
|
throw new Error("Invalid block");
|
|
123
153
|
}
|
|
124
154
|
|
|
@@ -268,9 +298,12 @@ export class ForkBlockchain
|
|
|
268
298
|
if (rpcBlock.baseFeePerGas === undefined) {
|
|
269
299
|
common.setHardfork("berlin");
|
|
270
300
|
} else if (rpcBlock.withdrawals === undefined) {
|
|
271
|
-
|
|
272
|
-
|
|
301
|
+
// ethereumjs uses this name for the merge hardfork
|
|
302
|
+
common.setHardfork("mergeForkIdTransition");
|
|
303
|
+
} else if (rpcBlock.parentBeaconBlockRoot === undefined) {
|
|
273
304
|
common.setHardfork("shanghai");
|
|
305
|
+
} else {
|
|
306
|
+
common.setHardfork("cancun");
|
|
274
307
|
}
|
|
275
308
|
|
|
276
309
|
// we don't include the transactions to add our own custom tx objects,
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EVMStateManagerInterface,
|
|
3
|
+
Proof,
|
|
4
|
+
StorageRange,
|
|
5
|
+
} from "@nomicfoundation/ethereumjs-common";
|
|
2
6
|
import {
|
|
3
7
|
Account,
|
|
4
8
|
bigIntToHex,
|
|
5
|
-
|
|
9
|
+
bytesToBigInt,
|
|
6
10
|
Address,
|
|
7
|
-
bufferToHex,
|
|
11
|
+
bytesToHex as bufferToHex,
|
|
12
|
+
equalsBytes,
|
|
8
13
|
KECCAK256_NULL,
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
toBytes,
|
|
15
|
+
unpadBytes,
|
|
11
16
|
} from "@nomicfoundation/ethereumjs-util";
|
|
12
17
|
import { Map as ImmutableMap, Record as ImmutableRecord } from "immutable";
|
|
13
18
|
|
|
@@ -25,8 +30,13 @@ import {
|
|
|
25
30
|
makeEmptyAccountState,
|
|
26
31
|
} from "./AccountState";
|
|
27
32
|
|
|
28
|
-
const encodeStorageKey = (
|
|
29
|
-
|
|
33
|
+
const encodeStorageKey = (
|
|
34
|
+
address: Uint8Array,
|
|
35
|
+
position: Uint8Array
|
|
36
|
+
): string => {
|
|
37
|
+
return `${Buffer.from(address).toString("hex")}${Buffer.from(
|
|
38
|
+
unpadBytes(position)
|
|
39
|
+
).toString("hex")}`;
|
|
30
40
|
};
|
|
31
41
|
|
|
32
42
|
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
@@ -42,16 +52,28 @@ const notCheckpointedError = (method: string) =>
|
|
|
42
52
|
const notSupportedError = (method: string) =>
|
|
43
53
|
new Error(`${method} is not supported when forking from remote network`);
|
|
44
54
|
|
|
45
|
-
export class ForkStateManager implements
|
|
55
|
+
export class ForkStateManager implements EVMStateManagerInterface {
|
|
46
56
|
private _state: State = ImmutableMap<string, ImmutableRecord<AccountState>>();
|
|
47
57
|
private _initialStateRoot: string = randomHash();
|
|
48
58
|
private _stateRoot: string = this._initialStateRoot;
|
|
49
59
|
private _stateRootToState: Map<string, State> = new Map();
|
|
50
|
-
private _originalStorageCache: Map<string,
|
|
60
|
+
private _originalStorageCache: Map<string, Uint8Array> = new Map();
|
|
51
61
|
private _stateCheckpoints: string[] = [];
|
|
52
62
|
private _contextBlockNumber = this._forkBlockNumber;
|
|
53
63
|
private _contextChanged = false;
|
|
54
64
|
|
|
65
|
+
public originalStorageCache: {
|
|
66
|
+
get(address: Address, key: Uint8Array): Promise<Uint8Array>;
|
|
67
|
+
clear(): void;
|
|
68
|
+
} = {
|
|
69
|
+
get: async (address: Address, key: Uint8Array): Promise<Uint8Array> => {
|
|
70
|
+
return this.getOriginalContractStorage(address, key);
|
|
71
|
+
},
|
|
72
|
+
clear: (): void => {
|
|
73
|
+
this.clearOriginalStorageCache();
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
55
77
|
constructor(
|
|
56
78
|
private readonly _jsonRpcClient: JsonRpcClient,
|
|
57
79
|
private readonly _forkBlockNumber: bigint
|
|
@@ -60,6 +82,24 @@ export class ForkStateManager implements StateManager {
|
|
|
60
82
|
|
|
61
83
|
this._stateRootToState.set(this._initialStateRoot, this._state);
|
|
62
84
|
}
|
|
85
|
+
public dumpStorageRange(
|
|
86
|
+
_address: Address,
|
|
87
|
+
_startKey: bigint,
|
|
88
|
+
_limit: number
|
|
89
|
+
): Promise<StorageRange> {
|
|
90
|
+
throw new Error("Method not implemented.");
|
|
91
|
+
}
|
|
92
|
+
public getProof(
|
|
93
|
+
_address: Address,
|
|
94
|
+
_storageSlots?: Uint8Array[] | undefined
|
|
95
|
+
): Promise<Proof> {
|
|
96
|
+
throw new Error("Method not implemented.");
|
|
97
|
+
}
|
|
98
|
+
public shallowCopy(
|
|
99
|
+
_downlevelCaches?: boolean | undefined
|
|
100
|
+
): EVMStateManagerInterface {
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
63
103
|
|
|
64
104
|
public async initializeGenesisAccounts(genesisAccounts: GenesisAccount[]) {
|
|
65
105
|
const accounts: Array<{ address: Address; account: Account }> = [];
|
|
@@ -70,7 +110,7 @@ export class ForkStateManager implements StateManager {
|
|
|
70
110
|
accounts.push(account);
|
|
71
111
|
|
|
72
112
|
const noncePromise = this._jsonRpcClient.getTransactionCount(
|
|
73
|
-
account.address.
|
|
113
|
+
account.address.toBytes(),
|
|
74
114
|
this._forkBlockNumber
|
|
75
115
|
);
|
|
76
116
|
noncesPromises.push(noncePromise);
|
|
@@ -112,14 +152,14 @@ export class ForkStateManager implements StateManager {
|
|
|
112
152
|
const localBalance = localAccount?.get("balance");
|
|
113
153
|
const localCode = localAccount?.get("code");
|
|
114
154
|
|
|
115
|
-
let nonce:
|
|
116
|
-
localNonce !== undefined ?
|
|
155
|
+
let nonce: Uint8Array | bigint | undefined =
|
|
156
|
+
localNonce !== undefined ? toBytes(localNonce) : undefined;
|
|
117
157
|
|
|
118
|
-
let balance:
|
|
119
|
-
localBalance !== undefined ?
|
|
158
|
+
let balance: Uint8Array | bigint | undefined =
|
|
159
|
+
localBalance !== undefined ? toBytes(localBalance) : undefined;
|
|
120
160
|
|
|
121
|
-
let code:
|
|
122
|
-
localCode !== undefined ?
|
|
161
|
+
let code: Uint8Array | undefined =
|
|
162
|
+
localCode !== undefined ? toBytes(localCode) : undefined;
|
|
123
163
|
|
|
124
164
|
if (balance === undefined || nonce === undefined || code === undefined) {
|
|
125
165
|
const accountData = await this._jsonRpcClient.getAccountData(
|
|
@@ -162,10 +202,10 @@ export class ForkStateManager implements StateManager {
|
|
|
162
202
|
this._state = this._state.set(hexAddress, account);
|
|
163
203
|
}
|
|
164
204
|
|
|
165
|
-
public async getContractCode(address: Address): Promise<
|
|
205
|
+
public async getContractCode(address: Address): Promise<Uint8Array> {
|
|
166
206
|
const localCode = this._state.get(address.toString())?.get("code");
|
|
167
207
|
if (localCode !== undefined) {
|
|
168
|
-
return
|
|
208
|
+
return toBytes(localCode);
|
|
169
209
|
}
|
|
170
210
|
|
|
171
211
|
const accountData = await this._jsonRpcClient.getAccountData(
|
|
@@ -178,8 +218,8 @@ export class ForkStateManager implements StateManager {
|
|
|
178
218
|
|
|
179
219
|
public async getContractStorage(
|
|
180
220
|
address: Address,
|
|
181
|
-
key:
|
|
182
|
-
): Promise<
|
|
221
|
+
key: Uint8Array
|
|
222
|
+
): Promise<Uint8Array> {
|
|
183
223
|
if (key.length !== 32) {
|
|
184
224
|
throw new Error("Storage key must be 32 bytes long");
|
|
185
225
|
}
|
|
@@ -189,21 +229,21 @@ export class ForkStateManager implements StateManager {
|
|
|
189
229
|
const localValue = account?.get("storage").get(bufferToHex(key));
|
|
190
230
|
|
|
191
231
|
if (localValue !== undefined) {
|
|
192
|
-
return
|
|
232
|
+
return toBytes(localValue);
|
|
193
233
|
}
|
|
194
234
|
|
|
195
235
|
const slotCleared = localValue === null;
|
|
196
236
|
if (contractStorageCleared || slotCleared) {
|
|
197
|
-
return
|
|
237
|
+
return toBytes([]);
|
|
198
238
|
}
|
|
199
239
|
|
|
200
240
|
const remoteValue = await this._jsonRpcClient.getStorageAt(
|
|
201
241
|
address,
|
|
202
|
-
|
|
242
|
+
bytesToBigInt(key),
|
|
203
243
|
this._contextBlockNumber
|
|
204
244
|
);
|
|
205
245
|
|
|
206
|
-
return
|
|
246
|
+
return unpadBytes(remoteValue);
|
|
207
247
|
}
|
|
208
248
|
|
|
209
249
|
public async putContractStorage(
|
|
@@ -219,7 +259,7 @@ export class ForkStateManager implements StateManager {
|
|
|
219
259
|
throw new Error("Storage value cannot be longer than 32 bytes");
|
|
220
260
|
}
|
|
221
261
|
|
|
222
|
-
const unpaddedValue =
|
|
262
|
+
const unpaddedValue = unpadBytes(value);
|
|
223
263
|
|
|
224
264
|
const hexAddress = address.toString();
|
|
225
265
|
let account = this._state.get(hexAddress) ?? makeAccountState();
|
|
@@ -266,18 +306,18 @@ export class ForkStateManager implements StateManager {
|
|
|
266
306
|
if (checkpointedRoot === undefined) {
|
|
267
307
|
throw notCheckpointedError("revert");
|
|
268
308
|
}
|
|
269
|
-
await this.setStateRoot(
|
|
309
|
+
await this.setStateRoot(toBytes(checkpointedRoot));
|
|
270
310
|
}
|
|
271
311
|
|
|
272
|
-
public async getStateRoot(): Promise<
|
|
312
|
+
public async getStateRoot(): Promise<Uint8Array> {
|
|
273
313
|
if (this._stateRootToState.get(this._stateRoot) !== this._state) {
|
|
274
314
|
this._stateRoot = randomHash();
|
|
275
315
|
this._stateRootToState.set(this._stateRoot, this._state);
|
|
276
316
|
}
|
|
277
|
-
return
|
|
317
|
+
return toBytes(this._stateRoot);
|
|
278
318
|
}
|
|
279
319
|
|
|
280
|
-
public async setStateRoot(stateRoot:
|
|
320
|
+
public async setStateRoot(stateRoot: Uint8Array): Promise<void> {
|
|
281
321
|
this._setStateRoot(stateRoot);
|
|
282
322
|
}
|
|
283
323
|
|
|
@@ -304,7 +344,7 @@ export class ForkStateManager implements StateManager {
|
|
|
304
344
|
return (
|
|
305
345
|
account.nonce === 0n &&
|
|
306
346
|
account.balance === 0n &&
|
|
307
|
-
account.codeHash
|
|
347
|
+
equalsBytes(account.codeHash, KECCAK256_NULL)
|
|
308
348
|
);
|
|
309
349
|
}
|
|
310
350
|
|
|
@@ -315,9 +355,9 @@ export class ForkStateManager implements StateManager {
|
|
|
315
355
|
}
|
|
316
356
|
|
|
317
357
|
public setBlockContext(
|
|
318
|
-
stateRoot:
|
|
358
|
+
stateRoot: Uint8Array,
|
|
319
359
|
blockNumber: bigint,
|
|
320
|
-
irregularState?:
|
|
360
|
+
irregularState?: Uint8Array
|
|
321
361
|
) {
|
|
322
362
|
if (this._stateCheckpoints.length !== 0) {
|
|
323
363
|
throw checkpointedError("setBlockContext");
|
|
@@ -329,7 +369,7 @@ export class ForkStateManager implements StateManager {
|
|
|
329
369
|
}
|
|
330
370
|
|
|
331
371
|
if (blockNumber === this._forkBlockNumber) {
|
|
332
|
-
this._setStateRoot(
|
|
372
|
+
this._setStateRoot(toBytes(this._initialStateRoot));
|
|
333
373
|
return;
|
|
334
374
|
}
|
|
335
375
|
if (blockNumber > this._forkBlockNumber) {
|
|
@@ -345,7 +385,7 @@ export class ForkStateManager implements StateManager {
|
|
|
345
385
|
// because the VM does it before executing a message anyway.
|
|
346
386
|
}
|
|
347
387
|
|
|
348
|
-
public restoreForkBlockContext(stateRoot:
|
|
388
|
+
public restoreForkBlockContext(stateRoot: Uint8Array) {
|
|
349
389
|
if (this._stateCheckpoints.length !== 0) {
|
|
350
390
|
throw checkpointedError("restoreForkBlockContext");
|
|
351
391
|
}
|
|
@@ -376,9 +416,9 @@ export class ForkStateManager implements StateManager {
|
|
|
376
416
|
|
|
377
417
|
public async getOriginalContractStorage(
|
|
378
418
|
address: Address,
|
|
379
|
-
key:
|
|
380
|
-
): Promise<
|
|
381
|
-
const storageKey = encodeStorageKey(address.
|
|
419
|
+
key: Uint8Array
|
|
420
|
+
): Promise<Uint8Array> {
|
|
421
|
+
const storageKey = encodeStorageKey(Buffer.from(address.toBytes()), key);
|
|
382
422
|
const cachedValue = this._originalStorageCache.get(storageKey);
|
|
383
423
|
if (cachedValue !== undefined) {
|
|
384
424
|
return cachedValue;
|
|
@@ -401,13 +441,13 @@ export class ForkStateManager implements StateManager {
|
|
|
401
441
|
|
|
402
442
|
// Code is set to empty string here to prevent unnecessary
|
|
403
443
|
// JsonRpcClient.getCode calls in getAccount method
|
|
404
|
-
if (account.codeHash
|
|
444
|
+
if (equalsBytes(account.codeHash, KECCAK256_NULL)) {
|
|
405
445
|
localAccount = localAccount.set("code", "0x");
|
|
406
446
|
}
|
|
407
447
|
this._state = this._state.set(hexAddress, localAccount);
|
|
408
448
|
}
|
|
409
449
|
|
|
410
|
-
private _setStateRoot(stateRoot:
|
|
450
|
+
private _setStateRoot(stateRoot: Uint8Array) {
|
|
411
451
|
const newRoot = bufferToHex(stateRoot);
|
|
412
452
|
const state = this._stateRootToState.get(newRoot);
|
|
413
453
|
if (state === undefined) {
|
|
@@ -24,6 +24,9 @@ export function rpcToBlockData(rpcBlock: RpcBlockWithTransactions): BlockData {
|
|
|
24
24
|
nonce: rpcBlock.nonce,
|
|
25
25
|
baseFeePerGas: rpcBlock.baseFeePerGas,
|
|
26
26
|
withdrawalsRoot: rpcBlock.withdrawalsRoot,
|
|
27
|
+
parentBeaconBlockRoot: rpcBlock.parentBeaconBlockRoot,
|
|
28
|
+
blobGasUsed: rpcBlock.blobGasUsed,
|
|
29
|
+
excessBlobGas: rpcBlock.excessBlobGas,
|
|
27
30
|
},
|
|
28
31
|
transactions: rpcBlock.transactions.map(rpcToTxData),
|
|
29
32
|
withdrawals: rpcBlock.withdrawals,
|
|
@@ -2,7 +2,7 @@ import type { BigIntLike } from "@nomicfoundation/ethereumjs-util";
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
AccessListEIP2930TxData,
|
|
5
|
-
|
|
5
|
+
LegacyTxData,
|
|
6
6
|
} from "@nomicfoundation/ethereumjs-tx";
|
|
7
7
|
|
|
8
8
|
import { RpcTransaction } from "../../../core/jsonrpc/types/output/transaction";
|
|
@@ -17,7 +17,7 @@ interface FeeMarketEIP1559TxData extends AccessListEIP2930TxData {
|
|
|
17
17
|
|
|
18
18
|
export function rpcToTxData(
|
|
19
19
|
rpcTransaction: RpcTransaction
|
|
20
|
-
):
|
|
20
|
+
): LegacyTxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData {
|
|
21
21
|
const isEip1559 = rpcTransaction.type === 2n;
|
|
22
22
|
|
|
23
23
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Block } from "@nomicfoundation/ethereumjs-block";
|
|
2
2
|
import {
|
|
3
|
-
bufferToHex,
|
|
4
|
-
|
|
3
|
+
bytesToHex as bufferToHex,
|
|
4
|
+
toBytes,
|
|
5
5
|
zeroAddress,
|
|
6
6
|
} from "@nomicfoundation/ethereumjs-util";
|
|
7
7
|
import {
|
|
@@ -94,7 +94,7 @@ export class Base {
|
|
|
94
94
|
rpcCall.from !== undefined
|
|
95
95
|
? rpcCall.from
|
|
96
96
|
: await this._getDefaultCallFrom(),
|
|
97
|
-
data: rpcCall.data !== undefined ? rpcCall.data :
|
|
97
|
+
data: rpcCall.data !== undefined ? rpcCall.data : Buffer.from([]),
|
|
98
98
|
gasLimit:
|
|
99
99
|
rpcCall.gas !== undefined ? rpcCall.gas : this._node.getBlockGasLimit(),
|
|
100
100
|
value: rpcCall.value !== undefined ? rpcCall.value : 0n,
|
|
@@ -148,9 +148,9 @@ export class Base {
|
|
|
148
148
|
const localAccounts = await this._node.getLocalAccountAddresses();
|
|
149
149
|
|
|
150
150
|
if (localAccounts.length === 0) {
|
|
151
|
-
return
|
|
151
|
+
return Buffer.from(toBytes(zeroAddress()));
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
return
|
|
154
|
+
return Buffer.from(toBytes(localAccounts[0]));
|
|
155
155
|
}
|
|
156
156
|
}
|