Skip to content

Commit

Permalink
Gray glacier support (v5) (#1984)
Browse files Browse the repository at this point in the history
* common: add GrayGlacier HF and EIP-5133

* block: add GrayGlacier to difficulty tests

* vm: add GrayGlacier/EIP-5133 to supported HF/EIP's

* common: add GrayGlacier support

* vm: add GrayGlacier support

* resolve comments

* common: increase hardfork count check

* fix eslint-config-typescrip error
  • Loading branch information
ScottyPoi authored Jun 23, 2022
1 parent 9ebbb0e commit 25db8e5
Show file tree
Hide file tree
Showing 15 changed files with 21,440 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-typestrict": "^1.0.0",
"eslint-config-typestrict": "1.0.3",
"eslint-plugin-implicit-dependencies": "^1.0.4",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-sonarjs": "^0.5.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/block/test/difficulty.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const hardforkTestData: TestData = {
arrowGlacier:
require('../../ethereum-tests/DifficultyTests/dfArrowGlacier/difficultyArrowGlacier.json')
.difficultyArrowGlacier.ArrowGlacier,
grayGlacier: require('./testdata/dfGrayGlacier/difficultyGrayGlacier.json').difficultyGrayGlacier
.GrayGlacier,
}

const chainTestData: TestData = {
Expand Down
7,056 changes: 7,056 additions & 0 deletions packages/block/test/testdata/dfGrayGlacier/difficultyGrayGlacier.json

Large diffs are not rendered by default.

4,016 changes: 4,016 additions & 0 deletions packages/block/test/testdata/dfGrayGlacier/difficultyGrayGlacierForkBlock.json

Large diffs are not rendered by default.

7,056 changes: 7,056 additions & 0 deletions packages/block/test/testdata/dfGrayGlacier/difficultyGrayGlacierMinus1.json

Large diffs are not rendered by default.

1,632 changes: 1,632 additions & 0 deletions packages/block/test/testdata/dfGrayGlacier/difficultyGrayGlacierTimeDiff1.json

Large diffs are not rendered by default.

1,632 changes: 1,632 additions & 0 deletions packages/block/test/testdata/dfGrayGlacier/difficultyGrayGlacierTimeDiff2.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 @@ -85,6 +85,11 @@
"block": 13773000,
"forkHash": "0x20c327fc"
},
{
"name": "grayGlacier",
"block": 15050000,
"forkHash": "0xf0afd0e3"
},
{
"name": "mergeForkIdTransition",
"block": null,
Expand Down
17 changes: 17 additions & 0 deletions packages/common/src/eips/5133.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "EIP-5133",
"number": 5133,
"comment": "Delaying Difficulty Bomb to mid-September 2022",
"url": "https://eips.ethereum.org/EIPS/eip-5133",
"status": "Draft",
"minimumHardfork": "grayGlacier",
"gasConfig": {},
"gasPrices": {},
"vm": {},
"pow": {
"difficultyBombDelay": {
"v": 11400000,
"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 @@ -22,4 +22,5 @@ export const EIPs: eipsType = {
3860: require('./3860.json'),
4345: require('./4345.json'),
4399: require('./4399.json'),
5133: require('./5133.json'),
}
11 changes: 11 additions & 0 deletions packages/common/src/hardforks/grayGlacier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "grayGlacier",
"comment": "Delaying the difficulty bomb to Mid September 2022",
"url": "https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/gray-glacier.md",
"status": "Draft",
"eips": [5133],
"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 @@ -13,6 +13,7 @@ export const hardforks = [
['london', require('./london.json')],
['shanghai', require('./shanghai.json')],
['arrowGlacier', require('./arrowGlacier.json')],
['grayGlacier', require('./grayGlacier.json')],
['mergeForkIdTransition', require('./mergeForkIdTransition.json')],
['merge', require('./merge.json')],
]
3 changes: 2 additions & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ export enum Hardfork {
Berlin = 'berlin',
London = 'london',
ArrowGlacier = 'arrowGlacier',
Shanghai = 'shanghai',
GrayGlacier = 'grayGlacier',
MergeForkIdTransition = 'mergeForkIdTransition',
Merge = 'merge',
Shanghai = 'shanghai',
}

export enum ConsensusType {
Expand Down
10 changes: 6 additions & 4 deletions packages/common/tests/hardforks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tape('[Common]: Hardfork logic', function (t: tape.Test) {
Hardfork.Berlin,
Hardfork.London,
Hardfork.ArrowGlacier,
Hardfork.GrayGlacier,
Hardfork.Shanghai,
Hardfork.Merge,
]
Expand All @@ -42,8 +43,8 @@ tape('[Common]: Hardfork logic', function (t: tape.Test) {
st.equal(c.getHardforkByBlockNumber(12244000), Hardfork.Berlin, msg)
st.equal(c.getHardforkByBlockNumber(12965000), Hardfork.London, msg)
st.equal(c.getHardforkByBlockNumber(13773000), Hardfork.ArrowGlacier, msg)
st.equal(c.getHardforkByBlockNumber(999999999999), Hardfork.ArrowGlacier, msg)

st.equal(c.getHardforkByBlockNumber(15050000), Hardfork.GrayGlacier, msg)
st.equal(c.getHardforkByBlockNumber(999999999999), Hardfork.GrayGlacier, msg)
msg = 'should set HF correctly'

st.equal(c.setHardforkByBlockNumber(0), Hardfork.Chainstart, msg)
Expand All @@ -53,7 +54,8 @@ tape('[Common]: Hardfork logic', function (t: tape.Test) {
st.equal(c.setHardforkByBlockNumber(12244000), Hardfork.Berlin, msg)
st.equal(c.setHardforkByBlockNumber(12965000), Hardfork.London, msg)
st.equal(c.setHardforkByBlockNumber(13773000), Hardfork.ArrowGlacier, msg)
st.equal(c.setHardforkByBlockNumber(999999999999), Hardfork.ArrowGlacier, msg)
st.equal(c.setHardforkByBlockNumber(15050000), Hardfork.GrayGlacier, msg)
st.equal(c.setHardforkByBlockNumber(999999999999), Hardfork.GrayGlacier, msg)

c = new Common({ chain: Chain.Ropsten })
st.equal(c.setHardforkByBlockNumber(0), 'tangerineWhistle', msg)
Expand Down Expand Up @@ -180,7 +182,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, 13, msg)
st.equal(c.activeHardforks().length, 14, msg)

c = new Common({ chain: Chain.Rinkeby })
msg = 'should return correct number of active HFs for rinkeby'
Expand Down
2 changes: 2 additions & 0 deletions packages/vm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface VMOpts {
* - [EIP-3855](https://eips.ethereum.org/EIPS/eip-3855) - PUSH0 instruction (`experimental`)
* - [EIP-3860](https://eips.ethereum.org/EIPS/eip-3860) - Limit and meter initcode (`experimental`)
* - [EIP-4399](https://eips.ethereum.org/EIPS/eip-4399) - Supplant DIFFICULTY opcode with PREVRANDAO (Merge) (`experimental`)
* - [EIP-5133](https://eips.ethereum.org/EIPS/eip-5133) - Delaying Difficulty Bomb to mid-September 2022
*
* *Annotations:*
*
Expand Down Expand Up @@ -282,6 +283,7 @@ export default class VM extends AsyncEventEmitter {
Hardfork.Berlin,
Hardfork.London,
Hardfork.ArrowGlacier,
Hardfork.GrayGlacier,
Hardfork.MergeForkIdTransition,
Hardfork.Merge,
]
Expand Down

0 comments on commit 25db8e5

Please sign in to comment.