diff --git a/packages/block/CHANGELOG.md b/packages/block/CHANGELOG.md index 736596d2664..3a930830915 100644 --- a/packages/block/CHANGELOG.md +++ b/packages/block/CHANGELOG.md @@ -27,12 +27,15 @@ This means that a Block object instantiated without providing an explicit `Commo If you want to prevent these kind of implicit HF switches in the future it is likely a good practice to just always do your upper-level library instantiations with a `Common` instance setting an explicit HF, e.g.: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/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 }) +const block = Block.fromBlockData( + { + // Provide your block data here or use default values + }, + { common } +) ``` ### BigInt Introduction / ES2020 Build Target @@ -51,11 +54,11 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient, it deviates from the ESM specification and forces downstream users into using these options, which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option *not* to, which you didn't have before). +Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option _not_ to, which you didn't have before). ### BigInt-Related API Changes -The `Block` option `hardforkByTD` (merge-related) is now taking in `BigIntLike` data types instead of `BNLike`. Header data fields internally represented as a number - like `number` or `gasLimit` - now have `BigInt` as their internal data type and are also passed in as `BigIntLike` instead of `BNLike`. +The `Block` option `hardforkByTD` (merge-related) is now taking in `BigIntLike` data types instead of `BNLike`. Header data fields internally represented as a number - like `number` or `gasLimit` - now have `BigInt` as their internal data type and are also passed in as `BigIntLike` instead of `BNLike`. The following method signatures have been changed along the update and need some attention: @@ -63,7 +66,7 @@ The following method signatures have been changed along the update and need some - `BlockHeader.ethashCanonicalDifficulty(parentBlock: Block): bigint` (method also renamed, see validation-refactor section) - `Block.ethashCanonicalDifficulty(parentBlock: Block): bigint` (method also renamed, see validation-refactor section) -Also worth to note that both the `raw()` and `toJSON()` methods are actually *not* affected, respectively delivering values as `Buffer` and `string`. +Also worth to note that both the `raw()` and `toJSON()` methods are actually _not_ affected, respectively delivering values as `Buffer` and `string`. ### API Method/Getter Removals @@ -74,7 +77,6 @@ Additionally the following deprecated methods/getters have been removed from the - `toJSON()` method: `baseFee` property (use `baseFeePerGas` instead) - `toJSON()` method: `bloom` property (use `logsBloom` instead) - ### Reworked BlockHeader Constructor API While the `BlockHeader` library main constructor usage is discouraged in favor of the various static constructor methods (e.g. `BlockHeader.fromHeaderData()`), it will realistically still be directly used and this change is therefore mentioned here in the release notes. @@ -147,12 +149,15 @@ An ArrowGlacier block can be instantiated with: ```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.ArrowGlacier }) -const block = Block.fromBlockData({ - // Provide your block data here or use default values -}, { common }) +const block = Block.fromBlockData( + { + // Provide your block data here or use default values + }, + { common } +) ``` ### Additional Error Context for Error Messages @@ -200,11 +205,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 } +) ``` See: PR [#1393](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1393) and PR [#1408](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1393) @@ -219,7 +227,6 @@ See. PR [#1473](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1473) - The hash from the `block.hash()` method now gets cached for blocks created with the `freeze` option (activated by default), PR [#1445](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1445) - ## 3.4.0 - 2021-07-08 ### Finalized London HF Support @@ -244,16 +251,19 @@ This `Block` release comes with full functional support for the `london` hardfor ```typescript import { BN } from 'ethereumjs-util' import { Block } from '@ethereumjs/block' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'london' }) -const block = Block.fromBlockData({ - header: { - baseFeePerGas: new BN(10), - gasLimit: new BN(100), - gasUsed: new BN(60) - } -}, { common }) +const block = Block.fromBlockData( + { + header: { + baseFeePerGas: new BN(10), + gasLimit: new BN(100), + gasUsed: new BN(60), + }, + }, + { common } +) // Base fee will increase for next block since the // gas used is greater than half the gas limit @@ -288,7 +298,7 @@ Please note that the default HF is still set to `istanbul`. You therefore need t ```typescript import { Block } from 'ethereumjs-block' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'berlin' }) const block = Block.fromBlockData({}, { common }) ``` diff --git a/packages/block/README.md b/packages/block/README.md index 5ced2cf6d94..33401fb9af5 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/blockchain/CHANGELOG.md b/packages/blockchain/CHANGELOG.md index ae8b431d50a..45da43610ad 100644 --- a/packages/blockchain/CHANGELOG.md +++ b/packages/blockchain/CHANGELOG.md @@ -34,7 +34,7 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient, it deviates from the ESM specification and forces downstream users into using these options, which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option *not* to, which you didn't have before). +Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option _not_ to, which you didn't have before). ### BigInt-Related and other API Changes @@ -115,8 +115,8 @@ Please note that for backwards-compatibility reasons the associated Common is st An ArrowGlacier blockchain object can be instantiated with: ```typescript -import Blockchain from '@ethereumjs/blockchain' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.ArrowGlacier }) const blockchain = await Blockchain.create({ common }) @@ -170,8 +170,8 @@ This release comes with full functional `london` HF support (all EIPs are finali Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `Blockchain` instance with a `london` HF activated: ```typescript -import Blockchain from '@ethereumjs/blockchain' -import Common from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'london' }) const blockchain = await Blockchain.create({ common }) ``` @@ -193,8 +193,8 @@ This release comes with full `berlin` HF support by setting the `Block`, `Tx` an Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `Blockchain` instance with a `berlin` HF activated: ```typescript -import Blockchain from '@ethereumjs/blockchain' -import Common from '@ethereumjs/common' +import { Blockchain } from '@ethereumjs/blockchain' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'berlin' }) const blockchain = await Blockchain.create({ common }) ``` @@ -266,7 +266,7 @@ See `Blockchain` [README](https://github.com/ethereumjs/ethereumjs-monorepo/tree The library now has an additional safe static constructor `Blockchain.create()` which awaits the init method and throws if the init method throws: ```typescript -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' const common = new Common({ chain: 'ropsten' }) const blockchain = await Blockchain.create({ common }) ``` @@ -279,7 +279,7 @@ Constructor options (both for the static and the main constructor) for chain set Genesis handling has been reworked to now be safer and reduce the risk of wiping a blockchain by setting a new genesis, see PR [#930](https://github.com/ethereumjs/ethereumjs-monorepo/pull/930). -**Breaking**: The dedicated `setGenesisBlock()` methods and the optional `isGenesis` option on `Blockchain.putBlock()` have been removed. Instead the genesis block is created on initialization either from the `Common` library instance passed or a custom genesis block passed along with the `genesisBlock` option. If a custom genesis block is used, this custom block now always has to be passed along on `Blockchain` initialization, also when operating on an already existing DB. +**Breaking**: The dedicated `setGenesisBlock()` methods and the optional `isGenesis` option on `Blockchain.putBlock()` have been removed. Instead the genesis block is created on initialization either from the `Common` library instance passed or a custom genesis block passed along with the `genesisBlock` option. If a custom genesis block is used, this custom block now always has to be passed along on `Blockchain` initialization, also when operating on an already existing DB. ### Removed deprecated `validate` option @@ -342,7 +342,7 @@ This is the new recommended way to instantiate a `Blockchain` object, see PR [#9 Genesis handling has been reworked to now be safer and reduce the risk of wiping a blockchain by setting a new genesis, see PR [#930](https://github.com/ethereumjs/ethereumjs-monorepo/pull/930). -**Breaking**: The dedicated `setGenesisBlock()` methods and the optional `isGenesis` option on `Blockchain.putBlock()` have been removed. Instead the genesis block is created on initialization either from the `Common` library instance passed or a custom genesis block passed along with the `genesisBlock` option. If a custom genesis block is used, this custom block now always has to be passed along on `Blockchain` initialization, also when operating on an already existing DB. +**Breaking**: The dedicated `setGenesisBlock()` methods and the optional `isGenesis` option on `Blockchain.putBlock()` have been removed. Instead the genesis block is created on initialization either from the `Common` library instance passed or a custom genesis block passed along with the `genesisBlock` option. If a custom genesis block is used, this custom block now always has to be passed along on `Blockchain` initialization, also when operating on an already existing DB. **Changes and Refactoring** @@ -401,7 +401,7 @@ Constructor options for chain setup on all VM monorepo libraries have been simpl Example: ```typescript -import Blockchain from '@ethereumjs/blockchain' +import { Blockchain } from '@ethereumjs/blockchain' const common = new Common({ chain: 'ropsten', hardfork: 'byzantium' }) const blockchain = new Blockchain({ common }) ``` @@ -412,8 +412,8 @@ The deprecated `validate` option has been removed, please use `valdiateBlock` an ### Dual ES5 and ES2017 Builds -We significantly updated our internal tool and CI setup along the work on -PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` +We significantly updated our internal tool and CI setup along the work on +PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup. Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce diff --git a/packages/blockchain/README.md b/packages/blockchain/README.md index 7ae41e9ac0e..86e5705aef4 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/common/CHANGELOG.md b/packages/common/CHANGELOG.md index 620f7da24f9..93bf78b8df0 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/common/CHANGELOG.md @@ -25,8 +25,8 @@ The `@ethereumjs/common` library is the base library for various upper-level Eth A typical usage looks like this: ```typescript -import VM from '@ethereumjs/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge }) const vm = await VM.create({ common }) @@ -52,7 +52,7 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient it deviates from the ESM specification and forces downstream users into these options which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along the breaking releases we have therefore deactivated both of these options and you might therefore need to adopt some import statements accordingly. Note that you still have got the possibility to activate these options in your bundle and/or transpilation pipeline (but now you also have the option to *not* do which you didn't have before). +Along the breaking releases we have therefore deactivated both of these options and you might therefore need to adopt some import statements accordingly. Note that you still have got the possibility to activate these options in your bundle and/or transpilation pipeline (but now you also have the option to _not_ do which you didn't have before). ### General and BigInt-Related API Changes @@ -124,7 +124,6 @@ The most imminent benefit from this is a **dramatically reduced bundle size for - New experimental EIP `EIP-3074`: Authcall, PR [#1789](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1789) - ## 2.6.4 - 2022-04-14 ### EIP-3651: Warm COINBASE @@ -185,13 +184,13 @@ Please note that for backwards-compatibility reasons Common is still instantiate An ArrowGlacier Common can be instantiated with: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.ArrowGlacier }) ``` ### Optimism L2 Support -There is now a better Optimism L2 chain integration in Common (PR [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554)) allowing to directly instantiate an Optimism chain with the `Common.custom()` constructor. Note that this only sets the correct chain ID (and e.g. *not* corresponding HF blocks or similar) and is therefore only suitable for a limited set of use cases (e.g. sending a tx to an Optimism chain). +There is now a better Optimism L2 chain integration in Common (PR [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554)) allowing to directly instantiate an Optimism chain with the `Common.custom()` constructor. Note that this only sets the correct chain ID (and e.g. _not_ corresponding HF blocks or similar) and is therefore only suitable for a limited set of use cases (e.g. sending a tx to an Optimism chain). Following Optimism chains are now integrated: @@ -218,7 +217,10 @@ In addition to initializing Common with a custom chain configuration it is now a ```typescript import myCustomChain1 from '[PATH_TO_MY_CHAINS]/myCustomChain1.json' import chain1GenesisState from '[PATH_TO_GENESIS_STATES]/chain1GenesisState.json' -const common = new Common({ chain: 'myCustomChain1', customChains: [ [ myCustomChain1, chain1GenesisState ] ]}) +const common = new Common({ + chain: 'myCustomChain1', + customChains: [[myCustomChain1, chain1GenesisState]], +}) ``` Accessing the genesis state is now integrated into the `Common` class and can be accessed in a much more natural way by doing: @@ -264,7 +266,7 @@ Improved Signature Types: - -> `bootstrapNodes(): BootstrapNode[]` - -> `dnsNetworks(): string[]` -**Potentially TypeScript Breaking**: Note while this is not strictly `TypeScript` breaking this might cause problems e.g. in the combination of using custom chain files with incomplete (but previously unused) parameters. So it is recommended to be a bit careful here. +**Potentially TypeScript Breaking**: Note while this is not strictly `TypeScript` breaking this might cause problems e.g. in the combination of using custom chain files with incomplete (but previously unused) parameters. So it is recommended to be a bit careful here. ### Changed Null Semantics for Hardfork Block Numbers in Chain Files @@ -313,7 +315,7 @@ const common = Common.custom(CustomChain.ArbitrumRinkebyTestnet) This `Common` release comes with two new enums `Chain` and `Hardfork`. These contain the currently supported chains and hardforks by the library and can be used for both instantiation and calling various methods where a chain or a hardfork is requested as a parameter, see PR [#1322](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1322). ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London }) common.hardforkIsActiveOnBlock(Hardfork.Berlin, 5) // false @@ -341,7 +343,7 @@ Small feature release. This `Common` release comes with full functional support for the `london` hardfork (all EIPs are finalized and integrated and `london` HF can be activated, there are no final block numbers for the HF integrated though yet). Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `Common` instance with a `london` HF activated: ```typescript -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'london' }) ``` @@ -358,8 +360,8 @@ Common now supports settings for the following additional EIPs: All new EIPs have their dedicated EIP configuration file and can also be activated spearately with the `eips` parameter (and the so-created `common` instance can then e.g. be used within the VM): ```typescript -import Common from '@ethereumjs/common' -const common = new Common({ chain: 'mainnet', hardfork: 'berlin', eips: [ 3529 ] }) +import { Common } from '@ethereumjs/common' +const common = new Common({ chain: 'mainnet', hardfork: 'berlin', eips: [3529] }) ``` ### Bug Fixes @@ -381,7 +383,7 @@ const common = new Common({ chain: 'mainnet', hardfork: 'berlin', eips: [ 3529 ] This `Common` release comes with full support for the `berlin` hardfork. Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `Common` instance with a `berlin` HF activated: ```typescript -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'berlin' }) ``` @@ -457,11 +459,14 @@ This new way adds a new `customChains` constructor option and can be used as fol import myCustomChain1 from './[PATH]/myCustomChain1.json' import myCustomChain2 from './[PATH]/myCustomChain2.json' // Add two custom chains, initial mainnet activation -const common1 = new Common({ chain: 'mainnet', customChains: [ myCustomChain1, myCustomChain2 ] }) +const common1 = new Common({ chain: 'mainnet', customChains: [myCustomChain1, myCustomChain2] }) // Somewhat later down the road... common1.setChain('customChain1') // Add two custom chains, activate customChain1 -const common1 = new Common({ chain: 'customChain1', customChains: [ myCustomChain1, myCustomChain2 ] }) +const common1 = new Common({ + chain: 'customChain1', + customChains: [myCustomChain1, myCustomChain2], +}) ``` The [README section](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/common#working-with-privatecustom-chains) on working with custom chains has been significantly expanded along the way and is a recommended read if you use common for custom chain initialization. @@ -503,7 +508,7 @@ npm i @ethereumjs/common Example: ```typescript -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'muirGlacier' }) ``` @@ -610,7 +615,7 @@ npm i @ethereumjs/common Example: ```typescript -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'muirGlacier' }) ``` @@ -670,8 +675,8 @@ Current default hardfork is set to `istanbul`, PR [#906](https://github.com/ethe ### Dual ES5 and ES2017 Builds -We significantly updated our internal tool and CI setup along the work on -PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` +We significantly updated our internal tool and CI setup along the work on +PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup. Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce diff --git a/packages/common/README.md b/packages/common/README.md index d75c16e60f1..12e93e42342 100644 --- a/packages/common/README.md +++ b/packages/common/README.md @@ -21,13 +21,12 @@ 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 { Common } 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 { Chain, Common, Hardfork } = require('@ethereumjs/common')` ## Parameters @@ -65,7 +64,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 +104,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 +211,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/ethash/CHANGELOG.md b/packages/ethash/CHANGELOG.md index 065ed1cec9f..b59489ae801 100644 --- a/packages/ethash/CHANGELOG.md +++ b/packages/ethash/CHANGELOG.md @@ -34,7 +34,7 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient, it deviates from the ESM specification and forces downstream users into using these options, which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option *not* to, which you didn't have before). +Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option _not_ to, which you didn't have before). ### Level DB Upgrade / Browser Compatibility @@ -52,8 +52,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' const level = require('level-mem') @@ -171,8 +171,8 @@ for a complete example. ### Dual ES5 and ES2017 Builds -We significantly updated our internal tool and CI setup along the work on -PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` +We significantly updated our internal tool and CI setup along the work on +PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup. Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce diff --git a/packages/ethash/README.md b/packages/ethash/README.md index b3adba1421e..5fb58daa0de 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/evm/CHANGELOG.md b/packages/evm/CHANGELOG.md index 1f180898af5..c059328f343 100644 --- a/packages/evm/CHANGELOG.md +++ b/packages/evm/CHANGELOG.md @@ -30,11 +30,11 @@ npm i @ethereumjs/evm The new EVM package extracts the bytecode execution logic and leaves the handling of the outer environment like setting up some pre-state, processing txs and blocks, generating receipts and paying miners (on a PoW chain) to the outer package. -This makes for a cleaner separation of concerns and generally brings the the new packages a lot closer to being a pure bytecode execution Ethereum Virtual Machine (EVM) implementation than before. This will allow for new ways of both customizing and adopting the inner EVM as well as providing an alternative environmental context and customize on the outer processing used in the outer VM package. +This makes for a cleaner separation of concerns and generally brings the the new packages a lot closer to being a pure bytecode execution Ethereum Virtual Machine (EVM) implementation than before. This will allow for new ways of both customizing and adopting the inner EVM as well as providing an alternative environmental context and customize on the outer processing used in the outer VM package. ### EVM, EEI and State -The EVM now provides interfaces for the `EVM` itself and for the `EEI`, the environmental interface which allows for the EVM to request external data like a blockhash for the respective `BLOCKHASH` opcode. The EEI is intended as "bridge" between the EVM, the VM, and the StateManager. It is now possible to import a new EVM and EEI into the VM, as long as these implement the provided interfaces. +The EVM now provides interfaces for the `EVM` itself and for the `EEI`, the environmental interface which allows for the EVM to request external data like a blockhash for the respective `BLOCKHASH` opcode. The EEI is intended as "bridge" between the EVM, the VM, and the StateManager. It is now possible to import a new EVM and EEI into the VM, as long as these implement the provided interfaces. Almost all environment related variables are extracted from EEI and are now in EVM. The environment provides information to the EVM about the code, the remaining gas left, etc. The only environment-related variables left in EEI are the warmed addresses and storage slots, and also keeps track of which accounts are touched (to cleanup later if these are "empty" after running a transaction). @@ -51,7 +51,7 @@ This means that a Block object instantiated without providing an explicit `Commo If you want to prevent these kind of implicit HF switches in the future it is likely a good practice to just always do your upper-level library instantiations with a `Common` instance setting an explicit HF, e.g.: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge }) ``` @@ -82,7 +82,7 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient, it deviates from the ESM specification and forces downstream users into using these options, which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option *not* to, which you didn't have before). +Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option _not_ to, which you didn't have before). ### Other Changes @@ -161,8 +161,8 @@ This release fully supports the Merge [Kiln](https://kiln.themerge.dev/) testnet In the VM the `merge` HF is now activated as being supported and an (experimental) Merge-ready VM can be instantiated with: ```typescript -import VM from '@ethereumjs/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge }) const vm = new VM({ common }) @@ -170,7 +170,7 @@ vm._common.isActivatedEIP(4399) // true ``` - [EIP-4399](https://eips.ethereum.org/EIPS/eip-4399) Support: Supplant DIFFICULTY opcode with PREVRANDAO, PR [#1565](https:// -github.com/ethereumjs/ethereumjs-monorepo/pull/1565) + github.com/ethereumjs/ethereumjs-monorepo/pull/1565) ### EIP-3540: EVM Object Format (EOF) v1 / EIP-3670: EOF - Code Validation @@ -181,7 +181,7 @@ Note that this EIP is not part of a specific hardfork yet and is considered `EXP For now the EIP has to be activated manually which can be done by using a respective `Common` instance: ```typescript -const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London, eips: [ 3540, 3670 ] }) +const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London, eips: [3540, 3670] }) ``` ### EIP-3860 Support: Limit and Meter Initcode @@ -191,7 +191,7 @@ Support for [EIP-3860](https://eips.ethereum.org/EIPS/eip-3860) has been added t Also here, implementation still `EXPERIMENTAL` and needs to be manually activated: ```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] }) ``` ### L2 Support: Genesis State with Code and Storage @@ -266,8 +266,8 @@ Please note that for backwards-compatibility reasons the associated Common is st An ArrowGlacier VM can be instantiated with: ```typescript -import VM from '@ethereumjs/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.ArrowGlacier }) const vm = new VM({ common }) @@ -362,7 +362,7 @@ Source files from the `src` folder are now included in the distribution build, s This release comes with some additional `EIP-1559` checks and functionality: -- Additional 1559 check in `VM.runTx()` that the tx sender balance must be >= gas_limit * max_fee_per_gas, PR [#1272](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1272) +- Additional 1559 check in `VM.runTx()` that the tx sender balance must be >= gas_limit \* max_fee_per_gas, PR [#1272](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1272) - Additional 1559 check in `VM.runTx()` to ensure that the user was willing to at least pay the base fee (`transaction.max_fee_per_gas >= block.base_fee_per_gas`), PR [#1276](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1276) - 1559 support for the BlockBuilder (`VM.buildBlock()`) by setting the new block's `baseFeePerGas` to `parentBlock.header.calcNextBaseFee()`, PR [#1280](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1280) @@ -373,8 +373,8 @@ This release comes with some additional `EIP-1559` checks and functionality: This `VM` release comes with full functional support for the `london` hardfork (all EIPs are finalized and integrated and `london` HF can be activated, there are no final block numbers for the HF integrated though yet). Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `VM` with the `london` HF activated: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'london' }) const vm = new VM({ common }) ``` @@ -389,7 +389,7 @@ Support for the following EIPs has been added: It is also possible to run these EIPs in isolation by instantiating a `berlin` common and activate selected EIPs with the `eips` option: ```typescript -const common = new Common({ chain: 'mainnet', hardfork: 'berlin', eips: [ 3529 ] }) +const common = new Common({ chain: 'mainnet', hardfork: 'berlin', eips: [3529] }) ``` #### EIP-1559: Gas Fee Market @@ -402,11 +402,11 @@ There is a new opcode `BASEFEE` added to the VM, see PR [#1148](https://github.c #### EIP-3529: Reduction in Refunds -`EIP-3529` removes gas refunds for `SELFDESTRUCT`, and reduces gas refunds for `SSTORE`, an implementation has been done in PR [#1239](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1239). +`EIP-3529` removes gas refunds for `SELFDESTRUCT`, and reduces gas refunds for `SSTORE`, an implementation has been done in PR [#1239](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1239). #### EIP-3541: Reject new Contracts with the 0xEF Byte -There is a new EVM Object Format (EOF) in preparation which will allow to validate contracts at deploy time. This EIP is a preparation for the introduction of this format and disallows contracts which start with the `0xEF` byte. Contracts created in the VM via create transaction, `CREATE` or `CREATE2` starting with this byte are now rejected when the EIP is activated and an `INVALID_BYTECODE_RESULT` is returned as an EVM error with the result, see PR [#1240](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1240). +There is a new EVM Object Format (EOF) in preparation which will allow to validate contracts at deploy time. This EIP is a preparation for the introduction of this format and disallows contracts which start with the `0xEF` byte. Contracts created in the VM via create transaction, `CREATE` or `CREATE2` starting with this byte are now rejected when the EIP is activated and an `INVALID_BYTECODE_RESULT` is returned as an EVM error with the result, see PR [#1240](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1240). ### StateManager: Preserve State History @@ -416,7 +416,7 @@ See PR [#1262](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1262) ### Error Handling: Correct Non-VM Error Propagation -In former versions of the VM non-VM errors happing inside the VM have been (unintentionally) shielded by a `try / catch` clause in the VM `Interpreter` class. This lead to existing bugs being hidden and channeled through as VM errors, which made it extremely difficult to trace such bugs down to the root cause. These kind of errors are now properly propagated and therefore lead to a break of the VM control flow. Please note that this might lead to your code breaking *if* you have got an error in your implementation (this should be a good this though since now this bug can finally be fixed 😀 ). +In former versions of the VM non-VM errors happing inside the VM have been (unintentionally) shielded by a `try / catch` clause in the VM `Interpreter` class. This lead to existing bugs being hidden and channeled through as VM errors, which made it extremely difficult to trace such bugs down to the root cause. These kind of errors are now properly propagated and therefore lead to a break of the VM control flow. Please note that this might lead to your code breaking _if_ you have got an error in your implementation (this should be a good this though since now this bug can finally be fixed 😀 ). See PR [#1168](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1168) @@ -439,7 +439,7 @@ See PR [#1198](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1198). **Features** -- Added `receipt` to `RunTxResult`, moved the tx receipt generation logic from `VM.runBlock()` to `VM.runTx()` (`generateTxReceipt()` and receipt exports in `runBlock` are now marked as *deprecated*), PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185) +- Added `receipt` to `RunTxResult`, moved the tx receipt generation logic from `VM.runBlock()` to `VM.runTx()` (`generateTxReceipt()` and receipt exports in `runBlock` are now marked as _deprecated_), PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185) **Bug Fixes** @@ -496,8 +496,8 @@ This release is the first VM release with official `berlin` HF support. All `Eth Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `VM` instance with a `berlin` HF activated: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'berlin' }) const vm = new VM({ common }) ``` @@ -565,15 +565,15 @@ This release introduces Clique/PoA support, see the main PR [#1032](https://gith Here is a simple example: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'goerli' }) const hardforkByBlockNumber = true const vm = new VM({ common, hardforkByBlockNumber }) const serialized = Buffer.from('f901f7a06bfee7294bf4457...', 'hex') -const block = Block.fromRLPSerializedBlock(serialized, { hardforkByBlockNumber }) +const block = Block.fromRLPSerializedBlock(serialized, { hardforkByBlockNumber }) const result = await vm.runBlock(block) ``` @@ -665,8 +665,8 @@ The following HFs have been added: A VM with the specific HF rules (on the chain provided) can be instantiated by passing in a `Common` instance: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'spuriousDragon' }) const vm = new VM({ common }) @@ -691,8 +691,8 @@ These integrations come along with an API addition to the VM to support the acti This API can be used as follows: ```typescript -import Common from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: 'mainnet', eips: [2537] }) const vm = new VM({ common }) @@ -719,7 +719,7 @@ The integration of this new interface is highly encouraged since this release al [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) package (this package will be retired) has been replaced by the new [Account class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) from the `ethereumjs-util` package. This affects all `Account` related `StateManager` methods, see PR [#911](https://github.com/ethereumjs/ethereumjs-monorepo/pull/911). -The Util package also introduces a new [Address class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_address_.md). This class replaces all current `Buffer` inputs on `StateManager` methods representing an address. +The Util package also introduces a new [Address class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_address_.md). This class replaces all current `Buffer` inputs on `StateManager` methods representing an address. ### Dual ES5 and ES2017 Builds @@ -735,7 +735,7 @@ Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `pac - Split opcodes logic into codes, fns, and utils files, PR [#896](https://github.com/ethereumjs/ethereumjs-monorepo/pull/896) - Group precompiles based upon hardfork, PR [#783](https://github.com/ethereumjs/ethereumjs-monorepo/pull/783) - **Breaking:** the `step` event now emits an `ethereumjs-util` [Account](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) object instead of an [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) -(package retired) object + (package retired) object - **Breaking:** `NewContractEvent` now emits an `address` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) - **Breaking:** `EVMResult` now returns a `createdAddress` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) - **Breaking:** `RunTxResult` now returns a `createdAddress` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) @@ -756,7 +756,7 @@ Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `pac - Various updates, fixes and refactoring work on the test runner, PR [#752](https://github.com/ethereumjs/ethereumjs-monorepo/pull/752) and PR [#849](https://github.com/ethereumjs/ethereumjs-monorepo/pull/849) - Integrated `ethereumjs-testing` code logic into VM for more flexible future test load optimizations, PR [#808](https://github.com/ethereumjs/ethereumjs-monorepo/pull/808) - Transition VM tests to TypeScript, PR [#881](https://github.com/ethereumjs/ethereumjs-monorepo/pull/881) and PR [#882](https://github.com/ethereumjs/ethereumjs-monorepo/pull/882) -- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) +- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) - Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-monorepo/pull/953) **Bug Fixes** @@ -771,7 +771,7 @@ Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `pac This is the first release candidate towards a final library release, see [beta.2](https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Fvm%405.0.0-beta.2) and especially [beta.1](https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Fvm%405.0.0-beta.1) release notes for an overview on the full changes since the last publicly released version. - Security fixes by `mcl-wasm` package dependency update, PR [#955](https://github.com/ethereumjs/ethereumjs-monorepo/pull/955) -- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) +- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) - Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-monorepo/pull/953) ## 5.0.0-beta.2 - 2020-11-12 @@ -818,8 +818,8 @@ A VM with the specific HF rules (on the chain provided) can be instantiated by passing in a `Common` instance: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'spuriousDragon' }) const vm = new VM({ common }) @@ -861,8 +861,8 @@ PR [#872](https://github.com/ethereumjs/ethereumjs-monorepo/pull/872). This API can be used as follows: ```typescript -import Common from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: 'mainnet', eips: [2537] }) const vm = new VM({ common }) @@ -902,14 +902,14 @@ also comes with `StateManager` API changes. Usage of the old from the `ethereumjs-util` package. This affects all `Account` related `StateManager` methods, see PR [#911](https://github.com/ethereumjs/ethereumjs-monorepo/pull/911). -The Util package also introduces a new +The Util package also introduces a new [Address class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_address_.md). This class replaces all current `Buffer` inputs on `StateManager` methods representing an address. ### Dual ES5 and ES2017 Builds -We significantly updated our internal tool and CI setup along the work on -PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` +We significantly updated our internal tool and CI setup along the work on +PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup. Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce @@ -928,10 +928,10 @@ in performance benefits for Node.js consumers, see [here](https://github.com/eth - Group precompiles based upon hardfork, PR [#783](https://github.com/ethereumjs/ethereumjs-monorepo/pull/783) - **Breaking:** the `step` event now emits an `ethereumjs-util` -[Account](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) -object instead of an [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) -(package retired) object -- **Breaking:** `NewContractEvent` now emits an `address` of + [Account](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) + object instead of an [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) + (package retired) object +- **Breaking:** `NewContractEvent` now emits an `address` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) - **Breaking:** `EVMResult` now returns a `createdAddress` of @@ -1364,7 +1364,7 @@ vm.runTx( // Handle errors appropriately } // Do something with the result - }, + } ) ``` diff --git a/packages/evm/README.md b/packages/evm/README.md index e1e4dee3ea1..ecc52c6abda 100644 --- a/packages/evm/README.md +++ b/packages/evm/README.md @@ -16,19 +16,18 @@ # USAGE ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' -import EVM from '@ethereumjs/evm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { EVM } from '@ethereumjs/evm' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London }) const blockchain = new Blockchain({ common }) const stateManager = new DefaultStateManager({ common }) const eei = EEI(stateManager, common, blockchain) const evm = new EVM({ - common, - blockchain, - eei, - }); - + common, + blockchain, + eei, +}) const STOP = '00' const ADD = '01' @@ -91,8 +90,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 @@ -128,8 +127,8 @@ A specific hardfork VM ruleset can be activated by passing in the hardfork along the `Common` instance: ```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 }) @@ -141,8 +140,8 @@ If you want to create a new instance of the VM and add your own genesis state, y instance with [custom genesis state](../common/README.md#initialize-using-customchains-array) and passing the flag `activateGenesisState` in `VMOpts`, e.g.: ```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' @@ -161,8 +160,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 }) diff --git a/packages/rlp/CHANGELOG.md b/packages/rlp/CHANGELOG.md index 1ef9b37bd17..c633bed81f0 100644 --- a/packages/rlp/CHANGELOG.md +++ b/packages/rlp/CHANGELOG.md @@ -34,7 +34,7 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient, it deviates from the ESM specification and forces downstream users into using these options, which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option *not* to, which you didn't have before). +Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option _not_ to, which you didn't have before). ## 3.0.0 - 2022-01-27 @@ -51,7 +51,7 @@ A new default export `RLP` now contains `encode` and `decode`. You can now import and use RLP like this: ```javascript -import RLP from 'rlp' +import { RLP } from 'rlp' RLP.encode(1) ``` @@ -71,7 +71,7 @@ const encoded = rlp.encode(bufArr) const decoded = rlp.decode(encoded) // New, rlp v3 -import RLP from 'rlp' +import { RLP } from 'rlp' const encoded: Uint8Array = RLP.encode(bufArrToArr(bufArr)) const encodedAsBuffer = Buffer.from(encoded) const decoded: Uint8Array[] = RLP.decode(encoded) diff --git a/packages/rlp/README.md b/packages/rlp/README.md index a85217495fb..a6a9ba94f4d 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/trie/README.md b/packages/trie/README.md index fe2dbf37617..79e0d3adb21 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/tx/CHANGELOG.md b/packages/tx/CHANGELOG.md index bc94ddc503a..a253511ba48 100644 --- a/packages/tx/CHANGELOG.md +++ b/packages/tx/CHANGELOG.md @@ -27,12 +27,15 @@ This means that a Transaction object instantiated without providing an explicit If you want to prevent these kind of implicit HF switches in the future it is likely a good practice to just always do your upper-level library instantiations with a `Common` instance setting an explicit HF, e.g.: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge }) -const tx = Transaction.fromTxData({ - // Provide your tx data here or use default values -}, { common }) +const tx = Transaction.fromTxData( + { + // Provide your tx data here or use default values + }, + { common } +) ``` ### BigInt Introduction / ES2020 Build Target @@ -51,7 +54,7 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient it deviates from the ESM specification and forces downstream users into these options which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along the breaking releases we have therefore deactivated both of these options and you might therefore need to adopt some import statements accordingly. Note that you still have got the possibility to activate these options in your bundle and/or transpilation pipeline (but now you also have the option to *not* do which you didn't have before). +Along the breaking releases we have therefore deactivated both of these options and you might therefore need to adopt some import statements accordingly. Note that you still have got the possibility to activate these options in your bundle and/or transpilation pipeline (but now you also have the option to _not_ do which you didn't have before). ### BigInt-Related API Changes @@ -101,7 +104,7 @@ Note that this EIP is not part of a specific hardfork yet and is considered `EXP For now the EIP has to be activated manually which can be done by using a respective `Common` instance: ```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] }) ``` ## 3.5.0 - 2022-02-01 @@ -126,7 +129,7 @@ An ArrowGlacier transaction can be instantiated with: ```typescript import { Transaction } from '@ethereumjs/tx' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.ArrowGlacier }) const tx = Transaction.fromTxData({}, { common }) @@ -152,7 +155,6 @@ The extended errors give substantial more object and chain context and should ea **Potentially breaking**: Attention! If you do react on errors in your code and do exact errror matching (`error.message === 'invalid transaction trie'`) things will break. Please make sure to do error comparisons with something like `error.message.includes('invalid transaction trie')` instead. This should generally be the pattern used for all error message comparisions and is assured to be future proof on all error messages (we won't change the core text in non-breaking releases). - ## Other Changes - The `dataFee` from `tx.getDataFee()` now gets cached for txs created with the `freeze` option (activated by default), PR [#1532](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1532) and PR [#1550](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1550) @@ -182,7 +184,7 @@ This tx release bumps the `Common` library dependency version to `v2.4.0` and is ```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] @@ -265,25 +267,24 @@ We tried to get more intelligent on the instantiation with a default chain if no Both these changes with the new default HF rules and the more intelligent chain ID instantiation now allows for an e.g. `EIP-155` tx instantiation without a Common (and generally for a safer non-Common tx instantiation) like this: - ```typescript -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' 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) @@ -297,10 +298,10 @@ This is just a note on documentation. There has been some confusion around how t ```typescript import { rlp } from 'ethereumjs-util' -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { Transaction } from '@ethereumjs/tx' -const common = new Common({ chain: 'goerli', hardfork: 'berlin'}) +const common = new Common({ chain: 'goerli', hardfork: 'berlin' }) const tx = Transaction.fromTxData({}, { common }) const message = tx.getMessageToSign(false) @@ -325,25 +326,25 @@ An `EIP-1559` tx inherits the access list feature from the `AccessListEIP2930Tra An `EIP-1559` tx can be instantiated with: ```typescript -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx' const common = new Common({ chain: 'mainnet', 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 }) @@ -373,7 +374,7 @@ This release fixes a critical EIP-2930 tx constructor bug which slipped through - Added alias `type` for `transactionType` so it can be interpreted correctly for an `AccessListEIP2930Transaction` instantiation when passed to `fromTxData()`, PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185) - `TransactionFactory.fromTxData()`: fixed a bug where instantiation was breaking when `type` was passed in as a 0x-prefixed hex string, PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185) - `AccessListEIP2930Transaction`: added a test that initializes correctly from its own data (adds coverage for `type` property alias), PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185) -- EIP-2930 aliases for `senderS`, `senderR`, `yParity` are now marked as *deprecated*, use `v`, `r`, `s` instead +- EIP-2930 aliases for `senderS`, `senderR`, `yParity` are now marked as _deprecated_, use `v`, `r`, `s` instead ## 3.1.2 - 2021-03-31 @@ -400,32 +401,32 @@ This release comes with full support for the `berlin` hardfork by updating the l `EIP-2930` transactions can be instantiated with: ```typescript -import Common from '@ethereumjs/common' +import { Common } from '@ethereumjs/common' import { AccessListEIP2930Transaction } from '@ethereumjs/tx' const common = new Common({ chain: 'mainnet', 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 }) diff --git a/packages/tx/README.md b/packages/tx/README.md index edc5e7f00c0..188bf117e38 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/docs/classes/Transaction.md b/packages/tx/docs/classes/Transaction.md index a4174795fbe..efee613d774 100644 --- a/packages/tx/docs/classes/Transaction.md +++ b/packages/tx/docs/classes/Transaction.md @@ -73,10 +73,10 @@ varying data types. #### Parameters -| Name | Type | -| :------ | :------ | -| `txData` | [`TxData`](../README.md#txdata) | -| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | +| Name | Type | +| :------- | :---------------------------------------- | +| `txData` | [`TxData`](../README.md#txdata) | +| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | #### Overrides @@ -100,7 +100,7 @@ BaseTransaction.common [legacyTransaction.ts:26](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L26) -___ +--- ### data @@ -114,7 +114,7 @@ BaseTransaction.data [baseTransaction.ts:47](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L47) -___ +--- ### gasLimit @@ -128,7 +128,7 @@ BaseTransaction.gasLimit [baseTransaction.ts:44](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L44) -___ +--- ### gasPrice @@ -138,7 +138,7 @@ ___ [legacyTransaction.ts:24](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L24) -___ +--- ### nonce @@ -152,7 +152,7 @@ BaseTransaction.nonce [baseTransaction.ts:43](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L43) -___ +--- ### r @@ -166,7 +166,7 @@ BaseTransaction.r [baseTransaction.ts:50](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L50) -___ +--- ### s @@ -180,7 +180,7 @@ BaseTransaction.s [baseTransaction.ts:51](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L51) -___ +--- ### to @@ -194,7 +194,7 @@ BaseTransaction.to [baseTransaction.ts:45](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L45) -___ +--- ### v @@ -208,7 +208,7 @@ BaseTransaction.v [baseTransaction.ts:49](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L49) -___ +--- ### value @@ -244,7 +244,7 @@ BaseTransaction.transactionType [baseTransaction.ts:118](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L118) -___ +--- ### type @@ -286,7 +286,7 @@ BaseTransaction.errorStr [legacyTransaction.ts:448](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L448) -___ +--- ### getBaseFee @@ -306,7 +306,7 @@ BaseTransaction.getBaseFee [baseTransaction.ts:175](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L175) -___ +--- ### getDataFee @@ -326,7 +326,7 @@ BaseTransaction.getDataFee [legacyTransaction.ts:237](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L237) -___ +--- ### getMessageToSign @@ -339,16 +339,16 @@ Note: the raw message message format for the legacy tx is not RLP encoded and you might need to do yourself with: ```javascript -import RLP from 'rlp' +import { RLP } from 'rlp' const message = tx.getMessageToSign(false) const serializedMessage = RLP.encode(message) // use this for the HW wallet input ``` #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `hashMessage` | ``false`` | Return hashed message if set to true (default: true) | +| Name | Type | Description | +| :------------ | :------ | :--------------------------------------------------- | +| `hashMessage` | `false` | Return hashed message if set to true (default: true) | #### Returns @@ -366,9 +366,9 @@ BaseTransaction.getMessageToSign #### Parameters -| Name | Type | -| :------ | :------ | -| `hashMessage?` | ``true`` | +| Name | Type | +| :------------- | :----- | +| `hashMessage?` | `true` | #### Returns @@ -382,7 +382,7 @@ BaseTransaction.getMessageToSign [legacyTransaction.ts:224](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L224) -___ +--- ### getMessageToVerifySignature @@ -402,7 +402,7 @@ BaseTransaction.getMessageToVerifySignature [legacyTransaction.ts:294](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L294) -___ +--- ### getSenderAddress @@ -422,7 +422,7 @@ BaseTransaction.getSenderAddress [baseTransaction.ts:280](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L280) -___ +--- ### getSenderPublicKey @@ -442,7 +442,7 @@ BaseTransaction.getSenderPublicKey [legacyTransaction.ts:306](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L306) -___ +--- ### getUpfrontCost @@ -462,7 +462,7 @@ BaseTransaction.getUpfrontCost [legacyTransaction.ts:255](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L255) -___ +--- ### hash @@ -485,7 +485,7 @@ BaseTransaction.hash [legacyTransaction.ts:265](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L265) -___ +--- ### isSigned @@ -503,7 +503,7 @@ BaseTransaction.isSigned [baseTransaction.ts:247](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L247) -___ +--- ### raw @@ -533,7 +533,7 @@ BaseTransaction.raw [legacyTransaction.ts:162](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L162) -___ +--- ### serialize @@ -559,7 +559,7 @@ BaseTransaction.serialize [legacyTransaction.ts:185](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L185) -___ +--- ### sign @@ -569,14 +569,15 @@ Signs a transaction. Note that the signed tx is returned as a new object, use as follows: + ```javascript const signedTx = tx.sign(privateKey) ``` #### Parameters -| Name | Type | -| :------ | :------ | +| Name | Type | +| :----------- | :------- | | `privateKey` | `Buffer` | #### Returns @@ -591,7 +592,7 @@ BaseTransaction.sign [baseTransaction.ts:298](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L298) -___ +--- ### supports @@ -614,8 +615,8 @@ on all supported capabilities. #### Parameters -| Name | Type | -| :------ | :------ | +| Name | Type | +| :----------- | :------------------------------------- | | `capability` | [`Capability`](../enums/Capability.md) | #### Returns @@ -630,7 +631,7 @@ BaseTransaction.supports [baseTransaction.ts:147](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L147) -___ +--- ### toCreationAddress @@ -650,7 +651,7 @@ BaseTransaction.toCreationAddress [baseTransaction.ts:215](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L215) -___ +--- ### toJSON @@ -670,7 +671,7 @@ BaseTransaction.toJSON [legacyTransaction.ts:365](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L365) -___ +--- ### validate @@ -695,9 +696,9 @@ BaseTransaction.validate #### Parameters -| Name | Type | -| :------ | :------ | -| `stringError` | ``false`` | +| Name | Type | +| :------------ | :------ | +| `stringError` | `false` | #### Returns @@ -715,9 +716,9 @@ BaseTransaction.validate #### Parameters -| Name | Type | -| :------ | :------ | -| `stringError` | ``true`` | +| Name | Type | +| :------------ | :----- | +| `stringError` | `true` | #### Returns @@ -731,7 +732,7 @@ BaseTransaction.validate [baseTransaction.ts:157](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L157) -___ +--- ### verifySignature @@ -751,7 +752,7 @@ BaseTransaction.verifySignature [baseTransaction.ts:267](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/baseTransaction.ts#L267) -___ +--- ### fromRlpSerializedTx @@ -765,10 +766,10 @@ in favor of the [Transaction.fromSerializedTx](Transaction.md#fromserializedtx) #### Parameters -| Name | Type | -| :------ | :------ | -| `serialized` | `Buffer` | -| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | +| Name | Type | +| :----------- | :---------------------------------------- | +| `serialized` | `Buffer` | +| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | #### Returns @@ -778,7 +779,7 @@ in favor of the [Transaction.fromSerializedTx](Transaction.md#fromserializedtx) [legacyTransaction.ts:62](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L62) -___ +--- ### fromSerializedTx @@ -790,10 +791,10 @@ Format: `rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])` #### Parameters -| Name | Type | -| :------ | :------ | -| `serialized` | `Buffer` | -| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | +| Name | Type | +| :----------- | :---------------------------------------- | +| `serialized` | `Buffer` | +| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | #### Returns @@ -803,7 +804,7 @@ Format: `rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])` [legacyTransaction.ts:45](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L45) -___ +--- ### fromTxData @@ -814,14 +815,15 @@ Instantiate a transaction from a data dictionary. Format: { nonce, gasPrice, gasLimit, to, value, data, v, r, s } Notes: + - All parameters are optional and have some basic default values #### Parameters -| Name | Type | -| :------ | :------ | -| `txData` | [`TxData`](../README.md#txdata) | -| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | +| Name | Type | +| :------- | :---------------------------------------- | +| `txData` | [`TxData`](../README.md#txdata) | +| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | #### Returns @@ -831,7 +833,7 @@ Notes: [legacyTransaction.ts:36](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/tx/src/legacyTransaction.ts#L36) -___ +--- ### fromValuesArray @@ -843,10 +845,10 @@ Format: `[nonce, gasPrice, gasLimit, to, value, data, v, r, s]` #### Parameters -| Name | Type | -| :------ | :------ | +| Name | Type | +| :------- | :-------------------------------------------- | | `values` | [`TxValuesArray`](../README.md#txvaluesarray) | -| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | +| `opts` | [`TxOptions`](../interfaces/TxOptions.md) | #### Returns diff --git a/packages/vm/CHANGELOG.md b/packages/vm/CHANGELOG.md index 05f9d9ca8e4..1ab373c3a3d 100644 --- a/packages/vm/CHANGELOG.md +++ b/packages/vm/CHANGELOG.md @@ -22,7 +22,7 @@ The EthereumJS Team This breaking release round comes with some broader changes to the VM package. The code base has been substantially modularized and two new packages, `@ethereumjs/evm` and `@ethereumjs/statemanager` have been created, also see the CHANGELOGs from both new packages for additional guidance. -The EVM package extracts the inner core, the Ethereum Virtual Machine (EVM) respectively the bytecode engine, see PRs [#1892](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1892), [#1955](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1955) and [#1977](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1977) for the main implementation work and PR [#1974](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1974) for the package extraction work. +The EVM package extracts the inner core, the Ethereum Virtual Machine (EVM) respectively the bytecode engine, see PRs [#1892](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1892), [#1955](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1955) and [#1977](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1977) for the main implementation work and PR [#1974](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1974) for the package extraction work. The StateManager extracts the high-level state access interface, see PR [#1817](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1817). Both can now directly be passed in to the `VM` package along instantiation or are otherwise instantiated as default versions with default values being set. @@ -48,7 +48,7 @@ This means that a Block object instantiated without providing an explicit `Commo If you want to prevent these kind of implicit HF switches in the future it is likely a good practice to just always do your upper-level library instantiations with a `Common` instance setting an explicit HF, e.g.: ```typescript -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge }) ``` @@ -71,7 +71,7 @@ This comes with a substantial increase in overall EVM performance, we will provi ### EIP-3074 Authcall Support -The EVM now comes with experimental support for [EIP-3074](https://eips.ethereum.org/EIPS/eip-3074) introducing two new opcodes `Auth` and `Authcall` to allow externally owned accounts to delegate control to a contract, see PRs [#1788](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1788) and [#1867]([#1788](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1788)). +The EVM now comes with experimental support for [EIP-3074](https://eips.ethereum.org/EIPS/eip-3074) introducing two new opcodes `Auth` and `Authcall` to allow externally owned accounts to delegate control to a contract, see PRs [#1788](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1788) and [#1867](<[#1788](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1788)>). ### Disabled esModuleInterop and allowSyntheticDefaultImports TypeScript Compiler Options @@ -79,7 +79,7 @@ The above TypeScript options provide some semantic sugar like allowing to write While this is convenient, it deviates from the ESM specification and forces downstream users into using these options, which might not be desirable, see [this TypeScript Semver docs section](https://www.semver-ts.org/#module-interop) for some more detailed argumentation. -Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option *not* to, which you didn't have before). +Along with the breaking releases we have therefore deactivated both of these options and you might therefore need to adapt some import statements accordingly. Note that you still can activate these options in your bundle and/or transpilation pipeline (but now you also have the option _not_ to, which you didn't have before). ### Folder Restructure @@ -175,8 +175,8 @@ This release fully supports the Merge [Kiln](https://kiln.themerge.dev/) testnet In the VM the `merge` HF is now activated as being supported and an (experimental) Merge-ready VM can be instantiated with: ```typescript -import VM from '@ethereumjs/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Merge }) const vm = new VM({ common }) @@ -184,7 +184,7 @@ vm._common.isActivatedEIP(4399) // true ``` - [EIP-4399](https://eips.ethereum.org/EIPS/eip-4399) Support: Supplant DIFFICULTY opcode with PREVRANDAO, PR [#1565](https:// -github.com/ethereumjs/ethereumjs-monorepo/pull/1565) + github.com/ethereumjs/ethereumjs-monorepo/pull/1565) ### EIP-3540: EVM Object Format (EOF) v1 / EIP-3670: EOF - Code Validation @@ -195,7 +195,7 @@ Note that this EIP is not part of a specific hardfork yet and is considered `EXP For now the EIP has to be activated manually which can be done by using a respective `Common` instance: ```typescript -const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London, eips: [ 3540, 3670 ] }) +const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London, eips: [3540, 3670] }) ``` ### EIP-3860 Support: Limit and Meter Initcode @@ -205,7 +205,7 @@ Support for [EIP-3860](https://eips.ethereum.org/EIPS/eip-3860) has been added t Also here, implementation still `EXPERIMENTAL` and needs to be manually activated: ```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] }) ``` ### L2 Support: Genesis State with Code and Storage @@ -280,8 +280,8 @@ Please note that for backwards-compatibility reasons the associated Common is st An ArrowGlacier VM can be instantiated with: ```typescript -import VM from '@ethereumjs/vm' -import Common, { Chain, Hardfork } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Chain, Common, Hardfork } from '@ethereumjs/common' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.ArrowGlacier }) const vm = new VM({ common }) @@ -376,7 +376,7 @@ Source files from the `src` folder are now included in the distribution build, s This release comes with some additional `EIP-1559` checks and functionality: -- Additional 1559 check in `VM.runTx()` that the tx sender balance must be >= gas_limit * max_fee_per_gas, PR [#1272](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1272) +- Additional 1559 check in `VM.runTx()` that the tx sender balance must be >= gas_limit \* max_fee_per_gas, PR [#1272](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1272) - Additional 1559 check in `VM.runTx()` to ensure that the user was willing to at least pay the base fee (`transaction.max_fee_per_gas >= block.base_fee_per_gas`), PR [#1276](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1276) - 1559 support for the BlockBuilder (`VM.buildBlock()`) by setting the new block's `baseFeePerGas` to `parentBlock.header.calcNextBaseFee()`, PR [#1280](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1280) @@ -387,8 +387,8 @@ This release comes with some additional `EIP-1559` checks and functionality: This `VM` release comes with full functional support for the `london` hardfork (all EIPs are finalized and integrated and `london` HF can be activated, there are no final block numbers for the HF integrated though yet). Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `VM` with the `london` HF activated: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'london' }) const vm = new VM({ common }) ``` @@ -403,7 +403,7 @@ Support for the following EIPs has been added: It is also possible to run these EIPs in isolation by instantiating a `berlin` common and activate selected EIPs with the `eips` option: ```typescript -const common = new Common({ chain: 'mainnet', hardfork: 'berlin', eips: [ 3529 ] }) +const common = new Common({ chain: 'mainnet', hardfork: 'berlin', eips: [3529] }) ``` #### EIP-1559: Gas Fee Market @@ -416,11 +416,11 @@ There is a new opcode `BASEFEE` added to the VM, see PR [#1148](https://github.c #### EIP-3529: Reduction in Refunds -`EIP-3529` removes gas refunds for `SELFDESTRUCT`, and reduces gas refunds for `SSTORE`, an implementation has been done in PR [#1239](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1239). +`EIP-3529` removes gas refunds for `SELFDESTRUCT`, and reduces gas refunds for `SSTORE`, an implementation has been done in PR [#1239](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1239). #### EIP-3541: Reject new Contracts with the 0xEF Byte -There is a new EVM Object Format (EOF) in preparation which will allow to validate contracts at deploy time. This EIP is a preparation for the introduction of this format and disallows contracts which start with the `0xEF` byte. Contracts created in the VM via create transaction, `CREATE` or `CREATE2` starting with this byte are now rejected when the EIP is activated and an `INVALID_BYTECODE_RESULT` is returned as an EVM error with the result, see PR [#1240](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1240). +There is a new EVM Object Format (EOF) in preparation which will allow to validate contracts at deploy time. This EIP is a preparation for the introduction of this format and disallows contracts which start with the `0xEF` byte. Contracts created in the VM via create transaction, `CREATE` or `CREATE2` starting with this byte are now rejected when the EIP is activated and an `INVALID_BYTECODE_RESULT` is returned as an EVM error with the result, see PR [#1240](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1240). ### StateManager: Preserve State History @@ -430,7 +430,7 @@ See PR [#1262](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1262) ### Error Handling: Correct Non-VM Error Propagation -In former versions of the VM non-VM errors happing inside the VM have been (unintentionally) shielded by a `try / catch` clause in the VM `Interpreter` class. This lead to existing bugs being hidden and channeled through as VM errors, which made it extremely difficult to trace such bugs down to the root cause. These kind of errors are now properly propagated and therefore lead to a break of the VM control flow. Please note that this might lead to your code breaking *if* you have got an error in your implementation (this should be a good this though since now this bug can finally be fixed 😀 ). +In former versions of the VM non-VM errors happing inside the VM have been (unintentionally) shielded by a `try / catch` clause in the VM `Interpreter` class. This lead to existing bugs being hidden and channeled through as VM errors, which made it extremely difficult to trace such bugs down to the root cause. These kind of errors are now properly propagated and therefore lead to a break of the VM control flow. Please note that this might lead to your code breaking _if_ you have got an error in your implementation (this should be a good this though since now this bug can finally be fixed 😀 ). See PR [#1168](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1168) @@ -453,7 +453,7 @@ See PR [#1198](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1198). **Features** -- Added `receipt` to `RunTxResult`, moved the tx receipt generation logic from `VM.runBlock()` to `VM.runTx()` (`generateTxReceipt()` and receipt exports in `runBlock` are now marked as *deprecated*), PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185) +- Added `receipt` to `RunTxResult`, moved the tx receipt generation logic from `VM.runBlock()` to `VM.runTx()` (`generateTxReceipt()` and receipt exports in `runBlock` are now marked as _deprecated_), PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185) **Bug Fixes** @@ -510,8 +510,8 @@ This release is the first VM release with official `berlin` HF support. All `Eth Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `VM` instance with a `berlin` HF activated: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'berlin' }) const vm = new VM({ common }) ``` @@ -579,15 +579,15 @@ This release introduces Clique/PoA support, see the main PR [#1032](https://gith Here is a simple example: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'goerli' }) const hardforkByBlockNumber = true const vm = new VM({ common, hardforkByBlockNumber }) const serialized = Buffer.from('f901f7a06bfee7294bf4457...', 'hex') -const block = Block.fromRLPSerializedBlock(serialized, { hardforkByBlockNumber }) +const block = Block.fromRLPSerializedBlock(serialized, { hardforkByBlockNumber }) const result = await vm.runBlock(block) ``` @@ -679,8 +679,8 @@ The following HFs have been added: A VM with the specific HF rules (on the chain provided) can be instantiated by passing in a `Common` instance: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'spuriousDragon' }) const vm = new VM({ common }) @@ -705,8 +705,8 @@ These integrations come along with an API addition to the VM to support the acti This API can be used as follows: ```typescript -import Common from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: 'mainnet', eips: [2537] }) const vm = new VM({ common }) @@ -733,7 +733,7 @@ The integration of this new interface is highly encouraged since this release al [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) package (this package will be retired) has been replaced by the new [Account class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) from the `ethereumjs-util` package. This affects all `Account` related `StateManager` methods, see PR [#911](https://github.com/ethereumjs/ethereumjs-monorepo/pull/911). -The Util package also introduces a new [Address class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_address_.md). This class replaces all current `Buffer` inputs on `StateManager` methods representing an address. +The Util package also introduces a new [Address class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_address_.md). This class replaces all current `Buffer` inputs on `StateManager` methods representing an address. ### Dual ES5 and ES2017 Builds @@ -749,7 +749,7 @@ Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `pac - Split opcodes logic into codes, fns, and utils files, PR [#896](https://github.com/ethereumjs/ethereumjs-monorepo/pull/896) - Group precompiles based upon hardfork, PR [#783](https://github.com/ethereumjs/ethereumjs-monorepo/pull/783) - **Breaking:** the `step` event now emits an `ethereumjs-util` [Account](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) object instead of an [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) -(package retired) object + (package retired) object - **Breaking:** `NewContractEvent` now emits an `address` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) - **Breaking:** `EVMResult` now returns a `createdAddress` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) - **Breaking:** `RunTxResult` now returns a `createdAddress` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) @@ -770,7 +770,7 @@ Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `pac - Various updates, fixes and refactoring work on the test runner, PR [#752](https://github.com/ethereumjs/ethereumjs-monorepo/pull/752) and PR [#849](https://github.com/ethereumjs/ethereumjs-monorepo/pull/849) - Integrated `ethereumjs-testing` code logic into VM for more flexible future test load optimizations, PR [#808](https://github.com/ethereumjs/ethereumjs-monorepo/pull/808) - Transition VM tests to TypeScript, PR [#881](https://github.com/ethereumjs/ethereumjs-monorepo/pull/881) and PR [#882](https://github.com/ethereumjs/ethereumjs-monorepo/pull/882) -- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) +- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) - Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-monorepo/pull/953) **Bug Fixes** @@ -785,7 +785,7 @@ Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `pac This is the first release candidate towards a final library release, see [beta.2](https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Fvm%405.0.0-beta.2) and especially [beta.1](https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Fvm%405.0.0-beta.1) release notes for an overview on the full changes since the last publicly released version. - Security fixes by `mcl-wasm` package dependency update, PR [#955](https://github.com/ethereumjs/ethereumjs-monorepo/pull/955) -- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) +- On-demand state and blockchain test runs for all hardforks triggered by PR label, PR [#951](https://github.com/ethereumjs/ethereumjs-monorepo/pull/951) - Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-monorepo/pull/953) ## 5.0.0-beta.2 - 2020-11-12 @@ -832,8 +832,8 @@ A VM with the specific HF rules (on the chain provided) can be instantiated by passing in a `Common` instance: ```typescript -import VM from '@ethereumjs/vm' -import Common from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' const common = new Common({ chain: 'mainnet', hardfork: 'spuriousDragon' }) const vm = new VM({ common }) @@ -875,8 +875,8 @@ PR [#872](https://github.com/ethereumjs/ethereumjs-monorepo/pull/872). This API can be used as follows: ```typescript -import Common from '@ethereumjs/common' -import VM from '@ethereumjs/vm' +import { Common } from '@ethereumjs/common' +import { VM } from '@ethereumjs/vm' const common = new Common({ chain: 'mainnet', eips: [2537] }) const vm = new VM({ common }) @@ -916,14 +916,14 @@ also comes with `StateManager` API changes. Usage of the old from the `ethereumjs-util` package. This affects all `Account` related `StateManager` methods, see PR [#911](https://github.com/ethereumjs/ethereumjs-monorepo/pull/911). -The Util package also introduces a new +The Util package also introduces a new [Address class](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_address_.md). This class replaces all current `Buffer` inputs on `StateManager` methods representing an address. ### Dual ES5 and ES2017 Builds -We significantly updated our internal tool and CI setup along the work on -PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` +We significantly updated our internal tool and CI setup along the work on +PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup. Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce @@ -942,10 +942,10 @@ in performance benefits for Node.js consumers, see [here](https://github.com/eth - Group precompiles based upon hardfork, PR [#783](https://github.com/ethereumjs/ethereumjs-monorepo/pull/783) - **Breaking:** the `step` event now emits an `ethereumjs-util` -[Account](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) -object instead of an [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) -(package retired) object -- **Breaking:** `NewContractEvent` now emits an `address` of + [Account](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/modules/_account_.md) + object instead of an [ethereumjs-account](https://github.com/ethereumjs/ethereumjs-account) + (package retired) object +- **Breaking:** `NewContractEvent` now emits an `address` of type `Address` (see `ethereumjs-util`) instead of a `Buffer`, PR [#919](https://github.com/ethereumjs/ethereumjs-monorepo/pull/919) - **Breaking:** `EVMResult` now returns a `createdAddress` of @@ -1378,7 +1378,7 @@ vm.runTx( // Handle errors appropriately } // Do something with the result - }, + } ) ``` diff --git a/packages/vm/README.md b/packages/vm/README.md index 61388b2da8a..36e6aa025a9 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -16,8 +16,8 @@ # USAGE ```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.London }) const vm = new VM({ common }) @@ -86,8 +86,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 @@ -123,8 +123,8 @@ A specific hardfork VM ruleset can be activated by passing in the hardfork along the `Common` instance: ```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 }) @@ -136,8 +136,8 @@ If you want to create a new instance of the VM and add your own genesis state, y instance with [custom genesis state](../common/README.md#initialize-using-customchains-array) and passing the flag `activateGenesisState` in `VMOpts`, e.g.: ```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' @@ -156,8 +156,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 })