47
47
from chia .consensus .augmented_chain import AugmentedBlockchain
48
48
from chia .consensus .block_body_validation import ForkInfo
49
49
from chia .consensus .blockchain import Blockchain
50
- from chia .consensus .coin_store_protocol import CoinStoreProtocol
50
+ from chia .consensus .consensus_store_protocol import ConsensusStoreProtocol
51
51
from chia .consensus .get_block_challenge import get_block_challenge
52
52
from chia .consensus .multiprocess_validation import PreValidationResult , pre_validate_block
53
53
from chia .consensus .pot_iterations import is_overflow_block
@@ -2505,7 +2505,7 @@ def print_coin_records(records: dict[bytes32, CoinRecord]) -> None: # pragma: n
2505
2505
print (f"{ rec } " )
2506
2506
2507
2507
2508
- async def validate_coin_set (coin_store : CoinStoreProtocol , blocks : list [FullBlock ]) -> None :
2508
+ async def validate_coin_set (consensus_store : ConsensusStoreProtocol , blocks : list [FullBlock ]) -> None :
2509
2509
prev_height = blocks [0 ].height - 1
2510
2510
prev_hash = blocks [0 ].prev_header_hash
2511
2511
for block in blocks :
@@ -2514,7 +2514,7 @@ async def validate_coin_set(coin_store: CoinStoreProtocol, blocks: list[FullBloc
2514
2514
prev_height = int (block .height )
2515
2515
prev_hash = block .header_hash
2516
2516
rewards = block .get_included_reward_coins ()
2517
- records = {rec .coin .name (): rec for rec in await coin_store .get_coins_added_at_height (block .height )}
2517
+ records = {rec .coin .name (): rec for rec in await consensus_store .get_coins_added_at_height (block .height )}
2518
2518
2519
2519
# validate reward coins
2520
2520
for reward in rewards :
@@ -2550,7 +2550,7 @@ async def validate_coin_set(coin_store: CoinStoreProtocol, blocks: list[FullBloc
2550
2550
print_coin_records (records )
2551
2551
assert records == {}
2552
2552
2553
- records = {rec .coin .name (): rec for rec in await coin_store .get_coins_removed_at_height (block .height )}
2553
+ records = {rec .coin .name (): rec for rec in await consensus_store .get_coins_removed_at_height (block .height )}
2554
2554
for name , rem in removals :
2555
2555
rec = records .pop (name )
2556
2556
assert rec is not None
@@ -2598,8 +2598,8 @@ async def test_long_reorg(
2598
2598
assert reorg_blocks [fork_point ] == default_10000_blocks [fork_point ]
2599
2599
assert reorg_blocks [fork_point + 1 ] != default_10000_blocks [fork_point + 1 ]
2600
2600
2601
- assert node .full_node ._coin_store is not None
2602
- await validate_coin_set (node .full_node ._coin_store , blocks )
2601
+ assert node .full_node .blockchain . consensus_store is not None
2602
+ await validate_coin_set (node .full_node .blockchain . consensus_store , blocks )
2603
2603
2604
2604
# one aspect of this test is to make sure we can reorg blocks that are
2605
2605
# not in the cache. We need to explicitly prune the cache to get that
@@ -2614,7 +2614,7 @@ async def test_long_reorg(
2614
2614
chain_2_weight = peak .weight
2615
2615
chain_2_peak = peak .header_hash
2616
2616
2617
- await validate_coin_set (node .full_node ._coin_store , reorg_blocks )
2617
+ await validate_coin_set (node .full_node .blockchain . consensus_store , reorg_blocks )
2618
2618
2619
2619
# if the reorg chain has lighter blocks, once we've re-orged onto it, we
2620
2620
# have a greater block height. If the reorg chain has heavier blocks, we
@@ -2639,7 +2639,7 @@ async def test_long_reorg(
2639
2639
assert peak .header_hash != chain_2_peak
2640
2640
assert peak .weight > chain_2_weight
2641
2641
2642
- await validate_coin_set (node .full_node ._coin_store , blocks )
2642
+ await validate_coin_set (node .full_node .blockchain . consensus_store , blocks )
2643
2643
2644
2644
2645
2645
@pytest .mark .anyio
@@ -2665,9 +2665,9 @@ async def test_long_reorg_nodes(
2665
2665
) -> None :
2666
2666
full_node_1 , full_node_2 , full_node_3 = three_nodes
2667
2667
2668
- assert full_node_1 .full_node ._coin_store is not None
2669
- assert full_node_2 .full_node ._coin_store is not None
2670
- assert full_node_3 .full_node ._coin_store is not None
2668
+ assert full_node_1 .full_node .blockchain . consensus_store is not None
2669
+ assert full_node_2 .full_node .blockchain . consensus_store is not None
2670
+ assert full_node_3 .full_node .blockchain . consensus_store is not None
2671
2671
2672
2672
if light_blocks :
2673
2673
if fork_point == 1500 :
@@ -2725,8 +2725,8 @@ def check_nodes_in_sync() -> bool:
2725
2725
assert p2 is not None
2726
2726
assert p2 .header_hash == reorg_blocks [- 1 ].header_hash
2727
2727
2728
- await validate_coin_set (full_node_1 .full_node ._coin_store , reorg_blocks )
2729
- await validate_coin_set (full_node_2 .full_node ._coin_store , reorg_blocks )
2728
+ await validate_coin_set (full_node_1 .full_node .blockchain . consensus_store , reorg_blocks )
2729
+ await validate_coin_set (full_node_2 .full_node .blockchain . consensus_store , reorg_blocks )
2730
2730
2731
2731
blocks = default_10000_blocks [:reorg_height ]
2732
2732
@@ -2766,9 +2766,9 @@ def check_nodes_in_sync2() -> bool:
2766
2766
print (f"reorg1 timing: { reorg1_timing :0.2f} s" )
2767
2767
print (f"reorg2 timing: { reorg2_timing :0.2f} s" )
2768
2768
2769
- await validate_coin_set (full_node_1 .full_node ._coin_store , blocks )
2770
- await validate_coin_set (full_node_2 .full_node ._coin_store , blocks )
2771
- await validate_coin_set (full_node_3 .full_node ._coin_store , blocks )
2769
+ await validate_coin_set (full_node_1 .full_node .blockchain . consensus_store , blocks )
2770
+ await validate_coin_set (full_node_2 .full_node .blockchain . consensus_store , blocks )
2771
+ await validate_coin_set (full_node_3 .full_node .blockchain . consensus_store , blocks )
2772
2772
2773
2773
2774
2774
@pytest .mark .anyio
@@ -2805,8 +2805,8 @@ def check_nodes_in_sync() -> bool:
2805
2805
return p1 == p2
2806
2806
2807
2807
await time_out_assert (10 , check_nodes_in_sync )
2808
- await validate_coin_set (full_node_1 .full_node .blockchain .coin_store , chain )
2809
- await validate_coin_set (full_node_2 .full_node .blockchain .coin_store , chain )
2808
+ await validate_coin_set (full_node_1 .full_node .blockchain .consensus_store , chain )
2809
+ await validate_coin_set (full_node_2 .full_node .blockchain .consensus_store , chain )
2810
2810
2811
2811
# we spend a coin in the next block
2812
2812
spend_bundle = wallet_a .generate_signed_transaction (uint64 (1_000 ), receiver_puzzlehash , all_coins .pop ())
@@ -2838,8 +2838,8 @@ def check_nodes_in_sync() -> bool:
2838
2838
await add_blocks_in_batches (chain_a [- 1 :], full_node_1 .full_node )
2839
2839
2840
2840
await time_out_assert (10 , check_nodes_in_sync )
2841
- await validate_coin_set (full_node_1 .full_node .blockchain .coin_store , chain_a )
2842
- await validate_coin_set (full_node_2 .full_node .blockchain .coin_store , chain_a )
2841
+ await validate_coin_set (full_node_1 .full_node .blockchain .consensus_store , chain_a )
2842
+ await validate_coin_set (full_node_2 .full_node .blockchain .consensus_store , chain_a )
2843
2843
2844
2844
await add_blocks_in_batches (chain_b [- 1 :], full_node_1 .full_node )
2845
2845
@@ -2849,8 +2849,8 @@ def check_nodes_in_sync() -> bool:
2849
2849
assert peak .header_hash == chain_b [- 1 ].header_hash
2850
2850
2851
2851
await time_out_assert (10 , check_nodes_in_sync )
2852
- await validate_coin_set (full_node_1 .full_node .blockchain .coin_store , chain_b )
2853
- await validate_coin_set (full_node_2 .full_node .blockchain .coin_store , chain_b )
2852
+ await validate_coin_set (full_node_1 .full_node .blockchain .consensus_store , chain_b )
2853
+ await validate_coin_set (full_node_2 .full_node .blockchain .consensus_store , chain_b )
2854
2854
2855
2855
# now continue building the chain on top of B
2856
2856
# since spend_bundle was supposed to have been reorged-out, we should be
@@ -2885,8 +2885,8 @@ def check_nodes_in_sync() -> bool:
2885
2885
2886
2886
await add_blocks_in_batches (chain [- 4 :], full_node_1 .full_node )
2887
2887
await time_out_assert (10 , check_nodes_in_sync )
2888
- await validate_coin_set (full_node_1 .full_node .blockchain .coin_store , chain )
2889
- await validate_coin_set (full_node_2 .full_node .blockchain .coin_store , chain )
2888
+ await validate_coin_set (full_node_1 .full_node .blockchain .consensus_store , chain )
2889
+ await validate_coin_set (full_node_2 .full_node .blockchain .consensus_store , chain )
2890
2890
2891
2891
2892
2892
@pytest .mark .anyio
0 commit comments