Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion benchmarks/block_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from chia_rs.sized_bytes import bytes32
from chia_rs.sized_ints import uint32

from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.blockchain import Blockchain
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.consensus.get_block_generator import get_block_generator
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.coin_store import CoinStore
from chia.types.blockchain_format.serialized_program import SerializedProgram
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/ram_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from chia_rs import ConsensusConstants

from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.blockchain import Blockchain
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.coin_store import CoinStore
from chia.util.db_wrapper import DBWrapper2
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/stores/test_block_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from chia._tests.blockchain.blockchain_test_utils import _validate_and_add_block
from chia._tests.util.db_connection import DBConnection, PathDBConnection
from chia.consensus.block_body_validation import ForkInfo
from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.blockchain import AddBlockResult, Blockchain
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.consensus.full_block_to_block_record import header_block_to_sub_block_record
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.coin_store import CoinStore
from chia.full_node.full_block_utils import GeneratorBlockInfo
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/stores/test_coin_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from chia._tests.util.db_connection import DBConnection
from chia._tests.util.misc import Marks, datacases
from chia.consensus.block_body_validation import ForkInfo
from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward
from chia.consensus.blockchain import AddBlockResult, Blockchain
from chia.consensus.coinbase import create_farmer_coin, create_pool_coin
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.coin_store import CoinStore
from chia.full_node.hint_store import HintStore
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/test_block_height_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from chia_rs.sized_ints import uint8, uint32

from chia._tests.util.db_connection import DBConnection
from chia.full_node.block_height_map import BlockHeightMap, SesCache
from chia.consensus.block_height_map import BlockHeightMap, SesCache
from chia.util.db_wrapper import DBWrapper2
from chia.util.files import write_file_async

Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/test_db_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from chia._tests.util.temp_file import TempFile
from chia.cmds.db_upgrade_func import convert_v1_to_v2
from chia.consensus.block_body_validation import ForkInfo
from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.blockchain import Blockchain
from chia.consensus.multiprocess_validation import PreValidationResult
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.coin_store import CoinStore
from chia.full_node.hint_store import HintStore
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/test_db_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from chia._tests.util.temp_file import TempFile
from chia.cmds.db_validate_func import validate_v2
from chia.consensus.block_body_validation import ForkInfo
from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.blockchain import Blockchain
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.consensus.multiprocess_validation import PreValidationResult
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.coin_store import CoinStore
from chia.simulator.block_tools import test_constants
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/util/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from chia_rs import ConsensusConstants, FullBlock
from chia_rs.sized_ints import uint64

from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.blockchain import Blockchain
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.coin_store import CoinStore
from chia.simulator.block_tools import BlockTools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from chia_rs.sized_bytes import bytes32
from chia_rs.sized_ints import uint32

from chia.consensus.block_height_map_protocol import BlockHeightMapProtocol
from chia.util.db_wrapper import DBWrapper2
from chia.util.files import write_file_async
from chia.util.streamable import Streamable, streamable
Expand All @@ -23,7 +24,7 @@ class SesCache(Streamable):
content: list[tuple[uint32, bytes]]


class BlockHeightMap:
class BlockHeightMap(BlockHeightMapProtocol):
db: DBWrapper2

# the below dictionaries are loaded from the database, from the peak
Expand Down
21 changes: 21 additions & 0 deletions chia/consensus/block_height_map_protocol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import annotations

from typing import Optional, Protocol

from chia_rs import SubEpochSummary
from chia_rs.sized_bytes import bytes32
from chia_rs.sized_ints import uint32


class BlockHeightMapProtocol(Protocol):
def update_height(self, height: uint32, header_hash: bytes32, ses: Optional[SubEpochSummary]) -> None: ...

def get_hash(self, height: uint32) -> bytes32: ...

def contains_height(self, height: uint32) -> bool: ...

def rollback(self, fork_height: int) -> None: ...

def get_ses(self, height: uint32) -> SubEpochSummary: ...

def get_ses_heights(self) -> list[uint32]: ...
2 changes: 1 addition & 1 deletion chia/consensus/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from chia.consensus.block_body_validation import ForkInfo, validate_block_body
from chia.consensus.block_header_validation import validate_unfinished_header_block
from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.coin_store_protocol import CoinStoreProtocol
from chia.consensus.cost_calculator import NPCResult
from chia.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_difficulty
Expand All @@ -34,7 +35,6 @@
from chia.consensus.generator_tools import get_block_header
from chia.consensus.get_block_generator import get_block_generator
from chia.consensus.multiprocess_validation import PreValidationResult
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.vdf import VDFInfo
Expand Down
2 changes: 1 addition & 1 deletion chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from chia.consensus.augmented_chain import AugmentedBlockchain
from chia.consensus.block_body_validation import ForkInfo
from chia.consensus.block_creation import unfinished_block_to_full_block
from chia.consensus.block_height_map import BlockHeightMap
from chia.consensus.blockchain import AddBlockResult, Blockchain, BlockchainMutexPriority, StateChangeSummary
from chia.consensus.blockchain_interface import BlockchainInterface
from chia.consensus.coin_store_protocol import CoinStoreProtocol
Expand All @@ -49,7 +50,6 @@
from chia.consensus.multiprocess_validation import PreValidationResult, pre_validate_block
from chia.consensus.pot_iterations import calculate_sp_iters
from chia.consensus.signage_point import SignagePoint
from chia.full_node.block_height_map import BlockHeightMap
from chia.full_node.block_store import BlockStore
from chia.full_node.check_fork_next_block import check_fork_next_block
from chia.full_node.coin_store import CoinStore
Expand Down
Loading