Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Merge f3e235f into bc2fa6f
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Jan 9, 2019
2 parents bc2fa6f + f3e235f commit 156ad99
Show file tree
Hide file tree
Showing 49 changed files with 1,606 additions and 916 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ build/Release
node_modules
package-lock.json


dist
3 changes: 3 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@ethereumjs/config-nyc"
}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.vscode
package.json
dist
.nyc_output
67 changes: 37 additions & 30 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,88 @@
# Changelog

All notable changes to this project will be documented in this file.

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
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).


## [0.6.1] - 2018-11-28
- Experimental support for the [Goerli](https://github.com/goerli/testnet) cross-client ``PoA`` testnet (``chains/goerli.json``), see PR [#31](https://github.com/ethereumjs/ethereumjs-common/pull/31)
- Unified hex-prefixing (so always prefixing with ``0x``) of account addresses in genesis files (fixes an issue with state root computation on other libraries), see PR [#32](https://github.com/ethereumjs/ethereumjs-common/issues/32)

- Experimental support for the [Goerli](https://github.com/goerli/testnet) cross-client `PoA` testnet (`chains/goerli.json`), see PR [#31](https://github.com/ethereumjs/ethereumjs-common/pull/31)
- Unified hex-prefixing (so always prefixing with `0x`) of account addresses in genesis files (fixes an issue with state root computation on other libraries), see PR [#32](https://github.com/ethereumjs/ethereumjs-common/issues/32)

[0.6.1]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.6.0...v0.6.1

## [0.6.0] - 2018-10-11
Parameter support for the ``Constantinople`` hardfork (see ``hardforks/constantinople.json``):
- Added ``SSTORE`` gas/refund prices (``EIP-1283``), PR [#27](https://github.com/ethereumjs/ethereumjs-common/pull/27)
- Added Block Reward Adjustment (``EIP-1234``), PR [#26](https://github.com/ethereumjs/ethereumjs-common/pull/26)

Parameter support for the `Constantinople` hardfork (see `hardforks/constantinople.json`):

- Added `SSTORE` gas/refund prices (`EIP-1283`), PR [#27](https://github.com/ethereumjs/ethereumjs-common/pull/27)
- Added Block Reward Adjustment (`EIP-1234`), PR [#26](https://github.com/ethereumjs/ethereumjs-common/pull/26)

[0.6.0]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.5.0...v0.6.0

## [0.5.0] - 2018-08-27
- Introduces **support for private chains** by allowing to pass a custom dictionary as the ``chain`` parameter
in the constructor or the ``setChain()`` method as an alternative to just passing one of the predefined
``chain`` ``String`` names (e.g. ``mainnet``, ``ropsten``), PR [#24](https://github.com/ethereumjs/ethereumjs-common/pull/24)

- Introduces **support for private chains** by allowing to pass a custom dictionary as the `chain` parameter
in the constructor or the `setChain()` method as an alternative to just passing one of the predefined
`chain` `String` names (e.g. `mainnet`, `ropsten`), PR [#24](https://github.com/ethereumjs/ethereumjs-common/pull/24)

[0.5.0]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.4.1...v0.5.0

## [0.4.1] - 2018-08-13
- Added ``timestamp`` field to genesis definitions in chain files, set for ``Rinkeby`` and ``null`` for other chains, PR [#21](https://github.com/ethereumjs/ethereumjs-common/pull/21)
- Updated ``Ropsten`` bootstrap nodes, PR [#20](https://github.com/ethereumjs/ethereumjs-common/pull/20)

- Added `timestamp` field to genesis definitions in chain files, set for `Rinkeby` and `null` for other chains, PR [#21](https://github.com/ethereumjs/ethereumjs-common/pull/21)
- Updated `Ropsten` bootstrap nodes, PR [#20](https://github.com/ethereumjs/ethereumjs-common/pull/20)

[0.4.1]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.4.0...v0.4.1

## [0.4.0] - 2018-06-20
- Remove leftover ...Gas postfix for some gas prices (e.g. ``ecAddGas`` -> ``ecAdd``) to

- Remove leftover ...Gas postfix for some gas prices (e.g. `ecAddGas` -> `ecAdd`) to
be consistent with overall gas price naming

[0.4.0]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.3.1...v0.4.0

## [0.3.1] - 2018-05-28
- Added two alias functions ``activeOnBlock()`` and ``gteHardfork()`` when hardfork is set for convenience, PR [#15](https://github.com/ethereumjs/ethereumjs-common/pull/15)
- Added option to dynamically choose genesis state (see ``README``), PR [#15](https://github.com/ethereumjs/ethereumjs-common/pull/15)

- Added two alias functions `activeOnBlock()` and `gteHardfork()` when hardfork is set for convenience, PR [#15](https://github.com/ethereumjs/ethereumjs-common/pull/15)
- Added option to dynamically choose genesis state (see `README`), PR [#15](https://github.com/ethereumjs/ethereumjs-common/pull/15)

[0.3.1]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.3.0...v0.3.1

## [0.3.0] - 2018-05-25
- Allow functions like ``hardforkIsActiveOnBlock()`` - where hardfork is provided as param - also to be run on hardfork set for greater flexibility/comfort, PR [#13](https://github.com/ethereumjs/ethereumjs-common/pull/13)
- New ``hardforkGteHardfork()`` method for HF order comparisons, PR [#13](https://github.com/ethereumjs/ethereumjs-common/pull/13)

- Allow functions like `hardforkIsActiveOnBlock()` - where hardfork is provided as param - also to be run on hardfork set for greater flexibility/comfort, PR [#13](https://github.com/ethereumjs/ethereumjs-common/pull/13)
- New `hardforkGteHardfork()` method for HF order comparisons, PR [#13](https://github.com/ethereumjs/ethereumjs-common/pull/13)

[0.3.0]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.2.0...v0.3.0

## [0.2.0] - 2018-05-14
- New optional initialization parameter ``allowedHardforks``, this allows for cleaner client
library implementations by preventing undefined behaviour, PR [#10](https://github.com/ethereumjs/ethereumjs-common/pull/10)
- Added ``activeHardfork()`` function to get latest active HF for chain or block, PR [#11](https://github.com/ethereumjs/ethereumjs-common/pull/11)

- New optional initialization parameter `allowedHardforks`, this allows for cleaner client
library implementations by preventing undefined behaviour, PR [#10](https://github.com/ethereumjs/ethereumjs-common/pull/10)
- Added `activeHardfork()` function to get latest active HF for chain or block, PR [#11](https://github.com/ethereumjs/ethereumjs-common/pull/11)

[0.2.0]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.1.1...v0.2.0

## [0.1.1] - 2018-05-09

- Remove dynamic require to prevent browserify issue, PR [#8](https://github.com/ethereumjs/ethereumjs-common/pull/8)

[0.1.1]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.1.0...v0.1.1

## [0.1.0] - 2018-05-09

- Initial version, this library succeeds the [ethereum/common](https://github.com/ethereumjs/common/issues/12)
library, being more future-proof through a better structured design

Features:

- Easy chain-/HF-based parameter access
- No parameter changes on library updates (``c.param('gasPrices', 'ecAddGas', 'byzantium')`` will always return the same value)
- Ease experimentation/research by allowing to include future HF parameters (already included as draft: ``constantinople`` and ``hybridCasper``) without breaking current installations
- Improved structure for parameter access (mainly through topics like ``gasPrices``, ``pow``, ``sharding``) for better readability/developer overview
- No parameter changes on library updates (`c.param('gasPrices', 'ecAddGas', 'byzantium')` will always return the same value)
- Ease experimentation/research by allowing to include future HF parameters (already included as draft: `constantinople` and `hybridCasper`) without breaking current installations
- Improved structure for parameter access (mainly through topics like `gasPrices`, `pow`, `sharding`) for better readability/developer overview
- See [README](https://github.com/ethereumjs/ethereumjs-common) and [API Docs](https://github.com/ethereumjs/ethereumjs-common/blob/master/docs/index.md) for a more in-depth feature overview and usage instructions

[0.1.0]: https://github.com/ethereumjs/ethereumjs-common/compare/6d0df89...v0.1.0





99 changes: 50 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs.svg?style=flat-square)]()

# ETHEREUMJS-COMMON

Resources common to all Ethereum implementations

Succeeds the old [ethereum/common](https://github.com/ethereumjs/common/) library.

# INSTALL

`npm install ethereumjs-common`

# USAGE

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

Here are some simple usage examples:

Expand All @@ -39,8 +41,8 @@ c.genesis().hash // 0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1
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``:
It is encouraged to also explicitly set the `supportedHardforks` if the initializing library
only supports a certain range of `hardforks`:

```javascript
let c = new Common('ropsten', null, ['byzantium', 'constantinople'])
Expand All @@ -53,83 +55,81 @@ like this prevents unpredicted behaviour.

See the API documentation for a full list of functions for accessing specific chain and
depending hardfork parameters. There are also additional helper functions like
``paramByBlock (topic, name, blockNumber)`` or ``hardforkIsActiveOnBlock (hardfork, blockNumber)``
to ease ``blockNumber`` based access to parameters.

- [API Docs](./docs/index.md)
`paramByBlock (topic, name, blockNumber)` or `hardforkIsActiveOnBlock (hardfork, blockNumber)`
to ease `blockNumber` based access to parameters.

- [API Docs](./docs/Readme.md)

# Hardfork Params

There are currently parameter changes by the following past and future hardfork by the
library supported:

- ``chainstart``
- ``homestead``
- ``dao``
- ``tangerineWhistle``
- ``spuriousDragon``
- ``byzantium``
- ``constantinople``


For hardfork-specific parameter access with the ``param()`` and ``paramByBlock()`` functions
you can use the following ``topics``:

- ``gasConfig``
- ``gasPrices``
- ``vm``
- ``pow``
- ``casper``
- ``sharding``

See one of the hardfork files like ``byzantium.json`` in the ``hardforks`` directory
for an overview. For consistency, the chain start (``chainstart``) is considered an own
- `chainstart`
- `homestead`
- `dao`
- `tangerineWhistle`
- `spuriousDragon`
- `byzantium`
- `constantinople`

For hardfork-specific parameter access with the `param()` and `paramByBlock()` functions
you can use the following `topics`:

- `gasConfig`
- `gasPrices`
- `vm`
- `pow`
- `casper`
- `sharding`

See one of the hardfork files like `byzantium.json` in the `hardforks` directory
for an overview. For consistency, the chain start (`chainstart`) is considered an own
hardfork.

The hardfork-specific json files only contain the deltas from ``chainstart`` and
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
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:

- ``mainnet``
- ``ropsten``
- ``rinkeby``
- ``kovan``
- ``goerli`` (EXPERIMENTAL)
- `mainnet`
- `ropsten`
- `rinkeby`
- `kovan`
- `goerli` (EXPERIMENTAL)
- Private/custom chain parameters

The following chain-specific parameters are provided:

- ``name``
- ``chainId``
- ``networkId``
- ``genesis`` block header values
- ``hardforks`` block numbers
- ``bootstrapNodes`` list
- `name`
- `chainId`
- `networkId`
- `genesis` block header values
- `hardforks` block numbers
- `bootstrapNodes` list

To get an overview of the different parameters have a look at one of the chain-specifc
files like ``mainnet.json`` in the ``chains`` directory.
files like `mainnet.json` in the `chains` directory.

If you want to set up a common instance with parameters for a **private/custom chain** you can pass a
dictionary - conforming to the parameter format described above - with your custom values in
the constructor or the ``setChain()`` method for the ``chain`` parameter.
the constructor or the `setChain()` method for the `chain` parameter.

# Bootstrap Nodes

There is no separate config file for bootstrap nodes like in the old ``ethereum-common`` library.
Instead use the ``common.bootstrapNodes()`` function to get nodes for a specific chain/network.
There is no separate config file for bootstrap nodes like in the old `ethereum-common` library.
Instead use the `common.bootstrapNodes()` function to get nodes for a specific chain/network.

# Genesis States

Network-specific genesis files are located in the ``genesisStates`` folder.
Network-specific genesis files are located in the `genesisStates` folder.

Due to the large file sizes genesis states are not directly included in the ``index.js`` file
Due to the large file sizes genesis states are not directly included in the `index.js` file
but have to be accessed directly, e.g.:

```javascript
Expand All @@ -145,4 +145,5 @@ const mainnetGenesisState = genesisStates[genesisStates['names'][1]] // alternat
```

# LICENSE

[MIT](https://opensource.org/licenses/MIT)
16 changes: 0 additions & 16 deletions chains/index.js

This file was deleted.

15 changes: 15 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ethereumjs-common

## Index

### Classes

- [Common](classes/common.md)

### Interfaces

- [chainsType](interfaces/chainstype.md)
- [genesisStatesType](interfaces/genesisstatestype.md)
- [hardforkOptions](interfaces/hardforkoptions.md)

---

0 comments on commit 156ad99

Please sign in to comment.