Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address failing tests from ethereum/tests v11.1 #2084

Merged
merged 1 commit into from
Oct 20, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/guides/understanding_the_mining_process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ zero value transfer transaction.
>>> nonce, mix_hash = mine_pow_nonce(
... block.number,
... block.header.mining_hash,
... block.header.difficulty
... )
... block.header.difficulty,
... ) # doctest: +SKIP (takes too long for doctest to process)

>>> chain.mine_block(mix_hash=mix_hash, nonce=nonce)
>>> chain.mine_block(mix_hash=mix_hash, nonce=nonce) # doctest: +SKIP
<ByzantiumBlock(#Block #1-0xe372..385c)>
2 changes: 1 addition & 1 deletion eth/vm/forks/byzantium/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def compute_difficulty(
)
difficulty = max(
parent_difficulty + offset * adj_factor,
min(parent_header.difficulty, DIFFICULTY_MINIMUM)
DIFFICULTY_MINIMUM
)
num_bomb_periods = (
max(
Expand Down
9 changes: 6 additions & 3 deletions eth/vm/forks/homestead/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ def compute_homestead_difficulty(parent_header: BlockHeaderAPI, timestamp: int)
offset = parent_header.difficulty // DIFFICULTY_ADJUSTMENT_DENOMINATOR
sign = max(
1 - (timestamp - parent_tstamp) // HOMESTEAD_DIFFICULTY_ADJUSTMENT_CUTOFF,
-99)
difficulty = int(max(
-99,
)
difficulty = max(
parent_header.difficulty + offset * sign,
min(parent_header.difficulty, DIFFICULTY_MINIMUM)))
DIFFICULTY_MINIMUM
)
num_bomb_periods = (
(parent_header.block_number + 1) // BOMB_EXPONENTIAL_PERIOD
) - BOMB_EXPONENTIAL_FREE_PERIODS

if num_bomb_periods >= 0:
return max(difficulty + 2**num_bomb_periods, DIFFICULTY_MINIMUM)
else:
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2084.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the ``DIFFICULTY_MINIMUM`` more appropriately as the lower limit in all difficulty calculations.
2 changes: 1 addition & 1 deletion tests/core/consensus/test_pow_mining.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ChainClass(MiningChain):

chain = genesis(ChainClass)

block = chain.mine_block()
block = chain.mine_block(difficulty=1)
check_pow(
block.number,
block.header.mining_hash,
Expand Down
9 changes: 0 additions & 9 deletions tests/json-fixtures/blockchain/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,6 @@ def blockchain_fixture_mark_fn(fixture_path, fixture_name, fixture_fork):
return pytest.mark.skip(
"EIP-2681 update not implemented. HighNonce tests turned off for now."
)
elif any(_ in fixture_name for _ in (
"CreateAddressWarmAfterFailureEF", "doubleSelfdestructTouch",
"delegatecall09Undefined_d0g0v0", "senderBalance_d0g0v0",
"touchAndGo_d0g0v0",
)):
return pytest.mark.skip(
"Skipped failing tests in v11.1 update to get Merge-related changes in. "
"Turn these back on and fix after the Merge is implemented."
)
elif "Merge" in fixture_name:
# TODO: Implement changes for the Merge and turn these tests on
return pytest.mark.skip("The Merge has not yet been implemented.")
Expand Down