From 2caedfb4106ed345914f2b11dc5b902bb458e411 Mon Sep 17 00:00:00 2001 From: Adam Kelly <338792+aqk@users.noreply.github.com> Date: Fri, 1 Sep 2023 09:27:56 -0700 Subject: [PATCH] Consider the blockchain height when validating partials. This allows us to take consensus rules changes (hard and soft forks) into consideration. --- pool/pool.py | 8 +++++++- pool/pool_server.py | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pool/pool.py b/pool/pool.py index 67a8abc..34fcaee 100644 --- a/pool/pool.py +++ b/pool/pool.py @@ -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() @@ -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}") diff --git a/pool/pool_server.py b/pool/pool_server.py index 0e20588..923c630 100644 --- a/pool/pool_server.py +++ b/pool/pool_server.py @@ -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} "