[CHIA-3793] after the hard fork, disallow block references (#20218)

* after the hard fork, disallow block references

* disable hard-fork 2 tests until we have a new test cache

* fix rate limits test
This commit is contained in:
Arvid Norberg
2025-11-06 09:36:44 -07:00
committed by GitHub
parent ece6de2af5
commit 43c3c63145
3 changed files with 18 additions and 5 deletions
+5 -1
View File
@@ -341,10 +341,14 @@ async def validate_block_body(
# the generator ref list for this block (or 'one' bytes [0x01] if no generator)
# 8b. The generator ref list length must be less than or equal to MAX_GENERATOR_REF_LIST_SIZE entries
# 8c. The generator ref list must not point to a height >= this block's height
if block.transactions_generator_ref_list in (None, []):
if block.transactions_generator_ref_list == []:
if block.transactions_info.generator_refs_root != bytes([1] * 32):
return Err.INVALID_TRANSACTIONS_GENERATOR_REFS_ROOT
else:
# With hard fork 2 we ban transactions_generator_ref_list.
if prev_transaction_block_height >= constants.HARD_FORK2_HEIGHT:
return Err.TOO_MANY_GENERATOR_REFS
# If we have a generator reference list, we must have a generator
if block.transactions_generator is None:
return Err.INVALID_TRANSACTIONS_GENERATOR_REFS_ROOT
+9 -4
View File
@@ -33,6 +33,7 @@ from chia.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_dif
from chia.consensus.find_fork_point import lookup_fork_chain
from chia.consensus.full_block_to_block_record import block_to_block_record
from chia.consensus.generator_tools import get_block_header
from chia.consensus.get_block_challenge import prev_tx_block
from chia.consensus.get_block_generator import get_block_generator
from chia.consensus.multiprocess_validation import PreValidationResult
from chia.full_node.block_store import BlockStore
@@ -698,12 +699,16 @@ class Blockchain:
if len(block.transactions_generator_ref_list) > self.constants.MAX_GENERATOR_REF_LIST_SIZE:
return None, Err.TOO_MANY_GENERATOR_REFS
if (
self.try_block_record(block.prev_header_hash) is None
and block.prev_header_hash != self.constants.GENESIS_CHALLENGE
):
prev_b = self.try_block_record(block.prev_header_hash)
if prev_b is None and block.prev_header_hash != self.constants.GENESIS_CHALLENGE:
return None, Err.INVALID_PREV_BLOCK_HASH
prev_tx_height = prev_tx_block(self, prev_b)
# With hard fork 2 we ban transactions_generator_ref_list.
if prev_tx_height >= self.constants.HARD_FORK2_HEIGHT and block.transactions_generator_ref_list != []:
return None, Err.TOO_MANY_GENERATOR_REFS
if block.transactions_info is not None:
if block.transactions_generator is not None:
if std_hash(bytes(block.transactions_generator)) != block.transactions_info.generator_root:
+4
View File
@@ -387,6 +387,10 @@ class BlockTools:
transaction_data: Optional[SpendBundle],
block_refs: list[uint32],
) -> Optional[NewBlockGenerator]:
if prev_tx_height >= self.constants.HARD_FORK2_HEIGHT:
assert block_refs == [], "block references are not allowed after hard fork 2"
dummy_block_references = False
# we don't know if the new block will be a transaction
# block or not, so even though we prepare a block
# generator, we can't update our state (like,