Skip to content

Commit

Permalink
Rename softfork (#17799)
Browse files Browse the repository at this point in the history
* remove disabled tests from CHIP-13

* rename the new soft-fotk to soft-fork 4. We've already had soft-fork 3, but it's activated and its logic has been removed
  • Loading branch information
arvidn authored Mar 29, 2024
1 parent f200fcf commit 4b90197
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 71 deletions.
8 changes: 4 additions & 4 deletions chia/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ def get_keychain():
class ConsensusMode(Enum):
PLAIN = 0
HARD_FORK_2_0 = 1
SOFT_FORK_3 = 2
SOFT_FORK_4 = 2


@pytest.fixture(
scope="session",
params=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0, ConsensusMode.SOFT_FORK_3],
params=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0, ConsensusMode.SOFT_FORK_4],
)
def consensus_mode(request):
return request.param
Expand All @@ -205,10 +205,10 @@ def consensus_mode(request):
def blockchain_constants(consensus_mode) -> ConsensusConstants:
if consensus_mode == ConsensusMode.PLAIN:
return test_constants
if consensus_mode == ConsensusMode.SOFT_FORK_3:
if consensus_mode == ConsensusMode.SOFT_FORK_4:
return dataclasses.replace(
test_constants,
SOFT_FORK3_HEIGHT=uint32(2),
SOFT_FORK4_HEIGHT=uint32(2),
)
if consensus_mode == ConsensusMode.HARD_FORK_2_0:
return dataclasses.replace(
Expand Down
54 changes: 0 additions & 54 deletions chia/_tests/core/full_node/full_sync/test_full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,60 +416,6 @@ async def test_sync_none_wp_response_backward_comp(self, three_nodes, default_10
duration = time.time() - start
assert duration > 5

@pytest.mark.limit_consensus_modes(reason="save time")
@pytest.mark.skip("This feature depends on (now removed) CHIP-13")
@pytest.mark.anyio
async def test_bad_peak_in_cache(
self, two_nodes, default_400_blocks, blockchain_constants, self_hostname, consensus_mode
):
full_node_1, full_node_2, server_1, server_2, bt = two_nodes
bt.constants = dataclasses.replace(blockchain_constants, SOFT_FORK4_HEIGHT=1000000)
blocks = bt.get_consecutive_blocks(700, default_400_blocks)
full_node_2.full_node.blockchain.constants = dataclasses.replace(
blockchain_constants,
SOFT_FORK4_HEIGHT=1000000,
)
full_node_1.full_node.blockchain.constants = dataclasses.replace(blockchain_constants, SOFT_FORK4_HEIGHT=400)
for block in blocks:
await full_node_2.full_node.add_block(block)
server_1 = full_node_1.full_node.server
server_2 = full_node_2.full_node.server
await server_2.start_client(
PeerInfo(self_hostname, uint16(server_1._port)), on_connect=full_node_2.full_node.on_connect
)
await time_out_assert(60, full_node_1.full_node.sync_store.get_long_sync, True)
await time_out_assert(250, full_node_1.full_node.sync_store.get_long_sync, False)
peak = full_node_2.full_node.blockchain.get_peak()
wp = await full_node_2.full_node.weight_proof_handler.get_proof_of_weight(peak.header_hash)
assert full_node_1.full_node.in_bad_peak_cache(wp) is True

@pytest.mark.limit_consensus_modes(reason="save time")
@pytest.mark.skip("This feature depends on (now removed) CHIP-13")
@pytest.mark.anyio
async def test_skip_bad_peak_validation(
self, two_nodes, default_400_blocks, blockchain_constants, self_hostname, consensus_mode
):
full_node_1, full_node_2, server_1, server_2, bt = two_nodes
blocks = bt.get_consecutive_blocks(700, default_400_blocks)
full_node_2.full_node.blockchain.constants = dataclasses.replace(
blockchain_constants,
SOFT_FORK4_HEIGHT=1000000,
)
full_node_1.full_node.blockchain.constants = dataclasses.replace(blockchain_constants, SOFT_FORK4_HEIGHT=400)
for block in blocks:
await full_node_2.full_node.add_block(block)

peak = full_node_2.full_node.blockchain.get_peak()
full_node_1.full_node.add_to_bad_peak_cache(peak.header_hash, peak.height)
await server_2.start_client(
PeerInfo(self_hostname, uint16(server_1._port)), on_connect=full_node_2.full_node.on_connect
)

await time_out_assert(60, has_peers_with_peak, True, full_node_1.full_node, peak.header_hash)

with pytest.raises(ValueError, match="Weight proof failed bad peak cache validation"):
await full_node_1.full_node.request_validate_wp(peak.header_hash, peak.height, peak.weight)

@pytest.mark.anyio
async def test_bad_peak_cache_invalidation(
self, two_nodes, default_1000_blocks, blockchain_constants, consensus_mode
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/test_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ async def test_announce_conditions_limit(
pre-v2-softfork, and rejects more than the announcement limit afterward.
"""

if condition1.startswith("(66") and consensus_mode != ConsensusMode.SOFT_FORK_3:
if condition1.startswith("(66") and consensus_mode != ConsensusMode.SOFT_FORK_4:
# The message conditions aren't enabled until Soft-fork 3, so there
# won't be any errors unless it's activated
expect_err = None
Expand Down
6 changes: 3 additions & 3 deletions chia/_tests/util/test_testnet_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_testnet10() -> None:
update_testnet_overrides("testnet10", overrides)
assert overrides == {
"SOFT_FORK2_HEIGHT": 3000000,
"SOFT_FORK3_HEIGHT": 4465000,
"SOFT_FORK4_HEIGHT": 4465000,
"HARD_FORK_HEIGHT": 2997292,
"HARD_FORK_FIX_HEIGHT": 3426000,
"PLOT_FILTER_128_HEIGHT": 3061804,
Expand All @@ -23,7 +23,7 @@ def test_testnet11() -> None:
overrides: Dict[str, Any] = {}
update_testnet_overrides("testnet11", overrides)
assert overrides == {
"SOFT_FORK3_HEIGHT": 641500,
"SOFT_FORK4_HEIGHT": 641500,
}


Expand All @@ -38,7 +38,7 @@ def test_testnet10_existing() -> None:
update_testnet_overrides("testnet10", overrides)
assert overrides == {
"SOFT_FORK2_HEIGHT": 3000000,
"SOFT_FORK3_HEIGHT": 4465000,
"SOFT_FORK4_HEIGHT": 4465000,
"HARD_FORK_HEIGHT": 42,
"HARD_FORK_FIX_HEIGHT": 3426000,
"PLOT_FILTER_128_HEIGHT": 42,
Expand Down
2 changes: 1 addition & 1 deletion chia/consensus/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ConsensusConstants:
SOFT_FORK2_HEIGHT: uint32

# soft fork initiated in 2.3.0 release
SOFT_FORK3_HEIGHT: uint32
SOFT_FORK4_HEIGHT: uint32

# the hard fork planned with the 2.0 release
# this is the block with the first plot filter adjustment
Expand Down
10 changes: 5 additions & 5 deletions chia/consensus/default_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
MAX_GENERATOR_REF_LIST_SIZE=uint32(512), # Number of references allowed in the block generator ref list
POOL_SUB_SLOT_ITERS=uint64(37600000000), # iters limit * NUM_SPS
SOFT_FORK2_HEIGHT=uint32(0),
SOFT_FORK3_HEIGHT=uint32(5650000),
SOFT_FORK4_HEIGHT=uint32(5650000),
# June 2024
HARD_FORK_HEIGHT=uint32(5496000),
HARD_FORK_FIX_HEIGHT=uint32(5496000),
Expand All @@ -82,8 +82,8 @@ def update_testnet_overrides(network_id: str, overrides: Dict[str, Any]) -> None
# these numbers are supposed to match initial-config.yaml
if "SOFT_FORK2_HEIGHT" not in overrides:
overrides["SOFT_FORK2_HEIGHT"] = 3000000
if "SOFT_FORK3_HEIGHT" not in overrides:
overrides["SOFT_FORK3_HEIGHT"] = 4465000
if "SOFT_FORK4_HEIGHT" not in overrides:
overrides["SOFT_FORK4_HEIGHT"] = 4465000
if "HARD_FORK_HEIGHT" not in overrides:
overrides["HARD_FORK_HEIGHT"] = 2997292
if "HARD_FORK_FIX_HEIGHT" not in overrides:
Expand All @@ -95,5 +95,5 @@ def update_testnet_overrides(network_id: str, overrides: Dict[str, Any]) -> None
if "PLOT_FILTER_32_HEIGHT" not in overrides:
overrides["PLOT_FILTER_32_HEIGHT"] = 13056556
if network_id == "testnet11":
if "SOFT_FORK3_HEIGHT" not in overrides:
overrides["SOFT_FORK3_HEIGHT"] = 641500
if "SOFT_FORK4_HEIGHT" not in overrides:
overrides["SOFT_FORK4_HEIGHT"] = 641500
2 changes: 1 addition & 1 deletion chia/full_node/mempool_check_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_flags_for_height_and_constants(height: int, constants: ConsensusConstant
if height >= constants.SOFT_FORK2_HEIGHT:
flags = flags | NO_RELATIVE_CONDITIONS_ON_EPHEMERAL

if height >= constants.SOFT_FORK3_HEIGHT:
if height >= constants.SOFT_FORK4_HEIGHT:
flags = flags | ENABLE_MESSAGE_CONDITIONS

if height >= constants.HARD_FORK_HEIGHT:
Expand Down
4 changes: 2 additions & 2 deletions chia/util/initial-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ network_overrides: &network_overrides
MEMPOOL_BLOCK_BUFFER: 10
MIN_PLOT_SIZE: 18
SOFT_FORK2_HEIGHT: 3000000
SOFT_FORK3_HEIGHT: 4465000
SOFT_FORK4_HEIGHT: 4465000
# planned 2.0 release is July 26, height 2965036 on testnet
# 1 week later
HARD_FORK_HEIGHT: 2997292
Expand All @@ -101,7 +101,7 @@ network_overrides: &network_overrides
# Forks activated from the beginning on this network
HARD_FORK_HEIGHT: 0
HARD_FORK_FIX_HEIGHT: 0
SOFT_FORK3_HEIGHT: 641500
SOFT_FORK4_HEIGHT: 641500
PLOT_FILTER_128_HEIGHT: 6029568
PLOT_FILTER_64_HEIGHT: 11075328
PLOT_FILTER_32_HEIGHT: 16121088
Expand Down

0 comments on commit 4b90197

Please sign in to comment.