Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HF to Istanbul #906

Merged
merged 1 commit into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block/src/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Block {
public readonly uncleHeaders: BlockHeader[] = []
public readonly txTrie = new Trie()

private readonly _common: Common
public readonly _common: Common
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question for context: is the idea to change _common visibility so it can be available on the tests?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah in general I agree with this so we don't have to keep doing (block as any)._common anymore 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is for the tests. Always not sure if this is the best way to tackle, but then do out of lack on alternative ideas on practical paths here.


/**
* Creates a new block object
Expand Down
2 changes: 1 addition & 1 deletion packages/block/src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class BlockHeader {
public mixHash!: Buffer
public nonce!: Buffer

readonly _common: Common
public readonly _common: Common
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making default public visibility explicit 👍


/**
* Creates a new block header.
Expand Down
4 changes: 3 additions & 1 deletion packages/block/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export interface BlockOptions {
* A Common object defining the chain and the hardfork a block/block header belongs to.
*
* Default: `Common` object set to `mainnet` and the HF currently defined as the default
* hardfork in the `Common` class
* hardfork in the `Common` class.
*
* Current default hardfork: `istanbul`
*/
common?: Common
/**
Expand Down
7 changes: 6 additions & 1 deletion packages/block/test/block.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ tape('[Block]: block functions', function (t) {

t.test('should initialize with undefined parameters without throwing', function (st) {
st.doesNotThrow(function () {
new Block()
const block = new Block()
st.equal(
block._common.hardfork(),
'istanbul',
'should initialize with the current default HF',
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

st.end()
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A new function `setHardforkByBlockNumber()` has been added, PR [#863](https://gi

### Default hardfork

The default hardfork has been added as an accessible readonly property `DEFAULT_HARDFORK`, PR [#863](https://github.com/ethereumjs/ethereumjs-vm/pull/863)
The default hardfork has been added as an accessible readonly property `DEFAULT_HARDFORK`, PR [#863](https://github.com/ethereumjs/ethereumjs-vm/pull/863). Current default hardfork is set to `istanbul`, PR [#906](https://github.com/ethereumjs/ethereumjs-vm/pull/906).

## [1.5.1] - 2020-05-04

Expand Down
2 changes: 1 addition & 1 deletion packages/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ library supported:
- `byzantium`
- `constantinople`
- `petersburg` (aka `constantinopleFix`, apply together with `constantinople`)
- `istanbul`
- `istanbul` (`DEFAULT_HARDFORK`)
- `muirGlacier`

## Future Hardforks
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface CommonOpts {
/**
* String identifier ('byzantium') for hardfork
*
* Default: `petersburg`
* Default: `istanbul`
*/
hardfork?: string
/**
Expand Down Expand Up @@ -44,7 +44,7 @@ interface hardforkOptions {
* Common class to access chain and hardfork parameters
*/
export default class Common {
readonly DEFAULT_HARDFORK: string = 'petersburg'
readonly DEFAULT_HARDFORK: string = 'istanbul'

private _chainParams: Chain
private _hardfork: string
Expand Down
7 changes: 6 additions & 1 deletion packages/common/tests/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ tape('[Common]: Initialization / Chain params', function (t: tape.Test) {
st.equal(c.chainName(), 'mainnet', 'should initialize with chain name')
st.equal(c.chainId(), 1, 'should return correct chain Id')
st.equal(c.networkId(), 1, 'should return correct network Id')
st.equal(c.hardfork(), 'petersburg', 'should set hardfork to the default hardfork')
st.equal(c.hardfork(), 'istanbul', 'should set hardfork to current default hardfork')
st.equal(
c.hardfork(),
c.DEFAULT_HARDFORK,
'should set hardfork to hardfork set as DEFAULT_HARDFORK',
)
st.equal(c._isSupportedHardfork('constantinople'), true, 'should not restrict supported HFs')

c = new Common({ chain: 1 })
Expand Down
6 changes: 6 additions & 0 deletions packages/tx/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const tx = Transaction.fromValuesArray(arr)

Learn more about the full API in the [docs](./docs/README.md).

#### New Default Hardfork

The default HF on the library has been updated from `petersburg` to `instanbul`.
The HF setting is now automatically taken from the HF set for `Common.DEAULT_HARDFORK`,
see PR [#906](https://github.com/ethereumjs/ethereumjs-vm/pull/906).

#### Immutability

The returned transaction is now frozen and immutable. To work with a maliable transaction, copy it with `const fakeTx = Object.create(tx)`.
Expand Down
2 changes: 2 additions & 0 deletions packages/tx/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface TxOptions {
* A Common object defining the chain and hardfork for the transaction.
*
* Default: `Common` object set to `mainnet` and the default hardfork as defined in the `Common` class.
*
* Current default hardfork: `istanbul`
*/
common?: Common
}
Expand Down
8 changes: 7 additions & 1 deletion packages/tx/test/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const txFixturesEip155: VitaliksTestsDataEntry[] = require('./json/ttTransaction
tape('[Transaction]: Basic functions', function (t) {
const transactions: Transaction[] = []

t.test('should initialize correctly', function (st) {
const tx = Transaction.fromTxData({})
st.equal(tx.common.hardfork(), 'istanbul', 'should initialize with correct default HF')
st.end()
})

t.test('should decode transactions', function (st) {
txFixtures.slice(0, 4).forEach(function (tx: any) {
const txData = tx.raw.map(toBuffer)
Expand Down Expand Up @@ -190,7 +196,7 @@ tape('[Transaction]: Basic functions', function (t) {
st.equals(tx.getDataFee().toNumber(), 0)

tx = Transaction.fromValuesArray(txFixtures[3].raw.map(toBuffer))
st.equals(tx.getDataFee().toNumber(), 2496)
st.equals(tx.getDataFee().toNumber(), 1716)

st.end()
})
Expand Down
4 changes: 4 additions & 0 deletions packages/vm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const common = new Common({ chain: 'mainnet', hardfork: 'spuriousDragon' })
const vm = new VM({ common })
```

The default HF from the VM has been updated from `petersburg` to `instanbul`.
The HF setting is now automatically taken from the HF set for `Common.DEAULT_HARDFORK`,
see PR [#906](https://github.com/ethereumjs/ethereumjs-vm/pull/906).

**Breaking**: Please note that the options to directly pass in
`chain` and `hardfork` strings have been removed to simplify the API.
Providing a `Common` instance is now the only way to change
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface VMOpts {
* Default setup if no `Common` instance is provided:
*
* - `chain`: `mainnet`
* - `hardfork`: `petersburg`
* - `hardfork`: `istanbul`
* - `eips`: `[]`
*/
common?: Common
Expand Down
1 change: 1 addition & 0 deletions packages/vm/tests/api/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tape('VM with default blockchain', (t) => {
KECCAK256_RLP,
'it has default trie',
)
st.equal(vm._common.hardfork(), 'istanbul', 'it has correct default HF')
st.end()
})

Expand Down