-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[CHIA-3793] after the hard fork, disallow block references #20218
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is such a bizarre magic number. I'm very puzzled why we wouldn't just use the serialization for the empty list. But I don't suppose it much matters now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't a list, it's a |
||
| 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| 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 @@ async def validate_unfinished_block_header( | |
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit puzzled as to why this is checked in multiple places. Maybe one is for all blocks and another is just for "transaction blocks"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We check it in |
||
|
|
||
| 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: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just a tidy-up, or is it required?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, this is unrelated. I was a bit surprised
mypydidn't flag this.transaction_generator_ref_listis notOptional[]. It can't beNone.