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

run_block_generator2() #16241

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions chia/consensus/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ConsensusConstants:
# the hard fork planned with the 2.0 release
# this is the block with the first plot filter adjustment
HARD_FORK_HEIGHT: uint32
HARD_FORK_FIX_HEIGHT: uint32

# the plot filter adjustment heights
PLOT_FILTER_128_HEIGHT: uint32
Expand Down
1 change: 1 addition & 0 deletions chia/consensus/default_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
# June 2024
"SOFT_FORK4_HEIGHT": 5496000,
"HARD_FORK_HEIGHT": 5496000,
"HARD_FORK_FIX_HEIGHT": 5496000,
# June 2027
"PLOT_FILTER_128_HEIGHT": 10542000,
# June 2030
Expand Down
1 change: 1 addition & 0 deletions chia/full_node/mempool_check_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def get_name_puzzle_conditions(
| ALLOW_BACKREFS
)

if height >= constants.HARD_FORK_FIX_HEIGHT:
run_block = run_block_generator2

try:
Expand Down
2 changes: 2 additions & 0 deletions chia/server/start_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def update_testnet_overrides(network_id: str, overrides: Dict[str, Any]) -> None
overrides["SOFT_FORK4_HEIGHT"] = 2997292
if "HARD_FORK_HEIGHT" not in overrides:
overrides["HARD_FORK_HEIGHT"] = 2997292
if "HARD_FORK_FIX_HEIGHT" not in overrides:
overrides["HARD_FORK_FIX_HEIGHT"] = 3426000
if "PLOT_FILTER_128_HEIGHT" not in overrides:
overrides["PLOT_FILTER_128_HEIGHT"] = 3061804
if "PLOT_FILTER_64_HEIGHT" not in overrides:
Expand Down
4 changes: 4 additions & 0 deletions chia/simulator/block_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
"MAX_FUTURE_TIME2": 3600 * 24 * 10,
"MEMPOOL_BLOCK_BUFFER": 6,
"UNIQUE_PLOTS_WINDOW": 2,
# we deliberately make this different from HARD_FORK_HEIGHT in the
# tests, to ensure they operate independently (which they need to do for
# testnet10)
"HARD_FORK_FIX_HEIGHT": 5496100,
}
)

Expand Down
2 changes: 2 additions & 0 deletions chia/util/initial-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ network_overrides: &network_overrides
# planned 2.0 release is July 26, height 2965036 on testnet
# 1 week later
HARD_FORK_HEIGHT: 2997292
# November 2023
arvidn marked this conversation as resolved.
Show resolved Hide resolved
HARD_FORK_FIX_HEIGHT: 3426000
# another 2 weeks later
PLOT_FILTER_128_HEIGHT: 3061804
# 3 years later
Expand Down
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ def blockchain_constants(consensus_mode) -> ConsensusConstants:
return test_constants.replace(SOFT_FORK3_HEIGHT=3, SOFT_FORK4_HEIGHT=3)
if consensus_mode == ConsensusMode.HARD_FORK_2_0:
return test_constants.replace(
HARD_FORK_HEIGHT=2, PLOT_FILTER_128_HEIGHT=10, PLOT_FILTER_64_HEIGHT=15, PLOT_FILTER_32_HEIGHT=20
HARD_FORK_HEIGHT=2,
HARD_FORK_FIX_HEIGHT=2,
PLOT_FILTER_128_HEIGHT=10,
PLOT_FILTER_64_HEIGHT=15,
PLOT_FILTER_32_HEIGHT=20,
)
raise AssertionError("Invalid Blockchain mode in simulation")

Expand Down Expand Up @@ -177,7 +181,7 @@ def db_version(request) -> int:
return request.param


SOFTFORK_HEIGHTS = [1000000, 4510000, 5496000]
SOFTFORK_HEIGHTS = [1000000, 4510000, 5496000, 5496100]


@pytest.fixture(scope="function", params=SOFTFORK_HEIGHTS)
Expand Down
16 changes: 8 additions & 8 deletions tests/core/mempool/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from chia.consensus.condition_costs import ConditionCost
from chia.consensus.cost_calculator import NPCResult
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.full_node.bitcoin_fee_estimator import create_bitcoin_fee_estimator
from chia.full_node.fee_estimation import EmptyMempoolInfo, MempoolInfo
from chia.full_node.full_node_api import FullNodeAPI
Expand All @@ -24,6 +23,7 @@
from chia.protocols.wallet_protocol import TransactionAck
from chia.server.outbound_message import Message
from chia.server.ws_connection import WSChiaConnection
from chia.simulator.block_tools import test_constants
from chia.simulator.simulator_protocol import FarmNewBlockProtocol
from chia.simulator.time_out_assert import time_out_assert
from chia.simulator.wallet_tools import WalletTool
Expand Down Expand Up @@ -1966,7 +1966,7 @@ def generator_condition_tester(
generator = BlockGenerator(program, [], [])
print(f"len: {len(bytes(program))}")
npc_result: NPCResult = get_name_puzzle_conditions(
generator, max_cost, mempool_mode=mempool_mode, height=height, constants=DEFAULT_CONSTANTS
generator, max_cost, mempool_mode=mempool_mode, height=height, constants=test_constants
)
return npc_result

Expand Down Expand Up @@ -2001,7 +2001,7 @@ def test_div(self, mempool, operand, expected, softfork_height):
)

# with the 2.0 hard fork, division with negative numbers is allowed
if operand < 0 and softfork_height >= DEFAULT_CONSTANTS.HARD_FORK_HEIGHT:
if operand < 0 and softfork_height >= test_constants.HARD_FORK_HEIGHT:
expected = None

assert npc_result.error == expected
Expand Down Expand Up @@ -2098,7 +2098,7 @@ def test_create_coin_cost(self, softfork_height):
# CREATE_COIN
puzzle_hash = "abababababababababababababababab"

if softfork_height >= DEFAULT_CONSTANTS.HARD_FORK_HEIGHT:
if softfork_height >= test_constants.HARD_FORK_FIX_HEIGHT:
generator_base_cost = 40
else:
generator_base_cost = 20470
Expand Down Expand Up @@ -2126,7 +2126,7 @@ def test_agg_sig_cost(self, softfork_height):
# AGG_SIG_ME
pubkey = "abababababababababababababababababababababababab"

if softfork_height >= DEFAULT_CONSTANTS.HARD_FORK_HEIGHT:
if softfork_height >= test_constants.HARD_FORK_FIX_HEIGHT:
generator_base_cost = 40
else:
generator_base_cost = 20512
Expand Down Expand Up @@ -2161,7 +2161,7 @@ def test_create_coin_different_parent(self, softfork_height):
)
generator = BlockGenerator(program, [], [])
npc_result: NPCResult = get_name_puzzle_conditions(
generator, MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height, constants=DEFAULT_CONSTANTS
generator, MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height, constants=test_constants
)
assert npc_result.error is None
assert len(npc_result.conds.spends) == 2
Expand Down Expand Up @@ -2245,7 +2245,7 @@ def test_softfork_condition(
expect_error = Err.INVALID_CONDITION.value
# the SOFTFORK condition is only activated with the hard fork, so
# before then there are no errors
elif softfork_height < DEFAULT_CONSTANTS.HARD_FORK_HEIGHT:
elif softfork_height < test_constants.HARD_FORK_HEIGHT:
expect_error = None

assert npc_result.error == expect_error
Expand Down Expand Up @@ -2490,7 +2490,7 @@ def test_duplicate_reserve_fee_negative(self, request: pytest.FixtureRequest, so
def test_duplicate_coin_announces(self, request, opcode, softfork_height):
# with soft-fork3, we only allow 1024 create- or assert announcements
# per spend
if softfork_height >= DEFAULT_CONSTANTS.SOFT_FORK3_HEIGHT:
if softfork_height >= test_constants.SOFT_FORK3_HEIGHT:
condition = CREATE_ANNOUNCE_COND.format(opcode=opcode.value[0], num=1024)
else:
condition = CREATE_ANNOUNCE_COND.format(opcode=opcode.value[0], num=5950000)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_cost_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def test_basics(self, softfork_height, bt):
assert spend_info.puzzle == coin_spend.puzzle_reveal
assert spend_info.solution == coin_spend.solution

if softfork_height >= bt.constants.HARD_FORK_HEIGHT:
if softfork_height >= bt.constants.HARD_FORK_FIX_HEIGHT:
clvm_cost = 27360
else:
clvm_cost = 404560
Expand Down
3 changes: 3 additions & 0 deletions tests/util/test_testnet_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_testnet10() -> None:
"SOFT_FORK3_HEIGHT": 2997292,
"SOFT_FORK4_HEIGHT": 2997292,
"HARD_FORK_HEIGHT": 2997292,
"HARD_FORK_FIX_HEIGHT": 3426000,
"PLOT_FILTER_128_HEIGHT": 3061804,
"PLOT_FILTER_64_HEIGHT": 8010796,
"PLOT_FILTER_32_HEIGHT": 13056556,
Expand All @@ -24,6 +25,7 @@ def test_testnet10_existing() -> None:
"SOFT_FORK3_HEIGHT": 42,
"SOFT_FORK4_HEIGHT": 45,
"HARD_FORK_HEIGHT": 42,
"HARD_FORK_FIX_HEIGHT": 3426000,
"PLOT_FILTER_128_HEIGHT": 42,
"PLOT_FILTER_64_HEIGHT": 42,
"PLOT_FILTER_32_HEIGHT": 42,
Expand All @@ -34,6 +36,7 @@ def test_testnet10_existing() -> None:
"SOFT_FORK3_HEIGHT": 42,
"SOFT_FORK4_HEIGHT": 45,
"HARD_FORK_HEIGHT": 42,
"HARD_FORK_FIX_HEIGHT": 3426000,
"PLOT_FILTER_128_HEIGHT": 42,
"PLOT_FILTER_64_HEIGHT": 42,
"PLOT_FILTER_32_HEIGHT": 42,
Expand Down