Skip to content
Merged
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 src/ethereum/frontier/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def calculate_block_difficulty(
# See https://github.com/ethereum/go-ethereum/pull/1588
num_bomb_periods = (int(block_number) // 100000) - 2
if num_bomb_periods >= 0:
difficulty += 2**num_bomb_periods
difficulty += Uint(2**num_bomb_periods)
Copy link
Contributor

Choose a reason for hiding this comment

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

num_bomb_periods = (block_number // Uint(100000)) - Uint(2)
if num_bomb_periods >= 0:
    difficulty += Uint(2) ** num_bomb_periods

Kinda just thinking out loud, but would it be better in your opinion to do the math as Uint, or do the conversion at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah was thinking the same! that would make it consistent with the other forks. Also do you think in that case converting difficulty to int for doing the calculations is better to be consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

difficulty = int(difficulty)
num_bomb_periods = (int(block_number) // 100000) - 2
if num_bomb_periods >= 0:
    difficulty += 2**num_bomb_periods

return max(Uint(difficulty), MINIMUM_DIFFICULTY)

is this better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does Frontier have a minimum difficulty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


# Some clients raise the difficulty to `MINIMUM_DIFFICULTY` prior to adding
# the bomb. This bug does not matter because the difficulty is always much
Expand Down
Loading