Skip to content

Commit

Permalink
Apply suggestions from code review (addendum).
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineKhaldi committed Sep 17, 2024
1 parent b86503c commit 49bed65
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
4 changes: 2 additions & 2 deletions chia/_tests/blockchain/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3949,8 +3949,8 @@ async def test_reorg_flip_flop(empty_blockchain: Blockchain, bt: BlockTools) ->
async def test_get_tx_peak(default_400_blocks: List[FullBlock], empty_blockchain: Blockchain) -> None:
bc = empty_blockchain
test_blocks = default_400_blocks[:100]
ssi = empty_blockchain.constants.SUB_SLOT_ITERS_STARTING
diff = empty_blockchain.constants.DIFFICULTY_STARTING
ssi = bc.constants.SUB_SLOT_ITERS_STARTING
diff = bc.constants.DIFFICULTY_STARTING
res = await pre_validate_blocks_multiprocessing(
bc.constants,
bc,
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/core/full_node/test_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ async def check_transaction_confirmed(transaction) -> bool:
await _validate_and_add_block_no_error(blockchain, reorg_block)
for i in range(1, height):
results = await pre_validate_blocks_multiprocessing(
bt.constants,
blockchain.constants,
blockchain,
all_blocks[:i],
blockchain.pool,
Expand All @@ -446,7 +446,7 @@ async def check_transaction_confirmed(transaction) -> bool:
await _validate_and_add_block_no_error(blockchain, block)
for i in range(1, height):
results = await pre_validate_blocks_multiprocessing(
bt.constants,
blockchain.constants,
blockchain,
all_blocks[:i],
blockchain.pool,
Expand Down
7 changes: 2 additions & 5 deletions chia/_tests/farmer_harvester/test_third_party_harvesters.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,11 @@ async def add_test_blocks_into_full_node(blocks: List[FullBlock], full_node: Ful
prev_ses_block = curr
new_slot = len(block.finished_sub_slots) > 0
ssi, diff = get_next_sub_slot_iters_and_difficulty(full_node.constants, new_slot, prev_b, full_node.blockchain)

constants = full_node.blockchain.constants
pool = full_node.blockchain.pool
pre_validation_results: List[PreValidationResult] = await pre_validate_blocks_multiprocessing(
constants,
full_node.blockchain.constants,
full_node.blockchain,
blocks,
pool,
full_node.blockchain.pool,
{},
sub_slot_iters=ssi,
difficulty=diff,
Expand Down
10 changes: 4 additions & 6 deletions chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,12 +1333,11 @@ async def add_block_batch(
# Validates signatures in multiprocessing since they take a while, and we don't have cached transactions
# for these blocks (unlike during normal operation where we validate one at a time)
pre_validate_start = time.monotonic()
pool = self.blockchain.pool
pre_validation_results: List[PreValidationResult] = await pre_validate_blocks_multiprocessing(
self.constants,
self.blockchain.constants,
self.blockchain,
blocks_to_validate,
pool,
self.blockchain.pool,
{},
sub_slot_iters=current_ssi,
difficulty=current_difficulty,
Expand Down Expand Up @@ -1864,12 +1863,11 @@ async def add_block(
prev_ses_block = curr
new_slot = len(block.finished_sub_slots) > 0
ssi, diff = get_next_sub_slot_iters_and_difficulty(self.constants, new_slot, prev_b, self.blockchain)
pool = self.blockchain.pool
pre_validation_results = await pre_validate_blocks_multiprocessing(
self.constants,
self.blockchain.constants,
self.blockchain,
[block],
pool,
self.blockchain.pool,
npc_results,
sub_slot_iters=ssi,
difficulty=diff,
Expand Down
10 changes: 4 additions & 6 deletions chia/simulator/full_node_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,11 @@ async def farm_new_transaction_block(
current_blocks = await self.get_all_full_blocks()
if len(current_blocks) == 0:
genesis = self.bt.get_consecutive_blocks(uint8(1))[0]
pool = self.full_node.blockchain.pool
pre_validation_results: List[PreValidationResult] = await pre_validate_blocks_multiprocessing(
self.bt.constants,
self.full_node.blockchain.constants,
self.full_node.blockchain,
[genesis],
pool,
self.full_node.blockchain.pool,
{},
sub_slot_iters=ssi,
difficulty=diff,
Expand Down Expand Up @@ -234,12 +233,11 @@ async def farm_new_block(self, request: FarmNewBlockProtocol, force_wait_for_tim
current_blocks = await self.get_all_full_blocks()
if len(current_blocks) == 0:
genesis = self.bt.get_consecutive_blocks(uint8(1))[0]
pool = self.full_node.blockchain.pool
pre_validation_results: List[PreValidationResult] = await pre_validate_blocks_multiprocessing(
self.bt.constants,
self.full_node.blockchain.constants,
self.full_node.blockchain,
[genesis],
pool,
self.full_node.blockchain.pool,
{},
sub_slot_iters=ssi,
difficulty=diffculty,
Expand Down

0 comments on commit 49bed65

Please sign in to comment.