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

HF Muir Glacier Difficulty bomb delay #80

Closed
8 changes: 7 additions & 1 deletion src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ export class BlockHeader {
dif = parentDif.add(offset.mul(a))
}

if (this._common.hardforkGteHardfork(hardfork, 'constantinople')) {
if (this._common.hardforkGteHardfork(hardfork, 'mountainGlacier')) {
// Istanbul/Berlin difficulty bomb delay (EIP2384)
num.isubn(9000000)
if (num.ltn(0)) {
num = new BN(0)
}
} else if (this._common.hardforkGteHardfork(hardfork, 'constantinople')) {
// Constantinople difficulty bomb delay (EIP1234)
num.isubn(5000000)
if (num.ltn(0)) {
Expand Down
19 changes: 17 additions & 2 deletions test/difficulty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ tape('[Header]: difficulty tests', t => {
homestead: require('./difficultyHomestead.json').tests,
byzantium: require('./difficultyByzantium.json').tests,
constantinople: require('./difficultyConstantinople.json').tests,
mountainGlacier: Object.assign(
require('./difficultyEIP2384.json').tests,
require('./difficultyEIP2384_random.json').tests,
require('./difficultyEIP2384_random_to20M.json').tests,
),
}
for (const hardfork in hardforkTestData) {
const testData = hardforkTestData[hardfork]
Expand All @@ -44,7 +49,12 @@ tape('[Header]: difficulty tests', t => {
block.header.difficulty = test.currentDifficulty
block.header.number = test.currentBlockNumber

runDifficultyTests(test, parentBlock, block, 'fork determination by hardfork param')
runDifficultyTests(
test,
parentBlock,
block,
`fork determination by hardfork param (${hardfork})`,
)
}
}

Expand All @@ -66,7 +76,12 @@ tape('[Header]: difficulty tests', t => {
block.header.difficulty = test.currentDifficulty
block.header.number = test.currentBlockNumber

runDifficultyTests(test, parentBlock, block, 'fork determination by block number')
runDifficultyTests(
test,
parentBlock,
block,
`fork determination by block number (${test.currentBlockNumber})`,
)
}
}

Expand Down
Loading