mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 10:05:29 -05:00
1.0.1 wp blue box fix (#1434)
* fix wp bluebox integration * lint * remove corrupted segments * log * typo in sql * cache wp on restart * remove bad log * lint * fix typo * block tools semi compacted blocks
This commit is contained in:
committed by
Justin England
parent
c600059d37
commit
de89254d98
@@ -37,9 +37,12 @@ class BlockStore:
|
||||
"block blob, sub_epoch_summary blob, is_peak tinyint, is_block tinyint)"
|
||||
)
|
||||
|
||||
# todo remove in v1.2
|
||||
await self.db.execute("DROP TABLE IF EXISTS sub_epoch_segments")
|
||||
|
||||
# Sub epoch segments for weight proofs
|
||||
await self.db.execute(
|
||||
"CREATE TABLE IF NOT EXISTS sub_epoch_segments(ses_height bigint PRIMARY KEY, challenge_segments blob)"
|
||||
"CREATE TABLE IF NOT EXISTS sub_epoch_segments_v2(ses_height bigint PRIMARY KEY, challenge_segments blob)"
|
||||
)
|
||||
|
||||
# Height index so we can look up in order of height for sync purposes
|
||||
@@ -106,7 +109,7 @@ class BlockStore:
|
||||
self, sub_epoch_summary_height: uint32, segments: List[SubEpochChallengeSegment]
|
||||
):
|
||||
cursor_1 = await self.db.execute(
|
||||
"INSERT OR REPLACE INTO sub_epoch_segments VALUES(?, ?)",
|
||||
"INSERT OR REPLACE INTO sub_epoch_segments_v2 VALUES(?, ?)",
|
||||
(sub_epoch_summary_height, bytes(SubEpochSegments(segments))),
|
||||
)
|
||||
await cursor_1.close()
|
||||
@@ -116,7 +119,7 @@ class BlockStore:
|
||||
sub_epoch_summary_height: uint32,
|
||||
) -> Optional[List[SubEpochChallengeSegment]]:
|
||||
cursor = await self.db.execute(
|
||||
"SELECT challenge_segments from sub_epoch_segments WHERE ses_height=?", (sub_epoch_summary_height,)
|
||||
"SELECT challenge_segments from sub_epoch_segments_v2 WHERE ses_height=?", (sub_epoch_summary_height,)
|
||||
)
|
||||
row = await cursor.fetchone()
|
||||
await cursor.close()
|
||||
@@ -125,7 +128,7 @@ class BlockStore:
|
||||
return None
|
||||
|
||||
async def delete_sub_epoch_challenge_segments(self, fork_height: uint32):
|
||||
cursor = await self.db.execute("delete from sub_epoch_segments WHERE ses_height>?", (fork_height,))
|
||||
cursor = await self.db.execute("delete from sub_epoch_segments_v2 WHERE ses_height>?", (fork_height,))
|
||||
await cursor.close()
|
||||
|
||||
async def get_full_block(self, header_hash: bytes32) -> Optional[FullBlock]:
|
||||
|
||||
@@ -122,6 +122,7 @@ class FullNode:
|
||||
f" {self.blockchain.get_peak().height}, "
|
||||
f"time taken: {int(time_taken)}s"
|
||||
)
|
||||
await self.weight_proof_handler.get_proof_of_weight(self.blockchain.get_peak().header_hash)
|
||||
pending_tx = await self.mempool_manager.new_peak(self.blockchain.get_peak())
|
||||
assert len(pending_tx) == 0 # no pending transactions when starting up
|
||||
|
||||
|
||||
@@ -376,9 +376,7 @@ class WeightProofHandler:
|
||||
tmp_sub_slots_data: List[SubSlotData] = []
|
||||
while not blocks[curr.header_hash].is_challenge_block(self.constants):
|
||||
if curr.first_in_sub_slot:
|
||||
# if not blue boxed
|
||||
if not blue_boxed_end_of_slot(curr.finished_sub_slots[0]):
|
||||
sub_slots_data.extend(tmp_sub_slots_data)
|
||||
sub_slots_data.extend(tmp_sub_slots_data)
|
||||
# add collected vdfs
|
||||
for idx, sub_slot in enumerate(curr.finished_sub_slots):
|
||||
prev_rec = blocks[curr.prev_header_hash]
|
||||
@@ -955,6 +953,19 @@ def _validate_sub_slot_data(
|
||||
log.error(f"failed cc slot end validation {sub_slot_data.cc_slot_end_info}")
|
||||
return False
|
||||
else:
|
||||
# find end of slot
|
||||
idx = sub_slot_idx
|
||||
while idx < len(sub_slots) - 1:
|
||||
curr_slot = sub_slots[idx]
|
||||
if curr_slot.is_end_of_slot():
|
||||
# dont validate intermediate vdfs if slot is blue boxed
|
||||
assert curr_slot.cc_slot_end
|
||||
if curr_slot.cc_slot_end.normalized_to_identity is True:
|
||||
log.debug(f"skip intermediate vdfs slot {sub_slot_idx}")
|
||||
return True
|
||||
else:
|
||||
break
|
||||
idx += 1
|
||||
if sub_slot_data.icc_infusion_point is not None and sub_slot_data.icc_ip_vdf_info is not None:
|
||||
input = ClassgroupElement.get_default_element()
|
||||
if not prev_ssd.is_challenge() and prev_ssd.icc_ip_vdf_info is not None:
|
||||
|
||||
+23
-20
@@ -269,7 +269,10 @@ class BlockTools:
|
||||
force_overflow: bool = False,
|
||||
skip_slots: int = 0, # Force at least this number of empty slots before the first SB
|
||||
guarantee_transaction_block: bool = False, # Force that this block must be a tx block
|
||||
normalized_to_identity: bool = False, # CC_EOS, ICC_EOS, CC_SP, CC_IP vdf proofs are normalized to identity.
|
||||
normalized_to_identity_cc_eos: bool = False,
|
||||
normalized_to_identity_icc_eos: bool = False,
|
||||
normalized_to_identity_cc_sp: bool = False,
|
||||
normalized_to_identity_cc_ip: bool = False,
|
||||
current_time: bool = False,
|
||||
) -> List[FullBlock]:
|
||||
assert num_blocks > 0
|
||||
@@ -368,7 +371,7 @@ class BlockTools:
|
||||
uint8(signage_point_index),
|
||||
finished_sub_slots_at_sp,
|
||||
sub_slot_iters,
|
||||
normalized_to_identity,
|
||||
normalized_to_identity_cc_sp,
|
||||
)
|
||||
if signage_point_index == 0:
|
||||
cc_sp_output_hash: bytes32 = slot_cc_challenge
|
||||
@@ -440,7 +443,7 @@ class BlockTools:
|
||||
signage_point,
|
||||
latest_block,
|
||||
seed,
|
||||
normalized_to_identity=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip,
|
||||
current_time=current_time,
|
||||
)
|
||||
if block_record.is_transaction_block:
|
||||
@@ -490,7 +493,7 @@ class BlockTools:
|
||||
eos_deficit: uint8 = (
|
||||
latest_block.deficit if latest_block.deficit > 0 else constants.MIN_BLOCKS_PER_CHALLENGE_BLOCK
|
||||
)
|
||||
icc_ip_vdf, icc_ip_proof = get_icc(
|
||||
icc_eos_vdf, icc_ip_proof = get_icc(
|
||||
constants,
|
||||
uint128(sub_slot_start_total_iters + sub_slot_iters),
|
||||
finished_sub_slots_at_ip,
|
||||
@@ -502,7 +505,7 @@ class BlockTools:
|
||||
# End of slot vdf info for icc and cc have to be from challenge block or start of slot, respectively,
|
||||
# in order for light clients to validate.
|
||||
cc_vdf = VDFInfo(cc_vdf.challenge, sub_slot_iters, cc_vdf.output)
|
||||
if normalized_to_identity:
|
||||
if normalized_to_identity_cc_eos:
|
||||
_, cc_proof = get_vdf_info_and_proof(
|
||||
constants,
|
||||
ClassgroupElement.get_default_element(),
|
||||
@@ -533,7 +536,7 @@ class BlockTools:
|
||||
new_sub_slot_iters = None
|
||||
new_difficulty = None
|
||||
|
||||
if icc_ip_vdf is not None:
|
||||
if icc_eos_vdf is not None:
|
||||
# Icc vdf (Deficit of latest block is <= 4)
|
||||
if len(finished_sub_slots_at_ip) == 0:
|
||||
# This means there are blocks in this sub-slot
|
||||
@@ -547,20 +550,20 @@ class BlockTools:
|
||||
else:
|
||||
# This means there are no blocks in this sub-slot
|
||||
icc_eos_iters = sub_slot_iters
|
||||
icc_ip_vdf = VDFInfo(
|
||||
icc_ip_vdf.challenge,
|
||||
icc_eos_vdf = VDFInfo(
|
||||
icc_eos_vdf.challenge,
|
||||
icc_eos_iters,
|
||||
icc_ip_vdf.output,
|
||||
icc_eos_vdf.output,
|
||||
)
|
||||
if normalized_to_identity:
|
||||
if normalized_to_identity_icc_eos:
|
||||
_, icc_ip_proof = get_vdf_info_and_proof(
|
||||
constants,
|
||||
ClassgroupElement.get_default_element(),
|
||||
icc_ip_vdf.challenge,
|
||||
icc_eos_vdf.challenge,
|
||||
icc_eos_iters,
|
||||
True,
|
||||
)
|
||||
icc_sub_slot: Optional[InfusedChallengeChainSubSlot] = InfusedChallengeChainSubSlot(icc_ip_vdf)
|
||||
icc_sub_slot: Optional[InfusedChallengeChainSubSlot] = InfusedChallengeChainSubSlot(icc_eos_vdf)
|
||||
assert icc_sub_slot is not None
|
||||
icc_sub_slot_hash = icc_sub_slot.get_hash() if latest_block.deficit == 0 else None
|
||||
cc_sub_slot = ChallengeChainSubSlot(
|
||||
@@ -622,7 +625,7 @@ class BlockTools:
|
||||
uint8(signage_point_index),
|
||||
finished_sub_slots_eos,
|
||||
sub_slot_iters,
|
||||
normalized_to_identity,
|
||||
normalized_to_identity_cc_sp,
|
||||
)
|
||||
if signage_point_index == 0:
|
||||
cc_sp_output_hash = slot_cc_challenge
|
||||
@@ -684,7 +687,7 @@ class BlockTools:
|
||||
seed,
|
||||
overflow_cc_challenge=overflow_cc_challenge,
|
||||
overflow_rc_challenge=overflow_rc_challenge,
|
||||
normalized_to_identity=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity_cc_ip,
|
||||
)
|
||||
|
||||
if block_record.is_transaction_block:
|
||||
@@ -966,7 +969,7 @@ def get_signage_point(
|
||||
signage_point_index: uint8,
|
||||
finished_sub_slots: List[EndOfSubSlotBundle],
|
||||
sub_slot_iters: uint64,
|
||||
normalized_to_identity: bool = False,
|
||||
normalized_to_identity_cc_sp: bool = False,
|
||||
) -> SignagePoint:
|
||||
if signage_point_index == 0:
|
||||
return SignagePoint(None, None, None, None)
|
||||
@@ -1006,7 +1009,7 @@ def get_signage_point(
|
||||
rc_vdf_iters,
|
||||
)
|
||||
cc_sp_vdf = replace(cc_sp_vdf, number_of_iterations=sp_iters)
|
||||
if normalized_to_identity:
|
||||
if normalized_to_identity_cc_sp:
|
||||
_, cc_sp_proof = get_vdf_info_and_proof(
|
||||
constants,
|
||||
ClassgroupElement.get_default_element(),
|
||||
@@ -1032,7 +1035,7 @@ def finish_block(
|
||||
latest_block: BlockRecord,
|
||||
sub_slot_iters: uint64,
|
||||
difficulty: uint64,
|
||||
normalized_to_identity: bool = False,
|
||||
normalized_to_identity_cc_ip: bool = False,
|
||||
):
|
||||
is_overflow = is_overflow_block(constants, signage_point_index)
|
||||
cc_vdf_challenge = slot_cc_challenge
|
||||
@@ -1051,7 +1054,7 @@ def finish_block(
|
||||
new_ip_iters,
|
||||
)
|
||||
cc_ip_vdf = replace(cc_ip_vdf, number_of_iterations=ip_iters)
|
||||
if normalized_to_identity:
|
||||
if normalized_to_identity_cc_ip:
|
||||
_, cc_ip_proof = get_vdf_info_and_proof(
|
||||
constants,
|
||||
ClassgroupElement.get_default_element(),
|
||||
@@ -1257,7 +1260,7 @@ def get_full_block_and_block_record(
|
||||
seed: bytes = b"",
|
||||
overflow_cc_challenge: bytes32 = None,
|
||||
overflow_rc_challenge: bytes32 = None,
|
||||
normalized_to_identity: bool = False,
|
||||
normalized_to_identity_cc_ip: bool = False,
|
||||
current_time: bool = False,
|
||||
) -> Tuple[FullBlock, BlockRecord]:
|
||||
if current_time is True:
|
||||
@@ -1309,7 +1312,7 @@ def get_full_block_and_block_record(
|
||||
prev_block,
|
||||
sub_slot_iters,
|
||||
difficulty,
|
||||
normalized_to_identity,
|
||||
normalized_to_identity_cc_ip,
|
||||
)
|
||||
|
||||
return full_block, block_record
|
||||
|
||||
@@ -6,14 +6,21 @@ from typing import Dict, List, Optional, Tuple
|
||||
import aiosqlite
|
||||
import pytest
|
||||
|
||||
from src.consensus.block_header_validation import validate_finished_header_block
|
||||
from src.consensus.block_record import BlockRecord
|
||||
from src.consensus.blockchain import Blockchain
|
||||
from src.consensus.default_constants import DEFAULT_CONSTANTS
|
||||
from src.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_difficulty
|
||||
from src.consensus.full_block_to_block_record import block_to_block_record
|
||||
from src.full_node.block_store import BlockStore
|
||||
from src.full_node.coin_store import CoinStore
|
||||
from src.server.start_full_node import SERVICE_NAME
|
||||
from src.types.blockchain_format.sized_bytes import bytes32
|
||||
from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary
|
||||
from src.util.block_cache import BlockCache
|
||||
from src.util.block_tools import test_constants
|
||||
from src.util.config import load_config
|
||||
from src.util.default_root import DEFAULT_ROOT_PATH
|
||||
from tests.setup_nodes import bt
|
||||
|
||||
try:
|
||||
@@ -244,7 +251,60 @@ class TestWeightProof:
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
10, block_list_input=blocks, seed=b"asdfghjkl", force_overflow=True, skip_slots=4
|
||||
1,
|
||||
block_list_input=blocks,
|
||||
seed=b"asdfghjkl",
|
||||
force_overflow=True,
|
||||
skip_slots=4,
|
||||
normalized_to_identity_cc_eos=True,
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
10,
|
||||
block_list_input=blocks,
|
||||
seed=b"asdfghjkl",
|
||||
force_overflow=True,
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
1,
|
||||
block_list_input=blocks,
|
||||
seed=b"asdfghjkl",
|
||||
force_overflow=True,
|
||||
skip_slots=4,
|
||||
normalized_to_identity_icc_eos=True,
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
10,
|
||||
block_list_input=blocks,
|
||||
seed=b"asdfghjkl",
|
||||
force_overflow=True,
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
1,
|
||||
block_list_input=blocks,
|
||||
seed=b"asdfghjkl",
|
||||
force_overflow=True,
|
||||
skip_slots=4,
|
||||
normalized_to_identity_cc_ip=True,
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
10,
|
||||
block_list_input=blocks,
|
||||
seed=b"asdfghjkl",
|
||||
force_overflow=True,
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
1,
|
||||
block_list_input=blocks,
|
||||
seed=b"asdfghjkl",
|
||||
force_overflow=True,
|
||||
skip_slots=4,
|
||||
normalized_to_identity_cc_sp=True,
|
||||
)
|
||||
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
@@ -321,7 +381,9 @@ class TestWeightProof:
|
||||
100,
|
||||
block_list_input=default_10000_blocks_compact,
|
||||
seed=b"asdfghjkl",
|
||||
normalized_to_identity=False,
|
||||
normalized_to_identity_cc_ip=True,
|
||||
normalized_to_identity_cc_eos=True,
|
||||
normalized_to_identity_icc_eos=True,
|
||||
)
|
||||
header_cache, height_to_hash, sub_blocks, summaries = await load_blocks_dont_validate(blocks)
|
||||
wpf = WeightProofHandler(test_constants, BlockCache(sub_blocks, header_cache, height_to_hash, summaries))
|
||||
|
||||
+34
-5
@@ -72,7 +72,14 @@ async def default_20000_blocks():
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
async def default_10000_blocks_compact():
|
||||
return persistent_blocks(10000, f"test_blocks_10000_compact_{block_format_version}.db", normalized_to_identity=True)
|
||||
return persistent_blocks(
|
||||
10000,
|
||||
f"test_blocks_10000_compact_{block_format_version}.db",
|
||||
normalized_to_identity_cc_eos=True,
|
||||
normalized_to_identity_icc_eos=True,
|
||||
normalized_to_identity_cc_ip=True,
|
||||
normalized_to_identity_cc_sp=True,
|
||||
)
|
||||
|
||||
|
||||
def persistent_blocks(
|
||||
@@ -80,7 +87,10 @@ def persistent_blocks(
|
||||
db_name: str,
|
||||
seed: bytes = b"",
|
||||
empty_sub_slots=0,
|
||||
normalized_to_identity: bool = False,
|
||||
normalized_to_identity_cc_eos: bool = False,
|
||||
normalized_to_identity_icc_eos: bool = False,
|
||||
normalized_to_identity_cc_sp: bool = False,
|
||||
normalized_to_identity_cc_ip: bool = False,
|
||||
):
|
||||
# try loading from disc, if not create new blocks.db file
|
||||
# TODO hash fixtures.py and blocktool.py, add to path, delete if the files changed
|
||||
@@ -103,18 +113,37 @@ def persistent_blocks(
|
||||
except EOFError:
|
||||
print("\n error reading db file")
|
||||
|
||||
return new_test_db(file_path, num_of_blocks, seed, empty_sub_slots, normalized_to_identity)
|
||||
return new_test_db(
|
||||
file_path,
|
||||
num_of_blocks,
|
||||
seed,
|
||||
empty_sub_slots,
|
||||
normalized_to_identity_cc_eos,
|
||||
normalized_to_identity_icc_eos,
|
||||
normalized_to_identity_cc_sp,
|
||||
normalized_to_identity_cc_ip,
|
||||
)
|
||||
|
||||
|
||||
def new_test_db(
|
||||
path: Path, num_of_blocks: int, seed: bytes, empty_sub_slots: int, normalized_to_identity: bool = False
|
||||
path: Path,
|
||||
num_of_blocks: int,
|
||||
seed: bytes,
|
||||
empty_sub_slots: int,
|
||||
normalized_to_identity_cc_eos: bool = False, # CC_EOS,
|
||||
normalized_to_identity_icc_eos: bool = False, # ICC_EOS
|
||||
normalized_to_identity_cc_sp: bool = False, # CC_SP,
|
||||
normalized_to_identity_cc_ip: bool = False, # CC_IP
|
||||
):
|
||||
print(f"create {path} with {num_of_blocks} blocks with ")
|
||||
blocks: List[FullBlock] = bt.get_consecutive_blocks(
|
||||
num_of_blocks,
|
||||
seed=seed,
|
||||
skip_slots=empty_sub_slots,
|
||||
normalized_to_identity=normalized_to_identity,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity_cc_eos,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity_icc_eos,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity_cc_sp,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity_cc_ip,
|
||||
)
|
||||
block_bytes_list: List[bytes] = []
|
||||
for block in blocks:
|
||||
|
||||
@@ -34,7 +34,14 @@ class TestFullNodeStore:
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_store(self, empty_blockchain, normalized_to_identity: bool = False):
|
||||
blockchain = empty_blockchain
|
||||
blocks = bt.get_consecutive_blocks(10, seed=b"1234", normalized_to_identity=normalized_to_identity)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
10,
|
||||
seed=b"1234",
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
|
||||
store = await FullNodeStore.create(test_constants)
|
||||
|
||||
@@ -79,7 +86,14 @@ class TestFullNodeStore:
|
||||
store.remove_unfinished_block(unf_block.partial_hash)
|
||||
assert store.get_unfinished_block(unf_block.partial_hash) is None
|
||||
|
||||
blocks = bt.get_consecutive_blocks(1, skip_slots=5, normalized_to_identity=normalized_to_identity)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
1,
|
||||
skip_slots=5,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
)
|
||||
sub_slots = blocks[0].finished_sub_slots
|
||||
assert len(sub_slots) == 5
|
||||
|
||||
@@ -143,8 +157,22 @@ class TestFullNodeStore:
|
||||
)
|
||||
|
||||
# Test adding non genesis peak directly
|
||||
blocks = bt.get_consecutive_blocks(2, skip_slots=2, normalized_to_identity=normalized_to_identity)
|
||||
blocks = bt.get_consecutive_blocks(3, block_list_input=blocks, normalized_to_identity=normalized_to_identity)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
2,
|
||||
skip_slots=2,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
3,
|
||||
block_list_input=blocks,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
for block in blocks:
|
||||
await blockchain.receive_block(block)
|
||||
sb = blockchain.block_record(block.header_hash)
|
||||
@@ -153,7 +181,13 @@ class TestFullNodeStore:
|
||||
assert res[0] is None
|
||||
|
||||
# Add reorg blocks
|
||||
blocks_reorg = bt.get_consecutive_blocks(20, normalized_to_identity=normalized_to_identity)
|
||||
blocks_reorg = bt.get_consecutive_blocks(
|
||||
20,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
for block in blocks_reorg:
|
||||
res, _, _ = await blockchain.receive_block(block)
|
||||
if res == ReceiveBlockResult.NEW_PEAK:
|
||||
@@ -164,7 +198,13 @@ class TestFullNodeStore:
|
||||
|
||||
# Add slots to the end
|
||||
blocks_2 = bt.get_consecutive_blocks(
|
||||
1, block_list_input=blocks_reorg, skip_slots=2, normalized_to_identity=normalized_to_identity
|
||||
1,
|
||||
block_list_input=blocks_reorg,
|
||||
skip_slots=2,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
for slot in blocks_2[-1].finished_sub_slots:
|
||||
store.new_finished_sub_slot(slot, blockchain, blockchain.get_peak(), await blockchain.get_full_peak())
|
||||
@@ -190,7 +230,12 @@ class TestFullNodeStore:
|
||||
blocks = blocks_reorg
|
||||
while True:
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
1, block_list_input=blocks, normalized_to_identity=normalized_to_identity
|
||||
1,
|
||||
block_list_input=blocks,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
res, _, _ = await blockchain.receive_block(blocks[-1])
|
||||
if res == ReceiveBlockResult.NEW_PEAK:
|
||||
@@ -210,7 +255,13 @@ class TestFullNodeStore:
|
||||
|
||||
# Add slots to the end, except for the last one, which we will use to test invalid SP
|
||||
blocks_2 = bt.get_consecutive_blocks(
|
||||
1, block_list_input=blocks, skip_slots=3, normalized_to_identity=normalized_to_identity
|
||||
1,
|
||||
block_list_input=blocks,
|
||||
skip_slots=3,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
for slot in blocks_2[-1].finished_sub_slots[:-1]:
|
||||
store.new_finished_sub_slot(slot, blockchain, blockchain.get_peak(), await blockchain.get_full_peak())
|
||||
@@ -331,7 +382,14 @@ class TestFullNodeStore:
|
||||
)
|
||||
assert store.new_signage_point(i, {}, None, peak.sub_slot_iters, sp)
|
||||
|
||||
blocks_3 = bt.get_consecutive_blocks(1, skip_slots=2, normalized_to_identity=normalized_to_identity)
|
||||
blocks_3 = bt.get_consecutive_blocks(
|
||||
1,
|
||||
skip_slots=2,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
for slot in blocks_3[-1].finished_sub_slots:
|
||||
store.new_finished_sub_slot(slot, {}, None, None)
|
||||
assert len(store.finished_sub_slots) == 3
|
||||
@@ -354,9 +412,21 @@ class TestFullNodeStore:
|
||||
assert store.new_signage_point(i, {}, None, peak.sub_slot_iters, sp)
|
||||
|
||||
# Test adding signage points after genesis
|
||||
blocks_4 = bt.get_consecutive_blocks(1, normalized_to_identity=normalized_to_identity)
|
||||
blocks_4 = bt.get_consecutive_blocks(
|
||||
1,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
blocks_5 = bt.get_consecutive_blocks(
|
||||
1, block_list_input=blocks_4, skip_slots=1, normalized_to_identity=normalized_to_identity
|
||||
1,
|
||||
block_list_input=blocks_4,
|
||||
skip_slots=1,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
|
||||
# If this is not the case, fix test to find a block that is
|
||||
@@ -389,11 +459,22 @@ class TestFullNodeStore:
|
||||
|
||||
# Test future EOS cache
|
||||
store.initialize_genesis_sub_slot()
|
||||
blocks = bt.get_consecutive_blocks(1, normalized_to_identity=normalized_to_identity)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
1,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
await blockchain.receive_block(blocks[-1])
|
||||
while True:
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
1, block_list_input=blocks, normalized_to_identity=normalized_to_identity
|
||||
1,
|
||||
block_list_input=blocks,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
)
|
||||
await blockchain.receive_block(blocks[-1])
|
||||
sb = blockchain.block_record(blocks[-1].header_hash)
|
||||
@@ -421,7 +502,13 @@ class TestFullNodeStore:
|
||||
|
||||
# Test future IP cache
|
||||
store.initialize_genesis_sub_slot()
|
||||
blocks = bt.get_consecutive_blocks(60, normalized_to_identity=normalized_to_identity)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
60,
|
||||
normalized_to_identity_cc_ip=normalized_to_identity,
|
||||
normalized_to_identity_cc_sp=normalized_to_identity,
|
||||
normalized_to_identity_cc_eos=normalized_to_identity,
|
||||
normalized_to_identity_icc_eos=normalized_to_identity,
|
||||
)
|
||||
|
||||
for block in blocks[:5]:
|
||||
await blockchain.receive_block(block)
|
||||
|
||||
Reference in New Issue
Block a user