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 #87

Merged
merged 3 commits into from
Dec 15, 2019
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"homepage": "https://github.com/ethereumjs/ethereumjs-block#readme",
"dependencies": {
"@types/bn.js": "^4.11.5",
"ethereumjs-common": "^1.3.0",
"ethereumjs-common": "^1.5.0",
Copy link
Contributor Author

@evertonfraga evertonfraga Dec 13, 2019

Choose a reason for hiding this comment

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

1.5.0 has the definitions for HF Muir Glacier

"ethereumjs-tx": "^2.1.1",
"ethereumjs-util": "^6.1.0",
"merkle-patricia-tree": "^2.1.2"
Expand Down
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, 'muirGlacier')) {
// 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,
muirGlacier: 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