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

Commit

Permalink
Merge pull request #75 from evertonfraga/add-eip2384
Browse files Browse the repository at this point in the history
Adds definition for HF Muir Glacier
  • Loading branch information
holgerd77 authored Dec 9, 2019
2 parents 0bc9b7b + 28ae896 commit c36a07c
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/chains/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
"block": 9069000,
"consensus": "pow",
"finality": null
},
{
"name": "muirGlacier",
"block": 9200000,
"consensus": "pow",
"finality": null
}
],
"bootstrapNodes": [
Expand Down
6 changes: 6 additions & 0 deletions src/chains/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
"block": 6485846,
"consensus": "pow",
"finality": null
},
{
"name": "muirGlacier",
"block": 7117117,
"consensus": "pow",
"finality": null
}
],
"bootstrapNodes": [
Expand Down
1 change: 1 addition & 0 deletions src/hardforks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export const hardforks = [
['constantinople', require('./constantinople.json')],
['petersburg', require('./petersburg.json')],
['istanbul', require('./istanbul.json')],
['muirGlacier', require('./muirGlacier.json')],
]
14 changes: 14 additions & 0 deletions src/hardforks/muirGlacier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "muirGlacier",
"comment": "HF to delay the difficulty bomb",
"eip": {
"url": "https://eips.ethereum.org/EIPS/eip-2384",
"status": "Last Call"
},
"gasConfig": {},
"gasPrices": {},
"vm": {},
"pow": {},
"casper": {},
"sharding": {}
}
4 changes: 2 additions & 2 deletions tests/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tape('[Common]: Initialization / Chain params', function(t: tape.Test) {
t.test('Should initialize with supportedHardforks provided', function(st: tape.Test) {
const c = new Common('mainnet', 'byzantium', ['byzantium', 'constantinople'])
st.equal(c._isSupportedHardfork('byzantium'), true, 'should return true for supported HF')
let msg = 'should return false for unsupported HF'
const msg = 'should return false for unsupported HF'
st.equal(c._isSupportedHardfork('spuriousDragon'), false, msg)

st.end()
Expand Down Expand Up @@ -56,7 +56,7 @@ tape('[Common]: Initialization / Chain params', function(t: tape.Test) {

t.test('Should provide correct access to chain parameters', function(st: tape.Test) {
const c = new Common('mainnet')
let hash = '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3'
const hash = '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3'
st.equal(c.genesis().hash, hash, 'should return correct genesis hash')
st.equal(c.hardforks()[3]['block'], 2463000, 'should return correct hardfork data')
st.equal(c.bootstrapNodes()[0].port, 30303, 'should return a bootstrap node array')
Expand Down
32 changes: 28 additions & 4 deletions tests/hardforks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ tape('[Common]: Hardfork logic', function(t: tape.Test) {

t.test('activeHardforks()', function(st: tape.Test) {
let c = new Common('ropsten')
let msg = 'should return 8 active hardforks for Ropsten'
st.equal(c.activeHardforks().length, 8, msg)
let msg = 'should return 9 active hardforks for Ropsten'
st.equal(c.activeHardforks().length, 9, msg)

msg = 'should return the correct HF data for Ropsten'
st.equal(c.activeHardforks()[3]['name'], 'spuriousDragon', msg)
Expand All @@ -80,13 +80,25 @@ tape('[Common]: Hardfork logic', function(t: tape.Test) {
msg = 'should return 2 active HFs when restricted to supported HFs'
st.equal(c.activeHardforks(null, { onlySupported: true }).length, 2, msg)

c = new Common('mainnet')
msg = 'should return 10 active HFs for mainnet'
st.equal(c.activeHardforks().length, 10, msg)

c = new Common('rinkeby')
msg = 'should return 8 active HFs for rinkeby'
st.equal(c.activeHardforks().length, 8, msg)

c = new Common('goerli')
msg = 'should return 9 active HFs for goerli'
st.equal(c.activeHardforks().length, 9, msg)

st.end()
})

t.test('activeHardfork()', function(st: tape.Test) {
let c = new Common('ropsten')
let msg = 'should return istanbul as latest active HF for Ropsten'
st.equal(c.activeHardfork(), 'istanbul', msg)
let msg = 'should return muirGlacier as latest active HF for Ropsten'
st.equal(c.activeHardfork(), 'muirGlacier', msg)

msg = 'should return spuriousDragon as latest active HF for Ropsten for block 10'
st.equal(c.activeHardfork(10), 'spuriousDragon', msg)
Expand All @@ -95,6 +107,10 @@ tape('[Common]: Hardfork logic', function(t: tape.Test) {
msg = 'should return spuriousDragon as latest active HF for Ropsten with limited supported HFs'
st.equal(c.activeHardfork(null, { onlySupported: true }), 'spuriousDragon', msg)

c = new Common('rinkeby')
msg = 'should return Istanbul as latest active HF for Rinkeby'
st.equal(c.activeHardfork(), 'istanbul', msg)

st.end()
})

Expand Down Expand Up @@ -164,6 +180,14 @@ tape('[Common]: Hardfork logic', function(t: tape.Test) {
st.end()
})

t.test('hardforkGteHardfork() ropsten', function(st: tape.Test) {
const c = new Common('ropsten')
const msg = 'ropsten, spuriousDragon >= muirGlacier (provided) -> false'
st.equal(c.hardforkGteHardfork('spuriousDragon', 'muirGlacier'), false, msg)

st.end()
})

t.test('hardforkIsActiveOnChain()', function(st: tape.Test) {
let c = new Common('ropsten')
let msg = 'should return true for byzantium (provided) on Ropsten'
Expand Down
2 changes: 1 addition & 1 deletion tests/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tape('[Common]: Parameter access', function(t: tape.Test) {

t.test('Parameter updates', function(st: tape.Test) {
const c = new Common('mainnet')
let f = function() {
const f = function() {
c.param('gasPrices', 'ecAdd', 'spuriousDragon')
}
let msg = 'Should throw for a value set on a later HF'
Expand Down

0 comments on commit c36a07c

Please sign in to comment.