Releases: ethereumjs/ethereumjs-monorepo
@ethereumjs/block v3.0.0
New Package Name
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:
ethereumjs-block
->@ethereumjs/block
Please update your library references accordingly or install with:
npm i @ethereumjs/block
TypeScript/Library Import
This is the first TypeScript based release of the library, see PR #72.
The import structure has slightly changed along:
TypeScript
import { BlockHeader } from 'ethereumjs-block'
import { Block } from 'ethereumjs-block'
JavaScript/Node.js
const BlockHeader = require('ethereumjs-block').BlockHeader
const Block = require('ethereumjs-block').Block
The library now also comes with a type declaration file distributed along with the package published.
Major Refactoring - Breaking Changes
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 (Promises) and PR #883 (refactoring of API and internal code structure).
New Constructor Params
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.
The old direct constructor usage is now discouraged in favor of different dedicated static factory methods to create new objects.
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.
BlockHeader Class
There are three new factory methods to create a new BlockHeader
:
- Pass in a Header-attribute named dictionary to
BlockHeader.fromHeaderData(headerData: HeaderData = {}, opts?: BlockOptions)
:
const headerData = {
number: 15,
parentHash: '0x6bfee7294bf44572b7266358e627f3c35105e1c3851f3de09e6d646f955725a7',
difficulty: 131072,
gasLimit: 8000000,
timestamp: 1562422144,
}
const header = BlockHeader.fromHeaderData(headerData)
- Create a
BlockHeader
from an RLP-serialized headerBuffer
withBlockHeader.fromRLPSerializedHeader(serialized: Buffer, opts: BlockOptions)
.
const serialized = Buffer.from(
'f901f7a06bfee7294bf44572b7266358e627f3c35105e1c3851f3de09e6d646f955725a7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200000f837a120080845d20ab8080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000',
'hex'
)
const header = BlockHeader.fromRLPSerializedHeader(serialized)
- Create a
BlockHeader
from an array ofBuffer
values, you can do a first short roundtrip test with:
const valuesArray = header.raw()
BlockHeader.fromValuesArray(valuesArray)
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
.
Block Class
There are analogue new static factories for the Block
class:
Block.fromBlockData(blockData: BlockData = {}, opts?: BlockOptions)
Block.fromRLPSerializedBlock(serialized: Buffer, opts?: BlockOptions)
Block.fromValuesArray(values: BlockBuffer, opts?: BlockOptions)
Learn more about the full API in the docs.
Immutability
The returned block is now frozen and immutable. To work with a maliable block, copy it with const fakeBlock = Object.create(block)
.
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.
Promise-based API
The API of this library is now completely promise-based and the old callback-style interface has been dropped.
This affects the following methods of the API now being defined as async
and returning a Promise
:
Header Class
BlockHeader.validate(blockchain: Blockchain, height?: BN): Promise<void>
Block Class
Block.genTxTrie(): Promise<void>
Block.validate(blockChain: Blockchain): Promise<void>
Block.validateUncles(blockchain: Blockchain): Promise<void>
Usage example:
try {
await block.validate(blockchain)
// Block validation has passed
} catch (err) {
// handle errors appropriately
}
Header Validation Methods > Signature Changes
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
:
BlockHeader.canonicalDifficulty(parentBlockHeader: BlockHeader): BN
BlockHeader.validateDifficulty(parentBlockHeader: BlockHeader): boolean
BlockHeader.validateGasLimit(parentBlockHeader: BlockHeader): boolean
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.
Breaking: Note that canonicalDifficulty()
and validateDifficulty()
in block and header now throw on non-PoW chains, see PR #937.
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
New Default Hardfork
Breaking: The default HF on the library has been updated from petersburg
to istanbul
, see PR #906.
The HF setting is now automatically taken from the HF set for Common.DEAULT_HARDFORK
, see PR #863.
Dual ES5 and ES2017 Builds
We significantly updated our internal tool and CI setup along the work on PR #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 a separate ES5
build distributed along using the browser
directive as an entrypoint, see PR #921. This will result in performance benefits for Node.js consumers, see here for a releated discussion.
Other Changes
Features
- Added
Block.genesis()
andBlockHeader.genesis()
aliases to create a genesis block or header, PR #883 - Added
DAO
hardfork support (check forextraData
attribute ifDAO
HF is active), PR #843 - Added the
calcDifficultyFromHeader
constructor option. If thisBlockHeader
is supplied, then thedifficulty
of the constructedBlockHeader
will be set to the canonical difficulty (also ifdifficulty
is set as parameter in the constructor). See #929 - 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 - Additional consistency and validation checks in
Block.validateUncles()
for included uncle headers, PR #935
Changes and Refactoring
- Added Node
10
,12
support, dropped Node7
support, PR #72 - Passing in a blockchain is now optional on
Block.validate()
, PR #883 - Breaking:
Block.validateTransactions(stringError: true)
now returns astring[]
, PR #883 - Breaking: Decoupling of the
Block.serialize()
andBlock.raw()
methods,Block.serialize()
now always returns the RLP-encoded block (signature change!),Block.raw()
always returns the pureBuffer
array, PR #883 - Breaking:
Block.toJSON()
now always returns the labeledJSON
representation, removal of thelabeled
function parameter, PR #883 - Updated
merkle-patricia-tree
dependency tov4
, PR #787 - Updated
ethereumjs-util
d...
@ethereumjs/vm v5.0.0-rc.1
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta and RC
Releases feedback issue #923 or our Discord channel.
This is the first release candidate towards a final library release, see beta.2 and especially beta.1 release notes for an overview on the full changes since the last publicly released version.
@ethereumjs/tx v3.0.0-rc.1
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta and RC
Releases feedback issue #923 or our Discord channel.
This is the first release candidate towards a final library release, see beta.2 and especially beta.1 release notes for an overview on the full changes since the last publicly released version.
- Dropped
ethereumjs-testing
dev dependency, PR #953
@ethereumjs/ethash v1.0.0-rc.1
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta and RC
Releases feedback issue #923 or our Discord channel.
This is the first release candidate towards a final library release, see beta.1 release notes for an overview on the full changes since the last publicly released version.
No changes since beta.1
release.
@ethereumjs/common v2.0.0-rc.1
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta and RC
Releases feedback issue #923 or our Discord channel.
This is the first release candidate towards a final library release, see beta.2 and especially beta.1 release notes for an overview on the full changes since the last publicly released version.
No changes since beta.2
release.
@ethereumjs/blockchain v5.0.0-rc.1
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta and RC
Releases feedback issue #923 or our Discord channel.
This is the first release candidate towards a final library release, see beta.2 and especially beta.1 release notes for an overview on the full changes since the last publicly released version.
- Exposed private
Blockchain._getTd()
total difficulty function asBlockchain.getTotalDifficulty()
, PR #956
@ethereumjs/block v3.0.0-rc.1
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta and RC
Releases feedback issue #923 or our Discord channel.
This is the first release candidate towards a final library release, see beta.2 and especially beta.1 release notes for an overview on the full changes since the last publicly released version.
- Additional consistency and validation checks in
Block.validateUncles()
for included uncle headers, PR #935
@ethereumjs/vm v5.0.0-beta.2
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta
Releases feedback issue #923 or our Discord channel.
This is the second beta release towards a final library release, see beta.1 release notes for an overview on the full changes since the last publicly released version.
@ethereumjs/tx v3.0.0-beta.2
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta
Releases feedback issue #923 or our Discord channel.
This is the second beta release towards a final library release, see beta.1 release notes for an overview on the full changes since the last publicly released version.
- Added
freeze
option to allow for transaction freeze deactivation (e.g. to allow for subclassing tx and adding additional parameters), see PR #941 - Breaking: Reworked constructor to take in data as a
TxData
typed dictionary instead of single values, theTx.fromTxData()
factory method becomes an alias for the constructor with this change, see PR #944
@ethereumjs/common v2.0.0-beta.2
ATTENTION: This is a pre-release and only meant to be used for testing purposes.
Do not use in production!
Feedback is extremely welcome, please use the beta
Releases feedback issue #923 or our Discord channel.
This is the second beta release towards a final library release, see beta.1 release notes for an overview on the full changes since the last publicly released version.
- Added consensus information to chains, new functions
Common.consensusType()
for consensus type access ("pow" or "poa") andCommon.consensusAlgorithm()
to get the associated algorithm or protocol (e.g. "ethash" PoW algorithm or "clique" PoA protocol), see PR #937