diff --git a/config/eslint.js b/config/eslint.js index 23f8e55c2a..b30106560c 100644 --- a/config/eslint.js +++ b/config/eslint.js @@ -1,6 +1,6 @@ module.exports = { parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint', 'implicit-dependencies', 'prettier'], + plugins: ['@typescript-eslint', 'implicit-dependencies', 'import', 'prettier'], env: { es2020: true, node: true, @@ -45,6 +45,7 @@ module.exports = { 'no-redeclare': 'off', '@typescript-eslint/no-redeclare': ['error'], '@typescript-eslint/restrict-plus-operands': 'off', + 'import/no-default-export' : ['error'] }, parserOptions: { sourceType: 'module', diff --git a/package-lock.json b/package-lock.json index 1d99f275cb..b66f6bf4f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "eslint-config-prettier": "^6.11.0", "eslint-config-typestrict": "1.0.3", "eslint-plugin-implicit-dependencies": "^1.0.4", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-sonarjs": "^0.5.0", "husky": "^4.2.5", @@ -1622,6 +1623,12 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true + }, "node_modules/@types/jwt-simple": { "version": "0.5.33", "resolved": "https://registry.npmjs.org/@types/jwt-simple/-/jwt-simple-0.5.33.tgz", @@ -2790,6 +2797,25 @@ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", "dev": true }, + "node_modules/array-includes": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", + "integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5", + "get-intrinsic": "^1.1.1", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -2832,6 +2858,24 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/array.prototype.flat": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", + "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.2", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -6181,6 +6225,85 @@ "findup": "^0.1.5" } }, + "node_modules/eslint-plugin-import": { + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", + "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", + "dev": true, + "dependencies": { + "array-includes": "^3.1.4", + "array.prototype.flat": "^1.2.5", + "debug": "^2.6.9", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.6", + "eslint-module-utils": "^2.7.3", + "has": "^1.0.3", + "is-core-module": "^2.8.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.values": "^1.1.5", + "resolve": "^1.22.0", + "tsconfig-paths": "^3.14.1" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/eslint-import-resolver-node": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", + "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", + "dev": true, + "dependencies": { + "debug": "^3.2.7", + "resolve": "^1.20.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/eslint-import-resolver-node/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/eslint-plugin-import/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, "node_modules/eslint-plugin-node": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-4.2.3.tgz", @@ -13176,6 +13299,23 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/object.values": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz", + "integrity": "sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -17586,6 +17726,39 @@ "node": ">=0.4.0" } }, + "node_modules/tsconfig-paths": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", + "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", + "dev": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.1", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tsconfig-paths/node_modules/json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/tsconfig-paths/node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -22742,6 +22915,12 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true + }, "@types/jwt-simple": { "version": "0.5.33", "resolved": "https://registry.npmjs.org/@types/jwt-simple/-/jwt-simple-0.5.33.tgz", @@ -23674,6 +23853,19 @@ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", "dev": true }, + "array-includes": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", + "integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5", + "get-intrinsic": "^1.1.1", + "is-string": "^1.0.7" + } + }, "array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -23704,6 +23896,18 @@ "es-shim-unscopables": "^1.0.0" } }, + "array.prototype.flat": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", + "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.2", + "es-shim-unscopables": "^1.0.0" + } + }, "asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -26663,6 +26867,80 @@ "findup": "^0.1.5" } }, + "eslint-plugin-import": { + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", + "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", + "dev": true, + "requires": { + "array-includes": "^3.1.4", + "array.prototype.flat": "^1.2.5", + "debug": "^2.6.9", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.6", + "eslint-module-utils": "^2.7.3", + "has": "^1.0.3", + "is-core-module": "^2.8.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.values": "^1.1.5", + "resolve": "^1.22.0", + "tsconfig-paths": "^3.14.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "eslint-import-resolver-node": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", + "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", + "dev": true, + "requires": { + "debug": "^3.2.7", + "resolve": "^1.20.0" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + } + } + }, "eslint-plugin-node": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-4.2.3.tgz", @@ -32187,6 +32465,17 @@ "object-keys": "^1.1.1" } }, + "object.values": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz", + "integrity": "sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.1" + } + }, "on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -35686,6 +35975,35 @@ } } }, + "tsconfig-paths": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", + "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", + "dev": true, + "requires": { + "@types/json5": "^0.0.29", + "json5": "^1.0.1", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true + } + } + }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", diff --git a/package.json b/package.json index b21e282e7a..1238b8394e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "eslint-config-prettier": "^6.11.0", "eslint-config-typestrict": "1.0.3", "eslint-plugin-implicit-dependencies": "^1.0.4", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-sonarjs": "^0.5.0", "husky": "^4.2.5", diff --git a/packages/block/README.md b/packages/block/README.md index 5ced2cf6d9..33401fb9af 100644 --- a/packages/block/README.md +++ b/packages/block/README.md @@ -7,7 +7,7 @@ [![Discord][discord-badge]][discord-link] | Implements schema and functions related to Ethereum's block. | -| --- | +| ------------------------------------------------------------ | Note: this `README` reflects the state of the library from `v3.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-block) for an introduction on the last preceding release. @@ -63,16 +63,19 @@ To instantiate an EIP-1559 block, the hardfork parameter on the `Common` instanc ```typescript import { Block } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London }) -const block = Block.fromBlockData({ - header: { - baseFeePerGas: BigInt(10), - gasLimit: BigInt(100), - gasUsed: BigInt(60) - } -}, { common }) +const block = Block.fromBlockData( + { + header: { + baseFeePerGas: BigInt(10), + gasLimit: BigInt(100), + gasUsed: BigInt(60), + }, + }, + { common } +) // Base fee will increase for next block since the // gas used is greater than half the gas limit @@ -81,17 +84,19 @@ block.header.calcNextBaseFee().toNumber() // 11 // So for creating a block with a matching base fee in a certain // chain context you can do: -const blockWithMatchingBaseFee = Block.fromBlockData({ - header: { - baseFeePerGas: parentHeader.calcNextBaseFee(), - gasLimit: BigInt(100), - gasUsed: BigInt(60) - } -}, { common }) - +const blockWithMatchingBaseFee = Block.fromBlockData( + { + header: { + baseFeePerGas: parentHeader.calcNextBaseFee(), + gasLimit: BigInt(100), + gasUsed: BigInt(60), + }, + }, + { common } +) ``` -EIP-1559 blocks have an extra `baseFeePerGas` field (default: `BigInt(7)`) and can encompass `FeeMarketEIP1559Transaction` txs (type `2`) (supported by `@ethereumjs/tx` `v3.2.0` or higher) as well as `Transaction` legacy txs (internal type `0`) and `AccessListEIP2930Transaction` txs (type `1`). +EIP-1559 blocks have an extra `baseFeePerGas` field (default: `BigInt(7)`) and can encompass `FeeMarketEIP1559Transaction` txs (type `2`) (supported by `@ethereumjs/tx` `v3.2.0` or higher) as well as `Transaction` legacy txs (internal type `0`) and `AccessListEIP2930Transaction` txs (type `1`). ## Consensus Types @@ -103,8 +108,8 @@ An Ethash/PoW block can be instantiated as follows: ```typescript import { Block } from '@ethereumjs/block' -import Common, { Chain } from '@ethereumjs/common' -const common = new Common({ chain: Chain.Mainnet }) +import { Chain, Common } from '@ethereumjs/common' +const common = new Common({ chain: Chain.Mainnet }) console.log(common.consensusType()) // 'pow' console.log(common.consensusAlgorithm()) // 'ethash' const block = Block.fromBlockData({}, { common }) @@ -120,8 +125,8 @@ A clique block can be instantiated as follows: ```typescript import { Block } from '@ethereumjs/block' -import Common, { Chain } from '@ethereumjs/common' -const common = new Common({ chain: Chain.Goerli }) +import { Chain, Common } from '@ethereumjs/common' +const common = new Common({ chain: Chain.Goerli }) console.log(common.consensusType()) // 'poa' console.log(common.consensusAlgorithm()) // 'clique' const block = Block.fromBlockData({}, { common }) @@ -157,11 +162,14 @@ You can instantiate a Merge/PoS block like this: ```typescript import { Block } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' -const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge, }) -const block = Block.fromBlockData({ - // Provide your block data here or use default values -}, { common }) +import { Chain, Common, Hardfork } from '@ethereumjs/common' +const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge }) +const block = Block.fromBlockData( + { + // Provide your block data here or use default values + }, + { common } +) ``` Note that all `Merge` respectively `Casper/PoS` related functionality is still considered `experimental`. diff --git a/packages/block/src/block.ts b/packages/block/src/block.ts index f71a3d8084..9dea8986a9 100644 --- a/packages/block/src/block.ts +++ b/packages/block/src/block.ts @@ -1,8 +1,8 @@ import { Trie } from '@ethereumjs/trie' import { keccak256 } from 'ethereum-cryptography/keccak' import { arrToBufArr, bufArrToArr, KECCAK256_RLP, bufferToHex } from '@ethereumjs/util' -import RLP from 'rlp' -import Common, { ConsensusType } from '@ethereumjs/common' +import { RLP } from 'rlp' +import { Common, ConsensusType } from '@ethereumjs/common' import { TransactionFactory, TypedTransaction, diff --git a/packages/block/src/from-rpc.ts b/packages/block/src/from-rpc.ts index cf39595322..f430e446b3 100644 --- a/packages/block/src/from-rpc.ts +++ b/packages/block/src/from-rpc.ts @@ -3,7 +3,7 @@ import { toBuffer, setLengthLeft } from '@ethereumjs/util' import { Block, BlockOptions } from './index' import { numberToHex } from './helpers' -import blockHeaderFromRpc from './header-from-rpc' +import { blockHeaderFromRpc } from './header-from-rpc' function normalizeTxParams(_txParams: any) { const txParams = Object.assign({}, _txParams) @@ -34,7 +34,7 @@ function normalizeTxParams(_txParams: any) { * @param uncles - Optional list of Ethereum JSON RPC of uncles (eth_getUncleByBlockHashAndIndex) * @param chainOptions - An object describing the blockchain */ -export default function blockFromRpc(blockParams: any, uncles: any[] = [], options?: BlockOptions) { +export function blockFromRpc(blockParams: any, uncles: any[] = [], options?: BlockOptions) { const header = blockHeaderFromRpc(blockParams, options) const transactions: TypedTransaction[] = [] diff --git a/packages/block/src/header-from-rpc.ts b/packages/block/src/header-from-rpc.ts index 4291732249..38234ada65 100644 --- a/packages/block/src/header-from-rpc.ts +++ b/packages/block/src/header-from-rpc.ts @@ -8,7 +8,7 @@ import { numberToHex } from './helpers' * @param blockParams - Ethereum JSON RPC of block (eth_getBlockByNumber) * @param chainOptions - An object describing the blockchain */ -export default function blockHeaderFromRpc(blockParams: any, options?: BlockOptions) { +export function blockHeaderFromRpc(blockParams: any, options?: BlockOptions) { const { parentHash, sha3Uncles, diff --git a/packages/block/src/header.ts b/packages/block/src/header.ts index 2f5644476b..ab2ae046c1 100644 --- a/packages/block/src/header.ts +++ b/packages/block/src/header.ts @@ -1,5 +1,6 @@ -import Common, { +import { Chain, + Common, ConsensusAlgorithm, ConsensusType, Hardfork, @@ -23,7 +24,7 @@ import { TypeOutput, zeros, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { BlockHeaderBuffer, BlockOptions, HeaderData, JsonHeader } from './types' import { CLIQUE_EXTRA_VANITY, CLIQUE_EXTRA_SEAL } from './clique' diff --git a/packages/block/src/types.ts b/packages/block/src/types.ts index f5a25aef58..10902a67d9 100644 --- a/packages/block/src/types.ts +++ b/packages/block/src/types.ts @@ -1,5 +1,5 @@ import { AddressLike, BigIntLike, BufferLike } from '@ethereumjs/util' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { TxData, JsonTx, AccessListEIP2930TxData, FeeMarketEIP1559TxData } from '@ethereumjs/tx' import { BlockHeader } from './header' diff --git a/packages/block/test/block.spec.ts b/packages/block/test/block.spec.ts index 862c8582a2..c6b78d6b31 100644 --- a/packages/block/test/block.spec.ts +++ b/packages/block/test/block.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { NestedUint8Array, toBuffer, zeros } from '@ethereumjs/util' -import RLP from 'rlp' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { RLP } from 'rlp' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Block, BlockBuffer } from '../src' -import blockFromRpc from '../src/from-rpc' +import { blockFromRpc } from '../src/from-rpc' import * as testnetMerge from './testdata/testnetMerge.json' import * as testDataPreLondon from './testdata/testdata_pre-london.json' import * as testDataPreLondon2 from './testdata/testdata_pre-london-2.json' diff --git a/packages/block/test/clique.spec.ts b/packages/block/test/clique.spec.ts index bed7d9e1f0..e4faa3c40b 100644 --- a/packages/block/test/clique.spec.ts +++ b/packages/block/test/clique.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { BlockHeader } from '../src/header' import { Address } from '@ethereumjs/util' diff --git a/packages/block/test/difficulty.spec.ts b/packages/block/test/difficulty.spec.ts index 25a5378233..26b88cfb83 100644 --- a/packages/block/test/difficulty.spec.ts +++ b/packages/block/test/difficulty.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import { bufferToInt } from '@ethereumjs/util' import { Block } from '../src' diff --git a/packages/block/test/eip1559block.spec.ts b/packages/block/test/eip1559block.spec.ts index 65f7db700b..a9ce291ef4 100644 --- a/packages/block/test/eip1559block.spec.ts +++ b/packages/block/test/eip1559block.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { BlockHeader } from '../src/header' import { Block } from '../src/block' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' diff --git a/packages/block/test/from-rpc.spec.ts b/packages/block/test/from-rpc.spec.ts index 6579654e03..f7af9f169c 100644 --- a/packages/block/test/from-rpc.spec.ts +++ b/packages/block/test/from-rpc.spec.ts @@ -1,8 +1,8 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' -import blockFromRpc from '../src/from-rpc' -import blockHeaderFromRpc from '../src/header-from-rpc' +import { blockFromRpc } from '../src/from-rpc' +import { blockHeaderFromRpc } from '../src/header-from-rpc' import * as blockData from './testdata/testdata-from-rpc.json' import * as blockDataDifficultyAsInteger from './testdata/testdata-from-rpc-difficulty-as-integer.json' import * as blockDataWithUncles from './testdata/testdata-from-rpc-with-uncles.json' diff --git a/packages/block/test/header.spec.ts b/packages/block/test/header.spec.ts index bd91803da0..a972b15dbd 100644 --- a/packages/block/test/header.spec.ts +++ b/packages/block/test/header.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Address, toBuffer, zeros, KECCAK256_RLP, KECCAK256_RLP_ARRAY } from '@ethereumjs/util' -import RLP from 'rlp' -import Common, { Chain, CliqueConfig, Hardfork } from '@ethereumjs/common' +import { RLP } from 'rlp' +import { Chain, Common, CliqueConfig, Hardfork } from '@ethereumjs/common' import { BlockHeader } from '../src/header' import { Block } from '../src' const blocksMainnet = require('./testdata/blocks_mainnet.json') diff --git a/packages/block/test/mergeBlock.spec.ts b/packages/block/test/mergeBlock.spec.ts index 4bd5d50a33..9a2f4ce986 100644 --- a/packages/block/test/mergeBlock.spec.ts +++ b/packages/block/test/mergeBlock.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { BlockHeader } from '../src/header' import { Address, KECCAK256_RLP, KECCAK256_RLP_ARRAY, zeros } from '@ethereumjs/util' import { Block } from '../src/block' diff --git a/packages/block/test/util.ts b/packages/block/test/util.ts index b7ea9b9ead..1dc0a22152 100644 --- a/packages/block/test/util.ts +++ b/packages/block/test/util.ts @@ -1,7 +1,7 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { keccak256 } from 'ethereum-cryptography/keccak' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Block, BlockHeader } from '../src' /** diff --git a/packages/blockchain/README.md b/packages/blockchain/README.md index 7ae41e9ac0..86e5705aef 100644 --- a/packages/blockchain/README.md +++ b/packages/blockchain/README.md @@ -7,7 +7,7 @@ [![Discord][discord-badge]][discord-link] | A module to store and interact with blocks. | -| --- | +| ------------------------------------------- | Note: this `README` reflects the state of the library from `v5.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-blockchain) for an introduction on the last preceding release. @@ -24,8 +24,8 @@ The following is an example to iterate through an existing Geth DB (needs `level This module performs write operations. Making a backup of your data before trying it is recommended. Otherwise, you can end up with a compromised DB state. ```typescript -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common } from '@ethereumjs/common' const { Level } = require('level') @@ -59,9 +59,9 @@ For debugging blockchain control flows the [debug](https://github.com/visionmedi The following initial logger is currently available: -| Logger | Description | -| - | - | -| `blockchain:clique` | Clique operations like updating the vote and/or signer list | +| Logger | Description | +| ------------------- | ----------------------------------------------------------- | +| `blockchain:clique` | Clique operations like updating the vote and/or signer list | The following is an example for a logger run: diff --git a/packages/blockchain/src/blockchain.ts b/packages/blockchain/src/blockchain.ts index 1de4e8cdc2..1cd34abed9 100644 --- a/packages/blockchain/src/blockchain.ts +++ b/packages/blockchain/src/blockchain.ts @@ -1,8 +1,9 @@ import Semaphore from 'semaphore-async-await' import { Block, BlockData, BlockHeader } from '@ethereumjs/block' -import Common, { +import { Chain, CliqueConfig, + Common, ConsensusAlgorithm, ConsensusType, Hardfork, diff --git a/packages/blockchain/src/consensus/clique.ts b/packages/blockchain/src/consensus/clique.ts index 4740c82073..9d8daad624 100644 --- a/packages/blockchain/src/consensus/clique.ts +++ b/packages/blockchain/src/consensus/clique.ts @@ -1,8 +1,8 @@ import { debug as createDebugLogger } from 'debug' import { Block, BlockHeader } from '@ethereumjs/block' import { Address, bigIntToBuffer, bufferToBigInt, arrToBufArr, bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' -import Blockchain from '..' +import { RLP } from 'rlp' +import { Blockchain } from '..' import { Consensus, ConsensusOptions } from './interface' import { CliqueConfig, ConsensusAlgorithm } from '@ethereumjs/common' diff --git a/packages/blockchain/src/consensus/ethash.ts b/packages/blockchain/src/consensus/ethash.ts index 2aff4c2f0a..e525b934e4 100644 --- a/packages/blockchain/src/consensus/ethash.ts +++ b/packages/blockchain/src/consensus/ethash.ts @@ -1,7 +1,7 @@ import { Block, BlockHeader } from '@ethereumjs/block' import { ConsensusAlgorithm } from '@ethereumjs/common' -import Ethash, { EthashCacheDB } from '@ethereumjs/ethash' -import Blockchain from '..' +import { Ethash, EthashCacheDB } from '@ethereumjs/ethash' +import { Blockchain } from '..' import { Consensus, ConsensusOptions } from './interface' /** diff --git a/packages/blockchain/src/consensus/interface.ts b/packages/blockchain/src/consensus/interface.ts index cf5fd59dba..cf69131fe0 100644 --- a/packages/blockchain/src/consensus/interface.ts +++ b/packages/blockchain/src/consensus/interface.ts @@ -1,6 +1,6 @@ import { Block, BlockHeader } from '@ethereumjs/block' import { ConsensusAlgorithm } from '@ethereumjs/common' -import Blockchain from '..' +import { Blockchain } from '..' /** * Interface that a consensus class needs to implement. diff --git a/packages/blockchain/src/db/cache.ts b/packages/blockchain/src/db/cache.ts index 4091886810..d84a3459c8 100644 --- a/packages/blockchain/src/db/cache.ts +++ b/packages/blockchain/src/db/cache.ts @@ -4,7 +4,7 @@ import * as LRUCache from 'lru-cache' * Simple LRU Cache that allows for keys of type Buffer * @hidden */ -export default class Cache { +export class Cache { _cache: LRUCache constructor(opts: LRUCache.Options) { diff --git a/packages/blockchain/src/db/helpers.ts b/packages/blockchain/src/db/helpers.ts index be71da6c3f..5707751752 100644 --- a/packages/blockchain/src/db/helpers.ts +++ b/packages/blockchain/src/db/helpers.ts @@ -1,6 +1,6 @@ import { DBOp, DBTarget } from './operation' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Block, BlockHeader } from '@ethereumjs/block' import { bufBE8 } from './constants' diff --git a/packages/blockchain/src/db/manager.ts b/packages/blockchain/src/db/manager.ts index 5f3fefd2f3..71ccb7bc8f 100644 --- a/packages/blockchain/src/db/manager.ts +++ b/packages/blockchain/src/db/manager.ts @@ -1,9 +1,9 @@ import { arrToBufArr, bufferToBigInt } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Block, BlockHeader, BlockOptions, BlockBuffer, BlockBodyBuffer } from '@ethereumjs/block' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { AbstractLevel } from 'abstract-level' -import Cache from './cache' +import { Cache } from './cache' import { DatabaseKey, DBOp, DBTarget, DBOpData } from './operation' class NotFoundError extends Error { diff --git a/packages/blockchain/src/genesisStates/index.ts b/packages/blockchain/src/genesisStates/index.ts index 2cb69393c2..112db0988b 100644 --- a/packages/blockchain/src/genesisStates/index.ts +++ b/packages/blockchain/src/genesisStates/index.ts @@ -1,7 +1,7 @@ import { SecureTrie as Trie } from '@ethereumjs/trie' import { keccak256 } from 'ethereum-cryptography/keccak' import { Account, isHexPrefixed, toBuffer, unpadBuffer, PrefixedHexString } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' export type StoragePair = [key: PrefixedHexString, value: PrefixedHexString] diff --git a/packages/blockchain/src/index.ts b/packages/blockchain/src/index.ts index c0ad9a9546..bbdd0c0407 100644 --- a/packages/blockchain/src/index.ts +++ b/packages/blockchain/src/index.ts @@ -1,3 +1,3 @@ export { Consensus, CasperConsensus, CliqueConsensus, EthashConsensus } from './consensus' -export { Blockchain as default } from './blockchain' +export { Blockchain } from './blockchain' export { BlockchainInterface, BlockchainOptions } from './types' diff --git a/packages/blockchain/src/types.ts b/packages/blockchain/src/types.ts index 2764ecdd6a..9268c3edbc 100644 --- a/packages/blockchain/src/types.ts +++ b/packages/blockchain/src/types.ts @@ -1,5 +1,5 @@ import { Block } from '@ethereumjs/block' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { AbstractLevel } from 'abstract-level' import { Consensus } from '.' import { GenesisState } from './genesisStates' diff --git a/packages/blockchain/test/blockValidation.spec.ts b/packages/blockchain/test/blockValidation.spec.ts index b1e9b93aca..86f1a9c481 100644 --- a/packages/blockchain/test/blockValidation.spec.ts +++ b/packages/blockchain/test/blockValidation.spec.ts @@ -1,12 +1,12 @@ import { Block, BlockHeader } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { bufArrToArr } from '@ethereumjs/util' import { keccak256 } from 'ethereum-cryptography/keccak' import { bytesToHex } from 'ethereum-cryptography/utils' -import RLP from 'rlp' +import { RLP } from 'rlp' import * as tape from 'tape' -import Blockchain from '../src' +import { Blockchain } from '../src' import { createBlock } from './util' tape('[Blockchain]: Block validation tests', (t) => { diff --git a/packages/blockchain/test/clique.spec.ts b/packages/blockchain/test/clique.spec.ts index 0f4bb4ac9c..e024688a86 100644 --- a/packages/blockchain/test/clique.spec.ts +++ b/packages/blockchain/test/clique.spec.ts @@ -1,5 +1,6 @@ import { Block } from '@ethereumjs/block' -import Common, { +import { + Common, Chain, CliqueConfig, ConsensusAlgorithm, @@ -8,7 +9,7 @@ import Common, { } from '@ethereumjs/common' import { Address } from '@ethereumjs/util' import * as tape from 'tape' -import Blockchain from '../src' +import { Blockchain } from '../src' import { CliqueConsensus, CLIQUE_NONCE_AUTH, CLIQUE_NONCE_DROP } from '../src/consensus/clique' tape('Clique: Initialization', (t) => { diff --git a/packages/blockchain/test/customConsensus.spec.ts b/packages/blockchain/test/customConsensus.spec.ts index 25d8356adf..316b166f40 100644 --- a/packages/blockchain/test/customConsensus.spec.ts +++ b/packages/blockchain/test/customConsensus.spec.ts @@ -1,7 +1,7 @@ import { Block, BlockHeader } from '@ethereumjs/block' import * as tape from 'tape' -import Blockchain, { Consensus, EthashConsensus } from '../src' -import Common, { Hardfork } from '@ethereumjs/common' +import { Blockchain, Consensus, EthashConsensus } from '../src' +import { Common, Hardfork } from '@ethereumjs/common' class fibonacciConsensus implements Consensus { algorithm: string diff --git a/packages/blockchain/test/index.spec.ts b/packages/blockchain/test/index.spec.ts index a8d1e37bf6..89f50a17d2 100644 --- a/packages/blockchain/test/index.spec.ts +++ b/packages/blockchain/test/index.spec.ts @@ -1,7 +1,7 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Block, BlockHeader, BlockOptions } from '@ethereumjs/block' import * as tape from 'tape' -import Blockchain from '../src' +import { Blockchain } from '../src' import { generateBlockchain, generateBlocks, isConsecutive, createTestDB } from './util' import * as testDataPreLondon from './testdata/testdata_pre-london.json' import * as blocksData from './testdata/blocks_mainnet.json' diff --git a/packages/blockchain/test/pos.spec.ts b/packages/blockchain/test/pos.spec.ts index e892aac09a..818d65bcd7 100644 --- a/packages/blockchain/test/pos.spec.ts +++ b/packages/blockchain/test/pos.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Common, { Hardfork } from '@ethereumjs/common' -import Blockchain from '../src' +import { Common, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '../src' import * as testnet from './testdata/testnet.json' const buildChain = async (blockchain: Blockchain, common: Common, height: number) => { diff --git a/packages/blockchain/test/reorg.spec.ts b/packages/blockchain/test/reorg.spec.ts index 3a16c4c352..de93bca948 100644 --- a/packages/blockchain/test/reorg.spec.ts +++ b/packages/blockchain/test/reorg.spec.ts @@ -1,8 +1,8 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' import { Address } from '@ethereumjs/util' import * as tape from 'tape' -import Blockchain from '../src' +import { Blockchain } from '../src' import { CliqueConsensus, CLIQUE_NONCE_AUTH } from '../src/consensus/clique' import { generateConsecutiveBlock } from './util' diff --git a/packages/blockchain/test/util.ts b/packages/blockchain/test/util.ts index 63bf8ec648..005be02b2e 100644 --- a/packages/blockchain/test/util.ts +++ b/packages/blockchain/test/util.ts @@ -1,8 +1,8 @@ import { bufArrToArr, toBuffer } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Block, BlockHeader } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import Blockchain from '../src' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '../src' import { MemoryLevel } from 'memory-level' import { Level } from 'level' import { keccak256 } from 'ethereum-cryptography/keccak' diff --git a/packages/client/bin/cli.ts b/packages/client/bin/cli.ts index bd6d6dc732..5e9e843b5b 100755 --- a/packages/client/bin/cli.ts +++ b/packages/client/bin/cli.ts @@ -6,8 +6,8 @@ import * as readline from 'readline' import { randomBytes } from 'crypto' import { existsSync } from 'fs' import { ensureDirSync, readFileSync, removeSync } from 'fs-extra' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork, ConsensusAlgorithm } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork, ConsensusAlgorithm } from '@ethereumjs/common' import { Address, toBuffer } from '@ethereumjs/util' import { parseMultiaddrs, @@ -15,7 +15,7 @@ import { parseCustomParams, setCommonForkHashes, } from '../lib/util' -import EthereumClient from '../lib/client' +import { EthereumClient } from '../lib/client' import { Config, DataDirectory, SyncMode } from '../lib/config' import { Logger, getLogger } from '../lib/logging' import { startRPCServers, helprpc } from './startRpc' diff --git a/packages/client/bin/startRpc.ts b/packages/client/bin/startRpc.ts index b1d69f1c71..62483f1c25 100644 --- a/packages/client/bin/startRpc.ts +++ b/packages/client/bin/startRpc.ts @@ -1,7 +1,7 @@ import { Server as RPCServer } from 'jayson/promise' import { readFileSync, writeFileSync } from 'fs-extra' import { RPCManager } from '../lib/rpc' -import EthereumClient from '../lib/client' +import { EthereumClient } from '../lib/client' import { MethodConfig, createRPCServer, diff --git a/packages/client/browser/index.ts b/packages/client/browser/index.ts index 85fe09195e..1c9dd54819 100644 --- a/packages/client/browser/index.ts +++ b/packages/client/browser/index.ts @@ -1,4 +1,4 @@ -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' // Blockchain export * from '../lib/blockchain/chain' @@ -23,7 +23,7 @@ export * from '../lib/net/server/libp2pserver' // EthereumClient export * from '../lib/client' -import EthereumClient from '../lib/client' +import { EthereumClient } from '../lib/client' // Service export * from '../lib/service/service' diff --git a/packages/client/lib/blockchain/chain.ts b/packages/client/lib/blockchain/chain.ts index f2912ef898..0d7a8389e4 100644 --- a/packages/client/lib/blockchain/chain.ts +++ b/packages/client/lib/blockchain/chain.ts @@ -1,5 +1,5 @@ import { Block, BlockHeader } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' import { ConsensusAlgorithm, Hardfork } from '@ethereumjs/common' import { AbstractLevel } from 'abstract-level' import { Config } from '../config' diff --git a/packages/client/lib/client.ts b/packages/client/lib/client.ts index eeb277ee97..c0445acfed 100644 --- a/packages/client/lib/client.ts +++ b/packages/client/lib/client.ts @@ -4,7 +4,7 @@ import { Config, SyncMode } from './config' import { FullEthereumService, LightEthereumService } from './service' import { Event } from './types' import { Chain } from './blockchain' -import type Blockchain from '@ethereumjs/blockchain' +import type { Blockchain } from '@ethereumjs/blockchain' import { AbstractLevel } from 'abstract-level' export interface EthereumClientOptions { @@ -53,7 +53,7 @@ export interface EthereumClientOptions { * lifecycle of included services. * @memberof module:node */ -export default class EthereumClient { +export class EthereumClient { public config: Config public chain: Chain public services: (FullEthereumService | LightEthereumService)[] diff --git a/packages/client/lib/config.ts b/packages/client/lib/config.ts index e508491128..e333a19404 100644 --- a/packages/client/lib/config.ts +++ b/packages/client/lib/config.ts @@ -1,5 +1,5 @@ -import Common, { Hardfork } from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Common, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' import { genPrivateKey } from '@ethereumjs/devp2p' import { Address } from '@ethereumjs/util' import { Multiaddr } from 'multiaddr' diff --git a/packages/client/lib/execution/receipt.ts b/packages/client/lib/execution/receipt.ts index fdbf9ca3da..1e705848f5 100644 --- a/packages/client/lib/execution/receipt.ts +++ b/packages/client/lib/execution/receipt.ts @@ -9,7 +9,7 @@ import { bufferToInt, intToBuffer, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { MetaDBManager, DBKey } from '../util/metaDBManager' import type { Block } from '@ethereumjs/block' diff --git a/packages/client/lib/execution/vmexecution.ts b/packages/client/lib/execution/vmexecution.ts index 94ac7c4404..f74571a4ce 100644 --- a/packages/client/lib/execution/vmexecution.ts +++ b/packages/client/lib/execution/vmexecution.ts @@ -5,7 +5,7 @@ import { DBSetHashToNumber, } from '@ethereumjs/blockchain/dist/db/helpers' import { ConsensusType, Hardfork } from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { VM } from '@ethereumjs/vm' import { bufferToHex } from '@ethereumjs/util' import { DefaultStateManager } from '@ethereumjs/statemanager' import { LevelDB, SecureTrie as Trie } from '@ethereumjs/trie' diff --git a/packages/client/lib/index.ts b/packages/client/lib/index.ts index e45659e203..c961c440c0 100644 --- a/packages/client/lib/index.ts +++ b/packages/client/lib/index.ts @@ -1,2 +1,2 @@ export * from './config' -export { default as EthereumClient } from './client' +export { EthereumClient } from './client' diff --git a/packages/client/lib/miner/miner.ts b/packages/client/lib/miner/miner.ts index 60afc0734c..29e565910e 100644 --- a/packages/client/lib/miner/miner.ts +++ b/packages/client/lib/miner/miner.ts @@ -1,4 +1,4 @@ -import Ethash, { Solution, Miner as EthashMiner } from '@ethereumjs/ethash' +import { Ethash, Solution, Miner as EthashMiner } from '@ethereumjs/ethash' import { BlockHeader } from '@ethereumjs/block' import { CliqueConsensus } from '@ethereumjs/blockchain' import { ConsensusType, Hardfork, CliqueConfig } from '@ethereumjs/common' diff --git a/packages/client/lib/miner/pendingBlock.ts b/packages/client/lib/miner/pendingBlock.ts index b58cf29e46..8a697098eb 100644 --- a/packages/client/lib/miner/pendingBlock.ts +++ b/packages/client/lib/miner/pendingBlock.ts @@ -1,5 +1,5 @@ import { randomBytes } from 'crypto' -import type VM from '@ethereumjs/vm' +import type { VM } from '@ethereumjs/vm' import type { TxReceipt } from '@ethereumjs/vm' import type { BlockBuilder } from '@ethereumjs/vm/dist/buildBlock' import type { Block, HeaderData } from '@ethereumjs/block' diff --git a/packages/client/lib/net/protocol/ethprotocol.ts b/packages/client/lib/net/protocol/ethprotocol.ts index 656e5b85c9..b748be92aa 100644 --- a/packages/client/lib/net/protocol/ethprotocol.ts +++ b/packages/client/lib/net/protocol/ethprotocol.ts @@ -15,7 +15,7 @@ import { bufferToInt, intToBuffer, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Chain } from './../../blockchain' import { Message, Protocol, ProtocolOptions } from './protocol' import type { TxReceiptWithType } from '../../execution/receipt' diff --git a/packages/client/lib/net/protocol/libp2psender.ts b/packages/client/lib/net/protocol/libp2psender.ts index 6dfb9527e3..d26640e29e 100644 --- a/packages/client/lib/net/protocol/libp2psender.ts +++ b/packages/client/lib/net/protocol/libp2psender.ts @@ -1,7 +1,7 @@ import * as pipe from 'it-pipe' import * as pushable from 'it-pushable' import { arrToBufArr, bufferToInt, bufArrToArr, intToBuffer } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Libp2pMuxedStream as MuxedStream } from '../../types' import { Sender } from './sender' diff --git a/packages/client/lib/rpc/index.ts b/packages/client/lib/rpc/index.ts index aca5d16a8c..4df445ec1a 100644 --- a/packages/client/lib/rpc/index.ts +++ b/packages/client/lib/rpc/index.ts @@ -1,5 +1,5 @@ import { Config } from '../config' -import EthereumClient from '../client' +import { EthereumClient } from '../client' import * as modules from './modules' import { INTERNAL_ERROR } from './error-code' diff --git a/packages/client/lib/rpc/modules/admin.ts b/packages/client/lib/rpc/modules/admin.ts index d0e5dd00ce..da24f15523 100644 --- a/packages/client/lib/rpc/modules/admin.ts +++ b/packages/client/lib/rpc/modules/admin.ts @@ -3,7 +3,7 @@ import { getClientVersion } from '../../util' import { middleware } from '../validation' import type { Chain } from '../../blockchain' import type { RlpxServer } from '../../net/server' -import type EthereumClient from '../../client' +import type { EthereumClient } from '../../client' import type { EthereumService } from '../../service' /** diff --git a/packages/client/lib/rpc/modules/engine.ts b/packages/client/lib/rpc/modules/engine.ts index e9aab6a194..a867255123 100644 --- a/packages/client/lib/rpc/modules/engine.ts +++ b/packages/client/lib/rpc/modules/engine.ts @@ -1,7 +1,7 @@ import { Block, HeaderData } from '@ethereumjs/block' import { TransactionFactory, TypedTransaction } from '@ethereumjs/tx' import { bufferToHex, toBuffer, zeros } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Trie } from '@ethereumjs/trie' import { Hardfork } from '@ethereumjs/common' @@ -10,8 +10,8 @@ import { INTERNAL_ERROR, INVALID_PARAMS } from '../error-code' import { short } from '../../util' import { PendingBlock } from '../../miner' import { CLConnectionManager } from '../util/CLConnectionManager' -import type VM from '@ethereumjs/vm' -import type EthereumClient from '../../client' +import type { VM } from '@ethereumjs/vm' +import type { EthereumClient } from '../../client' import type { Chain } from '../../blockchain' import type { VMExecution } from '../../execution' import type { Config } from '../../config' diff --git a/packages/client/lib/rpc/modules/eth.ts b/packages/client/lib/rpc/modules/eth.ts index b0a6201f46..4389b147af 100644 --- a/packages/client/lib/rpc/modules/eth.ts +++ b/packages/client/lib/rpc/modules/eth.ts @@ -19,12 +19,12 @@ import { toType, TypeOutput, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { middleware, validators } from '../validation' import { INTERNAL_ERROR, INVALID_PARAMS, PARSE_ERROR } from '../error-code' import { RpcTx } from '../types' import { EthereumService, FullEthereumService } from '../../service' -import type VM from '@ethereumjs/vm' +import type { VM } from '@ethereumjs/vm' import type { PostByzantiumTxReceipt, PreByzantiumTxReceipt, TxReceipt } from '@ethereumjs/vm' import type { Log } from '@ethereumjs/evm' import type { Proof } from '@ethereumjs/statemanager' diff --git a/packages/client/lib/service/txpool.ts b/packages/client/lib/service/txpool.ts index d905c51b97..4ca194bf3b 100644 --- a/packages/client/lib/service/txpool.ts +++ b/packages/client/lib/service/txpool.ts @@ -8,7 +8,7 @@ import { import { Address, bufferToHex } from '@ethereumjs/util' import { Config } from '../config' import { Peer } from '../net/peer' -import type VM from '@ethereumjs/vm' +import type { VM } from '@ethereumjs/vm' import type { FullEthereumService } from './fullethereumservice' import type { PeerPool } from '../net/peerpool' import type { Block } from '@ethereumjs/block' diff --git a/packages/client/lib/sync/skeleton.ts b/packages/client/lib/sync/skeleton.ts index 00ec2c6aeb..4210787e92 100644 --- a/packages/client/lib/sync/skeleton.ts +++ b/packages/client/lib/sync/skeleton.ts @@ -1,6 +1,6 @@ import { Block } from '@ethereumjs/block' import { bigIntToBuffer, bufferToBigInt } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { DBKey, MetaDBManager, MetaDBManagerOptions } from '../util/metaDBManager' import { short, timeDuration } from '../util' diff --git a/packages/client/lib/util/debug.ts b/packages/client/lib/util/debug.ts index 8af257ccbb..666e9f6cd2 100644 --- a/packages/client/lib/util/debug.ts +++ b/packages/client/lib/util/debug.ts @@ -23,12 +23,12 @@ export async function debugCodeReplayBlock(execution: VMExecution, block: Block) */ import { Level } from 'level'; -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' -import VM from './lib' +import { VM } from './lib' import { SecureTrie as Trie } from '@ethereumjs/trie' import { DefaultStateManager } from './lib/state' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' const main = async () => { const common = new Common({ chain: '${execution.config.execCommon.chainName()}', hardfork: '${ diff --git a/packages/client/lib/util/parse.ts b/packages/client/lib/util/parse.ts index 6dd75fef04..be6bb9f24f 100644 --- a/packages/client/lib/util/parse.ts +++ b/packages/client/lib/util/parse.ts @@ -10,7 +10,7 @@ import { } from '@ethereumjs/util' import type { MultiaddrLike } from '../types' import type { GenesisState } from '@ethereumjs/blockchain/dist/genesisStates' -import type Common from '@ethereumjs/common' +import type { Common } from '@ethereumjs/common' /** * Parses multiaddrs and bootnodes to multiaddr format. diff --git a/packages/client/test/blockchain/chain.spec.ts b/packages/client/test/blockchain/chain.spec.ts index 38ca928a29..ee3c87d7df 100644 --- a/packages/client/test/blockchain/chain.spec.ts +++ b/packages/client/test/blockchain/chain.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Block, BlockData, HeaderData } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' import { Chain } from '../../lib/blockchain' import { Config } from '../../lib/config' diff --git a/packages/client/test/client.spec.ts b/packages/client/test/client.spec.ts index e0e3c29d42..c0c4ec6b16 100644 --- a/packages/client/test/client.spec.ts +++ b/packages/client/test/client.spec.ts @@ -35,7 +35,7 @@ tape('[EthereumClient]', async (t) => { td.when(Server.prototype.stop()).thenResolve() td.when(Server.prototype.bootstrap()).thenResolve() - const { default: EthereumClient } = await import('../lib/client') + const { EthereumClient } = await import('../lib/client') t.test('should initialize correctly', (t) => { const config = new Config({ transports: [] }) diff --git a/packages/client/test/config.spec.ts b/packages/client/test/config.spec.ts index 20a47c7ce7..97616ff1e9 100644 --- a/packages/client/test/config.spec.ts +++ b/packages/client/test/config.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Config, DataDirectory } from '../lib/config' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' tape('[Config]', (t) => { t.test('Initialization with default parameters', (t) => { diff --git a/packages/client/test/execution/vmexecution.spec.ts b/packages/client/test/execution/vmexecution.spec.ts index b46436694a..9b24d19d3f 100644 --- a/packages/client/test/execution/vmexecution.spec.ts +++ b/packages/client/test/execution/vmexecution.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain as ChainEnum, Hardfork } from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain as ChainEnum, Common, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' import { Config } from '../../lib/config' import { Chain } from '../../lib/blockchain' import { VMExecution } from '../../lib/execution' diff --git a/packages/client/test/integration/beaconsync.spec.ts b/packages/client/test/integration/beaconsync.spec.ts index aa61274c89..9afa1d979e 100644 --- a/packages/client/test/integration/beaconsync.spec.ts +++ b/packages/client/test/integration/beaconsync.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Event } from '../../lib/types' import * as genesisJSON from '../testdata/geth-genesis/post-merge.json' import { parseCustomParams } from '../../lib/util' diff --git a/packages/client/test/integration/client.spec.ts b/packages/client/test/integration/client.spec.ts index 2c76504396..7640e65aef 100644 --- a/packages/client/test/integration/client.spec.ts +++ b/packages/client/test/integration/client.spec.ts @@ -1,8 +1,8 @@ import * as tape from 'tape' import { Config, SyncMode } from '../../lib/config' -import EthereumClient from '../../lib/client' +import { EthereumClient } from '../../lib/client' import { Event } from '../../lib/types' -import MockServer from './mocks/mockserver' +import { MockServer } from './mocks/mockserver' tape('[Integration:EthereumClient]', (t) => { const serverConfig = new Config() diff --git a/packages/client/test/integration/fullethereumservice.spec.ts b/packages/client/test/integration/fullethereumservice.spec.ts index aec5f55660..df3415307d 100644 --- a/packages/client/test/integration/fullethereumservice.spec.ts +++ b/packages/client/test/integration/fullethereumservice.spec.ts @@ -1,13 +1,13 @@ import * as tape from 'tape' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' import { Block } from '@ethereumjs/block' import { Account, toBuffer } from '@ethereumjs/util' import { Config } from '../../lib/config' import { FullEthereumService } from '../../lib/service' import { Event } from '../../lib/types' -import MockServer from './mocks/mockserver' -import MockChain from './mocks/mockchain' +import { MockServer } from './mocks/mockserver' +import { MockChain } from './mocks/mockchain' import { destroy } from './util' const config = new Config() diff --git a/packages/client/test/integration/merge.spec.ts b/packages/client/test/integration/merge.spec.ts index 979558648b..e101431ac0 100644 --- a/packages/client/test/integration/merge.spec.ts +++ b/packages/client/test/integration/merge.spec.ts @@ -1,6 +1,7 @@ import * as tape from 'tape' -import Blockchain, { CliqueConsensus } from '@ethereumjs/blockchain' -import Common, { +import { Blockchain, CliqueConsensus } from '@ethereumjs/blockchain' +import { + Common, Chain as ChainCommon, ConsensusType, ConsensusAlgorithm, @@ -11,7 +12,7 @@ import { Config } from '../../lib/config' import { Chain } from '../../lib/blockchain' import { FullEthereumService } from '../../lib/service' import { Event } from '../../lib/types' -import MockServer from './mocks/mockserver' +import { MockServer } from './mocks/mockserver' import { setup, destroy } from './util' import { BlockHeader } from '@ethereumjs/block' diff --git a/packages/client/test/integration/miner.spec.ts b/packages/client/test/integration/miner.spec.ts index a0d918f250..04b0f1432e 100644 --- a/packages/client/test/integration/miner.spec.ts +++ b/packages/client/test/integration/miner.spec.ts @@ -1,6 +1,7 @@ import * as tape from 'tape' -import Blockchain, { CliqueConsensus } from '@ethereumjs/blockchain' -import Common, { +import { Blockchain, CliqueConsensus } from '@ethereumjs/blockchain' +import { + Common, Chain as ChainCommon, ConsensusType, ConsensusAlgorithm, @@ -11,7 +12,7 @@ import { Config } from '../../lib/config' import { Chain } from '../../lib/blockchain' import { FullEthereumService } from '../../lib/service' import { Event } from '../../lib/types' -import MockServer from './mocks/mockserver' +import { MockServer } from './mocks/mockserver' import { setup, destroy } from './util' tape('[Integration:Miner]', async (t) => { diff --git a/packages/client/test/integration/mocks/mockchain.ts b/packages/client/test/integration/mocks/mockchain.ts index ae33a15ec6..2654bdd4b6 100644 --- a/packages/client/test/integration/mocks/mockchain.ts +++ b/packages/client/test/integration/mocks/mockchain.ts @@ -6,7 +6,7 @@ interface MockChainOptions extends ChainOptions { height?: number } -export default class MockChain extends Chain { +export class MockChain extends Chain { public height: number constructor(options: MockChainOptions) { diff --git a/packages/client/test/integration/mocks/mockpeer.ts b/packages/client/test/integration/mocks/mockpeer.ts index c12dd65fe8..e898b2c4c5 100644 --- a/packages/client/test/integration/mocks/mockpeer.ts +++ b/packages/client/test/integration/mocks/mockpeer.ts @@ -2,8 +2,8 @@ import * as EventEmitter from 'events' import * as pipe from 'it-pipe' import * as pushable from 'it-pushable' import { Peer, PeerOptions } from '../../../lib/net/peer' -import MockServer from './mockserver' -import MockSender from './mocksender' +import { MockServer } from './mockserver' +import { MockSender } from './mocksender' import { RemoteStream, createStream } from './network' import { Event } from '../../../lib/types' @@ -16,7 +16,7 @@ interface MockPeerOptions extends PeerOptions { location: string } -export default class MockPeer extends Peer { +export class MockPeer extends Peer { public location: string public connected: boolean diff --git a/packages/client/test/integration/mocks/mocksender.ts b/packages/client/test/integration/mocks/mocksender.ts index dda3e271bc..ffdec7f3fc 100644 --- a/packages/client/test/integration/mocks/mocksender.ts +++ b/packages/client/test/integration/mocks/mocksender.ts @@ -2,7 +2,7 @@ import EventEmitter from 'events' import { Sender } from '../../../lib/net/protocol' import { Pushable } from './mockpeer' -export default class MockSender extends Sender { +export class MockSender extends Sender { public protocol: string public pushable: Pushable public receiver: EventEmitter diff --git a/packages/client/test/integration/mocks/mockserver.ts b/packages/client/test/integration/mocks/mockserver.ts index a56cf736e4..c5ca7bc3f0 100644 --- a/packages/client/test/integration/mocks/mockserver.ts +++ b/packages/client/test/integration/mocks/mockserver.ts @@ -1,13 +1,13 @@ import { Server, ServerOptions } from '../../../lib/net/server' import { Event } from '../../../lib/types' -import MockPeer from './mockpeer' +import { MockPeer } from './mockpeer' import { RemoteStream, createServer, destroyServer, servers } from './network' interface MockServerOptions extends ServerOptions { location?: string } -export default class MockServer extends Server { +export class MockServer extends Server { public location: string public server: Server | null public peers: { [key: string]: MockPeer } diff --git a/packages/client/test/integration/peerpool.spec.ts b/packages/client/test/integration/peerpool.spec.ts index 15ccd71711..be67c3456e 100644 --- a/packages/client/test/integration/peerpool.spec.ts +++ b/packages/client/test/integration/peerpool.spec.ts @@ -1,11 +1,11 @@ import * as tape from 'tape' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' import { Config } from '../../lib/config' import { Event } from '../../lib/types' import { EthProtocol } from '../../lib/net/protocol' import { PeerPool } from '../../lib/net/peerpool' -import MockServer from './mocks/mockserver' -import MockChain from './mocks/mockchain' +import { MockServer } from './mocks/mockserver' +import { MockChain } from './mocks/mockchain' import { wait } from './util' tape('[Integration:PeerPool]', async (t) => { diff --git a/packages/client/test/integration/util.ts b/packages/client/test/integration/util.ts index 88c7cfb38f..6772cde464 100644 --- a/packages/client/test/integration/util.ts +++ b/packages/client/test/integration/util.ts @@ -1,10 +1,10 @@ -import Blockchain from '@ethereumjs/blockchain' -import Common from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Common } from '@ethereumjs/common' import { Config, SyncMode } from '../../lib/config' import { FullEthereumService, LightEthereumService } from '../../lib/service' import { Event } from '../../lib/types' -import MockServer from './mocks/mockserver' -import MockChain from './mocks/mockchain' +import { MockServer } from './mocks/mockserver' +import { MockChain } from './mocks/mockchain' import { MemoryLevel } from 'memory-level' interface SetupOptions { diff --git a/packages/client/test/miner/miner.spec.ts b/packages/client/test/miner/miner.spec.ts index 5ee74dd6c8..5d20d0e017 100644 --- a/packages/client/test/miner/miner.spec.ts +++ b/packages/client/test/miner/miner.spec.ts @@ -1,12 +1,12 @@ import * as tape from 'tape' import * as td from 'testdouble' -import Common, { Chain as CommonChain, Hardfork } from '@ethereumjs/common' +import { Chain as CommonChain, Common, Hardfork } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction, Transaction } from '@ethereumjs/tx' import { Block, BlockHeader } from '@ethereumjs/block' import { Address } from '@ethereumjs/util' import { keccak256 } from 'ethereum-cryptography/keccak' import { CliqueConsensus } from '@ethereumjs/blockchain' -import VM from '@ethereumjs/vm' +import { VM } from '@ethereumjs/vm' import { VmState } from '@ethereumjs/vm/dist/eei/vmState' import { Config } from '../../lib/config' diff --git a/packages/client/test/miner/pendingBlock.spec.ts b/packages/client/test/miner/pendingBlock.spec.ts index 21720e82e6..9813c22633 100644 --- a/packages/client/test/miner/pendingBlock.spec.ts +++ b/packages/client/test/miner/pendingBlock.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import * as td from 'testdouble' -import Common, { Chain as CommonChain, Hardfork } from '@ethereumjs/common' +import { Chain as CommonChain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { BlockHeader } from '@ethereumjs/block' -import VM from '@ethereumjs/vm' +import { VM } from '@ethereumjs/vm' import { Address, Account } from '@ethereumjs/util' import { Config } from '../../lib/config' import { TxPool } from '../../lib/service/txpool' diff --git a/packages/client/test/net/peerpool.spec.ts b/packages/client/test/net/peerpool.spec.ts index f3abe8756c..f4c8fc9012 100644 --- a/packages/client/test/net/peerpool.spec.ts +++ b/packages/client/test/net/peerpool.spec.ts @@ -4,7 +4,7 @@ import { EventEmitter } from 'events' import { Config } from '../../lib/config' import { RlpxServer } from '../../lib/net/server' import { Event } from '../../lib/types' -import MockPeer from '../integration/mocks/mockpeer' +import { MockPeer } from '../integration/mocks/mockpeer' tape('[PeerPool]', async (t) => { const Peer = td.replace('../../lib/net/peer/peer', function (this: any, id: string) { diff --git a/packages/client/test/net/protocol/ethprotocol.spec.ts b/packages/client/test/net/protocol/ethprotocol.spec.ts index a6eb55a40b..d0661f591d 100644 --- a/packages/client/test/net/protocol/ethprotocol.spec.ts +++ b/packages/client/test/net/protocol/ethprotocol.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Common, { Hardfork } from '@ethereumjs/common' +import { Common, Hardfork } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' import { Chain } from '../../../lib/blockchain/chain' import { Config } from '../../../lib/config' diff --git a/packages/client/test/rpc/eth/call.spec.ts b/packages/client/test/rpc/eth/call.spec.ts index c24f85a216..941adf10e9 100644 --- a/packages/client/test/rpc/eth/call.spec.ts +++ b/packages/client/test/rpc/eth/call.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address, bigIntToHex, bufferToHex } from '@ethereumjs/util' import { INVALID_PARAMS } from '../../../lib/rpc/error-code' diff --git a/packages/client/test/rpc/eth/chainId.spec.ts b/packages/client/test/rpc/eth/chainId.spec.ts index 05265eb879..c22ffdadc4 100644 --- a/packages/client/test/rpc/eth/chainId.spec.ts +++ b/packages/client/test/rpc/eth/chainId.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import { baseSetup, params, baseRequest, createClient, createManager, startRPC } from '../helpers' import { BlockHeader } from '@ethereumjs/block' import * as td from 'testdouble' diff --git a/packages/client/test/rpc/eth/estimateGas.spec.ts b/packages/client/test/rpc/eth/estimateGas.spec.ts index 5aec928b10..328e3047c1 100644 --- a/packages/client/test/rpc/eth/estimateGas.spec.ts +++ b/packages/client/test/rpc/eth/estimateGas.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address, bigIntToHex } from '@ethereumjs/util' import { INVALID_PARAMS } from '../../../lib/rpc/error-code' diff --git a/packages/client/test/rpc/eth/getBalance.spec.ts b/packages/client/test/rpc/eth/getBalance.spec.ts index 847d31c47f..8f5077f281 100644 --- a/packages/client/test/rpc/eth/getBalance.spec.ts +++ b/packages/client/test/rpc/eth/getBalance.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address, bigIntToHex } from '@ethereumjs/util' import { INVALID_PARAMS } from '../../../lib/rpc/error-code' diff --git a/packages/client/test/rpc/eth/getCode.spec.ts b/packages/client/test/rpc/eth/getCode.spec.ts index 692bcc331c..dce42bd2d1 100644 --- a/packages/client/test/rpc/eth/getCode.spec.ts +++ b/packages/client/test/rpc/eth/getCode.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address } from '@ethereumjs/util' import { INVALID_PARAMS } from '../../../lib/rpc/error-code' diff --git a/packages/client/test/rpc/eth/getProof.spec.ts b/packages/client/test/rpc/eth/getProof.spec.ts index 6948afc4f3..156b06b519 100644 --- a/packages/client/test/rpc/eth/getProof.spec.ts +++ b/packages/client/test/rpc/eth/getProof.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address, bigIntToHex } from '@ethereumjs/util' import { startRPC, createManager, createClient, params, baseRequest } from '../helpers' diff --git a/packages/client/test/rpc/eth/getStorageAt.spec.ts b/packages/client/test/rpc/eth/getStorageAt.spec.ts index 0350789075..8d6eabda56 100644 --- a/packages/client/test/rpc/eth/getStorageAt.spec.ts +++ b/packages/client/test/rpc/eth/getStorageAt.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { keccak256 } from 'ethereum-cryptography/keccak' import { Address, bigIntToHex, bufferToHex, toBuffer } from '@ethereumjs/util' diff --git a/packages/client/test/rpc/eth/getTransactionCount.spec.ts b/packages/client/test/rpc/eth/getTransactionCount.spec.ts index bb9cbe1534..0c53cf1388 100644 --- a/packages/client/test/rpc/eth/getTransactionCount.spec.ts +++ b/packages/client/test/rpc/eth/getTransactionCount.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address } from '@ethereumjs/util' import { INVALID_PARAMS } from '../../../lib/rpc/error-code' diff --git a/packages/client/test/rpc/eth/sendRawTransaction.spec.ts b/packages/client/test/rpc/eth/sendRawTransaction.spec.ts index 5558bdc613..49cf33bd88 100644 --- a/packages/client/test/rpc/eth/sendRawTransaction.spec.ts +++ b/packages/client/test/rpc/eth/sendRawTransaction.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { FeeMarketEIP1559Transaction, Transaction } from '@ethereumjs/tx' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { toBuffer } from '@ethereumjs/util' import { INTERNAL_ERROR, INVALID_PARAMS, PARSE_ERROR } from '../../../lib/rpc/error-code' import { baseSetup, params, baseRequest } from '../helpers' diff --git a/packages/client/test/rpc/helpers.ts b/packages/client/test/rpc/helpers.ts index df459fb047..5073c09074 100644 --- a/packages/client/test/rpc/helpers.ts +++ b/packages/client/test/rpc/helpers.ts @@ -1,8 +1,8 @@ import * as tape from 'tape' import { Server as RPCServer, HttpServer } from 'jayson/promise' import { BlockHeader } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain as ChainEnum } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain as ChainEnum, Common } from '@ethereumjs/common' import { Address } from '@ethereumjs/util' import { RPCManager as Manager } from '../../lib/rpc' import { getLogger } from '../../lib/logging' @@ -17,7 +17,7 @@ import { createRPCServerListener, createWsRPCServerListener } from '../../lib/ut import { mockBlockchain } from './mockBlockchain' import type { IncomingMessage } from 'connect' import type { TypedTransaction } from '@ethereumjs/tx' -import type EthereumClient from '../../lib/client' +import type { EthereumClient } from '../../lib/client' import type { FullEthereumService } from '../../lib/service' const request = require('supertest') import { MemoryLevel } from 'memory-level' diff --git a/packages/client/test/rpc/net/version.spec.ts b/packages/client/test/rpc/net/version.spec.ts index ddf8c152f9..e0a579a0e3 100644 --- a/packages/client/test/rpc/net/version.spec.ts +++ b/packages/client/test/rpc/net/version.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import { startRPC, createManager, createClient, baseSetup, params, baseRequest } from '../helpers' import * as td from 'testdouble' import { BlockHeader } from '@ethereumjs/block' diff --git a/packages/client/test/rpc/util/CLConnectionManager.spec.ts b/packages/client/test/rpc/util/CLConnectionManager.spec.ts index 2b3f716a2c..8365f54481 100644 --- a/packages/client/test/rpc/util/CLConnectionManager.spec.ts +++ b/packages/client/test/rpc/util/CLConnectionManager.spec.ts @@ -1,4 +1,4 @@ -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import * as tape from 'tape' import { Config } from '../../../lib' import { CLConnectionManager } from '../../../lib/rpc/util/CLConnectionManager' diff --git a/packages/client/test/service/fullethereumservice.spec.ts b/packages/client/test/service/fullethereumservice.spec.ts index 8a316a6a06..19dc1a47d1 100644 --- a/packages/client/test/service/fullethereumservice.spec.ts +++ b/packages/client/test/service/fullethereumservice.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import * as td from 'testdouble' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Config } from '../../lib/config' import { Event } from '../../lib/types' import { Chain } from '../../lib/blockchain' diff --git a/packages/client/test/sync/skeleton.spec.ts b/packages/client/test/sync/skeleton.spec.ts index 699db186f9..6a3b772b04 100644 --- a/packages/client/test/sync/skeleton.spec.ts +++ b/packages/client/test/sync/skeleton.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Block, BlockHeader } from '@ethereumjs/block' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Config } from '../../lib/config' import { Chain } from '../../lib/blockchain' import { parseCustomParams } from '../../lib/util' diff --git a/packages/client/test/sync/txpool.spec.ts b/packages/client/test/sync/txpool.spec.ts index f5acfce77e..c06b4f1c4b 100644 --- a/packages/client/test/sync/txpool.spec.ts +++ b/packages/client/test/sync/txpool.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { AccessListEIP2930Transaction, FeeMarketEIP1559Transaction } from '@ethereumjs/tx' import { Block } from '@ethereumjs/block' import { Account, privateToAddress } from '@ethereumjs/util' diff --git a/packages/client/test/util/rpc.spec.ts b/packages/client/test/util/rpc.spec.ts index 6b4a9c2a65..6465c845f2 100644 --- a/packages/client/test/util/rpc.spec.ts +++ b/packages/client/test/util/rpc.spec.ts @@ -6,7 +6,7 @@ import { createWsRPCServerListener, MethodConfig, } from '../../lib/util/rpc' -import Client from '../../lib/client' +import { EthereumClient } from '../../lib/client' import { Config } from '../../lib/config' import { METHOD_NOT_FOUND } from '../../lib/rpc/error-code' const request = require('supertest') @@ -14,7 +14,7 @@ const request = require('supertest') tape('[Util/RPC]', (t) => { t.test('should return enabled RPC servers', (st) => { const config = new Config({ transports: [] }) - const client = new Client({ config }) + const client = new EthereumClient({ config }) const manager = new RPCManager(client, config) const { logger } = config for (const methodConfig of Object.values(MethodConfig)) { @@ -49,7 +49,7 @@ tape('[Util/RPC]', (t) => { tape('[Util/RPC/Engine eth methods]', async (t) => { const config = new Config({ transports: [], saveReceipts: true }) - const client = new Client({ config }) + const client = new EthereumClient({ config }) const manager = new RPCManager(client, config) const { server } = createRPCServer(manager, { methodConfig: MethodConfig.EngineOnly, diff --git a/packages/common/README.md b/packages/common/README.md index d75c16e60f..c10c8d25bb 100644 --- a/packages/common/README.md +++ b/packages/common/README.md @@ -21,13 +21,11 @@ Note: this `README` reflects the state of the library from `v2.0.0` onwards. See import (CommonJS, TypeScript with `esModuleInterop` enabled): -`import Common from '@ethereumjs/common`\ -`import Common, { Chain, Hardfork } from '@ethereumjs/common` +`import { Chain, Common, Hardfork } from '@ethereumjs/common` require (ES Modules, Node.js): -`const Common = require('@ethereumjs/common').default`\ -`const { default: Common, Chain, Hardfork } = require('@ethereumjs/common')` +`const { Common, Chain, Hardfork } = require('@ethereumjs/common')` ## Parameters @@ -65,7 +63,7 @@ c = new Common({ chain: 'mainnet', eips: [2537] }) For an improved developer experience, there are `Chain` and `Hardfork` enums available: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' // Chain provided by Chain enum const c = new Common({ chain: Chain.Mainnet }) @@ -105,7 +103,7 @@ const c = new Common({ chain: 'ropsten' }) Or optionally with the `Chain` enum: ```typescript -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' const c = new Common({ chain: Chain.Ropsten }) ``` @@ -212,7 +210,7 @@ const c = new Common({ chain: 'ropsten', hardfork: 'byzantium' }) Or optionally with the `Hardfork` enum: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const c = new Common({ chain: Chain.Ropsten, diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index abc973cdc5..bd0b4e8aa5 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,3 +1,3 @@ -export { Common as default } from './common' +export * from './common' export * from './enums' export * from './types' diff --git a/packages/common/tests/chains.spec.ts b/packages/common/tests/chains.spec.ts index 7d4ce32133..4b2b6ca58c 100644 --- a/packages/common/tests/chains.spec.ts +++ b/packages/common/tests/chains.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from '../src/' +import { Chain, Common, ConsensusAlgorithm, ConsensusType, Hardfork } from '../src/' tape('[Common/Chains]: Initialization / Chain params', function (t: tape.Test) { t.test('Should initialize with chain provided', function (st: tape.Test) { diff --git a/packages/common/tests/customChains.spec.ts b/packages/common/tests/customChains.spec.ts index c30e7e11f9..4bc9accd30 100644 --- a/packages/common/tests/customChains.spec.ts +++ b/packages/common/tests/customChains.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, ConsensusType, CustomChain, Hardfork } from '../src/' +import { Chain, Common, ConsensusType, CustomChain, Hardfork } from '../src/' import * as testnet from './data/testnet.json' import * as testnet2 from './data/testnet2.json' import * as testnet3 from './data/testnet3.json' diff --git a/packages/common/tests/eips.spec.ts b/packages/common/tests/eips.spec.ts index fb1185bd19..4af5cd5ba4 100644 --- a/packages/common/tests/eips.spec.ts +++ b/packages/common/tests/eips.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '../src/' +import { Chain, Common, Hardfork } from '../src/' tape('[Common/EIPs]: Initialization / Chain params', function (t: tape.Test) { t.test('Correct initialization', function (st: tape.Test) { diff --git a/packages/common/tests/hardforks.spec.ts b/packages/common/tests/hardforks.spec.ts index aa7c0c8582..1faf7c1875 100644 --- a/packages/common/tests/hardforks.spec.ts +++ b/packages/common/tests/hardforks.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from '../src' +import { Chain, Common, ConsensusAlgorithm, ConsensusType, Hardfork } from '../src' tape('[Common]: Hardfork logic', function (t: tape.Test) { t.test('Hardfork access', function (st: tape.Test) { diff --git a/packages/common/tests/mergePOS.spec.ts b/packages/common/tests/mergePOS.spec.ts index 30304c8da7..66e9162cb4 100644 --- a/packages/common/tests/mergePOS.spec.ts +++ b/packages/common/tests/mergePOS.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Hardfork } from '../src' +import { Common, Hardfork } from '../src' import * as testnetMerge from './data/merge/testnetMerge.json' import * as testnetPOS from './data/merge/testnetPOS.json' diff --git a/packages/common/tests/params.spec.ts b/packages/common/tests/params.spec.ts index 5e4702b116..3ebb7c518a 100644 --- a/packages/common/tests/params.spec.ts +++ b/packages/common/tests/params.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '../src/' +import { Chain, Common, Hardfork } from '../src/' tape('[Common]: Parameter access for param(), paramByHardfork()', function (t: tape.Test) { t.test('Basic usage', function (st: tape.Test) { diff --git a/packages/devp2p/examples/peer-communication-les.ts b/packages/devp2p/examples/peer-communication-les.ts index 1f65ef1b74..7d90c3e4f8 100644 --- a/packages/devp2p/examples/peer-communication-les.ts +++ b/packages/devp2p/examples/peer-communication-les.ts @@ -1,6 +1,6 @@ import * as devp2p from '../src/index' import { LES, Peer } from '../src/index' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { TypedTransaction } from '@ethereumjs/tx' import { Block, BlockHeader } from '@ethereumjs/block' import ms from 'ms' diff --git a/packages/devp2p/examples/peer-communication.ts b/packages/devp2p/examples/peer-communication.ts index 356b06225f..2bac7ffe5d 100644 --- a/packages/devp2p/examples/peer-communication.ts +++ b/packages/devp2p/examples/peer-communication.ts @@ -2,11 +2,11 @@ import { randomBytes } from 'crypto' import LRUCache from 'lru-cache' import ms from 'ms' import chalk from 'chalk' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { TypedTransaction, TransactionFactory } from '@ethereumjs/tx' import { Block, BlockHeader } from '@ethereumjs/block' import { arrToBufArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import * as devp2p from '../src/index' import { ETH, Peer } from '../src/index' diff --git a/packages/devp2p/examples/simple.ts b/packages/devp2p/examples/simple.ts index b2fee47954..ad0f07afce 100644 --- a/packages/devp2p/examples/simple.ts +++ b/packages/devp2p/examples/simple.ts @@ -1,5 +1,5 @@ import chalk from 'chalk' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import { DPT } from '../src/index' const PRIVATE_KEY = 'd772e3d6a001a38064dd23964dd2836239fa0e6cec8b28972a87460a17210fe9' diff --git a/packages/devp2p/src/browser/dns.ts b/packages/devp2p/src/browser/dns.ts index cbe7b5ff22..8a7753dee0 100644 --- a/packages/devp2p/src/browser/dns.ts +++ b/packages/devp2p/src/browser/dns.ts @@ -12,7 +12,7 @@ const errorMessage = 'You can disable EIP-1459 DNS discovery in devp2p by setting the "shouldGetDnsPeers" ' + 'option to "false" in the DPTOptions object. ' -export default class dns { +export class dns { public static promises = { resolve: async function (_url: string, _recordType: string): Promise { throw new Error(errorMessage) diff --git a/packages/devp2p/src/dns/enr.ts b/packages/devp2p/src/dns/enr.ts index 9ce64c1525..af5f388c27 100644 --- a/packages/devp2p/src/dns/enr.ts +++ b/packages/devp2p/src/dns/enr.ts @@ -2,7 +2,7 @@ import { base32, base64url } from '@scure/base' import { sscanf } from 'scanf' import { Multiaddr } from 'multiaddr' import { arrToBufArr, bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { PeerInfo } from '../dpt' import { toNewUint8Array, keccak256 } from '../util' import { ecdsaVerify } from 'ethereum-cryptography/secp256k1-compat' diff --git a/packages/devp2p/src/dpt/message.ts b/packages/devp2p/src/dpt/message.ts index 4a6b01aa0f..a530649fdc 100644 --- a/packages/devp2p/src/dpt/message.ts +++ b/packages/devp2p/src/dpt/message.ts @@ -1,7 +1,7 @@ import { debug as createDebugLogger } from 'debug' import * as ip from 'ip' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { ecdsaRecover, ecdsaSign } from 'ethereum-cryptography/secp256k1-compat' import { keccak256, int2buffer, buffer2int, assertEq, unstrictDecode } from '../util' import { PeerInfo } from './dpt' diff --git a/packages/devp2p/src/protocol/eth.ts b/packages/devp2p/src/protocol/eth.ts index afce3d63c6..8d64114d48 100644 --- a/packages/devp2p/src/protocol/eth.ts +++ b/packages/devp2p/src/protocol/eth.ts @@ -6,7 +6,7 @@ import { bufferToBigInt, bufferToHex, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { int2buffer, buffer2int, assertEq, formatLogId, formatLogData } from '../util' import { Peer } from '../rlpx/peer' import { EthProtocol, Protocol, SendMethod } from './protocol' diff --git a/packages/devp2p/src/protocol/les.ts b/packages/devp2p/src/protocol/les.ts index 84990d82a4..982bc909ab 100644 --- a/packages/devp2p/src/protocol/les.ts +++ b/packages/devp2p/src/protocol/les.ts @@ -1,5 +1,5 @@ import { arrToBufArr, bigIntToBuffer, bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import ms = require('ms') import * as snappy from 'snappyjs' import { int2buffer, buffer2int, assertEq, formatLogData } from '../util' diff --git a/packages/devp2p/src/rlpx/ecies.ts b/packages/devp2p/src/rlpx/ecies.ts index 9fc90e463c..7695627a2c 100644 --- a/packages/devp2p/src/rlpx/ecies.ts +++ b/packages/devp2p/src/rlpx/ecies.ts @@ -1,7 +1,7 @@ import * as crypto from 'crypto' import { debug as createDebugLogger } from 'debug' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { getPublicKey } from 'ethereum-cryptography/secp256k1' import { unstrictDecode } from '../util' import { MAC } from './mac' diff --git a/packages/devp2p/src/rlpx/peer.ts b/packages/devp2p/src/rlpx/peer.ts index ffc605f9c3..84431649e9 100644 --- a/packages/devp2p/src/rlpx/peer.ts +++ b/packages/devp2p/src/rlpx/peer.ts @@ -5,9 +5,9 @@ import ms = require('ms') import * as snappy from 'snappyjs' import { debug as createDebugLogger, Debugger } from 'debug' import { devp2pDebug } from '../util' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { arrToBufArr, bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { ETH, LES } from '../' import { int2buffer, buffer2int, formatLogData } from '../util' import { ECIES } from './ecies' diff --git a/packages/devp2p/src/rlpx/rlpx.ts b/packages/devp2p/src/rlpx/rlpx.ts index 407ed767ea..b16d03c93c 100644 --- a/packages/devp2p/src/rlpx/rlpx.ts +++ b/packages/devp2p/src/rlpx/rlpx.ts @@ -6,7 +6,7 @@ import { EventEmitter } from 'events' import { debug as createDebugLogger, Debugger } from 'debug' import { devp2pDebug } from '../util' import * as LRUCache from 'lru-cache' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' // note: relative path only valid in .js file in dist const { version: pVersion } = require('../../package.json') import { pk2id, createDeferred, formatLogId, buffer2int } from '../util' diff --git a/packages/devp2p/src/util.ts b/packages/devp2p/src/util.ts index 7bff5468f5..51a2712231 100644 --- a/packages/devp2p/src/util.ts +++ b/packages/devp2p/src/util.ts @@ -1,5 +1,5 @@ import { arrToBufArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { utils } from 'ethereum-cryptography/secp256k1' import { publicKeyConvert } from 'ethereum-cryptography/secp256k1-compat' import { keccak256 as _keccak256 } from 'ethereum-cryptography/keccak' diff --git a/packages/devp2p/test/browser.ts b/packages/devp2p/test/browser.ts index 90e5a96419..c69f35cb92 100644 --- a/packages/devp2p/test/browser.ts +++ b/packages/devp2p/test/browser.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import dns from '../src/browser/dns' +import { dns } from '../src/browser/dns' tape('dns browser polyfill stub', async (t) => { const expectedError = 'EIP-1459 DNS Discovery is not supported for browser environments' diff --git a/packages/devp2p/test/integration/eth-simulator.ts b/packages/devp2p/test/integration/eth-simulator.ts index 4d07166c8c..af3f809df0 100644 --- a/packages/devp2p/test/integration/eth-simulator.ts +++ b/packages/devp2p/test/integration/eth-simulator.ts @@ -1,7 +1,7 @@ import * as test from 'tape' import * as devp2p from '../../src' import * as util from './util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { ETH } from '../../src' const GENESIS_TD = 17179869184 diff --git a/packages/devp2p/test/integration/les-simulator.ts b/packages/devp2p/test/integration/les-simulator.ts index 11689ff389..01dad777d9 100644 --- a/packages/devp2p/test/integration/les-simulator.ts +++ b/packages/devp2p/test/integration/les-simulator.ts @@ -1,5 +1,5 @@ import * as test from 'tape' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import * as devp2p from '../../src' import * as util from './util' diff --git a/packages/devp2p/test/integration/util.ts b/packages/devp2p/test/integration/util.ts index 6c801da5bd..5073411320 100644 --- a/packages/devp2p/test/integration/util.ts +++ b/packages/devp2p/test/integration/util.ts @@ -1,6 +1,6 @@ import * as test from 'tape' import { DPT, ETH, RLPx, genPrivateKey } from '../../src' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import * as testdata from '../testdata.json' type Test = test.Test diff --git a/packages/ethash/README.md b/packages/ethash/README.md index b3adba1421..5fb58daa0d 100644 --- a/packages/ethash/README.md +++ b/packages/ethash/README.md @@ -20,7 +20,7 @@ Note: this `README` reflects the state of the library from `v1.0.0` onwards. See ## PoW Validation ```typescript -import Ethash from '@ethereumjs/ethash' +import { Ethash } from '@ethereumjs/ethash' import { Block } from '@ethereumjs/block' import { MemoryLevel } from 'memory-level' @@ -44,8 +44,8 @@ See the following example on how to use the new `Miner` class: ```typescript import { Block } from '@ethereumjs/block' -import Ethash from '@ethereumjs/ethash' -import Common from '@ethereumjs/common' +import { Ethash } from '@ethereumjs/ethash' +import { Common } from '@ethereumjs/common' import { BN } from 'ethereumjs-util' import { MemoryLevel } from 'memory-level' diff --git a/packages/ethash/examples/example.ts b/packages/ethash/examples/example.ts index 296a4afd85..441a6d6923 100644 --- a/packages/ethash/examples/example.ts +++ b/packages/ethash/examples/example.ts @@ -1,4 +1,4 @@ -import Ethash from '../src' +import { Ethash } from '../src' const ethash = new Ethash() diff --git a/packages/ethash/src/index.ts b/packages/ethash/src/index.ts index 5cf26aba0d..069da3fa97 100644 --- a/packages/ethash/src/index.ts +++ b/packages/ethash/src/index.ts @@ -7,7 +7,7 @@ import { bufferToBigInt, setLengthLeft, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { params, fnv, @@ -151,7 +151,7 @@ export type EthashCacheDB = AbstractLevel< } > -export default class Ethash { +export class Ethash { dbOpts: Object cacheDB?: EthashCacheDB cache: Buffer[] diff --git a/packages/ethash/test/block.spec.ts b/packages/ethash/test/block.spec.ts index c4e97bed0e..c7c9d7a0dc 100644 --- a/packages/ethash/test/block.spec.ts +++ b/packages/ethash/test/block.spec.ts @@ -1,10 +1,10 @@ import * as tape from 'tape' import { Block, BlockBuffer } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { arrToBufArr, toBuffer } from '@ethereumjs/util' -import Ethash from '../src' +import { Ethash } from '../src' import { MemoryLevel } from 'memory-level' -import RLP from 'rlp' +import { RLP } from 'rlp' const cacheDB = new MemoryLevel() diff --git a/packages/ethash/test/ethash.spec.ts b/packages/ethash/test/ethash.spec.ts index 899a0a606f..e4389d47ac 100644 --- a/packages/ethash/test/ethash.spec.ts +++ b/packages/ethash/test/ethash.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import Ethash from '../src' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { Ethash } from '../src' import { getEpoc, getCacheSize, getFullSize } from '../src/util' import { BlockHeader } from '@ethereumjs/block' const powTests = require('./ethash_tests.json') diff --git a/packages/ethash/test/miner.spec.ts b/packages/ethash/test/miner.spec.ts index 33f52d6dd8..357836f344 100644 --- a/packages/ethash/test/miner.spec.ts +++ b/packages/ethash/test/miner.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Block, BlockHeader } from '@ethereumjs/block' -import Ethash from '../src' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Ethash } from '../src' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { MemoryLevel } from 'memory-level' const cacheDB = new MemoryLevel() diff --git a/packages/evm/README.md b/packages/evm/README.md index 2f7d6a2ef7..6e7bd7e30c 100644 --- a/packages/evm/README.md +++ b/packages/evm/README.md @@ -9,24 +9,22 @@ | TypeScript implementation of the Ethereum EVM. | | ---------------------------------------------- | - - # INSTALL `npm install @ethereumjs/evm` -This package provides the core Ethereum Virtual Machine (EVM) implementation which is capable of executing EVM-compatible bytecode. The package has been extracted from the [@ethereumjs/vm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm) package along the VM `v6` release. +This package provides the core Ethereum Virtual Machine (EVM) implementation which is capable of executing EVM-compatible bytecode. The package has been extracted from the [@ethereumjs/vm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm) package along the VM `v6` release. Note that this package atm cannot be run in a standalong mode but needs to be executed via the `VM` package which provides an outer Ethereum `mainnet` compatible execution context. Standalone functionality will be added along a future non-breaking release. # USAGE ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import Blockchain from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' import { EEI } from '@ethereumjs/vm' -import EVM from '@ethereumjs/evm' -import { DefaultStateManager } from '@ethereumjs/statemanager' +import { EVM } from '@ethereumjs/evm' +import { DefaultStateManager } from '@ethereumjs/statemanager' // Note: in a future release there will be an EEI default implementation // which will ease standalone initialization @@ -36,10 +34,10 @@ const stateManager = new DefaultStateManager({ common }) const eei = new EEI(stateManager, common, blockchain) const evm = new EVM({ - common, - blockchain, - eei, - }) + common, + blockchain, + eei, +}) const STOP = '00' const ADD = '01' @@ -131,8 +129,8 @@ along the `Common` instance to the outer `@ethereumjs/vm` instance. It is possible to individually activate EIP support in the EVM by instantiate the `Common` instance passed to the outer VM with the respective EIPs, e.g.: ```typescript -import Common, { Chain } from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Chain, Common } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: Chain.Mainnet, eips: [2537] }) const vm = new VM({ common }) @@ -204,13 +202,13 @@ If you want to understand your EVM runs we have added a hierarchically structure The following loggers are currently available: -| Logger | Description | -| --------------------------------- | ------------------------------------------------------------------ | -| `vm:evm` |  EVM control flow, CALL or CREATE message execution | -| `vm:evm:gas` |  EVM gas logger | -| `vm:eei:gas` |  EEI gas logger | -| `vm:ops` |  Opcode traces | -| `vm:ops:[Lower-case opcode name]` | Traces on a specific opcode | +| Logger | Description | +| --------------------------------- | --------------------------------------------------- | +| `vm:evm` |  EVM control flow, CALL or CREATE message execution | +| `vm:evm:gas` |  EVM gas logger | +| `vm:eei:gas` |  EEI gas logger | +| `vm:ops` |  Opcode traces | +| `vm:ops:[Lower-case opcode name]` | Traces on a specific opcode | Here are some examples for useful logger combinations. diff --git a/packages/evm/examples/decode-opcodes.ts b/packages/evm/examples/decode-opcodes.ts index eaf5fae9f7..2e6ae419d3 100644 --- a/packages/evm/examples/decode-opcodes.ts +++ b/packages/evm/examples/decode-opcodes.ts @@ -2,7 +2,7 @@ // // 1. Takes binary EVM code and decodes it into opcodes -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { getOpcodesForHF } from '../src/opcodes' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Istanbul }) diff --git a/packages/evm/examples/run-code-browser.js b/packages/evm/examples/run-code-browser.js index 9d630e1c3a..045cb573e0 100644 --- a/packages/evm/examples/run-code-browser.js +++ b/packages/evm/examples/run-code-browser.js @@ -10,7 +10,7 @@ * NOTE: THIS EXAMPLE IS CURRENTLY OUTDATED AND DOESN'T WORK WITH EVM v1. */ const BN = require('bn.js') -const VM = require('../dist').default +const { VM } = require('../dist') const run = async () => { // Create a new VM instance diff --git a/packages/evm/src/eof.ts b/packages/evm/src/eof.ts index f5be92d443..003ead514c 100644 --- a/packages/evm/src/eof.ts +++ b/packages/evm/src/eof.ts @@ -92,5 +92,4 @@ export const validOpcodes = (code: Buffer) => { return true } -const EOF = { FORMAT, MAGIC, VERSION, codeAnalysis, validOpcodes } -export default EOF +export const EOF = { FORMAT, MAGIC, VERSION, codeAnalysis, validOpcodes } diff --git a/packages/evm/src/evm.ts b/packages/evm/src/evm.ts index 28c1e8c671..b796088017 100644 --- a/packages/evm/src/evm.ts +++ b/packages/evm/src/evm.ts @@ -1,5 +1,5 @@ import { promisify } from 'util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import AsyncEventEmitter = require('async-eventemitter') import { debug as createDebugLogger } from 'debug' import { @@ -15,9 +15,9 @@ import { } from '@ethereumjs/util' import { ERROR, EvmError } from './exceptions' -import { default as Interpreter, InterpreterOpts, RunState } from './interpreter' -import Message, { MessageWithTo } from './message' -import EOF from './eof' +import { Interpreter, InterpreterOpts, RunState } from './interpreter' +import { Message, MessageWithTo } from './message' +import { EOF } from './eof' import { getOpcodesForHF, OpcodeList, OpHandler } from './opcodes' import { AsyncDynamicGasHandler, SyncDynamicGasHandler } from './opcodes/gas' import { CustomPrecompile, getActivePrecompiles, PrecompileFunc } from './precompiles' @@ -33,7 +33,7 @@ import { EVMRunCodeOpts, } from './types' import { EEIInterface } from './types' -import TransientStorage from './transientStorage' +import { TransientStorage } from './transientStorage' const debug = createDebugLogger('vm:evm') const debugGas = createDebugLogger('vm:evm:gas') @@ -132,7 +132,7 @@ export interface EVMOpts { * and storing them to state (or discarding changes in case of exceptions). * @ignore */ -export default class EVM extends AsyncEventEmitter implements EVMInterface { +export class EVM extends AsyncEventEmitter implements EVMInterface { protected _tx?: { gasPrice: bigint origin: Address diff --git a/packages/evm/src/index.ts b/packages/evm/src/index.ts index c73c6300bf..6140f67d3f 100644 --- a/packages/evm/src/index.ts +++ b/packages/evm/src/index.ts @@ -1,16 +1,15 @@ import { getActivePrecompiles } from './precompiles' import { EEIInterface, EVMInterface, EVMStateAccess, Log } from './types' -import EVM, { EVMResult } from './evm' +import { EVM, EVMResult } from './evm' import { EvmError } from './exceptions' export { getActivePrecompiles, EEIInterface, + EVM, EVMInterface, EvmError, EVMStateAccess, Log, EVMResult, } - -export default EVM diff --git a/packages/evm/src/interpreter.ts b/packages/evm/src/interpreter.ts index 3eeff86c7a..332eb51494 100644 --- a/packages/evm/src/interpreter.ts +++ b/packages/evm/src/interpreter.ts @@ -9,13 +9,13 @@ import { } from '@ethereumjs/util' import { ERROR, EvmError } from './exceptions' -import Memory from './memory' -import Stack from './stack' +import { Memory } from './memory' +import { Stack } from './stack' import { Opcode, OpHandler, AsyncOpHandler, trap } from './opcodes' -import EOF from './eof' -import Common, { ConsensusAlgorithm } from '@ethereumjs/common' -import EVM, { EVMResult } from './evm' -import Message from './message' +import { EOF } from './eof' +import { Common, ConsensusAlgorithm } from '@ethereumjs/common' +import { EVM, EVMResult } from './evm' +import { Message } from './message' import { Log } from './types' import { EEIInterface, Block } from './types' @@ -103,7 +103,7 @@ export interface InterpreterStep { /** * Parses and executes EVM bytecode. */ -export default class Interpreter { +export class Interpreter { protected _vm: any protected _runState: RunState protected _eei: EEIInterface diff --git a/packages/evm/src/memory.ts b/packages/evm/src/memory.ts index eeeea95244..4dff2445a5 100644 --- a/packages/evm/src/memory.ts +++ b/packages/evm/src/memory.ts @@ -11,7 +11,7 @@ const ceil = (value: number, ceiling: number): number => { * Memory implements a simple memory model * for the ethereum virtual machine. */ -export default class Memory { +export class Memory { _store: Buffer constructor() { diff --git a/packages/evm/src/message.ts b/packages/evm/src/message.ts index d8385958f1..625f8f7401 100644 --- a/packages/evm/src/message.ts +++ b/packages/evm/src/message.ts @@ -33,7 +33,7 @@ interface MessageOpts { gasRefund?: bigint } -export default class Message { +export class Message { to?: Address value: bigint caller: Address diff --git a/packages/evm/src/opcodes/EIP1283.ts b/packages/evm/src/opcodes/EIP1283.ts index 89ccacc7d8..a4a3be14b5 100644 --- a/packages/evm/src/opcodes/EIP1283.ts +++ b/packages/evm/src/opcodes/EIP1283.ts @@ -1,4 +1,4 @@ -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { RunState } from './../interpreter' /** diff --git a/packages/evm/src/opcodes/EIP2200.ts b/packages/evm/src/opcodes/EIP2200.ts index 4d6b9220f4..6f31d0f6fa 100644 --- a/packages/evm/src/opcodes/EIP2200.ts +++ b/packages/evm/src/opcodes/EIP2200.ts @@ -1,4 +1,4 @@ -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { RunState } from './../interpreter' import { ERROR } from '../exceptions' import { adjustSstoreGasEIP2929 } from './EIP2929' diff --git a/packages/evm/src/opcodes/EIP2929.ts b/packages/evm/src/opcodes/EIP2929.ts index e07c5b3362..e5cd08a481 100644 --- a/packages/evm/src/opcodes/EIP2929.ts +++ b/packages/evm/src/opcodes/EIP2929.ts @@ -1,4 +1,4 @@ -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Address } from '@ethereumjs/util' import { RunState } from './../interpreter' diff --git a/packages/evm/src/opcodes/codes.ts b/packages/evm/src/opcodes/codes.ts index 2993361bd8..5ea0523632 100644 --- a/packages/evm/src/opcodes/codes.ts +++ b/packages/evm/src/opcodes/codes.ts @@ -1,4 +1,4 @@ -import Common, { Hardfork } from '@ethereumjs/common' +import { Common, Hardfork } from '@ethereumjs/common' import { CustomOpcode } from '../types' import { getFullname } from './util' import { AsyncDynamicGasHandler, dynamicGasHandlers, SyncDynamicGasHandler } from './gas' diff --git a/packages/evm/src/opcodes/functions.ts b/packages/evm/src/opcodes/functions.ts index 482c558f0d..ea4dfb9270 100644 --- a/packages/evm/src/opcodes/functions.ts +++ b/packages/evm/src/opcodes/functions.ts @@ -1,4 +1,4 @@ -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { keccak256 } from 'ethereum-cryptography/keccak' import { bytesToHex } from 'ethereum-cryptography/utils' import { diff --git a/packages/evm/src/opcodes/gas.ts b/packages/evm/src/opcodes/gas.ts index d98eb21acd..52cb44a9a4 100644 --- a/packages/evm/src/opcodes/gas.ts +++ b/packages/evm/src/opcodes/gas.ts @@ -10,7 +10,7 @@ import { import { Address, bigIntToBuffer, setLengthLeft } from '@ethereumjs/util' import { ERROR } from '../exceptions' import { RunState } from '../interpreter' -import Common, { Hardfork } from '@ethereumjs/common' +import { Common, Hardfork } from '@ethereumjs/common' import { updateSstoreGasEIP1283 } from './EIP1283' import { updateSstoreGasEIP2200 } from './EIP2200' import { accessAddressEIP2929, accessStorageEIP2929 } from './EIP2929' diff --git a/packages/evm/src/opcodes/util.ts b/packages/evm/src/opcodes/util.ts index 7f972c4b46..456ed1cdc7 100644 --- a/packages/evm/src/opcodes/util.ts +++ b/packages/evm/src/opcodes/util.ts @@ -1,4 +1,4 @@ -import Common, { Hardfork } from '@ethereumjs/common' +import { Common, Hardfork } from '@ethereumjs/common' import { keccak256 } from 'ethereum-cryptography/keccak' import { bytesToHex } from 'ethereum-cryptography/utils' import { setLengthRight, setLengthLeft, bigIntToBuffer } from '@ethereumjs/util' diff --git a/packages/evm/src/precompiles/01-ecrecover.ts b/packages/evm/src/precompiles/01-ecrecover.ts index 42059bfa5d..8df17b739a 100644 --- a/packages/evm/src/precompiles/01-ecrecover.ts +++ b/packages/evm/src/precompiles/01-ecrecover.ts @@ -8,7 +8,7 @@ import { import { PrecompileInput } from './types' import { OOGResult, ExecResult } from '../evm' -export default function (opts: PrecompileInput): ExecResult { +export function precompile01(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const gasUsed = opts._common.param('gasPrices', 'ecRecover') diff --git a/packages/evm/src/precompiles/02-sha256.ts b/packages/evm/src/precompiles/02-sha256.ts index 3b6d86754a..b84110dc4a 100644 --- a/packages/evm/src/precompiles/02-sha256.ts +++ b/packages/evm/src/precompiles/02-sha256.ts @@ -3,7 +3,7 @@ import { toBuffer } from '@ethereumjs/util' import { PrecompileInput } from './types' import { OOGResult, ExecResult } from '../evm' -export default function (opts: PrecompileInput): ExecResult { +export function precompile02(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const data = opts.data diff --git a/packages/evm/src/precompiles/03-ripemd160.ts b/packages/evm/src/precompiles/03-ripemd160.ts index b15fe5ef0e..6a5023ba43 100644 --- a/packages/evm/src/precompiles/03-ripemd160.ts +++ b/packages/evm/src/precompiles/03-ripemd160.ts @@ -3,7 +3,7 @@ import { setLengthLeft, toBuffer } from '@ethereumjs/util' import { PrecompileInput } from './types' import { OOGResult, ExecResult } from '../evm' -export default function (opts: PrecompileInput): ExecResult { +export function precompile03(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const data = opts.data diff --git a/packages/evm/src/precompiles/04-identity.ts b/packages/evm/src/precompiles/04-identity.ts index 822f006ae9..9543de4051 100644 --- a/packages/evm/src/precompiles/04-identity.ts +++ b/packages/evm/src/precompiles/04-identity.ts @@ -1,7 +1,7 @@ import { PrecompileInput } from './types' import { OOGResult, ExecResult } from '../evm' -export default function (opts: PrecompileInput): ExecResult { +export function precompile04(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const data = opts.data diff --git a/packages/evm/src/precompiles/05-modexp.ts b/packages/evm/src/precompiles/05-modexp.ts index 4388e56a37..e1338b89d9 100644 --- a/packages/evm/src/precompiles/05-modexp.ts +++ b/packages/evm/src/precompiles/05-modexp.ts @@ -73,7 +73,7 @@ export function expmod(a: bigint, power: bigint, modulo: bigint) { return res } -export default function (opts: PrecompileInput): ExecResult { +export function precompile05(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const data = opts.data diff --git a/packages/evm/src/precompiles/06-ecadd.ts b/packages/evm/src/precompiles/06-ecadd.ts index 1f35d49311..46f5d6ec38 100644 --- a/packages/evm/src/precompiles/06-ecadd.ts +++ b/packages/evm/src/precompiles/06-ecadd.ts @@ -2,7 +2,7 @@ import { PrecompileInput } from './types' import { OOGResult, ExecResult } from '../evm' const bn128 = require('rustbn.js') -export default function (opts: PrecompileInput): ExecResult { +export function precompile06(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const inputData = opts.data diff --git a/packages/evm/src/precompiles/07-ecmul.ts b/packages/evm/src/precompiles/07-ecmul.ts index ae611bc4bf..629825ce9b 100644 --- a/packages/evm/src/precompiles/07-ecmul.ts +++ b/packages/evm/src/precompiles/07-ecmul.ts @@ -2,7 +2,7 @@ import { PrecompileInput } from './types' import { OOGResult, ExecResult } from '../evm' const bn128 = require('rustbn.js') -export default function (opts: PrecompileInput): ExecResult { +export function precompile07(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const inputData = opts.data diff --git a/packages/evm/src/precompiles/08-ecpairing.ts b/packages/evm/src/precompiles/08-ecpairing.ts index 64fca5eee9..626429c955 100644 --- a/packages/evm/src/precompiles/08-ecpairing.ts +++ b/packages/evm/src/precompiles/08-ecpairing.ts @@ -2,7 +2,7 @@ import { PrecompileInput } from './types' import { OOGResult, ExecResult } from '../evm' const bn128 = require('rustbn.js') -export default function (opts: PrecompileInput): ExecResult { +export function precompile08(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const inputData = opts.data diff --git a/packages/evm/src/precompiles/09-blake2f.ts b/packages/evm/src/precompiles/09-blake2f.ts index 252d75d337..e38bd51a4b 100644 --- a/packages/evm/src/precompiles/09-blake2f.ts +++ b/packages/evm/src/precompiles/09-blake2f.ts @@ -153,7 +153,7 @@ export function F(h: Uint32Array, m: Uint32Array, t: Uint32Array, f: boolean, ro } } -export default function (opts: PrecompileInput): ExecResult { +export function precompile09(opts: PrecompileInput): ExecResult { if (!opts.data) throw new Error('opts.data missing but required') const data = opts.data diff --git a/packages/evm/src/precompiles/0a-bls12-g1add.ts b/packages/evm/src/precompiles/0a-bls12-g1add.ts index 8908a4c9e0..5fd73bf77b 100644 --- a/packages/evm/src/precompiles/0a-bls12-g1add.ts +++ b/packages/evm/src/precompiles/0a-bls12-g1add.ts @@ -3,7 +3,7 @@ import { EvmErrorResult, ExecResult, OOGResult } from '../evm' import { ERROR, EvmError } from '../exceptions' const { BLS12_381_ToG1Point, BLS12_381_FromG1Point } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile0a(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/0b-bls12-g1mul.ts b/packages/evm/src/precompiles/0b-bls12-g1mul.ts index a980135dff..af1000b345 100644 --- a/packages/evm/src/precompiles/0b-bls12-g1mul.ts +++ b/packages/evm/src/precompiles/0b-bls12-g1mul.ts @@ -7,7 +7,7 @@ const { BLS12_381_ToFrPoint, } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile0b(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/0c-bls12-g1multiexp.ts b/packages/evm/src/precompiles/0c-bls12-g1multiexp.ts index 9442f739ec..9732fd0e1e 100644 --- a/packages/evm/src/precompiles/0c-bls12-g1multiexp.ts +++ b/packages/evm/src/precompiles/0c-bls12-g1multiexp.ts @@ -7,7 +7,7 @@ const { BLS12_381_FromG1Point, } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile0c(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/0d-bls12-g2add.ts b/packages/evm/src/precompiles/0d-bls12-g2add.ts index b13e61de07..3567f9c471 100644 --- a/packages/evm/src/precompiles/0d-bls12-g2add.ts +++ b/packages/evm/src/precompiles/0d-bls12-g2add.ts @@ -3,7 +3,7 @@ import { EvmErrorResult, ExecResult, OOGResult } from '../evm' import { ERROR, EvmError } from '../exceptions' const { BLS12_381_ToG2Point, BLS12_381_FromG2Point } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile0d(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/0e-bls12-g2mul.ts b/packages/evm/src/precompiles/0e-bls12-g2mul.ts index 7e456531bf..e5933152a0 100644 --- a/packages/evm/src/precompiles/0e-bls12-g2mul.ts +++ b/packages/evm/src/precompiles/0e-bls12-g2mul.ts @@ -7,7 +7,7 @@ const { BLS12_381_ToFrPoint, } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile0e(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/0f-bls12-g2multiexp.ts b/packages/evm/src/precompiles/0f-bls12-g2multiexp.ts index 14d5e9ae41..d1c77dc0c2 100644 --- a/packages/evm/src/precompiles/0f-bls12-g2multiexp.ts +++ b/packages/evm/src/precompiles/0f-bls12-g2multiexp.ts @@ -8,7 +8,7 @@ const { BLS12_381_FromG2Point, } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile0f(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/10-bls12-pairing.ts b/packages/evm/src/precompiles/10-bls12-pairing.ts index 6cd4968ae0..72b507e989 100644 --- a/packages/evm/src/precompiles/10-bls12-pairing.ts +++ b/packages/evm/src/precompiles/10-bls12-pairing.ts @@ -7,7 +7,7 @@ const { BLS12_381_ToG1Point, BLS12_381_ToG2Point } = require('./util/bls12_381') const zeroBuffer = Buffer.alloc(32, 0) const oneBuffer = Buffer.concat([Buffer.alloc(31, 0), Buffer.from('01', 'hex')]) -export default async function (opts: PrecompileInput): Promise { +export async function precompile10(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/11-bls12-map-fp-to-g1.ts b/packages/evm/src/precompiles/11-bls12-map-fp-to-g1.ts index 26c3d7e20f..53059d41f4 100644 --- a/packages/evm/src/precompiles/11-bls12-map-fp-to-g1.ts +++ b/packages/evm/src/precompiles/11-bls12-map-fp-to-g1.ts @@ -3,7 +3,7 @@ import { EvmErrorResult, ExecResult, OOGResult } from '../evm' import { ERROR, EvmError } from '../exceptions' const { BLS12_381_ToFpPoint, BLS12_381_FromG1Point } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile11(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/12-bls12-map-fp2-to-g2.ts b/packages/evm/src/precompiles/12-bls12-map-fp2-to-g2.ts index ef7471f3cc..ed56d9fb67 100644 --- a/packages/evm/src/precompiles/12-bls12-map-fp2-to-g2.ts +++ b/packages/evm/src/precompiles/12-bls12-map-fp2-to-g2.ts @@ -3,7 +3,7 @@ import { EvmErrorResult, ExecResult, OOGResult } from '../evm' import { ERROR, EvmError } from '../exceptions' const { BLS12_381_ToFp2Point, BLS12_381_FromG2Point } = require('./util/bls12_381') -export default async function (opts: PrecompileInput): Promise { +export async function precompile12(opts: PrecompileInput): Promise { if (!opts.data) throw new Error('opts.data missing but required') const mcl = (opts._EVM)._mcl! diff --git a/packages/evm/src/precompiles/index.ts b/packages/evm/src/precompiles/index.ts index d46596504a..abff4d8b04 100644 --- a/packages/evm/src/precompiles/index.ts +++ b/packages/evm/src/precompiles/index.ts @@ -1,24 +1,24 @@ import { Address } from '@ethereumjs/util' -import Common, { Hardfork } from '@ethereumjs/common' +import { Common, Hardfork } from '@ethereumjs/common' import { PrecompileInput, PrecompileFunc } from './types' -import { default as p1 } from './01-ecrecover' -import { default as p2 } from './02-sha256' -import { default as p3 } from './03-ripemd160' -import { default as p4 } from './04-identity' -import { default as p5 } from './05-modexp' -import { default as p6 } from './06-ecadd' -import { default as p7 } from './07-ecmul' -import { default as p8 } from './08-ecpairing' -import { default as p9 } from './09-blake2f' -import { default as pa } from './0a-bls12-g1add' -import { default as pb } from './0b-bls12-g1mul' -import { default as pc } from './0c-bls12-g1multiexp' -import { default as pd } from './0d-bls12-g2add' -import { default as pe } from './0e-bls12-g2mul' -import { default as pf } from './0f-bls12-g2multiexp' -import { default as p10 } from './10-bls12-pairing' -import { default as p11 } from './11-bls12-map-fp-to-g1' -import { default as p12 } from './12-bls12-map-fp2-to-g2' +import { precompile01 } from './01-ecrecover' +import { precompile02 } from './02-sha256' +import { precompile03 } from './03-ripemd160' +import { precompile04 } from './04-identity' +import { precompile05 } from './05-modexp' +import { precompile06 } from './06-ecadd' +import { precompile07 } from './07-ecmul' +import { precompile08 } from './08-ecpairing' +import { precompile09 } from './09-blake2f' +import { precompile0a } from './0a-bls12-g1add' +import { precompile0b } from './0b-bls12-g1mul' +import { precompile0c } from './0c-bls12-g1multiexp' +import { precompile0d } from './0d-bls12-g2add' +import { precompile0e } from './0e-bls12-g2mul' +import { precompile0f } from './0f-bls12-g2multiexp' +import { precompile10 } from './10-bls12-pairing' +import { precompile11 } from './11-bls12-map-fp-to-g1' +import { precompile12 } from './12-bls12-map-fp2-to-g2' interface Precompiles { [key: string]: PrecompileFunc @@ -49,24 +49,24 @@ interface PrecompileAvailabilityCheckTypeEIP { const ripemdPrecompileAddress = '0000000000000000000000000000000000000003' const precompiles: Precompiles = { - '0000000000000000000000000000000000000001': p1, - '0000000000000000000000000000000000000002': p2, - [ripemdPrecompileAddress]: p3, - '0000000000000000000000000000000000000004': p4, - '0000000000000000000000000000000000000005': p5, - '0000000000000000000000000000000000000006': p6, - '0000000000000000000000000000000000000007': p7, - '0000000000000000000000000000000000000008': p8, - '0000000000000000000000000000000000000009': p9, - '000000000000000000000000000000000000000a': pa, - '000000000000000000000000000000000000000b': pb, - '000000000000000000000000000000000000000c': pc, - '000000000000000000000000000000000000000d': pd, - '000000000000000000000000000000000000000e': pe, - '000000000000000000000000000000000000000f': pf, - '0000000000000000000000000000000000000010': p10, - '0000000000000000000000000000000000000011': p11, - '0000000000000000000000000000000000000012': p12, + '0000000000000000000000000000000000000001': precompile01, + '0000000000000000000000000000000000000002': precompile02, + [ripemdPrecompileAddress]: precompile03, + '0000000000000000000000000000000000000004': precompile04, + '0000000000000000000000000000000000000005': precompile05, + '0000000000000000000000000000000000000006': precompile06, + '0000000000000000000000000000000000000007': precompile07, + '0000000000000000000000000000000000000008': precompile08, + '0000000000000000000000000000000000000009': precompile09, + '000000000000000000000000000000000000000a': precompile0a, + '000000000000000000000000000000000000000b': precompile0b, + '000000000000000000000000000000000000000c': precompile0c, + '000000000000000000000000000000000000000d': precompile0d, + '000000000000000000000000000000000000000e': precompile0e, + '000000000000000000000000000000000000000f': precompile0f, + '0000000000000000000000000000000000000010': precompile10, + '0000000000000000000000000000000000000011': precompile11, + '0000000000000000000000000000000000000012': precompile12, } const precompileAvailability: PrecompileAvailability = { diff --git a/packages/evm/src/precompiles/types.ts b/packages/evm/src/precompiles/types.ts index c4ebe2663d..b955008f52 100644 --- a/packages/evm/src/precompiles/types.ts +++ b/packages/evm/src/precompiles/types.ts @@ -1,4 +1,4 @@ -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { ExecResult } from '../evm' import { EVMInterface } from '../types' diff --git a/packages/evm/src/stack.ts b/packages/evm/src/stack.ts index cfaade3558..94aebe3db6 100644 --- a/packages/evm/src/stack.ts +++ b/packages/evm/src/stack.ts @@ -4,7 +4,7 @@ import { ERROR, EvmError } from './exceptions' /** * Implementation of the stack used in evm. */ -export default class Stack { +export class Stack { _store: bigint[] _maxHeight: number diff --git a/packages/evm/src/transientStorage.ts b/packages/evm/src/transientStorage.ts index cea961fb51..db9e82a2ea 100644 --- a/packages/evm/src/transientStorage.ts +++ b/packages/evm/src/transientStorage.ts @@ -11,7 +11,7 @@ interface TransientStorageModification { type TransientStorageJournal = TransientStorageModification[] -export default class TransientStorage implements TransientStorageInterface { +export class TransientStorage implements TransientStorageInterface { /** * The current values of the transient storage, keyed by contract address and then slot */ diff --git a/packages/evm/src/types.ts b/packages/evm/src/types.ts index 46aa7395c6..e5467f8687 100644 --- a/packages/evm/src/types.ts +++ b/packages/evm/src/types.ts @@ -1,7 +1,7 @@ import { Account, Address, PrefixedHexString } from '@ethereumjs/util' -import EVM, { EVMResult, ExecResult } from './evm' +import { EVM, EVMResult, ExecResult } from './evm' import { InterpreterStep } from './interpreter' -import Message from './message' +import { Message } from './message' import { OpHandler } from './opcodes' import { AsyncDynamicGasHandler, SyncDynamicGasHandler } from './opcodes/gas' diff --git a/packages/evm/tests/customOpcodes.spec.ts b/packages/evm/tests/customOpcodes.spec.ts index f0d285189f..7a16b4bcd7 100644 --- a/packages/evm/tests/customOpcodes.spec.ts +++ b/packages/evm/tests/customOpcodes.spec.ts @@ -1,6 +1,6 @@ import { AddOpcode } from '../src/types' import { InterpreterStep, RunState } from '../src/interpreter' -import EVM from '../src/evm' +import { EVM } from '../src/evm' import { getEEI } from './utils' import * as tape from 'tape' diff --git a/packages/evm/tests/customPrecompiles.spec.ts b/packages/evm/tests/customPrecompiles.spec.ts index 54203dd0a4..1e4da1b9fd 100644 --- a/packages/evm/tests/customPrecompiles.spec.ts +++ b/packages/evm/tests/customPrecompiles.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Address } from '@ethereumjs/util' import { PrecompileInput } from '../src/precompiles' -import EVM, { ExecResult } from '../src/evm' +import { EVM, ExecResult } from '../src/evm' import { getEEI } from './utils' const sender = new Address(Buffer.from('44'.repeat(20), 'hex')) diff --git a/packages/evm/tests/memory.spec.ts b/packages/evm/tests/memory.spec.ts index 339380836f..7a64a360db 100644 --- a/packages/evm/tests/memory.spec.ts +++ b/packages/evm/tests/memory.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Memory from '../src/memory' +import { Memory } from '../src/memory' tape('Memory', (t) => { const m = new Memory() diff --git a/packages/evm/tests/opcodes.spec.ts b/packages/evm/tests/opcodes.spec.ts index 62a346f3ff..9a2cbc2af9 100644 --- a/packages/evm/tests/opcodes.spec.ts +++ b/packages/evm/tests/opcodes.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { getEEI } from './utils' -import EVM from '../src' +import { EVM } from '../src' tape('EVM -> getActiveOpcodes()', (t) => { const CHAINID = 0x46 //istanbul opcode diff --git a/packages/evm/tests/precompiles/06-ecadd.spec.ts b/packages/evm/tests/precompiles/06-ecadd.spec.ts index 3154ce501e..e86fde5d15 100644 --- a/packages/evm/tests/precompiles/06-ecadd.spec.ts +++ b/packages/evm/tests/precompiles/06-ecadd.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import EVM from '../../src' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { EVM } from '../../src' import { getActivePrecompiles } from '../../src/precompiles' import { getEEI } from '../utils' diff --git a/packages/evm/tests/precompiles/07-ecmul.spec.ts b/packages/evm/tests/precompiles/07-ecmul.spec.ts index 31e19c39ad..55bc7171a3 100644 --- a/packages/evm/tests/precompiles/07-ecmul.spec.ts +++ b/packages/evm/tests/precompiles/07-ecmul.spec.ts @@ -1,8 +1,8 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { getActivePrecompiles } from '../../src/precompiles' import { getEEI } from '../utils' -import EVM from '../../src' +import { EVM } from '../../src' tape('Precompiles: ECMUL', (t) => { t.test('ECMUL', async (st) => { diff --git a/packages/evm/tests/precompiles/08-ecpairing.spec.ts b/packages/evm/tests/precompiles/08-ecpairing.spec.ts index 3bc9e84657..5790236977 100644 --- a/packages/evm/tests/precompiles/08-ecpairing.spec.ts +++ b/packages/evm/tests/precompiles/08-ecpairing.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { getActivePrecompiles } from '../../src/precompiles' import { getEEI } from '../utils' -import EVM from '../../src' +import { EVM } from '../../src' tape('Precompiles: ECPAIRING', (t) => { t.test('ECPAIRING', async (st) => { diff --git a/packages/evm/tests/precompiles/hardfork.spec.ts b/packages/evm/tests/precompiles/hardfork.spec.ts index c4e7aaade2..897ba2d5c8 100644 --- a/packages/evm/tests/precompiles/hardfork.spec.ts +++ b/packages/evm/tests/precompiles/hardfork.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Address } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import EVM from '../../src' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { EVM } from '../../src' import { getActivePrecompiles } from '../../src/precompiles' import { getEEI } from '../utils' diff --git a/packages/evm/tests/runCall.spec.ts b/packages/evm/tests/runCall.spec.ts index ad4a25b5e7..15639d2c6d 100644 --- a/packages/evm/tests/runCall.spec.ts +++ b/packages/evm/tests/runCall.spec.ts @@ -1,10 +1,9 @@ import * as tape from 'tape' import { keccak256 } from 'ethereum-cryptography/keccak' import { Account, Address, MAX_UINT64, padToEven } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import VM from '../src' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { ERROR } from '../src/exceptions' -import EVM from '../src' +import { EVM } from '../src' import { getEEI } from './utils' // Non-protected Create2Address generator. Does not check if buffers have the right padding. @@ -141,7 +140,7 @@ tape('Ensure that Istanbul sstoreCleanRefundEIP2200 gas is applied correctly', a // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Istanbul }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) const code = '61000260005561000160005500' /* idea: store the original value in the storage slot, except it is now a 1-length buffer instead of a 32-length buffer @@ -193,7 +192,7 @@ tape('ensure correct gas for pre-constantinople sstore', async (t) => { // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Chainstart }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) // push 1 push 0 sstore stop const code = '600160015500' @@ -253,7 +252,7 @@ tape( // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Homestead }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) // code to call back into the calling account (0x00..00EE), // but using too much memory const code = '61FFFF60FF60006000600060EE6000F200' @@ -284,7 +283,7 @@ tape('ensure selfdestruct pays for creating new accounts', async (t) => { // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.TangerineWhistle }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) // code to call 0x00..00fe, with the GAS opcode used as gas // this cannot be paid, since we also have to pay for CALL (40 gas) // this should thus go OOG @@ -315,7 +314,7 @@ tape('ensure that sstores pay for the right gas costs pre-byzantium', async (t) // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Chainstart }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) // code to call 0x00..00fe, with the GAS opcode used as gas // this cannot be paid, since we also have to pay for CALL (40 gas) // this should thus go OOG @@ -386,7 +385,7 @@ tape( // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) const code = '60008080F060005500' /* This simple code tries to create an empty contract and then stores the address of the contract in the zero slot. @@ -441,7 +440,7 @@ tape('Ensure that IDENTITY precompile copies the memory', async (t) => { // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) const code = '3034526020600760203460045afa602034343e604034f3' const account = await eei.getAccount(caller) @@ -476,7 +475,7 @@ tape('Throws on negative call value', async (t) => { // setup the vm const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Istanbul }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) // setup the call arguments const runCallArgs = { @@ -498,7 +497,7 @@ tape('runCall() -> skipBalance behavior', async (t) => { t.plan(7) const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin }) const eei = await getEEI() - const evm = await VM.create({ common, eei }) + const evm = await EVM.create({ common, eei }) // runCall against a contract to reach `_reduceSenderBalance` const contractCode = Buffer.from('00', 'hex') // 00: STOP diff --git a/packages/evm/tests/runCode.spec.ts b/packages/evm/tests/runCode.spec.ts index 5e1158544c..9574fee2bf 100644 --- a/packages/evm/tests/runCode.spec.ts +++ b/packages/evm/tests/runCode.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { getEEI } from './utils' -import EVM from '../src' +import { EVM } from '../src' const STOP = '00' const JUMP = '56' diff --git a/packages/evm/tests/stack.spec.ts b/packages/evm/tests/stack.spec.ts index 5c37d85fc4..b38bca1c98 100644 --- a/packages/evm/tests/stack.spec.ts +++ b/packages/evm/tests/stack.spec.ts @@ -1,8 +1,8 @@ import * as tape from 'tape' import { Account, Address, bigIntToBuffer, setLengthLeft } from '@ethereumjs/util' -import Stack from '../src/stack' +import { Stack } from '../src/stack' import { createAccount, getEEI } from './utils' -import EVM from '../src' +import { EVM } from '../src' tape('Stack', (t) => { t.test('should be empty initially', (st) => { diff --git a/packages/evm/tests/transientStorage.spec.ts b/packages/evm/tests/transientStorage.spec.ts index c0a9908e86..e031a302ea 100644 --- a/packages/evm/tests/transientStorage.spec.ts +++ b/packages/evm/tests/transientStorage.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Address } from '@ethereumjs/util' -import TransientStorage from '../src/transientStorage' +import { TransientStorage } from '../src/transientStorage' tape('Transient Storage', (tester) => { const it = tester.test diff --git a/packages/evm/tests/utils.ts b/packages/evm/tests/utils.ts index 721dc8ba54..0f9be7993f 100644 --- a/packages/evm/tests/utils.ts +++ b/packages/evm/tests/utils.ts @@ -1,9 +1,9 @@ -import Blockchain from '../../blockchain/src' -import Common, { Chain } from '@ethereumjs/common' +import { Blockchain } from '../../blockchain/src' +import { Chain, Common } from '@ethereumjs/common' import { DefaultStateManager } from '@ethereumjs/statemanager' import { Account } from '@ethereumjs/util' import path from 'path' -import EEI from '../../vm/src/eei/eei' +import { EEI } from '../../vm/src/eei/eei' export async function getEEI() { return new EEI( diff --git a/packages/rlp/README.md b/packages/rlp/README.md index a85217495f..a6a9ba94f4 100644 --- a/packages/rlp/README.md +++ b/packages/rlp/README.md @@ -18,7 +18,7 @@ install with `-g` if you want to use the CLI. ```typescript import assert from 'assert' -import RLP from 'rlp' +import { RLP } from 'rlp' const nestedList = [[], [[]], [[], [[]]]] const encoded = RLP.encode(nestedList) @@ -39,7 +39,7 @@ If you would like to continue using Buffers like in rlp v2, you can use: ```typescript import assert from 'assert' import { arrToBufArr, bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' const bufferList = [Buffer.from('123', 'hex'), Buffer.from('456', 'hex')] const encoded = RLP.encode(bufArrToArr(bufferList)) diff --git a/packages/rlp/src/index.ts b/packages/rlp/src/index.ts index bc712bb873..b3b2136638 100644 --- a/packages/rlp/src/index.ts +++ b/packages/rlp/src/index.ts @@ -290,5 +290,4 @@ export const utils = { utf8ToBytes, } -const RLP = { encode, decode } -export default RLP +export const RLP = { encode, decode } diff --git a/packages/rlp/test/dataTypes.spec.ts b/packages/rlp/test/dataTypes.spec.ts index 5836904b0b..175e5b1464 100644 --- a/packages/rlp/test/dataTypes.spec.ts +++ b/packages/rlp/test/dataTypes.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import RLP, { utils } from '../src' +import { RLP, utils } from '../src' import { bytesToUtf8 } from './utils' const { bytesToHex, concatBytes, hexToBytes, utf8ToBytes } = utils diff --git a/packages/rlp/test/integration.spec.ts b/packages/rlp/test/integration.spec.ts index 24c665bdc2..bde8515704 100644 --- a/packages/rlp/test/integration.spec.ts +++ b/packages/rlp/test/integration.spec.ts @@ -2,7 +2,7 @@ import * as tape from 'tape' import { exec } from 'child_process' import { promisify } from 'util' import * as vm from 'vm' -import RLP from '../src' +import { RLP } from '../src' import { bytesToUtf8 } from './utils' import * as official from './fixture/rlptest.json' diff --git a/packages/rlp/test/invalid.spec.ts b/packages/rlp/test/invalid.spec.ts index bd1cf44d74..298debde7b 100644 --- a/packages/rlp/test/invalid.spec.ts +++ b/packages/rlp/test/invalid.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import RLP, { utils } from '../src' +import { RLP, utils } from '../src' import * as invalid from './fixture/invalid.json' const { hexToBytes } = utils diff --git a/packages/rlp/test/official.spec.ts b/packages/rlp/test/official.spec.ts index 6410b4dcdc..4ce85f154d 100644 --- a/packages/rlp/test/official.spec.ts +++ b/packages/rlp/test/official.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import RLP, { utils } from '../src' +import { RLP, utils } from '../src' import { numberToBytes } from './utils' import * as official from './fixture/rlptest.json' diff --git a/packages/statemanager/src/baseStateManager.ts b/packages/statemanager/src/baseStateManager.ts index 988a3ed297..2dc8c2b6b6 100644 --- a/packages/statemanager/src/baseStateManager.ts +++ b/packages/statemanager/src/baseStateManager.ts @@ -1,7 +1,7 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { debug as createDebugLogger, Debugger } from 'debug' import { Account, Address } from '@ethereumjs/util' -import Cache from './cache' +import { Cache } from './cache' import { AccountFields } from './interface' import { DefaultStateManagerOpts } from './stateManager' diff --git a/packages/statemanager/src/cache.ts b/packages/statemanager/src/cache.ts index 6ee4806e3e..9d6e325a01 100644 --- a/packages/statemanager/src/cache.ts +++ b/packages/statemanager/src/cache.ts @@ -14,7 +14,7 @@ export interface CacheOpts { /** * @ignore */ -export default class Cache { +export class Cache { _cache: any _checkpoints: any[] diff --git a/packages/statemanager/src/index.ts b/packages/statemanager/src/index.ts index 129d4ebb35..b90c245d52 100644 --- a/packages/statemanager/src/index.ts +++ b/packages/statemanager/src/index.ts @@ -1,3 +1,3 @@ export { StateManager, AccountFields, StateAccess } from './interface' export { BaseStateManager } from './baseStateManager' -export { default as DefaultStateManager, Proof } from './stateManager' +export { DefaultStateManager, Proof } from './stateManager' diff --git a/packages/statemanager/src/stateManager.ts b/packages/statemanager/src/stateManager.ts index 361d46067d..2904d239f9 100644 --- a/packages/statemanager/src/stateManager.ts +++ b/packages/statemanager/src/stateManager.ts @@ -13,10 +13,10 @@ import { setLengthLeft, short, } from '@ethereumjs/util' -import Common from '@ethereumjs/common' -import RLP from 'rlp' +import { Common } from '@ethereumjs/common' +import { RLP } from 'rlp' import { StateManager, StorageDump } from './interface' -import Cache, { getCb, putCb } from './cache' +import { Cache, getCb, putCb } from './cache' import { BaseStateManager } from './' type StorageProof = { @@ -69,7 +69,7 @@ export interface DefaultStateManagerOpts { * The default state manager implementation uses a * `@ethereumjs/trie` trie as a data backend. */ -export default class DefaultStateManager extends BaseStateManager implements StateManager { +export class DefaultStateManager extends BaseStateManager implements StateManager { _trie: Trie _storageTries: { [key: string]: Trie } diff --git a/packages/statemanager/tests/cache.spec.ts b/packages/statemanager/tests/cache.spec.ts index 72bbba13e0..c074d540fe 100644 --- a/packages/statemanager/tests/cache.spec.ts +++ b/packages/statemanager/tests/cache.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { SecureTrie as Trie } from '@ethereumjs/trie' import { Account, Address } from '@ethereumjs/util' -import Cache, { getCb, putCb } from '../src/cache' +import { Cache, getCb, putCb } from '../src/cache' import { createAccount } from './util' tape('cache initialization', (t) => { diff --git a/packages/statemanager/tests/stateManager.spec.ts b/packages/statemanager/tests/stateManager.spec.ts index 965257386c..1a03bf230f 100644 --- a/packages/statemanager/tests/stateManager.spec.ts +++ b/packages/statemanager/tests/stateManager.spec.ts @@ -10,7 +10,7 @@ import { unpadBuffer, zeros, } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { DefaultStateManager } from '../src' import { createAccount } from './util' diff --git a/packages/trie/README.md b/packages/trie/README.md index fe2dbf3761..79e0d3adb2 100644 --- a/packages/trie/README.md +++ b/packages/trie/README.md @@ -136,7 +136,7 @@ trie import level from 'level' import { SecureTrie as Trie } from '@ethereumjs/trie' import { Account, bufferToHex } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' const stateRoot = 'STATE_ROOT_OF_A_BLOCK' diff --git a/packages/trie/src/trie/node/branch.ts b/packages/trie/src/trie/node/branch.ts index 9ab58a21f9..323ec9fea7 100644 --- a/packages/trie/src/trie/node/branch.ts +++ b/packages/trie/src/trie/node/branch.ts @@ -1,6 +1,6 @@ import { keccak256 } from 'ethereum-cryptography/keccak' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { EmbeddedNode } from '../../types' export class BranchNode { diff --git a/packages/trie/src/trie/node/extension.ts b/packages/trie/src/trie/node/extension.ts index ab962e4581..5737d96e78 100644 --- a/packages/trie/src/trie/node/extension.ts +++ b/packages/trie/src/trie/node/extension.ts @@ -1,6 +1,6 @@ import { keccak256 } from 'ethereum-cryptography/keccak' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { nibblesToBuffer } from '../../util/nibbles' import { addHexPrefix, removeHexPrefix } from '../../util/hex' import { Nibbles } from '../../types' diff --git a/packages/trie/src/trie/node/leaf.ts b/packages/trie/src/trie/node/leaf.ts index 92097dcab0..8a44abde6b 100644 --- a/packages/trie/src/trie/node/leaf.ts +++ b/packages/trie/src/trie/node/leaf.ts @@ -1,6 +1,6 @@ import { keccak256 } from 'ethereum-cryptography/keccak' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { nibblesToBuffer } from '../../util/nibbles' import { addHexPrefix, removeHexPrefix } from '../../util/hex' import { Nibbles } from '../../types' diff --git a/packages/trie/src/trie/node/util.ts b/packages/trie/src/trie/node/util.ts index b5cfb87cc5..90342d0ce3 100644 --- a/packages/trie/src/trie/node/util.ts +++ b/packages/trie/src/trie/node/util.ts @@ -1,5 +1,5 @@ import { arrToBufArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { bufferToNibbles } from '../../util/nibbles' import { isTerminator } from '../../util/hex' import { BranchNode } from './branch' diff --git a/packages/trie/test/index.spec.ts b/packages/trie/test/index.spec.ts index 0f910ded2a..06081204e8 100644 --- a/packages/trie/test/index.spec.ts +++ b/packages/trie/test/index.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { bufArrToArr, KECCAK256_NULL } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { CheckpointTrie, LevelDB, Trie } from '../src' // explicitly import buffer, diff --git a/packages/tx/README.md b/packages/tx/README.md index edc5e7f00c..188bf117e3 100644 --- a/packages/tx/README.md +++ b/packages/tx/README.md @@ -7,7 +7,7 @@ [![Discord][discord-badge]][discord-link] | Implements schema and functions related to Ethereum's transaction. | -| --- | +| ------------------------------------------------------------------ | Note: this `README` reflects the state of the library from `v3.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-tx) for an introduction on the last preceding release. @@ -41,20 +41,20 @@ Starting with `v3.2.1` the tx library now deviates from the default HF for typed Supported Hardforks: -Hardfork | Introduced | Description ---- | --- | --- -`london` | `v3.2.0` | `EIP-1559` Transactions -`berlin` | `v3.1.0` | `EIP-2718` Typed Transactions, Optional Access Lists Tx Type `EIP-2930` -`muirGlacier` | `v2.1.2` | - -`istanbul` | `v2.1.1` | Support for reduced non-zero call data gas prices ([EIP-2028](https://eips.ethereum.org/EIPS/eip-2028)) -`spuriousDragon` | `v2.0.0` | `EIP-155` replay protection (disable by setting HF pre-`spuriousDragon`) +| Hardfork | Introduced | Description | +| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------- | +| `london` | `v3.2.0` | `EIP-1559` Transactions | +| `berlin` | `v3.1.0` |  `EIP-2718` Typed Transactions, Optional Access Lists Tx Type `EIP-2930` | +| `muirGlacier` |  `v2.1.2` |  - | +| `istanbul` |  `v2.1.1`  | Support for reduced non-zero call data gas prices ([EIP-2028](https://eips.ethereum.org/EIPS/eip-2028)) | +| `spuriousDragon` |  `v2.0.0` |  `EIP-155` replay protection (disable by setting HF pre-`spuriousDragon`) | ### Standalone EIPs The following "standalone" EIPs are supported by the library can be manually activated using a respectively initialized `Common` instance, e.g.: ```typescript -const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London, eips: [ 3860 ] }) +const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London, eips: [3860] }) ``` - [EIP-3860](https://eips.ethereum.org/EIPS/eip-3855): Limit and meter initcode (`experimental`) @@ -76,25 +76,25 @@ This library supports the following transaction types ([EIP-2718](https://eips.e This is the recommended tx type starting with the activation of the `london` HF, see the following code snipped for an example on how to instantiate: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London }) const txData = { - "data": "0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "gasLimit": "0x02625a00", - "maxPriorityFeePerGas": "0x01", - "maxFeePerGas": "0xff", - "nonce": "0x00", - "to": "0xcccccccccccccccccccccccccccccccccccccccc", - "value": "0x0186a0", - "v": "0x01", - "r": "0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9", - "s": "0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64", - "chainId": "0x01", - "accessList": [], - "type": "0x02" + data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + gasLimit: '0x02625a00', + maxPriorityFeePerGas: '0x01', + maxFeePerGas: '0xff', + nonce: '0x00', + to: '0xcccccccccccccccccccccccccccccccccccccccc', + value: '0x0186a0', + v: '0x01', + r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9', + s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64', + chainId: '0x01', + accessList: [], + type: '0x02', } const tx = FeeMarketEIP1559Transaction.fromTxData(txData, { common }) @@ -109,32 +109,32 @@ const tx = FeeMarketEIP1559Transaction.fromTxData(txData, { common }) This transaction type has been introduced along the `berlin` HF. See the following code snipped for an example on how to instantiate: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { AccessListEIP2930Transaction } from '@ethereumjs/tx' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin }) const txData = { - "data": "0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "gasLimit": "0x02625a00", - "gasPrice": "0x01", - "nonce": "0x00", - "to": "0xcccccccccccccccccccccccccccccccccccccccc", - "value": "0x0186a0", - "v": "0x01", - "r": "0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9", - "s": "0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64", - "chainId": "0x01", - "accessList": [ + data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + gasLimit: '0x02625a00', + gasPrice: '0x01', + nonce: '0x00', + to: '0xcccccccccccccccccccccccccccccccccccccccc', + value: '0x0186a0', + v: '0x01', + r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9', + s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64', + chainId: '0x01', + accessList: [ { - "address": "0x0000000000000000000000000000000000000101", - "storageKeys": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000000000000000000000000000000000000000060a7" - ] - } + address: '0x0000000000000000000000000000000000000101', + storageKeys: [ + '0x0000000000000000000000000000000000000000000000000000000000000000', + '0x00000000000000000000000000000000000000000000000000000000000060a7', + ], + }, ], - "type": "0x01" + type: '0x01', } const tx = AccessListEIP2930Transaction.fromTxData(txData, { common }) @@ -153,7 +153,7 @@ Legacy transaction are still valid transaction within Ethereum `mainnet` but wil See this [example script](./examples/transactions.ts) or the following code example on how to use. ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' const txParams = { @@ -170,7 +170,7 @@ const tx = Transaction.fromTxData(txParams, { common }) const privateKey = Buffer.from( 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', - 'hex', + 'hex' ) const signedTx = tx.sign(privateKey) @@ -183,7 +183,7 @@ const serializedTx = signedTx.serialize() If you only know on runtime which tx type will be used within your code or if you want to keep your code transparent to tx types, this library comes with a `TransactionFactory` for your convenience which can be used as follows: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { TransactionFactory } from '@ethereumjs/tx' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin }) @@ -212,7 +212,7 @@ This library has been tested to work with various L2 networks (`v3.3.0`+). All p ```typescript import { Transaction } from '@ethereumjs/tx' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' const from = 'PUBLIC_KEY' const PRIV_KEY = process.argv[2] @@ -235,14 +235,14 @@ const signedTx = tx.sign(Buffer.from(PRIV_KEY, 'hex')) The following L2 networks have been tested to work with `@ethereumjs/tx`, see usage examples as well as some notes on pecularities in the issues linked below: -| L2 Network | Common name | Issue | -|---|---|---| -| Arbitrum Rinkeby Testnet | `CustomChain.ArbitrumRinkebyTestnet` | [#1290](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1290) | -| Polygon Mainnet | `CustomChain.PolygonMainnet` | [#1289](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1289) | -| Polygon Mumbai Testnet | `CustomChain.PolygonMumbai` | [#1289](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1289) | -| xDai Chain | `Common.xDaiChain` | [#1323](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1323) | -| Optimistic Kovan | `Common.OptimisticKovan` | [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554) -| Optimistic Ethereum | `Common.OptimisticEthereum` | [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554) +|  L2 Network |  Common name |  Issue | +| ------------------------ | ------------------------------------- | ----------------------------------------------------------------------- | +| Arbitrum Rinkeby Testnet |  `CustomChain.ArbitrumRinkebyTestnet` |  [#1290](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1290) | +| Polygon Mainnet |  `CustomChain.PolygonMainnet` |  [#1289](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1289) | +| Polygon Mumbai Testnet |  `CustomChain.PolygonMumbai` |  [#1289](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1289) | +| xDai Chain |  `Common.xDaiChain` |  [#1323](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1323) | +| Optimistic Kovan | `Common.OptimisticKovan` | [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554) | +| Optimistic Ethereum | `Common.OptimisticEthereum` | [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554) | Note: For Optimistic Kovan and Optimistic Ethereum, the London hardfork has not been implemented so transactions submitted with a `baseFee` will revert. The London hardfork is targeted to implement on Optimism in Q1.22. @@ -265,9 +265,9 @@ Here is an example of signing txs with `@ledgerhq/hw-app-eth` as of `v6.5.0`: ```typescript import { Transaction, FeeMarketEIP1559Transaction } from '@ethereumjs/tx' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import { bufArrToArr } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import Eth from '@ledgerhq/hw-app-eth' const eth = new Eth(transport) diff --git a/packages/tx/examples/custom-chain-tx.ts b/packages/tx/examples/custom-chain-tx.ts index bfbfeed27d..1e60047058 100644 --- a/packages/tx/examples/custom-chain-tx.ts +++ b/packages/tx/examples/custom-chain-tx.ts @@ -1,5 +1,5 @@ import { Address } from '@ethereumjs/util' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Transaction } from '../src' // In this example we create a transaction for a custom network. @@ -8,7 +8,6 @@ import { Transaction } from '../src' // except for name, chainId, and networkId, // so we use the `Common.custom` method. const customCommon = Common.custom( - { name: 'my-network', networkId: 123, @@ -16,7 +15,8 @@ const customCommon = Common.custom( }, { baseChain: 'mainnet', - hardfork: 'petersburg',} + hardfork: 'petersburg', + } ) // We pass our custom Common object whenever we create a transaction @@ -28,7 +28,7 @@ const tx = Transaction.fromTxData( gasLimit: 1000000000, value: 100000, }, - opts, + opts ) // Once we created the transaction using the custom Common object, we can use it as a normal tx. @@ -36,7 +36,7 @@ const tx = Transaction.fromTxData( // Here we sign it and validate its signature const privateKey = Buffer.from( 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', - 'hex', + 'hex' ) const signedTx = tx.sign(privateKey) diff --git a/packages/tx/examples/ropsten-tx.ts b/packages/tx/examples/ropsten-tx.ts index 51d72db2de..0b1f50c823 100644 --- a/packages/tx/examples/ropsten-tx.ts +++ b/packages/tx/examples/ropsten-tx.ts @@ -1,9 +1,9 @@ import { Transaction } from '../src' import { toBuffer } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const txData = toBuffer( - '0xf9010b82930284d09dc30083419ce0942d18de92e0f9aee1a29770c3b15c6cf8ac5498e580b8a42f43f4fb0000000000000000000000000000000000000000000000000000016b78998da900000000000000000000000000000000000000000000000000000000000cb1b70000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000001363e4f00000000000000000000000000000000000000000000000000000000000186a029a0fac36e66d329af0e831b2e61179b3ec8d7c7a8a2179e303cfed3364aff2bc3e4a07cb73d56e561ccbd838818dd3dea5fa0b5158577ffc61c0e6ec1f0ed55716891', + '0xf9010b82930284d09dc30083419ce0942d18de92e0f9aee1a29770c3b15c6cf8ac5498e580b8a42f43f4fb0000000000000000000000000000000000000000000000000000016b78998da900000000000000000000000000000000000000000000000000000000000cb1b70000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000001363e4f00000000000000000000000000000000000000000000000000000000000186a029a0fac36e66d329af0e831b2e61179b3ec8d7c7a8a2179e303cfed3364aff2bc3e4a07cb73d56e561ccbd838818dd3dea5fa0b5158577ffc61c0e6ec1f0ed55716891' ) const common = new Common({ chain: Chain.Ropsten, hardfork: Hardfork.Petersburg }) diff --git a/packages/tx/src/baseTransaction.ts b/packages/tx/src/baseTransaction.ts index 9ac37b4c58..41ffdf5e2a 100644 --- a/packages/tx/src/baseTransaction.ts +++ b/packages/tx/src/baseTransaction.ts @@ -1,4 +1,4 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Address, BigIntLike, diff --git a/packages/tx/src/eip1559Transaction.ts b/packages/tx/src/eip1559Transaction.ts index 6903433fcc..7977768ea2 100644 --- a/packages/tx/src/eip1559Transaction.ts +++ b/packages/tx/src/eip1559Transaction.ts @@ -10,8 +10,8 @@ import { toBuffer, validateNoLeadingZeroes, } from '@ethereumjs/util' -import RLP from 'rlp' -import Common from '@ethereumjs/common' +import { RLP } from 'rlp' +import { Common } from '@ethereumjs/common' import { BaseTransaction } from './baseTransaction' import { AccessList, @@ -32,7 +32,7 @@ const TRANSACTION_TYPE_BUFFER = Buffer.from(TRANSACTION_TYPE.toString(16).padSta * - TransactionType: 2 * - EIP: [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) */ -export default class FeeMarketEIP1559Transaction extends BaseTransaction { +export class FeeMarketEIP1559Transaction extends BaseTransaction { public readonly chainId: bigint public readonly accessList: AccessListBuffer public readonly AccessListJSON: AccessList diff --git a/packages/tx/src/eip2930Transaction.ts b/packages/tx/src/eip2930Transaction.ts index 62d3b66c53..8677aa9391 100644 --- a/packages/tx/src/eip2930Transaction.ts +++ b/packages/tx/src/eip2930Transaction.ts @@ -10,8 +10,8 @@ import { toBuffer, validateNoLeadingZeroes, } from '@ethereumjs/util' -import RLP from 'rlp' -import Common from '@ethereumjs/common' +import { RLP } from 'rlp' +import { Common } from '@ethereumjs/common' import { BaseTransaction } from './baseTransaction' import { AccessList, @@ -33,7 +33,7 @@ const TRANSACTION_TYPE_BUFFER = Buffer.from(TRANSACTION_TYPE.toString(16).padSta * - TransactionType: 1 * - EIP: [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) */ -export default class AccessListEIP2930Transaction extends BaseTransaction { +export class AccessListEIP2930Transaction extends BaseTransaction { public readonly chainId: bigint public readonly accessList: AccessListBuffer public readonly AccessListJSON: AccessList diff --git a/packages/tx/src/index.ts b/packages/tx/src/index.ts index ea7745ec88..51ffb06874 100644 --- a/packages/tx/src/index.ts +++ b/packages/tx/src/index.ts @@ -1,5 +1,5 @@ -export { default as Transaction } from './legacyTransaction' -export { default as AccessListEIP2930Transaction } from './eip2930Transaction' -export { default as TransactionFactory } from './transactionFactory' -export { default as FeeMarketEIP1559Transaction } from './eip1559Transaction' +export { Transaction } from './legacyTransaction' +export { AccessListEIP2930Transaction } from './eip2930Transaction' +export { TransactionFactory } from './transactionFactory' +export { FeeMarketEIP1559Transaction } from './eip1559Transaction' export * from './types' diff --git a/packages/tx/src/legacyTransaction.ts b/packages/tx/src/legacyTransaction.ts index 026558c24d..a927738c50 100644 --- a/packages/tx/src/legacyTransaction.ts +++ b/packages/tx/src/legacyTransaction.ts @@ -11,10 +11,10 @@ import { unpadBuffer, validateNoLeadingZeroes, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { TxOptions, TxData, JsonTx, TxValuesArray, Capability } from './types' import { BaseTransaction } from './baseTransaction' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { checkMaxInitCodeSize } from './util' const TRANSACTION_TYPE = 0 @@ -28,7 +28,7 @@ function meetsEIP155(_v: bigint, chainId: bigint) { /** * An Ethereum non-typed (legacy) transaction */ -export default class Transaction extends BaseTransaction { +export class Transaction extends BaseTransaction { public readonly gasPrice: bigint public readonly common: Common @@ -208,7 +208,7 @@ export default class Transaction extends BaseTransaction { * * ```javascript * import { bufArrToArr } from '@ethereumjs/util' - * import RLP from 'rlp' + * import { RLP } from 'rlp' * const message = tx.getMessageToSign(false) * const serializedMessage = Buffer.from(RLP.encode(bufArrToArr(message))) // use this for the HW wallet input * ``` diff --git a/packages/tx/src/transactionFactory.ts b/packages/tx/src/transactionFactory.ts index d7779a7a3f..194ba189b5 100644 --- a/packages/tx/src/transactionFactory.ts +++ b/packages/tx/src/transactionFactory.ts @@ -8,7 +8,7 @@ import { } from './types' import { Transaction, AccessListEIP2930Transaction, FeeMarketEIP1559Transaction } from '.' -export default class TransactionFactory { +export class TransactionFactory { // It is not possible to instantiate a TransactionFactory object. private constructor() {} diff --git a/packages/tx/src/types.ts b/packages/tx/src/types.ts index 2cf7314b4d..b9c9069c9d 100644 --- a/packages/tx/src/types.ts +++ b/packages/tx/src/types.ts @@ -1,8 +1,8 @@ import { AddressLike, BigIntLike, BufferLike, PrefixedHexString } from '@ethereumjs/util' -import Common from '@ethereumjs/common' -import { default as Transaction } from './legacyTransaction' -import { default as AccessListEIP2930Transaction } from './eip2930Transaction' -import { default as FeeMarketEIP1559Transaction } from './eip1559Transaction' +import { Common } from '@ethereumjs/common' +import { Transaction } from './legacyTransaction' +import { AccessListEIP2930Transaction } from './eip2930Transaction' +import { FeeMarketEIP1559Transaction } from './eip1559Transaction' /** * Can be used in conjunction with {@link Transaction.supports} diff --git a/packages/tx/src/util.ts b/packages/tx/src/util.ts index a8d317927f..6b6cecdb0f 100644 --- a/packages/tx/src/util.ts +++ b/packages/tx/src/util.ts @@ -1,4 +1,4 @@ -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { bufferToHex, setLengthLeft, toBuffer } from '@ethereumjs/util' import { AccessList, AccessListBuffer, AccessListItem, isAccessList } from './types' diff --git a/packages/tx/test/base.spec.ts b/packages/tx/test/base.spec.ts index 99d25311ea..09acdbf53f 100644 --- a/packages/tx/test/base.spec.ts +++ b/packages/tx/test/base.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction, AccessListEIP2930Transaction, diff --git a/packages/tx/test/eip1559.spec.ts b/packages/tx/test/eip1559.spec.ts index 9061fef925..c4b0a9d008 100644 --- a/packages/tx/test/eip1559.spec.ts +++ b/packages/tx/test/eip1559.spec.ts @@ -1,6 +1,6 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { TWO_POW256 } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import * as tape from 'tape' import { FeeMarketEIP1559Transaction } from '../src' diff --git a/packages/tx/test/inputValue.spec.ts b/packages/tx/test/inputValue.spec.ts index 94a398d7c7..74f9b535ff 100644 --- a/packages/tx/test/inputValue.spec.ts +++ b/packages/tx/test/inputValue.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Address, AddressLike, BigIntLike, BufferLike, toBuffer } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '../src' // @returns: Array with subtypes of the AddressLike type for a given address diff --git a/packages/tx/test/legacy.spec.ts b/packages/tx/test/legacy.spec.ts index 9695144695..ba7ec016dc 100644 --- a/packages/tx/test/legacy.spec.ts +++ b/packages/tx/test/legacy.spec.ts @@ -8,8 +8,8 @@ import { toBuffer, unpadBuffer, } from '@ethereumjs/util' -import RLP from 'rlp' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { RLP } from 'rlp' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction, TxData } from '../src' import { TxsJsonEntry, VitaliksTestsDataEntry } from './types' diff --git a/packages/tx/test/transactionFactory.spec.ts b/packages/tx/test/transactionFactory.spec.ts index 5f774c8bef..112329bce2 100644 --- a/packages/tx/test/transactionFactory.spec.ts +++ b/packages/tx/test/transactionFactory.spec.ts @@ -1,4 +1,4 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import * as tape from 'tape' import { AccessListEIP2930Transaction, diff --git a/packages/tx/test/transactionRunner.ts b/packages/tx/test/transactionRunner.ts index 0a02a52cf5..238cf6434b 100644 --- a/packages/tx/test/transactionRunner.ts +++ b/packages/tx/test/transactionRunner.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import * as minimist from 'minimist' import { toBuffer } from '@ethereumjs/util' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { TransactionFactory } from '../src' import { ForkName, ForkNamesMap, OfficialTransactionTestData } from './types' import { getTests } from './testLoader' diff --git a/packages/tx/test/typedTxsAndEIP2930.spec.ts b/packages/tx/test/typedTxsAndEIP2930.spec.ts index 888de4e113..a3f8f4eb75 100644 --- a/packages/tx/test/typedTxsAndEIP2930.spec.ts +++ b/packages/tx/test/typedTxsAndEIP2930.spec.ts @@ -1,4 +1,4 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Address, bufferToHex, diff --git a/packages/util/src/account.ts b/packages/util/src/account.ts index 0072e476ec..9cc3c17f48 100644 --- a/packages/util/src/account.ts +++ b/packages/util/src/account.ts @@ -1,7 +1,7 @@ import { keccak256 } from 'ethereum-cryptography/keccak' import { bytesToHex } from 'ethereum-cryptography/utils' import { Point, utils } from 'ethereum-cryptography/secp256k1' -import RLP from 'rlp' +import { RLP } from 'rlp' import { stripHexPrefix } from './internal' import { KECCAK256_RLP, KECCAK256_NULL } from './constants' import { diff --git a/packages/util/test/account.spec.ts b/packages/util/test/account.spec.ts index 826a752517..cec9586251 100644 --- a/packages/util/test/account.spec.ts +++ b/packages/util/test/account.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Account, isValidPrivate, diff --git a/packages/vm/README.md b/packages/vm/README.md index 77a286d3c6..6cf090b1cd 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -9,7 +9,7 @@ | Execution Context for the Ethereum EVM Implementation. | | ------------------------------------------------------ | -This package provides an Ethereum `mainnet` compatible execution context for the +This package provides an Ethereum `mainnet` compatible execution context for the [@ethereumjs/evm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/evm) EVM implementation. @@ -23,9 +23,9 @@ Note that up till `v5` this package also was the bundled package for the EVM imp ```typescript import { Address } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' -import VM from '@ethereumjs/vm' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin }) const vm = await VM.create({ common }) @@ -92,8 +92,8 @@ Starting with `v5.1.0` the VM supports running both `Ethash/PoW` and `Clique/PoA The following is a simple example for a block run on `Goerli`: ```typescript -import VM from '@ethereumjs/vm' -import Common, { Chain } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Chain, Common } from '@ethereumjs/common' const common = new Common({ chain: Chain.Goerli }) const hardforkByBlockNumber = true @@ -111,8 +111,8 @@ For hardfork support see the [Hardfork Support](../evm#hardfork-support) section An explicit HF in the `VM` - which is then passed on to the inner `EVM` - can be set with: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin }) const vm = new VM({ common }) @@ -122,14 +122,13 @@ const vm = new VM({ common }) Genesis state code logic has been reworked substantially along the v6 breaking releases and a lot of the genesis state code moved from both the `@ethereumjs/common` and `@ethereumjs/block` libraries to the `@ethereumjs/blockchain` library, see PR [#1916](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1916) for an overview on the broad set of changes. - For initializing a custom genesis state you can now use the `genesisState` constructor option in the `Blockchain` library in a similar way this had been done in the `Common` library before. If you want to create a new instance of the VM and add your own genesis state, you can do it by passing a `Blockchain` instance with custom genesis state set with the `genesisState` constructor option and passing the flag `activateGenesisState` in `VMOpts`. ```typescript -import Common from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' import myCustomChain1 from '[PATH_TO_MY_CHAINS]/myCustomChain1.json' import chain1GenesisState from '[PATH_TO_GENESIS_STATES]/chain1GenesisState.json' @@ -150,8 +149,8 @@ It is possible to individually activate EIP support in the VM by instantiate the with the respective EIPs, e.g.: ```typescript -import Common, { Chain } from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Chain, Common } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: Chain.Mainnet, eips: [2537] }) const vm = new VM({ common }) @@ -207,12 +206,12 @@ If you want to understand your VM runs we have added a hierarchically structured The following loggers are currently available: -| Logger | Description | -| --------------------------------- | ------------------------------------------------------------------ | -| `vm:block` | Block operations (run txs, generating receipts, block rewards,...) | -| `vm:tx` |  Transaction operations (account updates, checkpointing,...)  | -| `vm:tx:gas` |  Transaction gas logger | -| `vm:state` | StateManager logger | +| Logger | Description | +| ----------- | ------------------------------------------------------------------ | +| `vm:block` | Block operations (run txs, generating receipts, block rewards,...) | +| `vm:tx` |  Transaction operations (account updates, checkpointing,...)  | +| `vm:tx:gas` |  Transaction gas logger | +| `vm:state` | StateManager logger | Note that there are additional EVM-specific loggers in the [@ethereumjs/evm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/evm) package. diff --git a/packages/vm/benchmarks/mainnetBlocks.ts b/packages/vm/benchmarks/mainnetBlocks.ts index 043b51f351..4ac214d255 100644 --- a/packages/vm/benchmarks/mainnetBlocks.ts +++ b/packages/vm/benchmarks/mainnetBlocks.ts @@ -1,9 +1,9 @@ import { readFileSync } from 'fs' import Benchmark from 'benchmark' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' -import blockFromRPC from '@ethereumjs/block/dist/from-rpc' -import VM from '../dist' +import { blockFromRpc } from '@ethereumjs/block/dist/from-rpc' +import { VM } from '../dist' import { getPreState, getBlockchain, verifyResult } from './util' const BLOCK_FIXTURE = 'benchmarks/fixture/blocks-prestate.json' @@ -31,7 +31,7 @@ export async function mainnetBlocks(suite?: Benchmark.Suite, numSamples?: number const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.MuirGlacier }) for (const blockData of data) { - const block = blockFromRPC(blockData.block, [], { common }) + const block = blockFromRpc(blockData.block, [], { common }) const blockNumber = Number(block.header.number) const { receipts, preState, blockhashes } = blockData diff --git a/packages/vm/benchmarks/mockchain.ts b/packages/vm/benchmarks/mockchain.ts index c743d78f0f..51340b5e1c 100644 --- a/packages/vm/benchmarks/mockchain.ts +++ b/packages/vm/benchmarks/mockchain.ts @@ -1,5 +1,5 @@ // Mockchain: only used to provide blockhashes for the BLOCKHASH opcode for the VM. Has no other uses. -export default class Mockchain { +export class Mockchain { _hashes: any constructor() { diff --git a/packages/vm/benchmarks/util.ts b/packages/vm/benchmarks/util.ts index bab7b57d3d..86a690ae9c 100644 --- a/packages/vm/benchmarks/util.ts +++ b/packages/vm/benchmarks/util.ts @@ -1,9 +1,9 @@ import { Account, Address, toBuffer } from '@ethereumjs/util' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' import { StateManager, DefaultStateManager } from '@ethereumjs/statemanager' import { RunBlockResult } from '../dist/types' -import Mockchain from './mockchain' +import { Mockchain } from './mockchain' export interface BenchmarkType { [key: string]: Function diff --git a/packages/vm/examples/helpers/account-utils.ts b/packages/vm/examples/helpers/account-utils.ts index 4ef29fefcf..ce0861be87 100644 --- a/packages/vm/examples/helpers/account-utils.ts +++ b/packages/vm/examples/helpers/account-utils.ts @@ -1,4 +1,4 @@ -import VM from '../../dist' +import { VM } from '../../dist' import { Account, Address } from '@ethereumjs/util' export const keyPair = { diff --git a/packages/vm/examples/run-blockchain.ts b/packages/vm/examples/run-blockchain.ts index 811d7493e7..b990959d7e 100644 --- a/packages/vm/examples/run-blockchain.ts +++ b/packages/vm/examples/run-blockchain.ts @@ -8,9 +8,9 @@ import { Account, Address, toBuffer, setLengthLeft } from '@ethereumjs/util' import { Block } from '@ethereumjs/block' -import Blockchain from '@ethereumjs/blockchain' -import Common, { ConsensusType } from '@ethereumjs/common' -import VM from '../' +import { Blockchain } from '@ethereumjs/blockchain' +import { Common, ConsensusType } from '@ethereumjs/common' +import { VM } from '../' import { testData } from './helpers/blockchain-mock-data' async function main() { @@ -26,7 +26,7 @@ async function main() { validateBlocks, genesisBlock, }) - + const vm = await VM.create({ blockchain, common }) await setupPreConditions(vm, testData) diff --git a/packages/vm/examples/run-solidity-contract.ts b/packages/vm/examples/run-solidity-contract.ts index df3bcc4216..3ba3c2fa28 100644 --- a/packages/vm/examples/run-solidity-contract.ts +++ b/packages/vm/examples/run-solidity-contract.ts @@ -2,9 +2,9 @@ import { join } from 'path' import { readFileSync } from 'fs' import { defaultAbiCoder as AbiCoder, Interface } from '@ethersproject/abi' import { Address } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' -import VM from '..' +import { VM } from '..' import { buildTransaction, encodeDeployment, encodeFunction } from './helpers/tx-builder' import { getAccountNonce, insertAccount } from './helpers/account-utils' import { Block } from '@ethereumjs/block' @@ -14,7 +14,7 @@ const INITIAL_GREETING = 'Hello, World!' const SECOND_GREETING = 'Hola, Mundo!' const common = new Common({ chain: Chain.Rinkeby, hardfork: Hardfork.Istanbul }) -const block = Block.fromBlockData({ header: { extraData: Buffer.alloc(97) }},{ common }) +const block = Block.fromBlockData({ header: { extraData: Buffer.alloc(97) } }, { common }) /** * This function creates the input for the Solidity compiler. @@ -145,7 +145,7 @@ async function getGreeting(vm: VM, contractAddress: Address, caller: Address) { caller: caller, origin: caller, // The tx.origin is also the caller here data: Buffer.from(sigHash.slice(2), 'hex'), - block + block, }) if (greetResult.execResult.exceptionError) { diff --git a/packages/vm/src/buildBlock.ts b/packages/vm/src/buildBlock.ts index 4c87e8d9e9..b62f4e641a 100644 --- a/packages/vm/src/buildBlock.ts +++ b/packages/vm/src/buildBlock.ts @@ -1,6 +1,6 @@ import { Address, toBuffer, toType, TypeOutput } from '@ethereumjs/util' import { Trie } from '@ethereumjs/trie' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Block, HeaderData } from '@ethereumjs/block' import { ConsensusType } from '@ethereumjs/common' import { TypedTransaction } from '@ethereumjs/tx' @@ -212,6 +212,6 @@ export class BlockBuilder { } } -export default async function buildBlock(this: VM, opts: BuildBlockOpts): Promise { +export async function buildBlock(this: VM, opts: BuildBlockOpts): Promise { return new BlockBuilder(this, opts) } diff --git a/packages/vm/src/eei/eei.ts b/packages/vm/src/eei/eei.ts index a3e10cd644..fe634e6eb2 100644 --- a/packages/vm/src/eei/eei.ts +++ b/packages/vm/src/eei/eei.ts @@ -1,5 +1,5 @@ import { Address, bufferToBigInt } from '@ethereumjs/util' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { VmState } from './vmState' import { StateManager } from '@ethereumjs/statemanager' @@ -22,7 +22,7 @@ type Blockchain = { * The EEI instance also keeps artifacts produced by the bytecode such as logs * and to-be-selfdestructed addresses. */ -export default class EEI extends VmState implements EEIInterface { +export class EEI extends VmState implements EEIInterface { protected _common: Common protected _blockchain: Blockchain diff --git a/packages/vm/src/eei/vmState.ts b/packages/vm/src/eei/vmState.ts index 7ca6feccd5..55852cb6b8 100644 --- a/packages/vm/src/eei/vmState.ts +++ b/packages/vm/src/eei/vmState.ts @@ -1,4 +1,4 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { AccessList, AccessListItem } from '@ethereumjs/tx' import { Account, Address, toBuffer } from '@ethereumjs/util' const Set = require('core-js-pure/es/set') diff --git a/packages/vm/src/index.ts b/packages/vm/src/index.ts index d005ac9382..0c7649485f 100644 --- a/packages/vm/src/index.ts +++ b/packages/vm/src/index.ts @@ -1,4 +1,4 @@ -export { VM as default } from './vm' +export { VM } from './vm' export * from './types' export * as EEI from './eei/eei' export { Bloom } from './bloom/index' diff --git a/packages/vm/src/runBlock.ts b/packages/vm/src/runBlock.ts index 77e9e8e34e..8173c9eb8f 100644 --- a/packages/vm/src/runBlock.ts +++ b/packages/vm/src/runBlock.ts @@ -1,7 +1,7 @@ import { debug as createDebugLogger } from 'debug' import { Trie } from '@ethereumjs/trie' import { Account, Address, bigIntToBuffer, bufArrToArr, intToBuffer, short } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { Block } from '@ethereumjs/block' import { ConsensusType, Hardfork } from '@ethereumjs/common' import { VM } from './vm' @@ -26,7 +26,7 @@ const DAORefundContract = DAOConfig.DAORefundContract /** * @ignore */ -export default async function runBlock(this: VM, opts: RunBlockOpts): Promise { +export async function runBlock(this: VM, opts: RunBlockOpts): Promise { const state = this.eei const { root } = opts let { block } = opts diff --git a/packages/vm/src/runTx.ts b/packages/vm/src/runTx.ts index 2879f154c5..6eb922e689 100644 --- a/packages/vm/src/runTx.ts +++ b/packages/vm/src/runTx.ts @@ -28,7 +28,7 @@ const debugGas = createDebugLogger('vm:tx:gas') /** * @ignore */ -export default async function runTx(this: VM, opts: RunTxOpts): Promise { +export async function runTx(this: VM, opts: RunTxOpts): Promise { // tx is required if (!opts.tx) { throw new Error('invalid input, tx is required') diff --git a/packages/vm/src/types.ts b/packages/vm/src/types.ts index 3d55e7f0f0..f321d67de7 100644 --- a/packages/vm/src/types.ts +++ b/packages/vm/src/types.ts @@ -2,9 +2,9 @@ import { Block, BlockOptions, HeaderData } from '@ethereumjs/block' import { AccessList, TypedTransaction } from '@ethereumjs/tx' import { EEIInterface, EVMInterface, EVMResult, Log } from '@ethereumjs/evm' import { BigIntLike } from '@ethereumjs/util' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' import { StateManager } from '@ethereumjs/statemanager' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Bloom } from './bloom' export type TxReceipt = PreByzantiumTxReceipt | PostByzantiumTxReceipt diff --git a/packages/vm/src/vm.ts b/packages/vm/src/vm.ts index 3c7093d665..b2fd4b56b3 100644 --- a/packages/vm/src/vm.ts +++ b/packages/vm/src/vm.ts @@ -1,17 +1,17 @@ import { Account, Address, toType, TypeOutput } from '@ethereumjs/util' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common } from '@ethereumjs/common' import { StateManager, DefaultStateManager } from '@ethereumjs/statemanager' -import { default as runTx } from './runTx' -import { default as runBlock } from './runBlock' -import { default as buildBlock, BlockBuilder } from './buildBlock' +import { runTx } from './runTx' +import { runBlock } from './runBlock' +import { buildBlock, BlockBuilder } from './buildBlock' import { RunTxOpts, RunTxResult, RunBlockOpts, RunBlockResult } from './types' import AsyncEventEmitter = require('async-eventemitter') import { promisify } from 'util' import { VMEvents, VMOpts, BuildBlockOpts } from './types' -import EVM, { getActivePrecompiles, EEIInterface, EVMInterface } from '@ethereumjs/evm' -import EEI from './eei/eei' +import { EVM, getActivePrecompiles, EEIInterface, EVMInterface } from '@ethereumjs/evm' +import { EEI } from './eei/eei' /** * Execution engine which can be used to run a blockchain, individual diff --git a/packages/vm/tests/api/EIPs/eip-1153.spec.ts b/packages/vm/tests/api/EIPs/eip-1153.spec.ts index 1a83bb2d4f..bf6b686cb7 100644 --- a/packages/vm/tests/api/EIPs/eip-1153.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-1153.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Account, Address, bufferToInt, privateToAddress } from '@ethereumjs/util' import { Transaction } from '@ethereumjs/tx' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' interface Test { steps: { expectedOpcode: string; expectedGasUsed: number; expectedStack: bigint[] }[] diff --git a/packages/vm/tests/api/EIPs/eip-1283-net-gas-metering.spec.ts b/packages/vm/tests/api/EIPs/eip-1283-net-gas-metering.spec.ts index 890b22cd64..e0f4829786 100644 --- a/packages/vm/tests/api/EIPs/eip-1283-net-gas-metering.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-1283-net-gas-metering.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Address, setLengthLeft, bigIntToBuffer } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { createAccount } from '../utils' diff --git a/packages/vm/tests/api/EIPs/eip-1559-FeeMarket.spec.ts b/packages/vm/tests/api/EIPs/eip-1559-FeeMarket.spec.ts index 188ffa9e79..4eaea96ff8 100644 --- a/packages/vm/tests/api/EIPs/eip-1559-FeeMarket.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-1559-FeeMarket.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Address, bigIntToBuffer, privateToAddress, setLengthLeft } from '@ethereumjs/util' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { AccessListEIP2930Transaction, FeeMarketEIP1559Transaction, diff --git a/packages/vm/tests/api/EIPs/eip-2315.spec.ts b/packages/vm/tests/api/EIPs/eip-2315.spec.ts index d67e6e555d..99a5e664dc 100644 --- a/packages/vm/tests/api/EIPs/eip-2315.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-2315.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import EVM from '@ethereumjs/evm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { EVM } from '@ethereumjs/evm' tape('Berlin: EIP 2315 tests', (t) => { const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin, eips: [2315] }) diff --git a/packages/vm/tests/api/EIPs/eip-2537-BLS.spec.ts b/packages/vm/tests/api/EIPs/eip-2537-BLS.spec.ts index 37bc5a22df..b451e7682f 100644 --- a/packages/vm/tests/api/EIPs/eip-2537-BLS.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-2537-BLS.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Address, bufferToHex } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { isRunningInKarma } from '../../util' import { getActivePrecompiles } from '@ethereumjs/evm' diff --git a/packages/vm/tests/api/EIPs/eip-2565-modexp-gas-cost.spec.ts b/packages/vm/tests/api/EIPs/eip-2565-modexp-gas-cost.spec.ts index c685953a6a..7fb4846bfd 100644 --- a/packages/vm/tests/api/EIPs/eip-2565-modexp-gas-cost.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-2565-modexp-gas-cost.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Address } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' // See https://github.com/holiman/go-ethereum/blob/2c99023b68c573ba24a5b01db13e000bd9b82417/core/vm/testdata/precompiles/modexp_eip2565.json diff --git a/packages/vm/tests/api/EIPs/eip-2929.spec.ts b/packages/vm/tests/api/EIPs/eip-2929.spec.ts index 8e80896e2a..7b26b4c456 100644 --- a/packages/vm/tests/api/EIPs/eip-2929.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-2929.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { Account, Address } from '@ethereumjs/util' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' // Test cases source: https://gist.github.com/holiman/174548cad102096858583c6fbbb0649a tape('EIP 2929: gas cost tests', (t) => { diff --git a/packages/vm/tests/api/EIPs/eip-2930-accesslists.spec.ts b/packages/vm/tests/api/EIPs/eip-2930-accesslists.spec.ts index 6f930180f1..6950cdac2f 100644 --- a/packages/vm/tests/api/EIPs/eip-2930-accesslists.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-2930-accesslists.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { Account, Address, bufferToHex } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { AccessListEIP2930Transaction } from '@ethereumjs/tx' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' const common = new Common({ eips: [2718, 2929, 2930], diff --git a/packages/vm/tests/api/EIPs/eip-3074-authcall.spec.ts b/packages/vm/tests/api/EIPs/eip-3074-authcall.spec.ts index 80d3337f51..3bc1d1ea23 100644 --- a/packages/vm/tests/api/EIPs/eip-3074-authcall.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3074-authcall.spec.ts @@ -11,13 +11,13 @@ import { toBuffer, zeros, } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { Transaction } from '@ethereumjs/tx' import { Block } from '@ethereumjs/block' import { ERROR } from '@ethereumjs/evm/dist/exceptions' import { InterpreterStep } from '@ethereumjs/evm/dist/interpreter' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' const common = new Common({ chain: Chain.Mainnet, diff --git a/packages/vm/tests/api/EIPs/eip-3198-BaseFee.spec.ts b/packages/vm/tests/api/EIPs/eip-3198-BaseFee.spec.ts index 2b9bd25472..6227a2a522 100644 --- a/packages/vm/tests/api/EIPs/eip-3198-BaseFee.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3198-BaseFee.spec.ts @@ -1,11 +1,11 @@ import * as tape from 'tape' import { Address, privateToAddress } from '@ethereumjs/util' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction, TypedTransaction } from '@ethereumjs/tx' import { Block } from '@ethereumjs/block' import { InterpreterStep } from '@ethereumjs/evm/dist/interpreter' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' const GWEI = BigInt('1000000000') const ETHER = GWEI * GWEI diff --git a/packages/vm/tests/api/EIPs/eip-3529.spec.ts b/packages/vm/tests/api/EIPs/eip-3529.spec.ts index c3042cd860..2cbc3dd88f 100644 --- a/packages/vm/tests/api/EIPs/eip-3529.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3529.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { Address } from '@ethereumjs/util' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' import { InterpreterStep } from '@ethereumjs/evm/dist/interpreter' const address = new Address(Buffer.from('11'.repeat(20), 'hex')) diff --git a/packages/vm/tests/api/EIPs/eip-3540-evm-object-format.spec.ts b/packages/vm/tests/api/EIPs/eip-3540-evm-object-format.spec.ts index b63cd10da4..84df9fa7e9 100644 --- a/packages/vm/tests/api/EIPs/eip-3540-evm-object-format.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3540-evm-object-format.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' import { Address, privateToAddress } from '@ethereumjs/util' -import EOF from '@ethereumjs/evm/dist/eof' +import { EOF } from '@ethereumjs/evm/dist/eof' const pkey = Buffer.from('20'.repeat(32), 'hex') const GWEI = BigInt('1000000000') diff --git a/packages/vm/tests/api/EIPs/eip-3541.spec.ts b/packages/vm/tests/api/EIPs/eip-3541.spec.ts index 3cbbdbe2c9..c3509b7384 100644 --- a/packages/vm/tests/api/EIPs/eip-3541.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3541.spec.ts @@ -1,10 +1,10 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address } from '@ethereumjs/util' import { InterpreterStep } from '@ethereumjs/evm/dist/interpreter' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' const pkey = Buffer.from('20'.repeat(32), 'hex') diff --git a/packages/vm/tests/api/EIPs/eip-3607.spec.ts b/packages/vm/tests/api/EIPs/eip-3607.spec.ts index 97715feed4..0969bfc4b3 100644 --- a/packages/vm/tests/api/EIPs/eip-3607.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3607.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address } from '@ethereumjs/util' import { VM } from '../../../src/vm' diff --git a/packages/vm/tests/api/EIPs/eip-3651-warm-coinbase.spec.ts b/packages/vm/tests/api/EIPs/eip-3651-warm-coinbase.spec.ts index 1b868e27e7..fbad8a8781 100644 --- a/packages/vm/tests/api/EIPs/eip-3651-warm-coinbase.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3651-warm-coinbase.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' import { Address, privateToAddress } from '@ethereumjs/util' import { Block } from '@ethereumjs/block' diff --git a/packages/vm/tests/api/EIPs/eip-3670-eof-code-validation.spec.ts b/packages/vm/tests/api/EIPs/eip-3670-eof-code-validation.spec.ts index 2d5c744f80..10789395d7 100644 --- a/packages/vm/tests/api/EIPs/eip-3670-eof-code-validation.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3670-eof-code-validation.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' import { Address, privateToAddress } from '@ethereumjs/util' -import EOF from '@ethereumjs/evm/dist/eof' +import { EOF } from '@ethereumjs/evm/dist/eof' const pkey = Buffer.from('20'.repeat(32), 'hex') const GWEI = BigInt('1000000000') const sender = new Address(privateToAddress(pkey)) diff --git a/packages/vm/tests/api/EIPs/eip-3855.spec.ts b/packages/vm/tests/api/EIPs/eip-3855.spec.ts index 91d9e706f0..5955ea4b65 100644 --- a/packages/vm/tests/api/EIPs/eip-3855.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3855.spec.ts @@ -1,8 +1,8 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { InterpreterStep } from '@ethereumjs/evm/dist/interpreter' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' import { ERROR } from '@ethereumjs/evm/dist/exceptions' tape('EIP 3541 tests', (t) => { diff --git a/packages/vm/tests/api/EIPs/eip-3860.spec.ts b/packages/vm/tests/api/EIPs/eip-3860.spec.ts index ec73b5e175..8210a87cdd 100644 --- a/packages/vm/tests/api/EIPs/eip-3860.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-3860.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { VM } from '../../../src/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' import { Address, privateToAddress } from '@ethereumjs/util' const pkey = Buffer.from('20'.repeat(32), 'hex') diff --git a/packages/vm/tests/api/EIPs/eip-4399-supplant-difficulty-opcode-with-prevrando.spec.ts b/packages/vm/tests/api/EIPs/eip-4399-supplant-difficulty-opcode-with-prevrando.spec.ts index 2b2d1dcd01..20a3052724 100644 --- a/packages/vm/tests/api/EIPs/eip-4399-supplant-difficulty-opcode-with-prevrando.spec.ts +++ b/packages/vm/tests/api/EIPs/eip-4399-supplant-difficulty-opcode-with-prevrando.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { bufferToBigInt } from '@ethereumjs/util' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' import { InterpreterStep } from '@ethereumjs/evm/dist/interpreter' tape('EIP-4399 -> 0x44 (DIFFICULTY) should return PREVRANDAO', (t) => { diff --git a/packages/vm/tests/api/buildBlock.spec.ts b/packages/vm/tests/api/buildBlock.spec.ts index 7c405bedf7..f947047d10 100644 --- a/packages/vm/tests/api/buildBlock.spec.ts +++ b/packages/vm/tests/api/buildBlock.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { Account, Address } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' import { Transaction, FeeMarketEIP1559Transaction } from '@ethereumjs/tx' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' import { VM } from '../../src/vm' import { setBalance } from './utils' diff --git a/packages/vm/tests/api/customChain.spec.ts b/packages/vm/tests/api/customChain.spec.ts index e00d2000cc..e7fa33bf4b 100644 --- a/packages/vm/tests/api/customChain.spec.ts +++ b/packages/vm/tests/api/customChain.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Common, Hardfork } from '@ethereumjs/common' import * as testChain from './testdata/testnet.json' import { VM } from '../../src/vm' import { TransactionFactory } from '@ethereumjs/tx' diff --git a/packages/vm/tests/api/eei.spec.ts b/packages/vm/tests/api/eei.spec.ts index 5541fa721a..56eb99250f 100644 --- a/packages/vm/tests/api/eei.spec.ts +++ b/packages/vm/tests/api/eei.spec.ts @@ -1,9 +1,9 @@ import * as tape from 'tape' import { Account, Address } from '@ethereumjs/util' import { DefaultStateManager as StateManager } from '@ethereumjs/statemanager' -import EEI from '../../../vm/src/eei/eei' -import Blockchain from '@ethereumjs/blockchain' -import Common from '@ethereumjs/common' +import { EEI } from '../../../vm/src/eei/eei' +import { Blockchain } from '@ethereumjs/blockchain' +import { Common } from '@ethereumjs/common' const ZeroAddress = Address.zero() diff --git a/packages/vm/tests/api/events.spec.ts b/packages/vm/tests/api/events.spec.ts index 1035a89883..f4bc57269b 100644 --- a/packages/vm/tests/api/events.spec.ts +++ b/packages/vm/tests/api/events.spec.ts @@ -3,7 +3,7 @@ import { toBuffer, bufferToHex, Address, Account } from '@ethereumjs/util' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' import { Block } from '@ethereumjs/block' import { VM } from '../../src/vm' -import EVM from '@ethereumjs/evm' +import { EVM } from '@ethereumjs/evm' tape('VM events', (t) => { const privKey = toBuffer('0xa5737ecdc1b89ca0091647e727ba082ed8953f29182e94adc397210dda643b07') diff --git a/packages/vm/tests/api/index.spec.ts b/packages/vm/tests/api/index.spec.ts index c4c606c00c..fb8aca4feb 100644 --- a/packages/vm/tests/api/index.spec.ts +++ b/packages/vm/tests/api/index.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Account, Address, KECCAK256_RLP } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { DefaultStateManager } from '@ethereumjs/statemanager' import { VM } from '../../src/vm' diff --git a/packages/vm/tests/api/istanbul/eip-1108.spec.ts b/packages/vm/tests/api/istanbul/eip-1108.spec.ts index 5c3f12a772..c35b75ba78 100644 --- a/packages/vm/tests/api/istanbul/eip-1108.spec.ts +++ b/packages/vm/tests/api/istanbul/eip-1108.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { getActivePrecompiles } from '@ethereumjs/evm' diff --git a/packages/vm/tests/api/istanbul/eip-1344.spec.ts b/packages/vm/tests/api/istanbul/eip-1344.spec.ts index cc7db21a01..eb925fe628 100644 --- a/packages/vm/tests/api/istanbul/eip-1344.spec.ts +++ b/packages/vm/tests/api/istanbul/eip-1344.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { bufferToBigInt } from '@ethereumjs/util' import { ERROR } from '@ethereumjs/evm/dist/exceptions' diff --git a/packages/vm/tests/api/istanbul/eip-152.spec.ts b/packages/vm/tests/api/istanbul/eip-152.spec.ts index 3d9a126626..774d8292a3 100644 --- a/packages/vm/tests/api/istanbul/eip-152.spec.ts +++ b/packages/vm/tests/api/istanbul/eip-152.spec.ts @@ -1,8 +1,8 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { ERROR } from '@ethereumjs/evm/dist/exceptions' -import { default as blake2f, F } from '@ethereumjs/evm/dist/precompiles/09-blake2f' +import { precompile09, F } from '@ethereumjs/evm/dist/precompiles/09-blake2f' // Test cases from: // https://github.com/keep-network/go-ethereum/blob/1bccafe5ef54ba849e414ce7c90f7b7130634a9a/core/vm/contracts_test.go @@ -90,7 +90,7 @@ tape('Istanbul: EIP-152', (t) => { for (const testCase of failingTestCases) { st.comment(testCase.name) - const res = blake2f({ + const res = precompile09({ data: Buffer.from(testCase.input, 'hex'), gasLimit: BigInt(20), _common: common, @@ -101,7 +101,7 @@ tape('Istanbul: EIP-152', (t) => { for (const testCase of testCases) { st.comment(testCase.name) - const res = blake2f({ + const res = precompile09({ data: Buffer.from(testCase.input, 'hex'), gasLimit: BigInt(10000000), _common: common, diff --git a/packages/vm/tests/api/istanbul/eip-1884.spec.ts b/packages/vm/tests/api/istanbul/eip-1884.spec.ts index 28131db4f7..5c760f3244 100644 --- a/packages/vm/tests/api/istanbul/eip-1884.spec.ts +++ b/packages/vm/tests/api/istanbul/eip-1884.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Address, bufferToBigInt } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { createAccount } from '../utils' import { ERROR } from '@ethereumjs/evm/dist/exceptions' diff --git a/packages/vm/tests/api/istanbul/eip-2200.spec.ts b/packages/vm/tests/api/istanbul/eip-2200.spec.ts index 1635687c72..b369ee25d1 100644 --- a/packages/vm/tests/api/istanbul/eip-2200.spec.ts +++ b/packages/vm/tests/api/istanbul/eip-2200.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Address, setLengthLeft, toBuffer } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' import { createAccount } from '../utils' diff --git a/packages/vm/tests/api/muirGlacier/index.spec.ts b/packages/vm/tests/api/muirGlacier/index.spec.ts index c3f0190b16..73965e98a4 100644 --- a/packages/vm/tests/api/muirGlacier/index.spec.ts +++ b/packages/vm/tests/api/muirGlacier/index.spec.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { KECCAK256_RLP } from '@ethereumjs/util' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { VM } from '../../../src/vm' tape('General MuirGlacier VM tests', (t) => { diff --git a/packages/vm/tests/api/runBlock.spec.ts b/packages/vm/tests/api/runBlock.spec.ts index 1446b415e0..8a5e3dca88 100644 --- a/packages/vm/tests/api/runBlock.spec.ts +++ b/packages/vm/tests/api/runBlock.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Account, Address, toBuffer, KECCAK256_RLP } from '@ethereumjs/util' -import RLP from 'rlp' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { RLP } from 'rlp' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' import { AccessListEIP2930Transaction, diff --git a/packages/vm/tests/api/runTx.spec.ts b/packages/vm/tests/api/runTx.spec.ts index dae1063c7b..8c7d6ec27d 100644 --- a/packages/vm/tests/api/runTx.spec.ts +++ b/packages/vm/tests/api/runTx.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Account, Address, MAX_INTEGER } from '@ethereumjs/util' import { Block } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Transaction, TransactionFactory, @@ -10,7 +10,7 @@ import { } from '@ethereumjs/tx' import { VM } from '../../src/vm' import { createAccount, getTransaction, setBalance } from './utils' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' const TRANSACTION_TYPES = [ { diff --git a/packages/vm/tests/api/state/accountExists.spec.ts b/packages/vm/tests/api/state/accountExists.spec.ts index fc2056d253..5d42f6a077 100644 --- a/packages/vm/tests/api/state/accountExists.spec.ts +++ b/packages/vm/tests/api/state/accountExists.spec.ts @@ -1,4 +1,4 @@ -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Address, toBuffer } from '@ethereumjs/util' import * as tape from 'tape' import { VM } from '../../../src/vm' diff --git a/packages/vm/tests/api/types.spec.ts b/packages/vm/tests/api/types.spec.ts index 7902f4e30e..d47f3cfe1f 100644 --- a/packages/vm/tests/api/types.spec.ts +++ b/packages/vm/tests/api/types.spec.ts @@ -1,5 +1,5 @@ import * as tape from 'tape' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { AccessListEIP2930Transaction, AccessListEIP2930TxData, diff --git a/packages/vm/tests/api/utils.ts b/packages/vm/tests/api/utils.ts index 70c7ed1ad8..ffce580da2 100644 --- a/packages/vm/tests/api/utils.ts +++ b/packages/vm/tests/api/utils.ts @@ -1,10 +1,10 @@ import { Account, Address } from '@ethereumjs/util' -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' import { VM } from '../../src/vm' import { VMOpts } from '../../src/types' import { Block } from '@ethereumjs/block' import { TransactionFactory } from '@ethereumjs/tx' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { MemoryLevel } from 'memory-level' diff --git a/packages/vm/tests/api/vmState.spec.ts b/packages/vm/tests/api/vmState.spec.ts index 0da4aa5bb7..2eabbab7e9 100644 --- a/packages/vm/tests/api/vmState.spec.ts +++ b/packages/vm/tests/api/vmState.spec.ts @@ -1,7 +1,7 @@ import * as tape from 'tape' import { Address } from '@ethereumjs/util' -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { DefaultStateManager } from '@ethereumjs/statemanager' import { createAccount, isRunningInKarma } from './utils' import { VmState } from '../../src/eei/vmState' diff --git a/packages/vm/tests/tester/config.ts b/packages/vm/tests/tester/config.ts index 485624fa7c..6ad2cb8f24 100644 --- a/packages/vm/tests/tester/config.ts +++ b/packages/vm/tests/tester/config.ts @@ -1,5 +1,5 @@ import * as path from 'path' -import Common, { Chain } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' /** * Default tests path (git submodule: ethereum-tests) diff --git a/packages/vm/tests/tester/index.ts b/packages/vm/tests/tester/index.ts index ce757cb0c7..4eb51d06ab 100755 --- a/packages/vm/tests/tester/index.ts +++ b/packages/vm/tests/tester/index.ts @@ -2,7 +2,7 @@ import * as process from 'process' import * as path from 'path' import * as tape from 'tape' import * as minimist from 'minimist' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { getCommon, getExpectedTests, @@ -13,8 +13,8 @@ import { DEFAULT_TESTS_PATH, } from './config' import { getTestFromSource, getTestsFromArgs } from './testLoader' -import stateTestsRunner from './runners/GeneralStateTestsRunner' -import blockchainTestsRunner from './runners/BlockchainTestsRunner' +import { runStateTest } from './runners/GeneralStateTestsRunner' +import { runBlockchainTest } from './runners/BlockchainTestsRunner' /** * Test runner @@ -49,10 +49,10 @@ async function runTests() { let runner: any if (argv.state) { name = 'GeneralStateTests' - runner = stateTestsRunner + runner = runStateTest } else if (argv.blockchain) { name = 'BlockchainTests' - runner = blockchainTestsRunner + runner = runBlockchainTest } else { console.log(`Test type not supported or provided`) process.exit(1) @@ -166,7 +166,7 @@ async function runTests() { return t.fail(err) } t.comment(`file: ${fileName} test: ${test.testName}`) - await stateTestsRunner(runnerArgs, test, t) + await runStateTest(runnerArgs, test, t) t.end() }) }) diff --git a/packages/vm/tests/tester/runners/BlockchainTestsRunner.ts b/packages/vm/tests/tester/runners/BlockchainTestsRunner.ts index ed7b71d0ae..2d19e0470b 100644 --- a/packages/vm/tests/tester/runners/BlockchainTestsRunner.ts +++ b/packages/vm/tests/tester/runners/BlockchainTestsRunner.ts @@ -1,10 +1,10 @@ import * as tape from 'tape' import { Block } from '@ethereumjs/block' -import Blockchain, { EthashConsensus } from '@ethereumjs/blockchain' -import Common, { ConsensusAlgorithm } from '@ethereumjs/common' +import { Blockchain, EthashConsensus } from '@ethereumjs/blockchain' +import { Common, ConsensusAlgorithm } from '@ethereumjs/common' import { TransactionFactory } from '@ethereumjs/tx' import { bufferToBigInt, isHexPrefixed, stripHexPrefix, toBuffer } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { SecureTrie as Trie } from '@ethereumjs/trie' import { setupPreConditions, verifyPostConditions } from '../../util' import { Level } from 'level' @@ -18,7 +18,7 @@ function formatBlockHeader(data: any) { return formatted } -export default async function runBlockchainTest(options: any, testData: any, t: tape.Test) { +export async function runBlockchainTest(options: any, testData: any, t: tape.Test) { // ensure that the test data is the right fork data if (testData.network != options.forkConfigTestSuite) { t.comment(`skipping test: no data available for ${options.forkConfigTestSuite}`) @@ -68,9 +68,9 @@ export default async function runBlockchainTest(options: any, testData: any, t: let VM if (options.dist) { - VM = require('../../../dist').default + ;({ VM } = require('../../../dist')) } else { - VM = require('../../../src').default + ;({ VM } = require('../../../src')) } const begin = Date.now() diff --git a/packages/vm/tests/tester/runners/GeneralStateTestsRunner.ts b/packages/vm/tests/tester/runners/GeneralStateTestsRunner.ts index becb4067f2..84601e146e 100644 --- a/packages/vm/tests/tester/runners/GeneralStateTestsRunner.ts +++ b/packages/vm/tests/tester/runners/GeneralStateTestsRunner.ts @@ -61,9 +61,9 @@ function parseTestCases( async function runTestCase(options: any, testData: any, t: tape.Test) { let VM if (options.dist) { - VM = require('../../../dist').default + ;({ VM } = require('../../../dist')) } else { - VM = require('../../../src').default + ;({ VM } = require('../../../src')) } const begin = Date.now() const common = options.common @@ -134,7 +134,7 @@ async function runTestCase(options: any, testData: any, t: tape.Test) { return parseFloat(timeSpent) } -export default async function runStateTest(options: any, testData: any, t: tape.Test) { +export async function runStateTest(options: any, testData: any, t: tape.Test) { try { const testCases = parseTestCases( options.forkConfigTestSuite, diff --git a/packages/vm/tests/util.ts b/packages/vm/tests/util.ts index 462d83c0fa..8e320e775d 100644 --- a/packages/vm/tests/util.ts +++ b/packages/vm/tests/util.ts @@ -1,6 +1,6 @@ import * as tape from 'tape' import { Block, BlockHeader, BlockOptions } from '@ethereumjs/block' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' import { AccessListEIP2930Transaction, FeeMarketEIP1559Transaction, @@ -20,7 +20,7 @@ import { stripHexPrefix, toBuffer, } from '@ethereumjs/util' -import RLP from 'rlp' +import { RLP } from 'rlp' import { VmState } from '../src/eei/vmState' export function dumpState(state: any, cb: Function) {