Skip to content

Commit

Permalink
Common, Block: Add arrowGlacier HF (#1527)
Browse files Browse the repository at this point in the history
* common/vm: add arrowGlacier HF

* common: fix tests

* common: fix eip 4345 minimum hardfork

* block: added ArrowGlacier difficulty tests

* Common: added forkHash for ArrowGlacier HF

Co-authored-by: holgerd77 <[email protected]>
  • Loading branch information
jochem-brouwer and holgerd77 authored Nov 8, 2021
1 parent c230e51 commit 309988c
Show file tree
Hide file tree
Showing 10 changed files with 7,101 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/block/test/difficulty.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ tape('[Header]: difficulty tests', (t) => {
require('./testdata/difficultyEIP2384_random.json').tests,
require('./testdata/difficultyEIP2384_random_to20M.json').tests
),
arrowGlacier: require('./testdata/difficultyArrowGlacier.json').difficultyArrowGlacier
.ArrowGlacier,
}

/* eslint-disable-next-line no-restricted-syntax */
Expand Down
7,056 changes: 7,056 additions & 0 deletions packages/block/test/testdata/difficultyArrowGlacier.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/common/src/chains/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
"block": 12965000,
"forkHash": "0xb715077d"
},
{
"name": "arrowGlacier",
"block": 13773000,
"forkHash": "0x20c327fc"
},
{
"name": "merge",
"block": null,
Expand Down
17 changes: 17 additions & 0 deletions packages/common/src/eips/4345.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "EIP-4345",
"number": 4345,
"comment": "Difficulty Bomb Delay to June 2022",
"url": "https://eips.ethereum.org/EIPS/eip-4345",
"status": "Review",
"minimumHardfork": "london",
"gasConfig": {},
"gasPrices": {},
"vm": {},
"pow": {
"difficultyBombDelay": {
"v": 10700000,
"d": "the amount of blocks to delay the difficulty bomb with"
}
}
}
1 change: 1 addition & 0 deletions packages/common/src/eips/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const EIPs: eipsType = {
3541: require('./3541.json'),
3554: require('./3554.json'),
3675: require('./3675.json'),
4345: require('./4345.json'),
}
11 changes: 11 additions & 0 deletions packages/common/src/hardforks/arrowGlacier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "arrowGlacier",
"comment": "HF to delay the difficulty bomb",
"url": "https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/arrow-glacier.md",
"status": "Final",
"eips": [4345],
"gasConfig": {},
"gasPrices": {},
"vm": {},
"pow": {}
}
1 change: 1 addition & 0 deletions packages/common/src/hardforks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export const hardforks = [
['berlin', require('./berlin.json')],
['london', require('./london.json')],
['shanghai', require('./shanghai.json')],
['arrowGlacier', require('./arrowGlacier.json')],
['merge', require('./merge.json')],
]
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export enum Hardfork {
MuirGlacier = 'muirGlacier',
Berlin = 'berlin',
London = 'london',
ArrowGlacier = 'arrowGlacier',
Shanghai = 'shanghai',
Merge = 'merge',
}
Expand Down
9 changes: 6 additions & 3 deletions packages/common/tests/hardforks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ tape('[Common]: Hardfork logic', function (t: tape.Test) {
Hardfork.Istanbul,
Hardfork.Berlin,
Hardfork.London,
Hardfork.ArrowGlacier,
Hardfork.Shanghai,
Hardfork.Merge,
]
Expand All @@ -40,7 +41,8 @@ tape('[Common]: Hardfork logic', function (t: tape.Test) {
st.equal(c.getHardforkByBlockNumber(9200000), Hardfork.MuirGlacier, msg)
st.equal(c.getHardforkByBlockNumber(12244000), Hardfork.Berlin, msg)
st.equal(c.getHardforkByBlockNumber(12965000), Hardfork.London, msg)
st.equal(c.getHardforkByBlockNumber(999999999999), Hardfork.London, msg)
st.equal(c.getHardforkByBlockNumber(13773000), Hardfork.ArrowGlacier, msg)
st.equal(c.getHardforkByBlockNumber(999999999999), Hardfork.ArrowGlacier, msg)

msg = 'should set HF correctly'

Expand All @@ -50,7 +52,8 @@ tape('[Common]: Hardfork logic', function (t: tape.Test) {
st.equal(c.setHardforkByBlockNumber(1400000), Hardfork.Homestead, msg)
st.equal(c.setHardforkByBlockNumber(12244000), Hardfork.Berlin, msg)
st.equal(c.setHardforkByBlockNumber(12965000), Hardfork.London, msg)
st.equal(c.setHardforkByBlockNumber(999999999999), Hardfork.London, msg)
st.equal(c.setHardforkByBlockNumber(13773000), Hardfork.ArrowGlacier, msg)
st.equal(c.setHardforkByBlockNumber(999999999999), Hardfork.ArrowGlacier, msg)

c = new Common({ chain: Chain.Ropsten })
st.equal(c.setHardforkByBlockNumber(0), 'tangerineWhistle', msg)
Expand Down Expand Up @@ -177,7 +180,7 @@ tape('[Common]: Hardfork logic', function (t: tape.Test) {

c = new Common({ chain: Chain.Mainnet })
msg = 'should return correct number of active HFs for mainnet'
st.equal(c.activeHardforks().length, 12, msg)
st.equal(c.activeHardforks().length, 13, msg)

c = new Common({ chain: Chain.Rinkeby })
msg = 'should return correct number of active HFs for rinkeby'
Expand Down
1 change: 1 addition & 0 deletions packages/vm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export default class VM extends AsyncEventEmitter {
'istanbul',
'muirGlacier',
'berlin',
'arrowGlacier',
]

this._common = new Common({
Expand Down

0 comments on commit 309988c

Please sign in to comment.