hardhat 2.13.0-dev.2 → 2.13.0-dev.4
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/compile.js +21 -7
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/console.js +5 -1
- package/builtin-tasks/console.js.map +1 -1
- package/builtin-tasks/flatten.js +1 -1
- package/builtin-tasks/flatten.js.map +1 -1
- package/builtin-tasks/help.js +2 -4
- package/builtin-tasks/help.js.map +1 -1
- package/builtin-tasks/task-names.d.ts +1 -0
- package/builtin-tasks/task-names.d.ts.map +1 -1
- package/builtin-tasks/task-names.js +3 -2
- package/builtin-tasks/task-names.js.map +1 -1
- package/builtin-tasks/test.js +27 -2
- package/builtin-tasks/test.js.map +1 -1
- package/builtin-tasks/utils/solidity-files-cache.js +5 -1
- package/builtin-tasks/utils/solidity-files-cache.js.map +1 -1
- package/builtin-tasks/utils/watch.js +5 -1
- package/builtin-tasks/utils/watch.js.map +1 -1
- package/common/index.js +5 -1
- package/common/index.js.map +1 -1
- package/config.js +5 -1
- package/config.js.map +1 -1
- package/internal/artifacts.js +5 -1
- package/internal/artifacts.js.map +1 -1
- package/internal/cli/analytics.js +5 -1
- package/internal/cli/analytics.js.map +1 -1
- package/internal/cli/autocomplete.js +5 -1
- package/internal/cli/autocomplete.js.map +1 -1
- package/internal/cli/bootstrap.d.ts +1 -0
- package/internal/cli/bootstrap.js +12 -20
- package/internal/cli/bootstrap.js.map +1 -1
- package/internal/cli/cli.d.ts +0 -1
- package/internal/cli/cli.d.ts.map +1 -1
- package/internal/cli/cli.js +20 -29
- package/internal/cli/cli.js.map +1 -1
- package/internal/cli/project-creation.d.ts +1 -2
- package/internal/cli/project-creation.d.ts.map +1 -1
- package/internal/cli/project-creation.js +110 -37
- package/internal/cli/project-creation.js.map +1 -1
- package/internal/cli/prompt.d.ts +2 -2
- package/internal/cli/prompt.d.ts.map +1 -1
- package/internal/cli/prompt.js +6 -3
- package/internal/cli/prompt.js.map +1 -1
- package/internal/cli/types.d.ts +1 -0
- package/internal/cli/types.d.ts.map +1 -1
- package/internal/core/config/config-env.d.ts +5 -11
- package/internal/core/config/config-env.d.ts.map +1 -1
- package/internal/core/config/config-env.js +7 -14
- package/internal/core/config/config-env.js.map +1 -1
- package/internal/core/config/config-loading.d.ts +2 -1
- package/internal/core/config/config-loading.d.ts.map +1 -1
- package/internal/core/config/config-loading.js +25 -7
- package/internal/core/config/config-loading.js.map +1 -1
- package/internal/core/config/config-validation.d.ts +2 -0
- package/internal/core/config/config-validation.d.ts.map +1 -1
- package/internal/core/config/config-validation.js +23 -2
- package/internal/core/config/config-validation.js.map +1 -1
- package/internal/core/config/extenders.d.ts +4 -7
- package/internal/core/config/extenders.d.ts.map +1 -1
- package/internal/core/config/extenders.js +5 -12
- package/internal/core/config/extenders.js.map +1 -1
- package/internal/core/errors-list.d.ts +28 -7
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +33 -10
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/jsonrpc/types/access-list.js +5 -1
- package/internal/core/jsonrpc/types/access-list.js.map +1 -1
- package/internal/core/jsonrpc/types/base-types.js +5 -1
- package/internal/core/jsonrpc/types/base-types.js.map +1 -1
- package/internal/core/jsonrpc/types/input/blockTag.d.ts +3 -3
- package/internal/core/jsonrpc/types/input/blockTag.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/input/blockTag.js +5 -1
- package/internal/core/jsonrpc/types/input/blockTag.js.map +1 -1
- package/internal/core/jsonrpc/types/input/callRequest.js +5 -1
- package/internal/core/jsonrpc/types/input/callRequest.js.map +1 -1
- package/internal/core/jsonrpc/types/input/debugTraceTransaction.js +5 -1
- package/internal/core/jsonrpc/types/input/debugTraceTransaction.js.map +1 -1
- package/internal/core/jsonrpc/types/input/filterRequest.js +5 -1
- package/internal/core/jsonrpc/types/input/filterRequest.js.map +1 -1
- package/internal/core/jsonrpc/types/input/hardhat-network.js +5 -1
- package/internal/core/jsonrpc/types/input/hardhat-network.js.map +1 -1
- package/internal/core/jsonrpc/types/input/logAddress.js +5 -1
- package/internal/core/jsonrpc/types/input/logAddress.js.map +1 -1
- package/internal/core/jsonrpc/types/input/logTopics.js +5 -1
- package/internal/core/jsonrpc/types/input/logTopics.js.map +1 -1
- package/internal/core/jsonrpc/types/input/solc.js +5 -1
- package/internal/core/jsonrpc/types/input/solc.js.map +1 -1
- package/internal/core/jsonrpc/types/input/subscribeRequest.js +5 -1
- package/internal/core/jsonrpc/types/input/subscribeRequest.js.map +1 -1
- package/internal/core/jsonrpc/types/input/transactionRequest.js +5 -1
- package/internal/core/jsonrpc/types/input/transactionRequest.js.map +1 -1
- package/internal/core/jsonrpc/types/output/block.js +5 -1
- package/internal/core/jsonrpc/types/output/block.js.map +1 -1
- package/internal/core/jsonrpc/types/output/log.js +5 -1
- package/internal/core/jsonrpc/types/output/log.js.map +1 -1
- package/internal/core/jsonrpc/types/output/receipt.js +5 -1
- package/internal/core/jsonrpc/types/output/receipt.js.map +1 -1
- package/internal/core/jsonrpc/types/output/transaction.js +5 -1
- package/internal/core/jsonrpc/types/output/transaction.js.map +1 -1
- package/internal/core/params/argumentTypes.js +5 -1
- package/internal/core/params/argumentTypes.js.map +1 -1
- package/internal/core/params/hardhat-params.js +5 -1
- package/internal/core/params/hardhat-params.js.map +1 -1
- package/internal/core/project-structure.d.ts.map +1 -1
- package/internal/core/project-structure.js +6 -0
- package/internal/core/project-structure.js.map +1 -1
- package/internal/core/providers/accounts.js +5 -1
- package/internal/core/providers/accounts.js.map +1 -1
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +25 -5
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/http.d.ts +2 -2
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +45 -19
- package/internal/core/providers/http.js.map +1 -1
- package/internal/core/runtime-environment.d.ts +4 -2
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js +57 -67
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/core/tasks/dsl.d.ts +6 -6
- package/internal/core/tasks/dsl.d.ts.map +1 -1
- package/internal/core/tasks/dsl.js.map +1 -1
- package/internal/core/tasks/task-definitions.d.ts +2 -2
- package/internal/core/tasks/task-definitions.d.ts.map +1 -1
- package/internal/core/tasks/task-definitions.js +5 -1
- package/internal/core/tasks/task-definitions.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.js +5 -1
- package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.d.ts +1 -0
- package/internal/hardhat-network/jsonrpc/handler.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.js +13 -18
- package/internal/hardhat-network/jsonrpc/handler.js.map +1 -1
- package/internal/hardhat-network/provider/BlockchainBase.js +5 -1
- package/internal/hardhat-network/provider/BlockchainBase.js.map +1 -1
- package/internal/hardhat-network/provider/PoolState.js +5 -1
- package/internal/hardhat-network/provider/PoolState.js.map +1 -1
- package/internal/hardhat-network/provider/RethnetState.d.ts +27 -0
- package/internal/hardhat-network/provider/RethnetState.d.ts.map +1 -0
- package/internal/hardhat-network/provider/RethnetState.js +89 -0
- package/internal/hardhat-network/provider/RethnetState.js.map +1 -0
- package/internal/hardhat-network/provider/TransactionQueue.js +5 -1
- package/internal/hardhat-network/provider/TransactionQueue.js.map +1 -1
- package/internal/hardhat-network/provider/TxPool.js +5 -1
- package/internal/hardhat-network/provider/TxPool.js.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.js +5 -1
- package/internal/hardhat-network/provider/modules/eth.js.map +1 -1
- package/internal/hardhat-network/provider/modules/evm.d.ts +2 -1
- package/internal/hardhat-network/provider/modules/evm.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/evm.js +15 -5
- package/internal/hardhat-network/provider/modules/evm.js.map +1 -1
- package/internal/hardhat-network/provider/modules/hardhat.js +5 -1
- package/internal/hardhat-network/provider/modules/hardhat.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +2 -0
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +11 -5
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/output.js +5 -1
- package/internal/hardhat-network/provider/output.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +25 -21
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +25 -42
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/return-data.js +2 -2
- package/internal/hardhat-network/provider/return-data.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +9 -3
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +9 -3
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +9 -3
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +5 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +5 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/utils/bloom.d.ts +32 -0
- package/internal/hardhat-network/provider/utils/bloom.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/bloom.js +79 -0
- package/internal/hardhat-network/provider/utils/bloom.js.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts +12 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.js +162 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.js.map +1 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +7 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +31 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +1 -0
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +2 -2
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js +5 -1
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js.map +1 -1
- package/internal/hardhat-network/provider/vm/block-builder.d.ts +31 -0
- package/internal/hardhat-network/provider/vm/block-builder.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/block-builder.js +151 -0
- package/internal/hardhat-network/provider/vm/block-builder.js.map +1 -0
- package/internal/hardhat-network/provider/vm/creation.d.ts +10 -0
- package/internal/hardhat-network/provider/vm/creation.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/creation.js +29 -0
- package/internal/hardhat-network/provider/vm/creation.js.map +1 -0
- package/internal/hardhat-network/provider/vm/dual.d.ts +44 -0
- package/internal/hardhat-network/provider/vm/dual.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/dual.js +501 -0
- package/internal/hardhat-network/provider/vm/dual.js.map +1 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts +57 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.js +420 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.js.map +1 -0
- package/internal/hardhat-network/provider/vm/exit.d.ts +23 -0
- package/internal/hardhat-network/provider/vm/exit.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/exit.js +130 -0
- package/internal/hardhat-network/provider/vm/exit.js.map +1 -0
- package/internal/hardhat-network/provider/vm/rethnet.d.ts +100 -0
- package/internal/hardhat-network/provider/vm/rethnet.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/rethnet.js +287 -0
- package/internal/hardhat-network/provider/vm/rethnet.js.map +1 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.d.ts +53 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.js +3 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.js.map +1 -0
- package/internal/hardhat-network/stack-traces/compiler-to-model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/compiler-to-model.js +37 -11
- package/internal/hardhat-network/stack-traces/compiler-to-model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js.map +1 -1
- package/internal/hardhat-network/stack-traces/constants.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/constants.js +1 -1
- package/internal/hardhat-network/stack-traces/debug.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +6 -2
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts +1 -0
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +85 -55
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/model.d.ts +3 -1
- package/internal/hardhat-network/stack-traces/model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +9 -1
- package/internal/hardhat-network/stack-traces/model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +2 -2
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +2 -2
- 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 +1 -0
- package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +5 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
- package/internal/lib/hardhat-lib.d.ts.map +1 -1
- package/internal/lib/hardhat-lib.js +1 -4
- package/internal/lib/hardhat-lib.js.map +1 -1
- package/internal/sentry/anonymizer.js +5 -1
- package/internal/sentry/anonymizer.js.map +1 -1
- package/internal/sentry/reporter.js +5 -1
- package/internal/sentry/reporter.js.map +1 -1
- package/internal/sentry/subprocess.js +5 -1
- package/internal/sentry/subprocess.js.map +1 -1
- package/internal/sentry/transport.js +5 -1
- package/internal/sentry/transport.js.map +1 -1
- package/internal/solidity/compiler/downloader.js +7 -3
- package/internal/solidity/compiler/downloader.js.map +1 -1
- package/internal/solidity/compiler/index.js +6 -2
- package/internal/solidity/compiler/index.js.map +1 -1
- package/internal/solidity/resolver.d.ts +4 -3
- package/internal/solidity/resolver.d.ts.map +1 -1
- package/internal/solidity/resolver.js +18 -7
- package/internal/solidity/resolver.js.map +1 -1
- package/internal/util/abi-helpers.d.ts +1 -0
- package/internal/util/abi-helpers.d.ts.map +1 -1
- package/internal/util/abi-helpers.js +14 -1
- package/internal/util/abi-helpers.js.map +1 -1
- package/internal/util/download.d.ts.map +1 -1
- package/internal/util/download.js +17 -12
- package/internal/util/download.js.map +1 -1
- package/internal/util/glob.js +5 -1
- package/internal/util/glob.js.map +1 -1
- package/internal/util/global-dir.js +5 -1
- package/internal/util/global-dir.js.map +1 -1
- package/internal/util/io-ts.js +5 -1
- package/internal/util/io-ts.js.map +1 -1
- package/internal/util/packageInfo.d.ts +6 -1
- package/internal/util/packageInfo.d.ts.map +1 -1
- package/internal/util/packageInfo.js +14 -11
- package/internal/util/packageInfo.js.map +1 -1
- package/internal/util/proxy.d.ts +2 -0
- package/internal/util/proxy.d.ts.map +1 -0
- package/internal/util/proxy.js +19 -0
- package/internal/util/proxy.js.map +1 -0
- package/internal/util/scripts-runner.js +5 -1
- package/internal/util/scripts-runner.js.map +1 -1
- package/package.json +9 -10
- package/register.js +1 -4
- package/register.js.map +1 -1
- package/sample-projects/javascript/hardhat.config.js +1 -1
- package/sample-projects/javascript/scripts/deploy.js +5 -4
- package/sample-projects/javascript-esm/LICENSE.md +11 -0
- package/sample-projects/javascript-esm/README.md +13 -0
- package/sample-projects/javascript-esm/contracts/Lock.sol +34 -0
- package/sample-projects/javascript-esm/hardhat.config.cjs +6 -0
- package/sample-projects/javascript-esm/scripts/deploy.js +23 -0
- package/sample-projects/javascript-esm/test/Lock.js +123 -0
- package/sample-projects/typescript/hardhat.config.ts +1 -1
- package/sample-projects/typescript/scripts/deploy.ts +5 -4
- package/sample-projects/typescript/tsconfig.json +2 -1
- package/src/builtin-tasks/compile.ts +28 -7
- package/src/builtin-tasks/flatten.ts +4 -1
- package/src/builtin-tasks/help.ts +15 -16
- package/src/builtin-tasks/task-names.ts +2 -0
- package/src/builtin-tasks/test.ts +30 -2
- package/src/internal/artifacts.ts +947 -0
- package/src/internal/cli/bootstrap.ts +14 -36
- package/src/internal/cli/cli.ts +38 -43
- package/src/internal/cli/project-creation.ts +128 -47
- package/src/internal/cli/prompt.ts +2 -4
- package/src/internal/cli/types.ts +2 -0
- package/src/internal/core/config/config-env.ts +15 -27
- package/src/internal/core/config/config-loading.ts +35 -11
- package/src/internal/core/config/config-validation.ts +20 -0
- package/src/internal/core/config/extenders.ts +6 -15
- package/src/internal/core/errors-list.ts +36 -10
- package/src/internal/core/project-structure.ts +8 -0
- package/src/internal/core/providers/construction.ts +29 -24
- package/src/internal/core/providers/http.ts +38 -26
- package/src/internal/core/runtime-environment.ts +84 -82
- package/src/internal/core/tasks/dsl.ts +17 -17
- package/src/internal/core/tasks/task-definitions.ts +6 -2
- package/src/internal/hardhat-network/jsonrpc/handler.ts +31 -28
- package/src/internal/hardhat-network/provider/modules/evm.ts +15 -3
- package/src/internal/hardhat-network/provider/node-types.ts +1 -1
- package/src/internal/hardhat-network/provider/node.ts +5 -1
- package/src/internal/hardhat-network/provider/provider.ts +60 -49
- package/src/internal/hardhat-network/provider/return-data.ts +2 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +5 -2
- package/src/internal/hardhat-network/provider/utils/makeFakeSignature.ts +46 -0
- package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/compiler-to-model.ts +71 -9
- package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/constants.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/debug.ts +9 -2
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +177 -89
- package/src/internal/hardhat-network/stack-traces/model.ts +11 -1
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidity-stack-trace.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +3 -0
- package/src/internal/lib/hardhat-lib.ts +1 -6
- package/src/internal/solidity/compiler/downloader.ts +2 -2
- package/src/internal/solidity/compiler/index.ts +1 -1
- package/src/internal/solidity/resolver.ts +28 -11
- package/src/internal/util/abi-helpers.ts +9 -0
- package/src/internal/util/download.ts +13 -15
- package/src/internal/util/packageInfo.ts +24 -10
- package/src/internal/util/proxy.ts +18 -0
- package/src/register.ts +1 -6
- package/src/types/artifacts.ts +14 -112
- package/src/types/config.ts +2 -0
- package/src/types/runtime.ts +16 -13
- package/types/artifacts.d.ts +10 -96
- package/types/artifacts.d.ts.map +1 -1
- package/types/builtin-tasks/index.js +5 -1
- package/types/builtin-tasks/index.js.map +1 -1
- package/types/config.d.ts +2 -0
- package/types/config.d.ts.map +1 -1
- package/types/index.js +5 -1
- package/types/index.js.map +1 -1
- package/types/runtime.d.ts +9 -10
- package/types/runtime.d.ts.map +1 -1
- package/internal/artifacts/caching.d.ts +0 -28
- package/internal/artifacts/caching.d.ts.map +0 -1
- package/internal/artifacts/caching.js +0 -178
- package/internal/artifacts/caching.js.map +0 -1
- package/internal/artifacts/index.d.ts +0 -45
- package/internal/artifacts/index.d.ts.map +0 -1
- package/internal/artifacts/index.js +0 -191
- package/internal/artifacts/index.js.map +0 -1
- package/internal/artifacts/mutable.d.ts +0 -29
- package/internal/artifacts/mutable.d.ts.map +0 -1
- package/internal/artifacts/mutable.js +0 -226
- package/internal/artifacts/mutable.js.map +0 -1
- package/internal/artifacts/readonly.d.ts +0 -94
- package/internal/artifacts/readonly.d.ts.map +0 -1
- package/internal/artifacts/readonly.js +0 -343
- package/internal/artifacts/readonly.js.map +0 -1
- package/src/internal/artifacts/caching.ts +0 -259
- package/src/internal/artifacts/index.ts +0 -302
- package/src/internal/artifacts/mutable.ts +0 -330
- package/src/internal/artifacts/readonly.ts +0 -470
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Block } from "@nomicfoundation/ethereumjs-block";
|
|
3
|
+
import { Common } from "@nomicfoundation/ethereumjs-common";
|
|
4
|
+
import { Account, Address } from "@nomicfoundation/ethereumjs-util";
|
|
5
|
+
import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
|
6
|
+
import { Blockchain, Rethnet } from "rethnet-evm";
|
|
7
|
+
import { NodeConfig } from "../node-types";
|
|
8
|
+
import { RpcDebugTraceOutput } from "../output";
|
|
9
|
+
import { RethnetStateManager } from "../RethnetState";
|
|
10
|
+
import { RpcDebugTracingConfig } from "../../../core/jsonrpc/types/input/debugTraceTransaction";
|
|
11
|
+
import { MessageTrace } from "../../stack-traces/message-trace";
|
|
12
|
+
import { RunTxResult, Trace, VMAdapter } from "./vm-adapter";
|
|
13
|
+
export declare class RethnetAdapter implements VMAdapter {
|
|
14
|
+
private _blockchain;
|
|
15
|
+
private _state;
|
|
16
|
+
private _rethnet;
|
|
17
|
+
private readonly _selectHardfork;
|
|
18
|
+
private _vmTracer;
|
|
19
|
+
constructor(_blockchain: Blockchain, _state: RethnetStateManager, _rethnet: Rethnet, _selectHardfork: (blockNumber: bigint) => string, common: Common);
|
|
20
|
+
static create(config: NodeConfig, selectHardfork: (blockNumber: bigint) => string, getBlockHash: (blockNumber: bigint) => Promise<Buffer>, common: Common): Promise<RethnetAdapter>;
|
|
21
|
+
/**
|
|
22
|
+
* Run `tx` with the given `blockContext`, without modifying the state.
|
|
23
|
+
*/
|
|
24
|
+
dryRun(tx: TypedTransaction, blockContext: Block, forceBaseFeeZero?: boolean): Promise<[RunTxResult, Trace]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the account info for the given address.
|
|
27
|
+
*/
|
|
28
|
+
getAccount(address: Address): Promise<Account>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the storage value at the given address and slot.
|
|
31
|
+
*/
|
|
32
|
+
getContractStorage(address: Address, key: Buffer): Promise<Buffer>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the contract code at the given address.
|
|
35
|
+
*/
|
|
36
|
+
getContractCode(address: Address): Promise<Buffer>;
|
|
37
|
+
/**
|
|
38
|
+
* Update the account info for the given address.
|
|
39
|
+
*/
|
|
40
|
+
putAccount(address: Address, account: Account): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Update the contract code for the given address.
|
|
43
|
+
*/
|
|
44
|
+
putContractCode(address: Address, value: Buffer): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Update the value of the given storage slot.
|
|
47
|
+
*/
|
|
48
|
+
putContractStorage(address: Address, key: Buffer, value: Buffer): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Get the root of the current state trie.
|
|
51
|
+
*/
|
|
52
|
+
getStateRoot(): Promise<Buffer>;
|
|
53
|
+
/**
|
|
54
|
+
* Reset the state trie to the point after `block` was mined. If
|
|
55
|
+
* `irregularStateOrUndefined` is passed, use it as the state root.
|
|
56
|
+
*/
|
|
57
|
+
setBlockContext(block: Block, irregularStateOrUndefined: Buffer | undefined): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Reset the state trie to the point where it had the given state root.
|
|
60
|
+
*
|
|
61
|
+
* Throw if it can't.
|
|
62
|
+
*/
|
|
63
|
+
restoreContext(stateRoot: Buffer): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Start a new block and accept transactions sent with `runTxInBlock`.
|
|
66
|
+
*/
|
|
67
|
+
startBlock(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Must be called after `startBlock`, and before `addBlockRewards`.
|
|
70
|
+
*/
|
|
71
|
+
runTxInBlock(tx: TypedTransaction, block: Block): Promise<[RunTxResult, Trace]>;
|
|
72
|
+
/**
|
|
73
|
+
* Must be called after `startBlock` and all `runTxInBlock` calls.
|
|
74
|
+
*/
|
|
75
|
+
addBlockRewards(rewards: Array<[Address, bigint]>): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Finish the block successfully. Must be called after `addBlockRewards`.
|
|
78
|
+
*/
|
|
79
|
+
sealBlock(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Revert the block and discard the changes to the state. Can be called
|
|
82
|
+
* at any point after `startBlock`.
|
|
83
|
+
*/
|
|
84
|
+
revertBlock(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Re-execute the transactions in the block up until the transaction with the
|
|
87
|
+
* given hash, and trace the execution of that transaction.
|
|
88
|
+
*/
|
|
89
|
+
traceTransaction(hash: Buffer, block: Block, config: RpcDebugTracingConfig): Promise<RpcDebugTraceOutput>;
|
|
90
|
+
makeSnapshot(): Promise<[Buffer, boolean]>;
|
|
91
|
+
removeSnapshot(stateRoot: Buffer): Promise<boolean>;
|
|
92
|
+
getLastTrace(): {
|
|
93
|
+
trace: MessageTrace | undefined;
|
|
94
|
+
error: Error | undefined;
|
|
95
|
+
};
|
|
96
|
+
clearLastError(): void;
|
|
97
|
+
private _getBlockEnvDifficulty;
|
|
98
|
+
private _getBlockPrevRandao;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=rethnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rethnet.d.ts","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/vm/rethnet.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EACL,OAAO,EACP,OAAO,EAER,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAEL,UAAU,EAEV,OAAO,EAER,MAAM,aAAa,CAAC;AAErB,OAAO,EAAsB,UAAU,EAAE,MAAM,eAAe,CAAC;AAS/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAK7D,qBAAa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
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RethnetAdapter = void 0;
|
|
4
|
+
const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util");
|
|
5
|
+
const rethnet_evm_1 = require("rethnet-evm");
|
|
6
|
+
const node_types_1 = require("../node-types");
|
|
7
|
+
const convertToRethnet_1 = require("../utils/convertToRethnet");
|
|
8
|
+
const hardforks_1 = require("../../../util/hardforks");
|
|
9
|
+
const keccak_1 = require("../../../util/keccak");
|
|
10
|
+
const RethnetState_1 = require("../RethnetState");
|
|
11
|
+
const vm_tracer_1 = require("../../stack-traces/vm-tracer");
|
|
12
|
+
/* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
14
|
+
class RethnetAdapter {
|
|
15
|
+
constructor(_blockchain, _state, _rethnet, _selectHardfork, common) {
|
|
16
|
+
this._blockchain = _blockchain;
|
|
17
|
+
this._state = _state;
|
|
18
|
+
this._rethnet = _rethnet;
|
|
19
|
+
this._selectHardfork = _selectHardfork;
|
|
20
|
+
this._vmTracer = new vm_tracer_1.VMTracer(common, false);
|
|
21
|
+
}
|
|
22
|
+
static async create(config, selectHardfork, getBlockHash, common) {
|
|
23
|
+
if ((0, node_types_1.isForkedNodeConfig)(config)) {
|
|
24
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
25
|
+
throw new Error("Forking is not supported for Rethnet yet");
|
|
26
|
+
}
|
|
27
|
+
const blockchain = new rethnet_evm_1.Blockchain(getBlockHash);
|
|
28
|
+
const limitContractCodeSize = config.allowUnlimitedContractSize === true ? 2n ** 64n - 1n : undefined;
|
|
29
|
+
const state = RethnetState_1.RethnetStateManager.withGenesisAccounts(config.genesisAccounts);
|
|
30
|
+
const rethnet = new rethnet_evm_1.Rethnet(blockchain, state.asInner(), {
|
|
31
|
+
chainId: BigInt(config.chainId),
|
|
32
|
+
specId: (0, convertToRethnet_1.ethereumsjsHardforkToRethnet)(config.hardfork),
|
|
33
|
+
limitContractCodeSize,
|
|
34
|
+
disableBlockGasLimit: true,
|
|
35
|
+
disableEip3607: true,
|
|
36
|
+
});
|
|
37
|
+
return new RethnetAdapter(blockchain, state, rethnet, selectHardfork, common);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Run `tx` with the given `blockContext`, without modifying the state.
|
|
41
|
+
*/
|
|
42
|
+
async dryRun(tx, blockContext, forceBaseFeeZero) {
|
|
43
|
+
const rethnetTx = (0, convertToRethnet_1.ethereumjsTransactionToRethnet)(tx);
|
|
44
|
+
const difficulty = this._getBlockEnvDifficulty(blockContext.header.difficulty);
|
|
45
|
+
const prevRandao = this._getBlockPrevRandao(blockContext.header.number, blockContext.header.mixHash);
|
|
46
|
+
const rethnetResult = await this._rethnet.guaranteedDryRun(rethnetTx, {
|
|
47
|
+
number: blockContext.header.number,
|
|
48
|
+
coinbase: blockContext.header.coinbase.buf,
|
|
49
|
+
timestamp: blockContext.header.timestamp,
|
|
50
|
+
basefee: forceBaseFeeZero === true ? 0n : blockContext.header.baseFeePerGas,
|
|
51
|
+
gasLimit: blockContext.header.gasLimit,
|
|
52
|
+
difficulty,
|
|
53
|
+
prevrandao: prevRandao,
|
|
54
|
+
});
|
|
55
|
+
for (const traceItem of rethnetResult.trace) {
|
|
56
|
+
if ("pc" in traceItem) {
|
|
57
|
+
// step
|
|
58
|
+
await this._vmTracer.addStep(traceItem);
|
|
59
|
+
}
|
|
60
|
+
else if ("executionResult" in traceItem) {
|
|
61
|
+
// after message
|
|
62
|
+
await this._vmTracer.addAfterMessage(traceItem);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// before message
|
|
66
|
+
await this._vmTracer.addBeforeMessage(traceItem);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const result = (0, convertToRethnet_1.rethnetResultToRunTxResult)(rethnetResult.result, blockContext.header.gasUsed);
|
|
71
|
+
return [result, rethnetResult.trace];
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
// console.log("Rethnet trace");
|
|
75
|
+
// console.log(rethnetResult.trace);
|
|
76
|
+
throw e;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the account info for the given address.
|
|
81
|
+
*/
|
|
82
|
+
async getAccount(address) {
|
|
83
|
+
const account = await this._state.getAccount(address);
|
|
84
|
+
const storageRoot = await this._state.getAccountStorageRoot(address);
|
|
85
|
+
return new ethereumjs_util_1.Account(account?.nonce, account?.balance, storageRoot ?? undefined, account?.codeHash);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the storage value at the given address and slot.
|
|
89
|
+
*/
|
|
90
|
+
async getContractStorage(address, key) {
|
|
91
|
+
return this._state.getContractStorage(address, key);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the contract code at the given address.
|
|
95
|
+
*/
|
|
96
|
+
async getContractCode(address) {
|
|
97
|
+
return this._state.getContractCode(address);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Update the account info for the given address.
|
|
101
|
+
*/
|
|
102
|
+
async putAccount(address, account) {
|
|
103
|
+
const contractCode = account.codeHash === ethereumjs_util_1.KECCAK256_NULL
|
|
104
|
+
? undefined
|
|
105
|
+
: await this._state.getContractCode(address);
|
|
106
|
+
return this._state.modifyAccount(address, async function (_balance, _nonce, code) {
|
|
107
|
+
const newCode = account.codeHash === ethereumjs_util_1.KECCAK256_NULL
|
|
108
|
+
? undefined
|
|
109
|
+
: account.codeHash === code?.hash
|
|
110
|
+
? code
|
|
111
|
+
: {
|
|
112
|
+
hash: account.codeHash,
|
|
113
|
+
code: contractCode,
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
balance: account.balance,
|
|
117
|
+
nonce: account.nonce,
|
|
118
|
+
code: newCode,
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Update the contract code for the given address.
|
|
124
|
+
*/
|
|
125
|
+
async putContractCode(address, value) {
|
|
126
|
+
const codeHash = (0, keccak_1.keccak256)(value);
|
|
127
|
+
return this._state.modifyAccount(address, async function (balance, nonce, code) {
|
|
128
|
+
const newCode = codeHash === ethereumjs_util_1.KECCAK256_NULL
|
|
129
|
+
? undefined
|
|
130
|
+
: codeHash === code?.hash
|
|
131
|
+
? code
|
|
132
|
+
: {
|
|
133
|
+
hash: codeHash,
|
|
134
|
+
code: value,
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
balance,
|
|
138
|
+
nonce,
|
|
139
|
+
code: newCode,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Update the value of the given storage slot.
|
|
145
|
+
*/
|
|
146
|
+
async putContractStorage(address, key, value) {
|
|
147
|
+
await this._state.putContractStorage(address, key, value);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get the root of the current state trie.
|
|
151
|
+
*/
|
|
152
|
+
async getStateRoot() {
|
|
153
|
+
return this._state.getStateRoot();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Reset the state trie to the point after `block` was mined. If
|
|
157
|
+
* `irregularStateOrUndefined` is passed, use it as the state root.
|
|
158
|
+
*/
|
|
159
|
+
async setBlockContext(block, irregularStateOrUndefined) {
|
|
160
|
+
return this._state.setStateRoot(irregularStateOrUndefined ?? block.header.stateRoot);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Reset the state trie to the point where it had the given state root.
|
|
164
|
+
*
|
|
165
|
+
* Throw if it can't.
|
|
166
|
+
*/
|
|
167
|
+
async restoreContext(stateRoot) {
|
|
168
|
+
return this._state.setStateRoot(stateRoot);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Start a new block and accept transactions sent with `runTxInBlock`.
|
|
172
|
+
*/
|
|
173
|
+
async startBlock() {
|
|
174
|
+
await this._state.checkpoint();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Must be called after `startBlock`, and before `addBlockRewards`.
|
|
178
|
+
*/
|
|
179
|
+
async runTxInBlock(tx, block) {
|
|
180
|
+
const rethnetTx = (0, convertToRethnet_1.ethereumjsTransactionToRethnet)(tx);
|
|
181
|
+
const difficulty = this._getBlockEnvDifficulty(block.header.difficulty);
|
|
182
|
+
const prevRandao = this._getBlockPrevRandao(block.header.number, block.header.mixHash);
|
|
183
|
+
const rethnetResult = await this._rethnet.run(rethnetTx, (0, convertToRethnet_1.ethereumjsHeaderDataToRethnet)(block.header, difficulty, prevRandao));
|
|
184
|
+
for (const traceItem of rethnetResult.trace) {
|
|
185
|
+
if ("pc" in traceItem) {
|
|
186
|
+
// step
|
|
187
|
+
await this._vmTracer.addStep(traceItem);
|
|
188
|
+
}
|
|
189
|
+
else if ("executionResult" in traceItem) {
|
|
190
|
+
// after message
|
|
191
|
+
await this._vmTracer.addAfterMessage(traceItem);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// before message
|
|
195
|
+
await this._vmTracer.addBeforeMessage(traceItem);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const result = (0, convertToRethnet_1.rethnetResultToRunTxResult)(rethnetResult.result, block.header.gasUsed);
|
|
200
|
+
return [result, rethnetResult.trace];
|
|
201
|
+
}
|
|
202
|
+
catch (e) {
|
|
203
|
+
// console.log("Rethnet trace");
|
|
204
|
+
// console.log(rethnetResult.trace);
|
|
205
|
+
throw e;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Must be called after `startBlock` and all `runTxInBlock` calls.
|
|
210
|
+
*/
|
|
211
|
+
async addBlockRewards(rewards) {
|
|
212
|
+
const blockBuilder = rethnet_evm_1.BlockBuilder.new(this._blockchain, this._state.asInner(), {}, {
|
|
213
|
+
// Dummy values
|
|
214
|
+
parentHash: Buffer.alloc(32, 0),
|
|
215
|
+
ommersHash: Buffer.alloc(32, 0),
|
|
216
|
+
beneficiary: Buffer.alloc(20, 0),
|
|
217
|
+
stateRoot: Buffer.alloc(32, 0),
|
|
218
|
+
transactionsRoot: Buffer.alloc(32, 0),
|
|
219
|
+
receiptsRoot: Buffer.alloc(32, 0),
|
|
220
|
+
logsBloom: Buffer.alloc(256, 0),
|
|
221
|
+
difficulty: 0n,
|
|
222
|
+
number: 0n,
|
|
223
|
+
gasLimit: 0n,
|
|
224
|
+
gasUsed: 0n,
|
|
225
|
+
timestamp: 0n,
|
|
226
|
+
extraData: Buffer.allocUnsafe(0),
|
|
227
|
+
mixHash: Buffer.alloc(32, 0),
|
|
228
|
+
nonce: 0n,
|
|
229
|
+
}, {});
|
|
230
|
+
await blockBuilder.finalize(rewards.map(([address, reward]) => {
|
|
231
|
+
return [address.buf, reward];
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Finish the block successfully. Must be called after `addBlockRewards`.
|
|
236
|
+
*/
|
|
237
|
+
async sealBlock() { }
|
|
238
|
+
/**
|
|
239
|
+
* Revert the block and discard the changes to the state. Can be called
|
|
240
|
+
* at any point after `startBlock`.
|
|
241
|
+
*/
|
|
242
|
+
async revertBlock() {
|
|
243
|
+
await this._state.revert();
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Re-execute the transactions in the block up until the transaction with the
|
|
247
|
+
* given hash, and trace the execution of that transaction.
|
|
248
|
+
*/
|
|
249
|
+
async traceTransaction(hash, block, config) {
|
|
250
|
+
throw new Error("traceTransaction not implemented for Rethnet");
|
|
251
|
+
}
|
|
252
|
+
async makeSnapshot() {
|
|
253
|
+
return this._state.makeSnapshot();
|
|
254
|
+
}
|
|
255
|
+
async removeSnapshot(stateRoot) {
|
|
256
|
+
return this._state.removeSnapshot(stateRoot);
|
|
257
|
+
}
|
|
258
|
+
getLastTrace() {
|
|
259
|
+
const trace = this._vmTracer.getLastTopLevelMessageTrace();
|
|
260
|
+
const error = this._vmTracer.getLastError();
|
|
261
|
+
return { trace, error };
|
|
262
|
+
}
|
|
263
|
+
clearLastError() {
|
|
264
|
+
this._vmTracer.clearLastError();
|
|
265
|
+
}
|
|
266
|
+
_getBlockEnvDifficulty(difficulty) {
|
|
267
|
+
const MAX_DIFFICULTY = 2n ** 32n - 1n;
|
|
268
|
+
if (difficulty !== undefined && difficulty > MAX_DIFFICULTY) {
|
|
269
|
+
console.debug("Difficulty is larger than U256::max:", difficulty.toString(16));
|
|
270
|
+
return MAX_DIFFICULTY;
|
|
271
|
+
}
|
|
272
|
+
return difficulty;
|
|
273
|
+
}
|
|
274
|
+
_getBlockPrevRandao(blockNumber, mixHash) {
|
|
275
|
+
const hardfork = this._selectHardfork(blockNumber);
|
|
276
|
+
const isPostMergeHardfork = (0, hardforks_1.hardforkGte)(hardfork, hardforks_1.HardforkName.MERGE);
|
|
277
|
+
if (isPostMergeHardfork) {
|
|
278
|
+
if (mixHash === undefined) {
|
|
279
|
+
throw new Error("mixHash must be set for post-merge hardfork");
|
|
280
|
+
}
|
|
281
|
+
return mixHash;
|
|
282
|
+
}
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
exports.RethnetAdapter = RethnetAdapter;
|
|
287
|
+
//# sourceMappingURL=rethnet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rethnet.js","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/vm/rethnet.ts"],"names":[],"mappings":";;;AAEA,sEAI0C;AAE1C,6CAMqB;AAErB,8CAA+D;AAC/D,gEAKmC;AACnC,uDAAoE;AACpE,iDAAiD;AAEjD,kDAAsD;AAGtD,4DAAwD;AAIxD,yEAAyE;AACzE,sDAAsD;AAEtD,MAAa,cAAc;IAGzB,YACU,WAAuB,EACvB,MAA2B,EAC3B,QAAiB,EACR,eAAgD,EACjE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AAC,CACxB,CAAC;YACF,OAAO,cAAc,CAAC;SACvB;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAEO,mBAAmB,CACzB,WAAmB,EACnB,OAA2B;QAE3B,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QACnD,MAAM,mBAAmB,GAAG,IAAA,uBAAW,EACrC,QAAwB,EACxB,wBAAY,CAAC,KAAK,CACnB,CAAC;QAEF,IAAI,mBAAmB,EAAE;YACvB,IAAI,OAAO,KAAK,SAAS,EAAE;gBACzB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAChE;YAED,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAjaD,wCAiaC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Block } from "@nomicfoundation/ethereumjs-block";
|
|
3
|
+
import type { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
|
4
|
+
import type { Account, Address } from "@nomicfoundation/ethereumjs-util";
|
|
5
|
+
import type { TxReceipt } from "@nomicfoundation/ethereumjs-vm";
|
|
6
|
+
import type { RpcDebugTracingConfig } from "../../../core/jsonrpc/types/input/debugTraceTransaction";
|
|
7
|
+
import type { RpcDebugTraceOutput } from "../output";
|
|
8
|
+
import { MessageTrace } from "../../stack-traces/message-trace";
|
|
9
|
+
import { Bloom } from "../utils/bloom";
|
|
10
|
+
import { Exit } from "./exit";
|
|
11
|
+
export declare type Trace = any;
|
|
12
|
+
export interface RunTxResult {
|
|
13
|
+
bloom: Bloom;
|
|
14
|
+
createdAddress?: Address;
|
|
15
|
+
gasUsed: bigint;
|
|
16
|
+
returnValue: Buffer;
|
|
17
|
+
exit: Exit;
|
|
18
|
+
receipt: TxReceipt;
|
|
19
|
+
}
|
|
20
|
+
export interface RunBlockResult {
|
|
21
|
+
results: RunTxResult[];
|
|
22
|
+
receipts: TxReceipt[];
|
|
23
|
+
stateRoot: Buffer;
|
|
24
|
+
logsBloom: Buffer;
|
|
25
|
+
receiptsRoot: Buffer;
|
|
26
|
+
gasUsed: bigint;
|
|
27
|
+
}
|
|
28
|
+
export interface VMAdapter {
|
|
29
|
+
dryRun(tx: TypedTransaction, blockContext: Block, forceBaseFeeZero?: boolean): Promise<[RunTxResult, Trace]>;
|
|
30
|
+
getAccount(address: Address): Promise<Account>;
|
|
31
|
+
getContractStorage(address: Address, key: Buffer): Promise<Buffer>;
|
|
32
|
+
getContractCode(address: Address): Promise<Buffer>;
|
|
33
|
+
putAccount(address: Address, account: Account): Promise<void>;
|
|
34
|
+
putContractCode(address: Address, value: Buffer): Promise<void>;
|
|
35
|
+
putContractStorage(address: Address, key: Buffer, value: Buffer): Promise<void>;
|
|
36
|
+
getStateRoot(): Promise<Buffer>;
|
|
37
|
+
setBlockContext(block: Block, irregularStateOrUndefined: Buffer | undefined): Promise<void>;
|
|
38
|
+
restoreContext(stateRoot: Buffer): Promise<void>;
|
|
39
|
+
startBlock(): Promise<void>;
|
|
40
|
+
runTxInBlock(tx: TypedTransaction, block: Block): Promise<[RunTxResult, Trace]>;
|
|
41
|
+
addBlockRewards(rewards: Array<[Address, bigint]>): Promise<void>;
|
|
42
|
+
sealBlock(): Promise<void>;
|
|
43
|
+
revertBlock(): Promise<void>;
|
|
44
|
+
getLastTrace(): {
|
|
45
|
+
trace: MessageTrace | undefined;
|
|
46
|
+
error: Error | undefined;
|
|
47
|
+
};
|
|
48
|
+
clearLastError(): void;
|
|
49
|
+
traceTransaction(hash: Buffer, block: Block, config: RpcDebugTracingConfig): Promise<RpcDebugTraceOutput>;
|
|
50
|
+
makeSnapshot(): Promise<[Buffer, boolean]>;
|
|
51
|
+
removeSnapshot(stateRoot: Buffer): Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=vm-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm-adapter.d.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AS,CAAC;QAChC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;KAC1B,CAAC;IACF,cAAc,IAAI,IAAI,CAAC;IACvB,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAGhC,YAAY,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3C,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm-adapter.js","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/vm/vm-adapter.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler-to-model.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/compiler-to-model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compiler-to-model.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/compiler-to-model.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EACL,QAAQ,EAST,MAAM,SAAS,CAAC;AAgBjB,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAC7B,QAAQ,EAAE,CAqBZ"}
|
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createModelsAndDecodeBytecodes = void 0;
|
|
7
7
|
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
const ethereumjs_abi_1 = __importDefault(require("ethereumjs-abi"));
|
|
9
8
|
const library_utils_1 = require("./library-utils");
|
|
10
9
|
const model_1 = require("./model");
|
|
11
10
|
const source_maps_1 = require("./source-maps");
|
|
11
|
+
const abi = require("ethereumjs-abi");
|
|
12
12
|
const log = (0, debug_1.default)("hardhat:core:hardhat-network:compiler-to-model");
|
|
13
13
|
function createModelsAndDecodeBytecodes(solcVersion, compilerInput, compilerOutput) {
|
|
14
14
|
const fileIdToSourceFile = new Map();
|
|
@@ -21,7 +21,17 @@ function createModelsAndDecodeBytecodes(solcVersion, compilerInput, compilerOutp
|
|
|
21
21
|
exports.createModelsAndDecodeBytecodes = createModelsAndDecodeBytecodes;
|
|
22
22
|
function createSourcesModelFromAst(compilerOutput, compilerInput, fileIdToSourceFile, contractIdToContract) {
|
|
23
23
|
const contractIdToLinearizedBaseContractIds = new Map();
|
|
24
|
+
// Create a `sourceName => contract => abi` mapping
|
|
25
|
+
const sourceNameToContractToAbi = new Map();
|
|
26
|
+
for (const [sourceName, contracts] of Object.entries(compilerOutput.contracts)) {
|
|
27
|
+
const contractToAbi = new Map();
|
|
28
|
+
sourceNameToContractToAbi.set(sourceName, contractToAbi);
|
|
29
|
+
for (const [contractName, contract] of Object.entries(contracts)) {
|
|
30
|
+
contractToAbi.set(contractName, contract.abi);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
24
33
|
for (const [sourceName, source] of Object.entries(compilerOutput.sources)) {
|
|
34
|
+
const contractToAbi = sourceNameToContractToAbi.get(sourceName);
|
|
25
35
|
const file = new model_1.SourceFile(sourceName, compilerInput.sources[sourceName].content);
|
|
26
36
|
fileIdToSourceFile.set(source.id, file);
|
|
27
37
|
for (const node of source.ast.nodes) {
|
|
@@ -30,7 +40,8 @@ function createSourcesModelFromAst(compilerOutput, compilerInput, fileIdToSource
|
|
|
30
40
|
if (contractType === undefined) {
|
|
31
41
|
continue;
|
|
32
42
|
}
|
|
33
|
-
|
|
43
|
+
const contractAbi = contractToAbi?.get(node.name);
|
|
44
|
+
processContractAstNode(file, node, fileIdToSourceFile, contractType, contractIdToContract, contractIdToLinearizedBaseContractIds, contractAbi);
|
|
34
45
|
}
|
|
35
46
|
// top-level functions
|
|
36
47
|
if (node.nodeType === "FunctionDefinition") {
|
|
@@ -40,7 +51,7 @@ function createSourcesModelFromAst(compilerOutput, compilerInput, fileIdToSource
|
|
|
40
51
|
}
|
|
41
52
|
applyContractsInheritance(contractIdToContract, contractIdToLinearizedBaseContractIds);
|
|
42
53
|
}
|
|
43
|
-
function processContractAstNode(file, contractNode, fileIdToSourceFile, contractType, contractIdToContract, contractIdToLinearizedBaseContractIds) {
|
|
54
|
+
function processContractAstNode(file, contractNode, fileIdToSourceFile, contractType, contractIdToContract, contractIdToLinearizedBaseContractIds, contractAbi) {
|
|
44
55
|
const contractLocation = astSrcToSourceLocation(contractNode.src, fileIdToSourceFile);
|
|
45
56
|
const contract = new model_1.Contract(contractNode.name, contractType, contractLocation);
|
|
46
57
|
contractIdToContract.set(contractNode.id, contract);
|
|
@@ -48,17 +59,19 @@ function processContractAstNode(file, contractNode, fileIdToSourceFile, contract
|
|
|
48
59
|
file.addContract(contract);
|
|
49
60
|
for (const node of contractNode.nodes) {
|
|
50
61
|
if (node.nodeType === "FunctionDefinition") {
|
|
51
|
-
|
|
62
|
+
const functionAbis = contractAbi?.filter((abiEntry) => abiEntry.name === node.name);
|
|
63
|
+
processFunctionDefinitionAstNode(node, fileIdToSourceFile, contract, file, functionAbis);
|
|
52
64
|
}
|
|
53
65
|
else if (node.nodeType === "ModifierDefinition") {
|
|
54
66
|
processModifierDefinitionAstNode(node, fileIdToSourceFile, contract, file);
|
|
55
67
|
}
|
|
56
68
|
else if (node.nodeType === "VariableDeclaration") {
|
|
57
|
-
|
|
69
|
+
const getterAbi = contractAbi?.find((abiEntry) => abiEntry.name === node.name);
|
|
70
|
+
processVariableDeclarationAstNode(node, fileIdToSourceFile, contract, file, getterAbi);
|
|
58
71
|
}
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
|
-
function processFunctionDefinitionAstNode(functionDefinitionNode, fileIdToSourceFile, contract, file) {
|
|
74
|
+
function processFunctionDefinitionAstNode(functionDefinitionNode, fileIdToSourceFile, contract, file, functionAbis) {
|
|
62
75
|
if (functionDefinitionNode.implemented === false) {
|
|
63
76
|
return;
|
|
64
77
|
}
|
|
@@ -71,7 +84,19 @@ function processFunctionDefinitionAstNode(functionDefinitionNode, fileIdToSource
|
|
|
71
84
|
visibility === model_1.ContractFunctionVisibility.PUBLIC)) {
|
|
72
85
|
selector = astFunctionDefinitionToSelector(functionDefinitionNode);
|
|
73
86
|
}
|
|
74
|
-
|
|
87
|
+
// function can be overloaded, match the abi by the selector
|
|
88
|
+
const matchingFunctionAbi = functionAbis?.find((functionAbi) => {
|
|
89
|
+
if (functionAbi.name === undefined) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const functionAbiSelector = abi.methodID(functionAbi.name, functionAbi.inputs?.map((input) => input.type) ?? []);
|
|
93
|
+
if (selector === undefined || functionAbiSelector === undefined) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return selector.equals(functionAbiSelector);
|
|
97
|
+
});
|
|
98
|
+
const paramTypes = matchingFunctionAbi?.inputs?.map((input) => input.type);
|
|
99
|
+
const cf = new model_1.ContractFunction(functionDefinitionNode.name, functionType, functionLocation, contract, visibility, functionDefinitionNode.stateMutability === "payable", selector, paramTypes);
|
|
75
100
|
if (contract !== undefined) {
|
|
76
101
|
contract.addLocalFunction(cf);
|
|
77
102
|
}
|
|
@@ -116,17 +141,18 @@ function getPublicVariableSelectorFromDeclarationAstNode(variableDeclaration) {
|
|
|
116
141
|
break;
|
|
117
142
|
}
|
|
118
143
|
}
|
|
119
|
-
return
|
|
144
|
+
return abi.methodID(variableDeclaration.name, paramTypes);
|
|
120
145
|
}
|
|
121
|
-
function processVariableDeclarationAstNode(variableDeclarationNode, fileIdToSourceFile, contract, file) {
|
|
146
|
+
function processVariableDeclarationAstNode(variableDeclarationNode, fileIdToSourceFile, contract, file, getterAbi) {
|
|
122
147
|
const visibility = astVisibilityToVisibility(variableDeclarationNode.visibility);
|
|
123
148
|
// Variables can't be external
|
|
124
149
|
if (visibility !== model_1.ContractFunctionVisibility.PUBLIC) {
|
|
125
150
|
return;
|
|
126
151
|
}
|
|
127
152
|
const functionLocation = astSrcToSourceLocation(variableDeclarationNode.src, fileIdToSourceFile);
|
|
153
|
+
const paramTypes = getterAbi?.inputs?.map((input) => input.type);
|
|
128
154
|
const cf = new model_1.ContractFunction(variableDeclarationNode.name, model_1.ContractFunctionType.GETTER, functionLocation, contract, visibility, false, // Getters aren't payable
|
|
129
|
-
getPublicVariableSelectorFromDeclarationAstNode(variableDeclarationNode));
|
|
155
|
+
getPublicVariableSelectorFromDeclarationAstNode(variableDeclarationNode), paramTypes);
|
|
130
156
|
contract.addLocalFunction(cf);
|
|
131
157
|
file.addFunction(cf);
|
|
132
158
|
}
|
|
@@ -259,7 +285,7 @@ function astFunctionDefinitionToSelector(functionDefinition) {
|
|
|
259
285
|
}
|
|
260
286
|
paramTypes.push(toCanonicalAbiType(typename.name));
|
|
261
287
|
}
|
|
262
|
-
return
|
|
288
|
+
return abi.methodID(functionDefinition.name, paramTypes);
|
|
263
289
|
}
|
|
264
290
|
function isContractType(param) {
|
|
265
291
|
return ((param.typeName?.nodeType === "UserDefinedTypeName" ||
|