Overflow sub-blocks in new sub-epoch
This commit is contained in:
parent
3095dca92a
commit
292da475f2
|
@ -337,7 +337,6 @@ async def validate_unfinished_header_block(
|
|||
)
|
||||
if expected_sub_epoch_summary.get_hash() != ses_hash:
|
||||
return None, Err.INVALID_SUB_EPOCH_SUMMARY
|
||||
print(f"Verified sub epoch: {expected_sub_epoch_summary}")
|
||||
else:
|
||||
# 3d. Check that we don't have to include a sub-epoch summary
|
||||
if new_sub_slot and not genesis_block:
|
||||
|
@ -378,10 +377,9 @@ async def validate_unfinished_header_block(
|
|||
# Blocks with very low required iters are not overflow blocks
|
||||
assert not overflow
|
||||
|
||||
# 5. Check no overflows in new sub-epoch
|
||||
if overflow and ses_hash is not None:
|
||||
log.error("block %s failed validation at step %d overflow block with no ses hash", header_block.header_hash, 5)
|
||||
return None, Err.NO_OVERFLOWS_IN_NEW_SUBEPOCH
|
||||
# 5. Check no overflows in the first sub-slot of a new epoch (although they are OK in the second sub-slot)
|
||||
if overflow and finishes_epoch and len(header_block.finished_sub_slots) < 2:
|
||||
return None, Err.NO_OVERFLOWS_IN_FIRST_SUB_SLOT_NEW_EPOCH
|
||||
|
||||
# If sub_block state is correct, we should always find a challenge here
|
||||
# This computes what the challenge should be for this sub-block
|
||||
|
@ -411,12 +409,11 @@ async def validate_unfinished_header_block(
|
|||
if curr.height == 0:
|
||||
break
|
||||
curr = sub_blocks[curr.prev_hash]
|
||||
challenge = reversed_challenge_hashes[-challenges_to_look_for]
|
||||
challenge = reversed_challenge_hashes[challenges_to_look_for - 1]
|
||||
assert challenge is not None
|
||||
|
||||
# 6. Check challenge in proof of space is valid
|
||||
if challenge != header_block.reward_chain_sub_block.proof_of_space.challenge_hash:
|
||||
print("Challenge", challenge, header_block.reward_chain_sub_block.proof_of_space, header_block.total_iters)
|
||||
return None, Err.INVALID_POSPACE_CHALLENGE
|
||||
|
||||
# 7. Check total iters
|
||||
|
|
|
@ -270,6 +270,7 @@ class BlockTools:
|
|||
slot_cc_challenge, slot_rc_challenge = get_challenges(
|
||||
sub_blocks, finished_sub_slots, latest_sub_block.header_hash
|
||||
)
|
||||
print(f"Starting slot cc: {slot_cc_challenge}")
|
||||
|
||||
# Get all proofs of space for challenge.
|
||||
proofs_of_space: List[Tuple[uint64, ProofOfSpace]] = self.get_pospaces_for_challenge(
|
||||
|
@ -393,7 +394,7 @@ class BlockTools:
|
|||
if new_ips is not None:
|
||||
ips = new_ips
|
||||
difficulty = new_difficulty
|
||||
overflow_sub_blocks = [] # No overflow blocks on new difficulty
|
||||
overflow_pos = [] # No overflow blocks on new difficulty
|
||||
else:
|
||||
ses_hash = None
|
||||
new_ips = None
|
||||
|
@ -533,7 +534,6 @@ class BlockTools:
|
|||
rc_sp_vdf: Optional[VDFInfo] = None
|
||||
rc_sp_proof: Optional[VDFProof] = None
|
||||
cc_sp_hash: Optional[bytes32] = slot_cc_challenge
|
||||
rc_sp_hash: Optional[bytes32] = slot_rc_challenge
|
||||
if sp_iters != 0:
|
||||
if is_genesis:
|
||||
cc_vdf_input = ClassgroupElement.get_default_element()
|
||||
|
@ -1007,8 +1007,8 @@ class BlockTools:
|
|||
proof_xs,
|
||||
)
|
||||
found_proofs.append((required_iters, proof_of_space))
|
||||
if len(found_proofs) >= 2:
|
||||
random_sample = random.sample(found_proofs, len(found_proofs) - 1)
|
||||
if len(found_proofs) >= 4:
|
||||
random_sample = random.sample(found_proofs, len(found_proofs) - 3)
|
||||
else:
|
||||
random_sample = found_proofs
|
||||
print(
|
||||
|
|
|
@ -115,7 +115,7 @@ class Err(Enum):
|
|||
IP_SHOULD_BE_NONE = 90
|
||||
INVALID_REWARD_BLOCK_HASH = 91
|
||||
INVALID_MADE_NON_OVERFLOW_INFUSIONS = 92
|
||||
NO_OVERFLOWS_IN_NEW_SUBEPOCH = 93
|
||||
NO_OVERFLOWS_IN_FIRST_SUB_SLOT_NEW_EPOCH = 93
|
||||
|
||||
MEMPOOL_NOT_INITIALIZED = 94
|
||||
SHOULD_NOT_HAVE_ICC = 95
|
||||
|
|
|
@ -92,7 +92,7 @@ class TestGenesisBlock:
|
|||
class TestAddingMoreBlocks:
|
||||
@pytest.mark.asyncio
|
||||
async def test_non_genesis(self, empty_blockchain):
|
||||
blocks = bt.get_consecutive_blocks(test_constants, 30, force_overflow=False, force_empty_slots=0)
|
||||
blocks = bt.get_consecutive_blocks(test_constants, 300, force_overflow=False, force_empty_slots=0)
|
||||
for block in blocks:
|
||||
result, err, _ = await empty_blockchain.receive_block(block)
|
||||
assert err is None
|
||||
|
|
Loading…
Reference in New Issue