Skip to content

Commit a61be5d

Browse files
authored
Merge pull request ethereumjs#962 from ethereumjs/final-releases
Final releases
2 parents 2f74c81 + 06d1438 commit a61be5d

File tree

12 files changed

+648
-17
lines changed

12 files changed

+648
-17
lines changed

packages/block/CHANGELOG.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,190 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
(modification: no type change headlines) and this project adheres to
77
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

9+
## 3.0.0 - 2020-11-24
10+
11+
### New Package Name
12+
13+
**Attention!** This new version is part of a series of EthereumJS releases all moving to a new scoped package name format. In this case the library is renamed as follows:
14+
15+
- `ethereumjs-block` -> `@ethereumjs/block`
16+
17+
Please update your library references accordingly or install with:
18+
19+
```shell
20+
npm i @ethereumjs/block
21+
```
22+
23+
### TypeScript/Library Import
24+
25+
This is the first TypeScript based release of the library, see PR [#72](https://github.com/ethereumjs/ethereumjs-block/pull/72).
26+
The import structure has slightly changed along:
27+
28+
**TypeScript**
29+
30+
```typescript
31+
import { BlockHeader } from 'ethereumjs-block'
32+
import { Block } from 'ethereumjs-block'
33+
```
34+
35+
**JavaScript/Node.js**
36+
37+
```javascript
38+
const BlockHeader = require('ethereumjs-block').BlockHeader
39+
const Block = require('ethereumjs-block').Block
40+
```
41+
42+
The library now also comes with a **type declaration file** distributed along with the package published.
43+
44+
### Major Refactoring - Breaking Changes
45+
46+
This release is a major refactoring of the block library to simplify and strengthen its code base. Refactoring work has been done along PR [#72](https://github.com/ethereumjs/ethereumjs-block/pull/72) (Promises) and PR [#883](https://github.com/ethereumjs/ethereumjs-vm/pull/883) (refactoring of API and internal code structure).
47+
48+
#### New Constructor Params
49+
50+
The way to instantiate a new `BlockHeader` or `Block` object has been completely reworked and is now more explicit, less error prone and produces more `TypeScript` friendly and readable code.
51+
52+
The old direct constructor usage is now discouraged in favor of different dedicated static factory methods to create new objects.
53+
54+
**Breaking**: While the main constructors can still be called, signatures changed significantly and your old `new Block(...)`, `new BlockHeader(...)` instantiations won't work any more and needs to be updated.
55+
56+
**BlockHeader Class**
57+
58+
There are three new factory methods to create a new `BlockHeader`:
59+
60+
1. Pass in a Header-attribute named dictionary to `BlockHeader.fromHeaderData(headerData: HeaderData = {}, opts?: BlockOptions)`:
61+
62+
```typescript
63+
const headerData = {
64+
number: 15,
65+
parentHash: '0x6bfee7294bf44572b7266358e627f3c35105e1c3851f3de09e6d646f955725a7',
66+
difficulty: 131072,
67+
gasLimit: 8000000,
68+
timestamp: 1562422144,
69+
}
70+
const header = BlockHeader.fromHeaderData(headerData)
71+
```
72+
73+
2. Create a `BlockHeader` from an RLP-serialized header `Buffer` with `BlockHeader.fromRLPSerializedHeader(serialized: Buffer, opts: BlockOptions)`.
74+
75+
```typescript
76+
const serialized = Buffer.from(
77+
'f901f7a06bfee7294bf44572b7266358e627f3c35105e1c3851f3de09e6d646f955725a7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200000f837a120080845d20ab8080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000',
78+
'hex'
79+
)
80+
const header = BlockHeader.fromRLPSerializedHeader(serialized)
81+
```
82+
83+
3. Create a `BlockHeader` from an array of `Buffer` values, you can do a first short roundtrip test with:
84+
85+
```typescript
86+
const valuesArray = header.raw()
87+
BlockHeader.fromValuesArray(valuesArray)
88+
```
89+
90+
Generally internal types representing block header values are now closer to their domain representation (number, difficulty, gasLimit) instead of having everthing represented as a `Buffer`.
91+
92+
**Block Class**
93+
94+
There are analogue new static factories for the `Block` class:
95+
96+
- `Block.fromBlockData(blockData: BlockData = {}, opts?: BlockOptions)`
97+
- `Block.fromRLPSerializedBlock(serialized: Buffer, opts?: BlockOptions)`
98+
- `Block.fromValuesArray(values: BlockBuffer, opts?: BlockOptions)`
99+
100+
Learn more about the full API in the [docs](./docs/README.md).
101+
102+
#### Immutability
103+
104+
The returned block is now frozen and immutable. To work with a maliable block, copy it with `const fakeBlock = Object.create(block)`.
105+
106+
If you need `Block` mutability - e.g. because you want to subclass `Block` and modifiy its behavior - there is a `freeze` option to prevent the `Object.freeze()` call on initialization, see PR [#941](https://github.com/ethereumjs/ethereumjs-vm/pull/941).
107+
108+
#### Promise-based API
109+
110+
The API of this library is now completely promise-based and the old callback-style interface has been dropped.
111+
112+
This affects the following methods of the API now being defined as `async` and returning a `Promise`:
113+
114+
**Header Class**
115+
116+
- `BlockHeader.validate(blockchain: Blockchain, height?: BN): Promise<void>`
117+
118+
**Block Class**
119+
120+
- `Block.genTxTrie(): Promise<void>`
121+
- `Block.validate(blockChain: Blockchain): Promise<void>`
122+
- `Block.validateUncles(blockchain: Blockchain): Promise<void>`
123+
124+
Usage example:
125+
126+
```javascript
127+
try {
128+
await block.validate(blockchain)
129+
// Block validation has passed
130+
} catch (err) {
131+
// handle errors appropriately
132+
}
133+
```
134+
135+
### Header Validation Methods > Signature Changes
136+
137+
**Breaking**: The signatures of the following header validation methods have been updated to take a `parentBlockHeader` instead of a `parentBlock` input parameter for consistency and removing a circling dependency with `Block`:
138+
139+
- `BlockHeader.canonicalDifficulty(parentBlockHeader: BlockHeader): BN`
140+
- `BlockHeader.validateDifficulty(parentBlockHeader: BlockHeader): boolean`
141+
- `BlockHeader.validateGasLimit(parentBlockHeader: BlockHeader): boolean`
142+
143+
On the `Block` library new corresponding methods have been added which both operate on a block instance and expect a `parentBlock` as an input parameter.
144+
145+
**Breaking:** Note that `canonicalDifficulty()` and `validateDifficulty()` in block and header now throw on non-PoW chains, see PR [#937](https://github.com/ethereumjs/ethereumjs-vm/pull/937).
146+
147+
**Breaking:** Non-blockchain dependent validation checks have been extracted from `validate()` to its own `Block.validateData()` function. For the `validate()` method in block and header `blockchain` is now a mandatory parameter, see PR [#942](https://github.com/ethereumjs/ethereumjs-vm/pull/942)
148+
149+
### New Default Hardfork
150+
151+
**Breaking:** The default HF on the library has been updated from `petersburg` to `istanbul`, see PR [#906](https://github.com/ethereumjs/ethereumjs-vm/pull/906).
152+
153+
The HF setting is now automatically taken from the HF set for `Common.DEAULT_HARDFORK`, see PR [#863](https://github.com/ethereumjs/ethereumjs-vm/pull/863).
154+
155+
### Dual ES5 and ES2017 Builds
156+
157+
We significantly updated our internal tool and CI setup along the work on PR [#913](https://github.com/ethereumjs/ethereumjs-vm/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup.
158+
159+
Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce a separate `ES5` build distributed along using the `browser` directive as an entrypoint, see PR [#921](https://github.com/ethereumjs/ethereumjs-vm/pull/921). This will result in performance benefits for Node.js consumers, see [here](https://github.com/ethereumjs/merkle-patricia-tree/pull/117) for a releated discussion.
160+
161+
### Other Changes
162+
163+
**Features**
164+
165+
- Added `Block.genesis()` and `BlockHeader.genesis()` aliases to create a genesis block or header, PR [#883](https://github.com/ethereumjs/ethereumjs-vm/pull/883)
166+
- Added `DAO` hardfork support (check for `extraData` attribute if `DAO` HF is active), PR [#843](https://github.com/ethereumjs/ethereumjs-vm/pull/843)
167+
- Added the `calcDifficultyFromHeader` constructor option. If this `BlockHeader` is supplied, then the `difficulty` of the constructed `BlockHeader` will be set to the canonical difficulty (also if `difficulty` is set as parameter in the constructor). See [#929](https://github.com/ethereumjs/ethereumjs-vm/pull/929)
168+
- Added full uncle validation, which verifies if the uncles' `parentHash` points to the canonical chain, is not yet included and also is an uncle and not a canonical block. See PR [#935](https://github.com/ethereumjs/ethereumjs-vm/pull/935)
169+
- Additional consistency and validation checks in `Block.validateUncles()` for included uncle headers, PR [#935](https://github.com/ethereumjs/ethereumjs-vm/pull/935)
170+
171+
**Changes and Refactoring**
172+
173+
- Added Node `10`, `12` support, dropped Node `7` support, PR [#72](https://github.com/ethereumjs/ethereumjs-block/pull/72)
174+
- Passing in a blockchain is now optional on `Block.validate()`, PR [#883](https://github.com/ethereumjs/ethereumjs-vm/pull/883)
175+
- **Breaking**: `Block.validateTransactions(stringError: true)` now returns a `string[]`, PR [#883](https://github.com/ethereumjs/ethereumjs-vm/pull/883)
176+
- **Breaking**: Decoupling of the `Block.serialize()` and `Block.raw()` methods, `Block.serialize()` now always returns the RLP-encoded block (signature change!), `Block.raw()` always returns the pure `Buffer` array, PR [#883](https://github.com/ethereumjs/ethereumjs-vm/pull/883)
177+
- **Breaking**: `Block.toJSON()` now always returns the labeled `JSON` representation, removal of the `labeled` function parameter, PR [#883](https://github.com/ethereumjs/ethereumjs-vm/pull/883)
178+
- Updated `merkle-patricia-tree` dependency to `v4`, PR [#787](https://github.com/ethereumjs/ethereumjs-vm/pull/787)
179+
- Updated `ethereumjs-util` dependency to `v7`, PR [#748](https://github.com/ethereumjs/ethereumjs-vm/pull/748)
180+
- Removal of the `async` dependency, PR [#72](https://github.com/ethereumjs/ethereumjs-block/pull/72)
181+
182+
**CI and Testing**
183+
184+
- Browser test run on CI, PR [#72](https://github.com/ethereumjs/ethereumjs-block/pull/72)
185+
- Karma browser test run config modernization and simplification, PR [#72](https://github.com/ethereumjs/ethereumjs-block/pull/72)
186+
- Updated test source files to `TypeScript`, PR [#72](https://github.com/ethereumjs/ethereumjs-block/pull/72)
187+
188+
**Bug Fixes**
189+
190+
- Signature fix for pre-homestead blocks, PR [#67](https://github.com/ethereumjs/ethereumjs-block/issues/67)
191+
- Fixed bug where block options have not been passed on to the main constructor from the static factory methods, see PR [#941](https://github.com/ethereumjs/ethereumjs-vm/pull/941)
192+
9193
## 3.0.0-rc.1 - 2020-11-19
10194

11195
This is the first release candidate towards a final library release, see [beta.2](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblock%403.0.0-beta.2) and especially [beta.1](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblock%403.0.0-beta.1) release notes for an overview on the full changes since the last publicly released version.

packages/block/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ethereumjs/block",
3-
"version": "3.0.0-rc.1",
3+
"version": "3.0.0",
44
"description": "Provides Block serialization and help functions",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -39,8 +39,8 @@
3939
},
4040
"homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/block#readme",
4141
"dependencies": {
42-
"@ethereumjs/common": "2.0.0-rc.1",
43-
"@ethereumjs/tx": "3.0.0-rc.1",
42+
"@ethereumjs/common": "^2.0.0",
43+
"@ethereumjs/tx": "^3.0.0",
4444
"@types/bn.js": "^4.11.6",
4545
"ethereumjs-util": "^7.0.7",
4646
"merkle-patricia-tree": "^4.0.0"

packages/blockchain/CHANGELOG.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,95 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
(modification: no type change headlines) and this project adheres to
77
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

9+
## 5.0.0 - 2020-11-24
10+
11+
### New Package Name
12+
13+
**Attention!** This new version is part of a series of EthereumJS releases all moving to a new scoped package name format. In this case the library is renamed as follows:
14+
15+
- `ethereumjs-blockchain` -> `@ethereumjs/blockchain`
16+
17+
Please update your library references accordingly or install with:
18+
19+
```shell
20+
npm i @ethereumjs/blockchain
21+
```
22+
23+
### Library Promisification
24+
25+
The `Blockchain` library has been promisified and callbacks have been removed along PR [#833](https://github.com/ethereumjs/ethereumjs-vm/pull/833) and preceeding PR [#779](https://github.com/ethereumjs/ethereumjs-vm/pull/779).
26+
27+
Old API example:
28+
29+
```typescript
30+
blockchain.getBlock(blockId, (block) => {
31+
console.log(block)
32+
})
33+
```
34+
35+
New API example:
36+
37+
```typescript
38+
const block = await blockchain.getBlock(blockId)
39+
console.log(block)
40+
```
41+
42+
See `Blockchain` [README](https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/blockchain#example) for a complete example.
43+
44+
**Safe Static Constructor**
45+
46+
The library now has an additional safe static constructor `Blockchain.create()` which awaits the init method and throws if the init method throws:
47+
48+
```typescript
49+
import Blockchain from '@ethereumjs/blockchain'
50+
const common = new Common({ chain: 'ropsten' })
51+
const blockchain = await Blockchain.create({ common })
52+
```
53+
54+
This is the new recommended way to instantiate a `Blockchain` object, see PR [#930](https://github.com/ethereumjs/ethereumjs-vm/pull/930).
55+
56+
Constructor options (both for the static and the main constructor) for chain setup on all VM monorepo libraries have been simplified and the plain `chain` and `hardfork` options have been removed. Passing in a `Common` instance is now the single way to switch to a non-default chain (`mainnet`) or start a blockchain with a higher than `chainstart` hardfork, see PR [#863](https://github.com/ethereumjs/ethereumjs-vm/pull/863).
57+
58+
**Refactored Genesis Block Handling Mechanism**
59+
60+
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-vm/pull/930).
61+
62+
**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.
63+
64+
### Removed deprecated `validate` option
65+
66+
The deprecated `validate` option has been removed, please use `valdiateBlock` and `validatePow` for options when instantiating a new `Blockchain`.
67+
68+
### Dual ES5 and ES2017 Builds
69+
70+
We significantly updated our internal tool and CI setup along the work on PR [#913](https://github.com/ethereumjs/ethereumjs-vm/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup.
71+
72+
Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce a separate `ES5` build distributed along using the `browser` directive as an entrypoint, see PR [#921](https://github.com/ethereumjs/ethereumjs-vm/pull/921). This will result in performance benefits for Node.js consumers, see [here](https://github.com/ethereumjs/merkle-patricia-tree/pull/117) for a releated discussion.
73+
74+
### Other Changes
75+
76+
**Changes and Refactoring**
77+
78+
- **Breaking:** `validatePow` option has been renamed to `validateConsensus` to prepare for a future integration of non-PoW (PoA) consensus mechanisms, `validateConsensus` as well as `validateBlocks` options now throw when set to `true` for validation on a non-PoW chain (determined by `Common`, e.g. 'goerli'), see PR [#937](https://github.com/ethereumjs/ethereumjs-vm/pull/937)
79+
- Exposed private `Blockchain._getTd()` total difficulty function as `Blockchain.getTotalDifficulty()`, PR [#956](https://github.com/ethereumjs/ethereumjs-vm/issues/956)
80+
- Refactored `DBManager` with the introduction of an abstract DB operation handling mechanism, if you have modified `DBManager` in your code this will be a **potentially breaking** change for you, PR [#927](https://github.com/ethereumjs/ethereumjs-vm/pull/927)
81+
- Renaming of internal variables like `Blockchain._headBlock`, if you are using these variables in your code this will be a **potentially breaking** change for you, PR [#930](https://github.com/ethereumjs/ethereumjs-vm/pull/930)
82+
- Made internal `_` methods like `_saveHeads()` private, if you are using these functions in your code this will be a **potentially breaking** change for you, PR [#930](https://github.com/ethereumjs/ethereumjs-vm/pull/930)
83+
- Improved code documentation, PR [#930](https://github.com/ethereumjs/ethereumjs-vm/pull/930)
84+
- Fixed potential blockchain DB concurrency issues along PR [#930](https://github.com/ethereumjs/ethereumjs-vm/pull/930)
85+
- Use `@ethereumjs/block` `v3.0.0` block library version, PR [#883](https://github.com/ethereumjs/ethereumjs-vm/pull/883)
86+
- Removed `async` dependency, PR [#779](https://github.com/ethereumjs/ethereumjs-vm/pull/779)
87+
- Updated `ethereumjs-util` to v7, PR [#748](https://github.com/ethereumjs/ethereumjs-vm/pull/748)
88+
89+
**Bug Fixes**
90+
91+
- Fixed blockchain hanging forever in case code throws between a semaphore `lock`/`unlock`,
92+
Issue [#877](https://github.com/ethereumjs/ethereumjs-vm/issues/877)
93+
94+
**Testing and CI**
95+
96+
- Dedicated `blockchain` reorg test setup and executable test, PR [#926](https://github.com/ethereumjs/ethereumjs-vm/pull/926)
97+
998
## 5.0.0-rc.1 2020-11-19
1099

11100
This is the first release candidate towards a final library release, see [beta.2](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblockchain%405.0.0-beta.2) and especially [beta.1](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblockchain%405.0.0-beta.1) release notes for an overview on the full changes since the last publicly released version.

packages/blockchain/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ethereumjs/blockchain",
3-
"version": "5.0.0-rc.1",
3+
"version": "5.0.0",
44
"description": "A module to store and interact with blocks",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -36,9 +36,9 @@
3636
},
3737
"homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/blockchain#readme",
3838
"dependencies": {
39-
"@ethereumjs/block": "3.0.0-rc.1",
40-
"@ethereumjs/common": "2.0.0-rc.1",
41-
"@ethereumjs/ethash": "1.0.0-rc.1",
39+
"@ethereumjs/block": "^3.0.0",
40+
"@ethereumjs/common": "^2.0.0",
41+
"@ethereumjs/ethash": "^1.0.0",
4242
"ethereumjs-util": "^7.0.7",
4343
"level-mem": "^5.0.1",
4444
"lru-cache": "^5.1.1",

0 commit comments

Comments
 (0)