Skip to content
Draft
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
12 changes: 6 additions & 6 deletions src/ethereum/forks/homestead/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,21 +765,21 @@ def calculate_block_difficulty(
Computed difficulty for a block.
"""
offset = (
int(parent_difficulty)
// 2048
* max(1 - int(block_timestamp - parent_timestamp) // 10, -99)
parent_difficulty
// Uint(2048)
* max(1 - (block_timestamp - parent_timestamp) // U256(10), -99)
)
difficulty = int(parent_difficulty) + offset
difficulty = parent_difficulty + offset
# Historical Note: The difficulty bomb was not present in Ethereum at the
# start of Frontier, but was added shortly after launch. However since the
# bomb has no effect prior to block 200000 we pretend it existed from
# genesis.
# See https://github.com/ethereum/go-ethereum/pull/1588
num_bomb_periods = (int(block_number) // 100000) - 2
num_bomb_periods = (block_number // Uint(100000)) - 2
if num_bomb_periods >= 0:
difficulty += 2**num_bomb_periods

# Some clients raise the difficulty to `MINIMUM_DIFFICULTY` prior to adding
# the bomb. This bug does not matter because the difficulty is always much
# greater than `MINIMUM_DIFFICULTY` on Mainnet.
return Uint(max(difficulty, int(MINIMUM_DIFFICULTY)))
return Uint(max(difficulty, MINIMUM_DIFFICULTY))