Skip to content

Commit

Permalink
Merge pull request #946 from ethereumjs/beta.2-releases
Browse files Browse the repository at this point in the history
Beta.2 Releases
  • Loading branch information
holgerd77 authored Nov 12, 2020
2 parents daf1bb7 + 96504cc commit d8e7066
Show file tree
Hide file tree
Showing 36 changed files with 474 additions and 302 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ This monorepo uses [Lerna](https://lerna.js.org/). It links the local packages t
TLDR: Setup
```sh
npm install
npm build
npm run build
```

TLDR: To update dependencies and (re-)link packages
```sh
npm run bootstrap
npm build
npm run build
```

Above is the quickest way to set you up. Going down the road, there are two sets of commands: *project* and *package-specific* commands. You can find them at `./package.json` and `./packages/*/package.json`, respectively. Here's a breakdown:
Expand Down
4 changes: 3 additions & 1 deletion packages/block/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 3.0.0-beta.2 - UNRELEASED
## 3.0.0-beta.2 - 2020-11-12

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.

- Added `freeze` option to allow for block freeze deactivation (e.g. to allow for subclassing block and adding additional parameters), see PR [#941](https://github.com/ethereumjs/ethereumjs-vm/pull/941)
- **Breaking:** Difficulty-depending methods `canonicalDifficulty()` and `validateDifficulty()` in block and header now throw on non-PoW chains, see PR [#937](https://github.com/ethereumjs/ethereumjs-vm/pull/937)
Expand Down
36 changes: 34 additions & 2 deletions packages/block/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,45 @@

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 preceeding release.

# INSTALL

`npm install @ethereumjs/block`

# BROWSER
# USAGE

There are three static factories to instantiate a `Block` or `BlockHeader`:

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

Instantiation Example:

```typescript
const headerData = {
number: 15,
parentHash: '0x6bfee7294bf44572b7266358e627f3c35105e1c3851f3de09e6d646f955725a7',
difficulty: 131072,
gasLimit: 8000000,
timestamp: 1562422144,
}
const header = BlockHeader.fromHeaderData(headerData)
```

Properties of a `Block` or `BlockHeader` object are frozen with `Object.freeze()` which gives you enhanced security and consistency properties when working with the instantiated object. This behavior can be modified using the `freeze` option in the constructor if needed.

API Usage Example:

This module works with `browserify`.
```typescript
try {
await block.validate(blockchain)
// Block validation has passed
} catch (err) {
// handle errors appropriately
}
```

# API

Expand Down
6 changes: 3 additions & 3 deletions packages/block/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ethereumjs/block",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.2",
"description": "Provides Block serialization and help functions",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -39,8 +39,8 @@
},
"homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/block#synopsis",
"dependencies": {
"@ethereumjs/common": "2.0.0-beta.1",
"@ethereumjs/tx": "3.0.0-beta.1",
"@ethereumjs/common": "2.0.0-beta.2",
"@ethereumjs/tx": "3.0.0-beta.2",
"@types/bn.js": "^4.11.6",
"ethereumjs-util": "^7.0.7",
"merkle-patricia-tree": "^4.0.0"
Expand Down
6 changes: 2 additions & 4 deletions packages/blockchain/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 5.0.0-beta.2 - UNRELEASED
## 5.0.0-beta.2 - 2020-11-12

This is the second beta release towards a final `v5.0.0` `Blockchain` library release, see [v5.0.0-beta.1 release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblockchain%405.0.0-beta.1) for an overview on the full changes since the last publicly released version.
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%2Fblockchain%405.0.0-beta.1) for an overview on the full changes since the last publicly released version.

This release introduces **new breaking changes**, so please carefully read the additional release note sections!

Expand Down Expand Up @@ -122,8 +122,6 @@ in performance benefits for Node.js consumers, see [here](https://github.com/eth
- Fixed blockchain hanging forever in case code throws between a semaphore `lock`/`unlock`,
Issue [#877](https://github.com/ethereumjs/ethereumjs-vm/issues/877)

[5.0.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblockchain%404.0.2...%40ethereumjs%2Fblockchain%405.0.0

## 4.0.4 - 2020-07-27

This release replaces the tilde (`~`) dependency from `ethereumjs-util` for a caret (`^`) one, meaning that any update to `ethereumjs-util` v6 will also be available for this library.
Expand Down
18 changes: 11 additions & 7 deletions packages/blockchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@

A module to store and interact with blocks.

# INSTALL

`npm install ethereumjs-blockchain`
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 preceeding release.

# API
# INSTALL

[Documentation](./docs/README.md)
`npm install @ethereumjs/blockchain`

# EXAMPLE
# USAGE

The following is an example to iterate through an existing Geth DB (needs `level` to be installed separately).

Expand All @@ -29,8 +27,10 @@ const level = require('level')

const gethDbPath = './chaindata' // Add your own path here. It will get modified, see remarks.

const common = new Common({ chain: 'ropsten' })
const db = level(gethDbPath)
const blockchain = new Blockchain({ db })
// Use the safe static constructor which awaits the init method
const blockchain = Blockchain.create({ common, db })

blockchain.iterator('i', (block) => {
const blockNumber = block.header.number.toString()
Expand All @@ -41,6 +41,10 @@ blockchain.iterator('i', (block) => {

**WARNING**: Since `@ethereumjs/blockchain` is also doing write operations on the DB for safety reasons only run this on a copy of your database, otherwise this might lead to a compromised DB state.

# API

[Documentation](./docs/README.md)

# EthereumJS

See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices.
Expand Down
6 changes: 3 additions & 3 deletions packages/blockchain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ethereumjs/blockchain",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"description": "A module to store and interact with blocks",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -36,8 +36,8 @@
},
"homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/blockchain#synopsis",
"dependencies": {
"@ethereumjs/block": "3.0.0-beta.1",
"@ethereumjs/common": "2.0.0-beta.1",
"@ethereumjs/block": "3.0.0-beta.2",
"@ethereumjs/common": "2.0.0-beta.2",
"@ethereumjs/ethash": "1.0.0-beta.1",
"ethereumjs-util": "^7.0.7",
"level-mem": "^5.0.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 2.0.0-beta.2 - UNRELEASED
## 2.0.0-beta.2 - 2020-11-12

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%2Fcommon%402.0.0-beta.1) 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") and `Common.consensusAlgorithm()` to get the associated algorithm or protocol (e.g. "ethash" PoW algorithm or "clique" PoA protocol), see PR [#937](https://github.com/ethereumjs/ethereumjs-vm/pull/937)

Expand Down
42 changes: 25 additions & 17 deletions packages/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Resources common to all Ethereum implementations.

Succeeds the old [ethereum/common](https://github.com/ethereumjs/common/) library.
Note: this `README` reflects the state of the library from `v2.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-common) for an introduction on the last preceeding release.

# INSTALL

Expand All @@ -20,30 +20,36 @@ All parameters can be accessed through the `Common` class which can be required
main package and instantiated either with just the `chain` (e.g. 'mainnet') or the `chain`
together with a specific `hardfork` provided.

If no hardfork is provided the common is initialized with the default hardfork.

Current `DEFAULT_HARDFORK`: `istanbul`

Here are some simple usage examples:

```javascript
const Common = require('@ethereumjs/common')
```typescript
import Common from '@ethereumjs/common'

// Instantiate with only the chain
let c = new Common({ chain: 'ropsten' })
c.param('gasPrices', 'ecAddGas', 'byzantium') // 500
// Instantiate with the chain (and the default hardfork)
const c = new Common({ chain: 'ropsten' })
c.param('gasPrices', 'ecAddGas') // 500

// Chain and hardfork provided
c = new Common({ chain: 'ropsten', hardfork: 'byzantium' })
c.param('pow', 'minerReward') // 3000000000000000000

// Instantiate with an EIP activated
const c = new Common({ chain: 'mainnet', eips: [2537] })

// Access genesis data for Ropsten network
c.genesis().hash // 0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d

// Get bootstrap nodes for chain/network
c.bootstrapNodes() // Array with current nodes
```

It is encouraged to also explicitly set the `supportedHardforks` if the initializing library
only supports a certain range of `hardforks`:
If the initializing library only supports a certain range of `hardforks` you can use the `supportedHardforks` option to restrict hardfork access on the `Common` instance:

```javascript
```typescript
let c = new Common({
chain: 'ropsten',
supportedHardforks: ['byzantium', 'constantinople', 'petersburg'],
Expand Down Expand Up @@ -77,13 +83,16 @@ library supported:
- `byzantium`
- `constantinople`
- `petersburg` (aka `constantinopleFix`, apply together with `constantinople`)
- `istanbul` (`DEFAULT_HARDFORK`)
- `muirGlacier`
- `istanbul` (`DEFAULT_HARDFORK` (`v2.0.0` release series))
- `muirGlacier` (since `v1.5.0`)

## Future Hardforks

The `muirGlacier` HF delaying the difficulty bomb and scheduled for January 2020
is supported by the library since `v1.5.0`.
General support for the `berlin` hardfork has been added along `v2.0.0`, specification of the hardfork regarding EIPs included was not finalized upon release date.

Currently supported `berlin` EIPs:

- `EIP-2315`

## Parameter Access

Expand All @@ -102,9 +111,6 @@ hardfork.
The hardfork-specific json files only contain the deltas from `chainstart` and
shouldn't be accessed directly until you have a specific reason for it.

Note: The list of `gasPrices` and gas price changes on hardforks is consistent
but not complete, so there are currently gas price values missing (PRs welcome!).

# Chain Params

Supported chains:
Expand All @@ -113,14 +119,16 @@ Supported chains:
- `ropsten`
- `rinkeby`
- `kovan`
- `goerli` (final configuration since `v1.1.0`)
- `goerli`
- Private/custom chain parameters

The following chain-specific parameters are provided:

- `name`
- `chainId`
- `networkId`
- `consensusType` (e.g. `pow` or `poa`)
- `consensusAlgorithm` (e.g. `ethash` or `clique`)
- `genesis` block header values
- `hardforks` block numbers
- `bootstrapNodes` list
Expand Down
34 changes: 32 additions & 2 deletions packages/common/docs/classes/_index_.common.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Common class to access chain and hardfork parameters
* [bootstrapNodes](_index_.common.md#bootstrapnodes)
* [chainId](_index_.common.md#chainid)
* [chainName](_index_.common.md#chainname)
* [consensusAlgorithm](_index_.common.md#consensusalgorithm)
* [consensusType](_index_.common.md#consensustype)
* [eips](_index_.common.md#eips)
* [forkHash](_index_.common.md#forkhash)
* [genesis](_index_.common.md#genesis)
Expand Down Expand Up @@ -269,6 +271,34 @@ chain name (lower case)

___

### consensusAlgorithm

▸ **consensusAlgorithm**(): *string*

*Defined in [index.ts:649](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L649)*

Returns the concrete consensus implementation
algorithm or protocol for the network
e.g. "ethash" for "pow" consensus type or
"clique" for "poa" consensus type

**Returns:** *string*

___

### consensusType

▸ **consensusType**(): *string*

*Defined in [index.ts:639](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L639)*

Returns the consensus type of the network
Possible values: "pow"|"poa"

**Returns:** *string*

___

### eips

▸ **eips**(): *number[]*
Expand Down Expand Up @@ -338,13 +368,13 @@ ___

### hardfork

**hardfork**(): *string | null*
▸ **hardfork**(): *string*

*Defined in [index.ts:599](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L599)*

Returns the hardfork set

**Returns:** *string | null*
**Returns:** *string*

Hardfork name

Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ethereumjs/common",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "Resources common to all Ethereum implementations",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export default class Common {
* Returns the hardfork set
* @returns Hardfork name
*/
hardfork(): string | null {
hardfork(): string {
return this._hardfork
}

Expand Down
12 changes: 7 additions & 5 deletions packages/ethash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@

Implements [Ethash](https://github.com/ethereum/wiki/wiki/Ethash).

Note: this `README` reflects the state of the library from `v1.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethashjs) for an introduction on the last preceeding release.

# INSTALL

`npm install ethashjs`
`npm install @ethereumjs/ethash`

# USAGE

```javascript
const Ethash = require('@ethereumjs/ethash')
const Block = require('@ethereumjs/block')
```typescript
import Ethash from '@ethereumjs/ethash'
import { Block } from '@ethereumjs/block'
const level = require('level-mem')

const cacheDB = level()
Expand All @@ -25,7 +27,7 @@ const ethash = new Ethash(cacheDB)
const validblockRlp =
'f90667f905fba0a8d5b7a4793baaede98b5236954f634a0051842df6a252f6a80492fd888678bda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0f93c8db1e931daa2e22e39b5d2da6fb4074e3d544094857608536155e3521bc1a0bb7495628f9160ddbcf6354380ee32c300d594e833caec3a428041a66e7bade1a0c7778a7376099ee2e5c455791c1885b5c361b95713fddcbe32d97fd01334d296b90100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000400000000000000000000000000000000000000000000000000000008302000001832fefd882560b84559c17b9b9040001020304050607080910111213141516171819202122232410000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000a09c7b47112a3afb385c12924bf6280d273c106eea7caeaf5131d8776f61056c148876ae05d46b58d1fff866f864800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d8785012a05f200801ba01d2c92cfaeb04e53acdff2b5d42005ff6aacdb0105e64eb8c30c273f445d2782a01e7d50ffce57840360c57d94977b8cdebde614da23e8d1e77dc07928763cfe21c0'

const validBlock = new Block(Buffer.from(validblockRlp, 'hex'))
const validBlock = Block.fromRLPSerializedBlock(Buffer.from(validblockRlp, 'hex'))

const result = await ethash.verifyPOW(validBlock)
console.log(result) // => true
Expand Down
Loading

0 comments on commit d8e7066

Please sign in to comment.