Skip to content

Commit c9c76bb

Browse files
authored
Merge pull request #958 from ethereumjs/rc.1-releases
Rc.1 Releases
2 parents fc3a70f + 791d9f8 commit c9c76bb

34 files changed

+432
-332
lines changed

packages/block/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ 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-rc.1 - 2020-11-19
10+
11+
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.
12+
13+
- Additional consistency and validation checks in `Block.validateUncles()` for included uncle headers, PR [#935](https://github.com/ethereumjs/ethereumjs-vm/pull/935)
14+
915
## 3.0.0-beta.2 - 2020-11-12
1016

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

packages/block/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ Note: this `README` reflects the state of the library from `v3.0.0` onwards. See
1717

1818
# USAGE
1919

20-
There are three static factories to instantiate a `Block` or `BlockHeader`:
20+
There are three static factories to instantiate a `Block`:
2121

2222
- `Block.fromBlockData(blockData: BlockData = {}, opts?: BlockOptions)`
2323
- `Block.fromRLPSerializedBlock(serialized: Buffer, opts?: BlockOptions)`
2424
- `Block.fromValuesArray(values: BlockBuffer, opts?: BlockOptions)`
2525

26+
For `BlockHeader` instantiation analogue factory methods exists, see API docs linked below.
27+
2628
Instantiation Example:
2729

2830
```typescript
31+
import { BlockHeader } from '@ethereumjs/block'
32+
2933
const headerData = {
3034
number: 15,
3135
parentHash: '0x6bfee7294bf44572b7266358e627f3c35105e1c3851f3de09e6d646f955725a7',

packages/block/docs/classes/_block_.block.md

Lines changed: 81 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ An object that represents the block.
3232
* [serialize](_block_.block.md#serialize)
3333
* [toJSON](_block_.block.md#tojson)
3434
* [validate](_block_.block.md#validate)
35+
* [validateData](_block_.block.md#validatedata)
3536
* [validateDifficulty](_block_.block.md#validatedifficulty)
3637
* [validateGasLimit](_block_.block.md#validategaslimit)
3738
* [validateTransactions](_block_.block.md#validatetransactions)
@@ -49,7 +50,7 @@ An object that represents the block.
4950

5051
\+ **new Block**(`header?`: [BlockHeader](_header_.blockheader.md), `transactions`: Transaction[], `uncleHeaders`: [BlockHeader](_header_.blockheader.md)[], `opts`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)*
5152

52-
*Defined in [block.ts:82](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L82)*
53+
*Defined in [block.ts:92](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L92)*
5354

5455
This constructor takes the values, validates them, assigns them and freezes the object.
5556
Use the static factory methods to assist in creating a Block object from varying data types and options.
@@ -111,7 +112,7 @@ ___
111112

112113
**canonicalDifficulty**(`parentBlock`: [Block](_block_.block.md)): *BN*
113114

114-
*Defined in [block.ts:245](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L245)*
115+
*Defined in [block.ts:286](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L286)*
115116

116117
Returns the canonical difficulty for this block.
117118

@@ -129,7 +130,7 @@ ___
129130

130131
**genTxTrie**(): *Promise‹void›*
131132

132-
*Defined in [block.ts:137](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L137)*
133+
*Defined in [block.ts:150](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L150)*
133134

134135
Generates transaction trie for validation.
135136

@@ -141,7 +142,7 @@ ___
141142

142143
**hash**(): *Buffer*
143144

144-
*Defined in [block.ts:116](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L116)*
145+
*Defined in [block.ts:129](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L129)*
145146

146147
Produces a hash the RLP of the block.
147148

@@ -153,7 +154,7 @@ ___
153154

154155
**isGenesis**(): *boolean*
155156

156-
*Defined in [block.ts:123](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L123)*
157+
*Defined in [block.ts:136](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L136)*
157158

158159
Determines if this block is the genesis block.
159160

@@ -165,7 +166,7 @@ ___
165166

166167
**raw**(): *[BlockBuffer](../modules/_index_.md#blockbuffer)*
167168

168-
*Defined in [block.ts:105](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L105)*
169+
*Defined in [block.ts:118](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L118)*
169170

170171
Returns a Buffer Array of the raw Buffers of this block, in order.
171172

@@ -177,7 +178,7 @@ ___
177178

178179
**serialize**(): *Buffer*
179180

180-
*Defined in [block.ts:130](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L130)*
181+
*Defined in [block.ts:143](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L143)*
181182

182183
Returns the rlp encoding of the block.
183184

@@ -189,7 +190,7 @@ ___
189190

190191
**toJSON**(): *[JsonBlock](../interfaces/_index_.jsonblock.md)*
191192

192-
*Defined in [block.ts:270](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L270)*
193+
*Defined in [block.ts:312](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L312)*
193194

194195
Returns the block in JSON format.
195196

@@ -199,17 +200,41 @@ ___
199200

200201
### validate
201202

202-
**validate**(`blockchain?`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›*
203+
**validate**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›*
204+
205+
*Defined in [block.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L209)*
203206

204-
*Defined in [block.ts:188](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L188)*
207+
Performs the following consistency checks on the block:
205208

206-
Validates the block, throwing if invalid.
209+
- Value checks on the header fields
210+
- Signature and gasLimit validation for included txs
211+
- Validation of the tx trie
212+
- Consistency checks and header validation of included uncles
213+
214+
Throws if invalid.
207215

208216
**Parameters:**
209217

210218
Name | Type | Description |
211219
------ | ------ | ------ |
212-
`blockchain?` | [Blockchain](../interfaces/_index_.blockchain.md) | additionally validate against a @ethereumjs/blockchain |
220+
`blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | validate against a @ethereumjs/blockchain |
221+
222+
**Returns:** *Promise‹void›*
223+
224+
___
225+
226+
### validateData
227+
228+
**validateData**(): *Promise‹void›*
229+
230+
*Defined in [block.ts:222](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L222)*
231+
232+
Validates the block data, throwing if invalid.
233+
This can be checked on the Block itself without needing access to any parent block
234+
It checks:
235+
- All transactions are valid
236+
- The transactions trie is valid
237+
- The uncle hash is valid
213238

214239
**Returns:** *Promise‹void›*
215240

@@ -219,7 +244,7 @@ ___
219244

220245
**validateDifficulty**(`parentBlock`: [Block](_block_.block.md)): *boolean*
221246

222-
*Defined in [block.ts:254](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L254)*
247+
*Defined in [block.ts:295](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L295)*
223248

224249
Checks that the block's `difficulty` matches the canonical difficulty.
225250

@@ -237,9 +262,10 @@ ___
237262

238263
**validateGasLimit**(`parentBlock`: [Block](_block_.block.md)): *boolean*
239264

240-
*Defined in [block.ts:263](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L263)*
265+
*Defined in [block.ts:305](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L305)*
241266

242-
Validates the gasLimit.
267+
Validates if the block gasLimit remains in the
268+
boundaries set by the protocol.
243269

244270
**Parameters:**
245271

@@ -255,15 +281,15 @@ ___
255281

256282
**validateTransactions**(): *boolean*
257283

258-
*Defined in [block.ts:167](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L167)*
284+
*Defined in [block.ts:181](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L181)*
259285

260-
Validates the transactions.
286+
Validates transaction signatures and minimum gas requirements.
261287

262288
**Returns:** *boolean*
263289

264290
**validateTransactions**(`stringError`: false): *boolean*
265291

266-
*Defined in [block.ts:168](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L168)*
292+
*Defined in [block.ts:182](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L182)*
267293

268294
**Parameters:**
269295

@@ -275,7 +301,7 @@ Name | Type |
275301

276302
**validateTransactions**(`stringError`: true): *string[]*
277303

278-
*Defined in [block.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L169)*
304+
*Defined in [block.ts:183](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L183)*
279305

280306
**Parameters:**
281307

@@ -291,27 +317,39 @@ ___
291317

292318
**validateTransactionsTrie**(): *Promise‹boolean›*
293319

294-
*Defined in [block.ts:150](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L150)*
320+
*Defined in [block.ts:164](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L164)*
295321

296-
Validates the transaction trie.
322+
Validates the transaction trie by generating a trie
323+
and do a check on the root hash.
297324

298325
**Returns:** *Promise‹boolean›*
299326

300327
___
301328

302329
### validateUncles
303330

304-
**validateUncles**(`blockchain?`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›*
331+
**validateUncles**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›*
332+
333+
*Defined in [block.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L262)*
305334

306-
*Defined in [block.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L221)*
335+
Consistency checks and header validation for uncles included,
336+
in the block, if any.
307337

308-
Validates the uncles that are in the block, if any. This method throws if they are invalid.
338+
Throws if invalid.
339+
340+
The rules of uncles are the following:
341+
Uncle Header is a valid header.
342+
Uncle Header is an orphan, i.e. it is not one of the headers of the canonical chain.
343+
Uncle Header has a parentHash which points to the canonical chain. This parentHash is within the last 7 blocks.
344+
Uncle Header is not already included as uncle in another block.
345+
Header has at most 2 uncles.
346+
Header does not count an uncle twice.
309347

310348
**Parameters:**
311349

312350
Name | Type | Description |
313351
------ | ------ | ------ |
314-
`blockchain?` | [Blockchain](../interfaces/_index_.blockchain.md) | additionally validate against a @ethereumjs/blockchain |
352+
`blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | additionally validate against an @ethereumjs/blockchain instance |
315353

316354
**Returns:** *Promise‹void›*
317355

@@ -321,7 +359,7 @@ ___
321359

322360
**validateUnclesHash**(): *boolean*
323361

324-
*Defined in [block.ts:211](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L211)*
362+
*Defined in [block.ts:241](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L241)*
325363

326364
Validates the uncle's hash.
327365

@@ -331,7 +369,7 @@ ___
331369

332370
### `Static` fromBlockData
333371

334-
**fromBlockData**(`blockData`: [BlockData](../interfaces/_index_.blockdata.md), `opts`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
372+
**fromBlockData**(`blockData`: [BlockData](../interfaces/_index_.blockdata.md), `opts?`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
335373

336374
*Defined in [block.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L20)*
337375

@@ -340,51 +378,51 @@ ___
340378
Name | Type | Default |
341379
------ | ------ | ------ |
342380
`blockData` | [BlockData](../interfaces/_index_.blockdata.md) | {} |
343-
`opts` | [BlockOptions](../interfaces/_index_.blockoptions.md) | {} |
381+
`opts?` | [BlockOptions](../interfaces/_index_.blockoptions.md) | - |
344382

345383
**Returns:** *[Block](_block_.block.md)‹›*
346384

347385
___
348386

349387
### `Static` fromRLPSerializedBlock
350388

351-
**fromRLPSerializedBlock**(`serialized`: Buffer, `opts`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
389+
**fromRLPSerializedBlock**(`serialized`: Buffer, `opts?`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
352390

353-
*Defined in [block.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L42)*
391+
*Defined in [block.ts:46](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L46)*
354392

355393
**Parameters:**
356394

357-
Name | Type | Default |
358-
------ | ------ | ------ |
359-
`serialized` | Buffer | - |
360-
`opts` | [BlockOptions](../interfaces/_index_.blockoptions.md) | {} |
395+
Name | Type |
396+
------ | ------ |
397+
`serialized` | Buffer |
398+
`opts?` | [BlockOptions](../interfaces/_index_.blockoptions.md) |
361399

362400
**Returns:** *[Block](_block_.block.md)‹›*
363401

364402
___
365403

366404
### `Static` fromValuesArray
367405

368-
**fromValuesArray**(`values`: [BlockBuffer](../modules/_index_.md#blockbuffer), `opts`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
406+
**fromValuesArray**(`values`: [BlockBuffer](../modules/_index_.md#blockbuffer), `opts?`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
369407

370-
*Defined in [block.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L52)*
408+
*Defined in [block.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L56)*
371409

372410
**Parameters:**
373411

374-
Name | Type | Default |
375-
------ | ------ | ------ |
376-
`values` | [BlockBuffer](../modules/_index_.md#blockbuffer) | - |
377-
`opts` | [BlockOptions](../interfaces/_index_.blockoptions.md) | {} |
412+
Name | Type |
413+
------ | ------ |
414+
`values` | [BlockBuffer](../modules/_index_.md#blockbuffer) |
415+
`opts?` | [BlockOptions](../interfaces/_index_.blockoptions.md) |
378416

379417
**Returns:** *[Block](_block_.block.md)‹›*
380418

381419
___
382420

383421
### `Static` genesis
384422

385-
**genesis**(`blockData`: [BlockData](../interfaces/_index_.blockdata.md), `opts`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
423+
**genesis**(`blockData`: [BlockData](../interfaces/_index_.blockdata.md), `opts?`: [BlockOptions](../interfaces/_index_.blockoptions.md)): *[Block](_block_.block.md)‹›*
386424

387-
*Defined in [block.ts:79](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L79)*
425+
*Defined in [block.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L89)*
388426

389427
Alias for Block.fromBlockData() with initWithGenesisHeader set to true.
390428

@@ -393,6 +431,6 @@ Alias for Block.fromBlockData() with initWithGenesisHeader set to true.
393431
Name | Type | Default |
394432
------ | ------ | ------ |
395433
`blockData` | [BlockData](../interfaces/_index_.blockdata.md) | {} |
396-
`opts` | [BlockOptions](../interfaces/_index_.blockoptions.md) | {} |
434+
`opts?` | [BlockOptions](../interfaces/_index_.blockoptions.md) | - |
397435

398436
**Returns:** *[Block](_block_.block.md)‹›*

0 commit comments

Comments
 (0)