From c8fe842bbc7ebfb85a4cc61ca882ed1a18ebcf40 Mon Sep 17 00:00:00 2001 From: Gene Hoffman Date: Sun, 21 Feb 2021 15:09:36 -0800 Subject: [PATCH] Clean up some lingering sub block language --- src/consensus/block_body_validation.py | 12 ++++++------ src/consensus/blockchain.py | 5 +++-- src/full_node/full_node_api.py | 2 +- src/wallet/wallet_blockchain.py | 7 ++++--- src/wallet/wallet_state_manager.py | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/consensus/block_body_validation.py b/src/consensus/block_body_validation.py index 6d3bfe140c..33dc224f73 100644 --- a/src/consensus/block_body_validation.py +++ b/src/consensus/block_body_validation.py @@ -231,16 +231,16 @@ async def validate_block_body( # 15. Check if removals exist and were not previously spent. (unspent_db + diff_store + this_block) if peak is None or height == 0: - fork_sub_h: int = -1 + fork_h: int = -1 elif fork_point_with_peak is not None: - fork_sub_h = fork_point_with_peak + fork_h = fork_point_with_peak else: - fork_sub_h = find_fork_point_in_chain(blocks, peak, blocks.block_record(block.prev_header_hash)) + fork_h = find_fork_point_in_chain(blocks, peak, blocks.block_record(block.prev_header_hash)) - if fork_sub_h == -1: + if fork_h == -1: coin_store_reorg_height = -1 else: - last_sb_in_common = await blocks.get_block_record_from_db(blocks.height_to_hash(uint32(fork_sub_h))) + last_sb_in_common = await blocks.get_block_record_from_db(blocks.height_to_hash(uint32(fork_h))) assert last_sb_in_common is not None coin_store_reorg_height = last_sb_in_common.height @@ -253,7 +253,7 @@ async def validate_block_body( curr: Optional[FullBlock] = await block_store.get_full_block(block.prev_header_hash) assert curr is not None - while curr.height > fork_sub_h: + while curr.height > fork_h: removals_in_curr, additions_in_curr = curr.tx_removals_and_additions() for c_name in removals_in_curr: removals_since_fork.add(c_name) diff --git a/src/consensus/blockchain.py b/src/consensus/blockchain.py index 53a08865fd..d5e0137932 100644 --- a/src/consensus/blockchain.py +++ b/src/consensus/blockchain.py @@ -572,8 +572,9 @@ class Blockchain(BlockchainInterface): def clean_block_records(self): """ - Cleans the cache so that we only maintain relevant blocks. This removes block records that have sub - height < peak - BLOCKS_CACHE_SIZE. These blocks are necessary for calculating future difficulty adjustments. + Cleans the cache so that we only maintain relevant blocks. This removes + block records that have height < peak - BLOCKS_CACHE_SIZE. + These blocks are necessary for calculating future difficulty adjustments. """ if len(self.__block_records) < self.constants.BLOCKS_CACHE_SIZE: diff --git a/src/full_node/full_node_api.py b/src/full_node/full_node_api.py index e8a68533af..e944d1a690 100644 --- a/src/full_node/full_node_api.py +++ b/src/full_node/full_node_api.py @@ -404,7 +404,7 @@ class FullNodeAPI: num_non_empty_sub_slots_seen = 0 for _ in range(30): if num_non_empty_sub_slots_seen >= 3: - self.log.debug("Diverged from peer. Don't have the same sub-blocks") + self.log.debug("Diverged from peer. Don't have the same blocks") return None # If this is an end of sub slot, and we don't have the prev, request the prev instead # We want to catch up to the latest slot so we can receive signage points diff --git a/src/wallet/wallet_blockchain.py b/src/wallet/wallet_blockchain.py index b721cb2578..bc35a55cd8 100644 --- a/src/wallet/wallet_blockchain.py +++ b/src/wallet/wallet_blockchain.py @@ -245,7 +245,7 @@ class WalletBlockchain(BlockchainInterface): fork_height: Optional[uint32] = await self._reconsider_peak(block_record, genesis, fork_point_with_peak) if fork_height is not None: - self.log.info(f"💰 Updated wallet peak to sub height {block_record.height}, weight {block_record.weight}, ") + self.log.info(f"💰 Updated wallet peak to height {block_record.height}, weight {block_record.weight}, ") return ReceiveBlockResult.NEW_PEAK, None, fork_height else: return ReceiveBlockResult.ADDED_AS_ORPHAN, None, None @@ -437,8 +437,9 @@ class WalletBlockchain(BlockchainInterface): def clean_block_records(self): """ - Cleans the cache so that we only maintain relevant blocks. This removes block records that have sub - height < peak - BLOCKS_CACHE_SIZE. These blocks are necessary for calculating future difficulty adjustments. + Cleans the cache so that we only maintain relevant blocks. + This removes block records that have height < peak - BLOCKS_CACHE_SIZE. + These blocks are necessary for calculating future difficulty adjustments. """ if len(self.__block_records) < self.constants.BLOCKS_CACHE_SIZE: diff --git a/src/wallet/wallet_state_manager.py b/src/wallet/wallet_state_manager.py index 9d8973eca8..7ac4bfd1c4 100644 --- a/src/wallet/wallet_state_manager.py +++ b/src/wallet/wallet_state_manager.py @@ -488,8 +488,8 @@ class WalletStateManager: farmer_rewards = set() prev = await self.blockchain.get_block_record_from_db(block.prev_hash) - # [sub 1] [sub 2] [block 3] [sub 4] [sub 5] [block6] - # [block 6] will contain rewards for [sub 1] [sub 2] [block 3] + # [block 1] [block 2] [tx block 3] [block 4] [block 5] [tx block 6] + # [tx block 6] will contain rewards for [block 1] [block 2] [tx block 3] while prev is not None: # step 1 find previous block if prev.is_transaction_block: