Skip to content

Commit

Permalink
Consider the blockchain height when validating partials. This allows …
Browse files Browse the repository at this point in the history
…us to take consensus rules changes (hard and soft forks) into consideration.
  • Loading branch information
aqk committed Sep 1, 2023
1 parent 1c827f0 commit 2caedfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pool/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ async def process_partial(
partial: PostPartialRequest,
farmer_record: FarmerRecord,
time_received_partial: uint64,
peak_height: uint32,
) -> Dict:
# Validate signatures
message: bytes32 = partial.payload.get_hash()
Expand Down Expand Up @@ -898,8 +899,13 @@ async def get_signage_point_or_eos():
assert end_of_sub_slot.challenge_chain
challenge_hash = end_of_sub_slot.challenge_chain.get_hash()

# Note the use of peak_height + 1. We Are evaluating the suitability for the next block
quality_string: Optional[bytes32] = verify_and_get_quality_string(
partial.payload.proof_of_space, self.constants, challenge_hash, partial.payload.sp_hash
partial.payload.proof_of_space,
self.constants,
challenge_hash,
partial.payload.sp_hash,
height=uint32(peak_height + 1),
)
if quality_string is None:
return error_dict(PoolErrorCode.INVALID_PROOF, f"Invalid proof of space {partial.payload.sp_hash}")
Expand Down
6 changes: 5 additions & 1 deletion pool/pool_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ async def post_partial(self, request_obj) -> web.Response:
f"Farmer with launcher_id {partial.payload.launcher_id.hex()} not known.",
)

post_partial_response = await self.pool.process_partial(partial, farmer_record, uint64(int(start_time)))
peak_height = self.pool.blockchain_state["peak"].height
# Note the use of peak_height + 1. We Are evaluating the suitability for the next block
post_partial_response = await self.pool.process_partial(
partial, farmer_record, uint64(int(start_time)), peak_height + 1
)

self.pool.log.info(
f"post_partial response {post_partial_response}, time: {time.time() - start_time} "
Expand Down

0 comments on commit 2caedfb

Please sign in to comment.