Skip to content

Commit e6c5e88

Browse files
committed
revert strength
1 parent bbc9fc0 commit e6c5e88

File tree

12 files changed

+66
-115
lines changed

12 files changed

+66
-115
lines changed

chia/_tests/farmer_harvester/test_farmer_harvester.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ async def test_v2_partial_proofs_new_sp_hash(
341341
partial_proofs=[b"test_partial_proof_1"],
342342
signage_point_index=uint8(0),
343343
plot_size=uint8(32),
344-
difficulty=uint64(1000),
345344
pool_public_key=None,
346345
pool_contract_puzzle_hash=bytes32(b"4" * 32),
347346
plot_public_key=G1Element(),
@@ -371,7 +370,6 @@ async def test_v2_partial_proofs_missing_sp_hash(
371370
partial_proofs=[b"test_partial_proof_1"],
372371
signage_point_index=uint8(0),
373372
plot_size=uint8(32),
374-
difficulty=uint64(1000),
375373
pool_public_key=None,
376374
pool_contract_puzzle_hash=bytes32(b"4" * 32),
377375
plot_public_key=G1Element(),
@@ -414,7 +412,6 @@ async def test_v2_partial_proofs_with_existing_sp(
414412
partial_proofs=[b"test_partial_proof_1", b"test_partial_proof_2"],
415413
signage_point_index=uint8(0),
416414
plot_size=uint8(32),
417-
difficulty=uint64(1000),
418415
pool_public_key=G1Element(),
419416
pool_contract_puzzle_hash=bytes32(b"4" * 32),
420417
plot_public_key=G1Element(),
@@ -448,7 +445,6 @@ async def test_solution_response_handler(
448445
partial_proofs=[b"test_partial_proof_for_quality"],
449446
signage_point_index=uint8(0),
450447
plot_size=uint8(32),
451-
difficulty=uint64(1000),
452448
pool_public_key=G1Element(),
453449
pool_contract_puzzle_hash=bytes32(b"4" * 32),
454450
plot_public_key=G1Element(),
@@ -525,7 +521,6 @@ async def test_solution_response_empty_proof(
525521
partial_proofs=[b"test_partial_proof_for_quality"],
526522
signage_point_index=uint8(0),
527523
plot_size=uint8(32),
528-
difficulty=uint64(1000),
529524
pool_public_key=G1Element(),
530525
pool_contract_puzzle_hash=bytes32(b"4" * 32),
531526
plot_public_key=G1Element(),
@@ -587,7 +582,6 @@ async def test_v2_partial_proofs_solver_exception(
587582
partial_proofs=[b"test_partial_proof_1"],
588583
signage_point_index=uint8(0),
589584
plot_size=uint8(32),
590-
difficulty=uint64(1000),
591585
pool_public_key=G1Element(),
592586
pool_contract_puzzle_hash=bytes32(b"4" * 32),
593587
plot_public_key=G1Element(),

chia/_tests/solver/test_solver_service.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from chia.simulator.block_tools import create_block_tools_async
1212
from chia.simulator.keyring import TempKeyring
1313
from chia.simulator.setup_services import setup_solver
14-
from chia.solver.solver_rpc_client import SolverRpcClient
1514

1615

1716
@pytest.mark.anyio
@@ -28,28 +27,3 @@ async def test_solver_api_methods(blockchain_constants: ConsensusConstants, tmp_
2827
api_result = await solver_api.solve(test_info)
2928
assert api_result is not None
3029
assert isinstance(api_result, Message)
31-
32-
33-
@pytest.mark.anyio
34-
async def test_solver_error_handling(
35-
blockchain_constants: ConsensusConstants, self_hostname: str, tmp_path: Path
36-
) -> None:
37-
with TempKeyring(populate=True) as keychain:
38-
bt = await create_block_tools_async(constants=blockchain_constants, keychain=keychain)
39-
async with setup_solver(tmp_path, bt, blockchain_constants) as solver_service:
40-
assert solver_service.rpc_server is not None
41-
solver_rpc_client = await SolverRpcClient.create(
42-
self_hostname, solver_service.rpc_server.listen_port, solver_service.root_path, solver_service.config
43-
)
44-
try:
45-
await solver_rpc_client.solve("invalid_hex")
46-
assert False, "should have raised exception for invalid hex"
47-
except Exception:
48-
pass # expected
49-
# test solver handles exception in solve method
50-
solver = solver_service._node
51-
test_info = SolverInfo(partial_proof=b"test_partial_proof_zeros")
52-
with patch.object(solver, "solve", side_effect=RuntimeError("test error")):
53-
# solver api should handle exceptions gracefully
54-
result = await solver_service._api.solve(test_info)
55-
assert result is None # api returns None on error

chia/_tests/util/network_protocol_data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
[b"partial-proof1", b"partial-proof2"],
159159
uint8(4),
160160
uint8(32),
161-
uint64(100000),
162161
G1Element.from_bytes(
163162
bytes.fromhex(
164163
"a04c6b5ac7dfb935f6feecfdd72348ccf1d4be4fe7e26acf271ea3b7d308da61e0a308f7a62495328a81f5147b66634c"
-8 Bytes
Binary file not shown.

chia/_tests/util/protocol_messages_json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"partial_proofs": ["0x7061727469616c2d70726f6f6631", "0x7061727469616c2d70726f6f6632"],
7373
"signage_point_index": 4,
7474
"plot_size": 32,
75-
"difficulty": 100000,
7675
"pool_public_key": "0xa04c6b5ac7dfb935f6feecfdd72348ccf1d4be4fe7e26acf271ea3b7d308da61e0a308f7a62495328a81f5147b66634c",
7776
"pool_contract_puzzle_hash": "0x91240fbacdf93b44c0571caa74fd99f163d4c5d7deaedac87125528721493f7a",
7877
"plot_public_key": "0xa04c6b5ac7dfb935f6feecfdd72348ccf1d4be4fe7e26acf271ea3b7d308da61e0a308f7a62495328a81f5147b66634c",

chia/cmds/solver.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,3 @@ def get_state_cmd(
3131
from chia.cmds.solver_funcs import get_state
3232

3333
asyncio.run(get_state(ChiaCliContext.set_default(ctx), solver_rpc_port))
34-
35-
36-
@solver_cmd.command("solve", help="Solve a partial proof of space, turning it into a full proof")
37-
@click.option(
38-
"-sp",
39-
"--solver-rpc-port",
40-
help="Set the port where the Solver is hosting the RPC interface. See the rpc_port under solver in config.yaml",
41-
type=int,
42-
default=None,
43-
show_default=True,
44-
)
45-
@click.option(
46-
"-p",
47-
"--partial_proof",
48-
help="partial proof string to solve (hex format)",
49-
type=str,
50-
required=True,
51-
)
52-
@click.pass_context
53-
def solve_cmd(
54-
ctx: click.Context,
55-
solver_rpc_port: Optional[int],
56-
partial_proof: str,
57-
) -> None:
58-
import asyncio
59-
60-
from chia.cmds.solver_funcs import solve_partial_proof
61-
62-
asyncio.run(solve_partial_proof(ChiaCliContext.set_default(ctx), solver_rpc_port, partial_proof))

chia/cmds/solver_funcs.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,3 @@ async def get_state(
1919
print(json.dumps(response, indent=2))
2020
except Exception as e:
2121
print(f"Failed to get solver state: {e}")
22-
23-
24-
async def solve_partial_proof(
25-
ctx: ChiaCliContext,
26-
solver_rpc_port: Optional[int],
27-
partial_proof: str,
28-
) -> None:
29-
"""Solve a partial proof via RPC."""
30-
try:
31-
async with get_any_service_client(SolverRpcClient, ctx.root_path, solver_rpc_port) as (client, _):
32-
response = await client.solve(partial_proof)
33-
print(json.dumps(response, indent=2))
34-
except Exception as e:
35-
print(f"Failed to solve partial proof: {e}")

chia/harvester/harvester_api.py

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import logging
55
import time
6+
from collections.abc import Awaitable, Sequence
67
from pathlib import Path
78
from typing import TYPE_CHECKING, ClassVar, Optional, cast
89

@@ -65,6 +66,47 @@ def _plot_passes_filter(self, plot_info: PlotInfo, challenge: harvester_protocol
6566
challenge.sp_hash,
6667
)
6768

69+
async def _handle_v1_responses(
70+
self,
71+
awaitables: Sequence[Awaitable[tuple[Path, list[harvester_protocol.NewProofOfSpace]]]],
72+
start_time: float,
73+
peer: WSChiaConnection,
74+
) -> int:
75+
proofs_found = 0
76+
for filename_sublist_awaitable in asyncio.as_completed(awaitables):
77+
filename, sublist = await filename_sublist_awaitable
78+
time_taken = time.monotonic() - start_time
79+
if time_taken > 8:
80+
self.harvester.log.warning(
81+
f"Looking up qualities on {filename} took: {time_taken}. This should be below 8 seconds"
82+
f" to minimize risk of losing rewards."
83+
)
84+
for response in sublist:
85+
proofs_found += 1
86+
msg = make_msg(ProtocolMessageTypes.new_proof_of_space, response)
87+
await peer.send_message(msg)
88+
return proofs_found
89+
90+
async def _handle_v2_responses(
91+
self, v2_awaitables: Sequence[Awaitable[Optional[PartialProofsData]]], start_time: float, peer: WSChiaConnection
92+
) -> int:
93+
partial_proofs_found = 0
94+
for quality_awaitable in asyncio.as_completed(v2_awaitables):
95+
partial_proofs_data = await quality_awaitable
96+
if partial_proofs_data is None:
97+
continue
98+
time_taken = time.monotonic() - start_time
99+
if time_taken > 8:
100+
self.harvester.log.warning(
101+
f"Looking up partial proofs on {partial_proofs_data.plot_identifier}"
102+
f"took: {time_taken}. This should be below 8 seconds"
103+
f"to minimize risk of losing rewards."
104+
)
105+
partial_proofs_found += len(partial_proofs_data.partial_proofs)
106+
msg = make_msg(ProtocolMessageTypes.partial_proofs, partial_proofs_data)
107+
await peer.send_message(msg)
108+
return partial_proofs_found
109+
68110
@metadata.request(peer_required=True)
69111
async def harvester_handshake(
70112
self, harvester_handshake: harvester_protocol.HarvesterHandshake, peer: WSChiaConnection
@@ -139,37 +181,36 @@ def blocking_lookup_v2_partial_proofs(filename: Path, plot_info: PlotInfo) -> Op
139181
break
140182

141183
# Filter qualities that pass the required_iters check (same as V1 flow)
142-
good_qualities = []
184+
good_partial_proofs = []
143185
sp_interval_iters = calculate_sp_interval_iters(self.harvester.constants, sub_slot_iters)
144186

145187
for partial_proof in partial_proofs:
146188
quality_str = quality_for_partial_proof(partial_proof, new_challenge.challenge_hash)
147189
required_iters: uint64 = calculate_iterations_quality(
148190
self.harvester.constants,
149191
quality_str,
150-
plot_info.prover.get_size(), # TODO: todo_v2_plots update for V2
192+
plot_info.prover.get_size(),
151193
difficulty,
152194
new_challenge.sp_hash,
153195
sub_slot_iters,
154196
new_challenge.last_tx_height,
155197
)
156198

157199
if required_iters < sp_interval_iters:
158-
good_qualities.append(partial_proof)
200+
good_partial_proofs.append(partial_proof)
159201

160-
if len(good_qualities) == 0:
202+
if len(good_partial_proofs) == 0:
161203
return None
162204

163205
size = plot_info.prover.get_size().size_v2
164206
assert size is not None
165207
return PartialProofsData(
166208
new_challenge.challenge_hash,
167209
new_challenge.sp_hash,
168-
good_qualities[0].hex() + str(filename.resolve()),
169-
good_qualities,
210+
good_partial_proofs[0].hex() + str(filename.resolve()),
211+
good_partial_proofs,
170212
new_challenge.signage_point_index,
171213
size,
172-
difficulty,
173214
plot_info.pool_public_key,
174215
plot_info.pool_contract_puzzle_hash,
175216
plot_info.plot_public_key,
@@ -354,30 +395,22 @@ async def lookup_challenge(
354395
total_proofs_found = 0
355396
total_v2_partial_proofs_found = 0
356397

357-
# Process V1 plot responses (existing flow)
358-
for filename_sublist_awaitable in asyncio.as_completed(awaitables):
359-
filename, sublist = await filename_sublist_awaitable
360-
time_taken = time.monotonic() - start
361-
if time_taken > 8:
362-
self.harvester.log.warning(
363-
f"Looking up qualities on {filename} took: {time_taken}. This should be below 8 seconds"
364-
f" to minimize risk of losing rewards."
365-
)
366-
else:
367-
pass
368-
# self.harvester.log.info(f"Looking up qualities on {filename} took: {time_taken}")
369-
for response in sublist:
370-
total_proofs_found += 1
371-
msg = make_msg(ProtocolMessageTypes.new_proof_of_space, response)
372-
await peer.send_message(msg)
373-
374-
# Process V2 plot quality collections (new flow)
375-
for quality_awaitable in asyncio.as_completed(v2_awaitables):
376-
partial_proofs_data = await quality_awaitable
377-
if partial_proofs_data is not None:
378-
total_v2_partial_proofs_found += len(partial_proofs_data.partial_proofs)
379-
msg = make_msg(ProtocolMessageTypes.partial_proofs, partial_proofs_data)
380-
await peer.send_message(msg)
398+
# run both concurrently
399+
tasks = []
400+
if awaitables:
401+
tasks.append(self._handle_v1_responses(awaitables, start, peer))
402+
if v2_awaitables:
403+
tasks.append(self._handle_v2_responses(v2_awaitables, start, peer))
404+
405+
if tasks:
406+
results = await asyncio.gather(*tasks)
407+
if len(results) == 2:
408+
total_proofs_found, total_v2_partial_proofs_found = results
409+
elif len(results) == 1:
410+
if awaitables:
411+
total_proofs_found = results[0]
412+
else:
413+
total_v2_partial_proofs_found = results[0]
381414

382415
now = uint64(time.time())
383416

chia/protocols/harvester_protocol.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class PartialProofsData(Streamable):
7272
partial_proofs: list[bytes] # 16 * k bits blobs instead of 32-byte quality strings
7373
signage_point_index: uint8
7474
plot_size: uint8
75-
difficulty: uint64
7675
pool_public_key: Optional[G1Element]
7776
pool_contract_puzzle_hash: Optional[bytes32]
7877
plot_public_key: G1Element

chia/solver/solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def manage(self) -> AsyncIterator[None]:
6666
self.log.info("Solver service shutdown complete")
6767

6868
def solve(self, partial_proof: bytes) -> Optional[bytes]:
69-
self.log.debug(f"Solve request: quality={partial_proof.hex()}")
69+
self.log.debug(f"Solve request: partial={partial_proof.hex()}")
7070
# TODO todo_v2_plots implement actualy calling the solver
7171
return None
7272

0 commit comments

Comments
 (0)