Skip to content

Commit 3766d4c

Browse files
committed
uint8 strength, remove solve cmd
1 parent 2b0c41d commit 3766d4c

File tree

11 files changed

+22
-110
lines changed

11 files changed

+22
-110
lines changed

chia/_tests/farmer_harvester/test_farmer_harvester.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ 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-
plot_strength=uint64(1000),
344+
plot_strength=uint8(10),
345345
pool_public_key=None,
346346
pool_contract_puzzle_hash=bytes32(b"4" * 32),
347347
plot_public_key=G1Element(),
@@ -371,7 +371,7 @@ async def test_v2_partial_proofs_missing_sp_hash(
371371
partial_proofs=[b"test_partial_proof_1"],
372372
signage_point_index=uint8(0),
373373
plot_size=uint8(32),
374-
plot_strength=uint64(1000),
374+
plot_strength=uint8(10),
375375
pool_public_key=None,
376376
pool_contract_puzzle_hash=bytes32(b"4" * 32),
377377
plot_public_key=G1Element(),
@@ -414,7 +414,7 @@ async def test_v2_partial_proofs_with_existing_sp(
414414
partial_proofs=[b"test_partial_proof_1", b"test_partial_proof_2"],
415415
signage_point_index=uint8(0),
416416
plot_size=uint8(32),
417-
plot_strength=uint64(1000),
417+
plot_strength=uint8(10),
418418
pool_public_key=G1Element(),
419419
pool_contract_puzzle_hash=bytes32(b"4" * 32),
420420
plot_public_key=G1Element(),
@@ -448,7 +448,7 @@ async def test_solution_response_handler(
448448
partial_proofs=[b"test_partial_proof_for_quality"],
449449
signage_point_index=uint8(0),
450450
plot_size=uint8(32),
451-
plot_strength=uint64(1000),
451+
plot_strength=uint8(10),
452452
pool_public_key=G1Element(),
453453
pool_contract_puzzle_hash=bytes32(b"4" * 32),
454454
plot_public_key=G1Element(),
@@ -525,7 +525,7 @@ async def test_solution_response_empty_proof(
525525
partial_proofs=[b"test_partial_proof_for_quality"],
526526
signage_point_index=uint8(0),
527527
plot_size=uint8(32),
528-
plot_strength=uint64(1000),
528+
plot_strength=uint8(10),
529529
pool_public_key=G1Element(),
530530
pool_contract_puzzle_hash=bytes32(b"4" * 32),
531531
plot_public_key=G1Element(),
@@ -587,7 +587,7 @@ async def test_v2_partial_proofs_solver_exception(
587587
partial_proofs=[b"test_partial_proof_1"],
588588
signage_point_index=uint8(0),
589589
plot_size=uint8(32),
590-
plot_strength=uint64(1000),
590+
plot_strength=uint8(10),
591591
pool_public_key=G1Element(),
592592
pool_contract_puzzle_hash=bytes32(b"4" * 32),
593593
plot_public_key=G1Element(),

chia/_tests/solver/test_solver_service.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
import pytest
77
from chia_rs import ConsensusConstants
8-
from chia_rs.sized_ints import uint64
8+
from chia_rs.sized_ints import uint8
99

1010
from chia.protocols.outbound_message import Message
1111
from chia.protocols.solver_protocol import SolverInfo
1212
from chia.simulator.block_tools import create_block_tools_async
1313
from chia.simulator.keyring import TempKeyring
1414
from chia.simulator.setup_services import setup_solver
15-
from chia.solver.solver_rpc_client import SolverRpcClient
1615

1716

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

chia/_tests/util/network_protocol_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
[b"partial-proof1", b"partial-proof2"],
159159
uint8(4),
160160
uint8(32),
161-
uint64(100000),
161+
uint8(8),
162162
G1Element.from_bytes(
163163
bytes.fromhex(
164164
"a04c6b5ac7dfb935f6feecfdd72348ccf1d4be4fe7e26acf271ea3b7d308da61e0a308f7a62495328a81f5147b66634c"
@@ -1106,6 +1106,6 @@
11061106
)
11071107

11081108
# SOLVER PROTOCOL
1109-
solver_info = solver_protocol.SolverInfo(partial_proof=b"partial-proof", plot_strength=uint64(2))
1109+
solver_info = solver_protocol.SolverInfo(partial_proof=b"partial-proof", plot_strength=uint8(2))
11101110

11111111
solver_response = solver_protocol.SolverResponse(b"partial-proof", b"full-proof")
-14 Bytes
Binary file not shown.

chia/_tests/util/protocol_messages_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"partial_proofs": ["0x7061727469616c2d70726f6f6631", "0x7061727469616c2d70726f6f6632"],
7373
"signage_point_index": 4,
7474
"plot_size": 32,
75-
"plot_strength": 100000,
75+
"plot_strength": 8,
7676
"pool_public_key": "0xa04c6b5ac7dfb935f6feecfdd72348ccf1d4be4fe7e26acf271ea3b7d308da61e0a308f7a62495328a81f5147b66634c",
7777
"pool_contract_puzzle_hash": "0x91240fbacdf93b44c0571caa74fd99f163d4c5d7deaedac87125528721493f7a",
7878
"plot_public_key": "0xa04c6b5ac7dfb935f6feecfdd72348ccf1d4be4fe7e26acf271ea3b7d308da61e0a308f7a62495328a81f5147b66634c",

chia/cmds/solver.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,41 +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.option(
53-
"-s",
54-
"--plot_strength",
55-
help="Plot plot_strength (default: 1000)",
56-
type=int,
57-
default=1000,
58-
show_default=True,
59-
)
60-
@click.pass_context
61-
def solve_cmd(
62-
ctx: click.Context,
63-
solver_rpc_port: Optional[int],
64-
partial_proof: str,
65-
plot_strength: int,
66-
) -> None:
67-
import asyncio
68-
69-
from chia.cmds.solver_funcs import solve_partial_proof
70-
71-
asyncio.run(solve_partial_proof(ChiaCliContext.set_default(ctx), solver_rpc_port, partial_proof, plot_strength))

chia/cmds/solver_funcs.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import json
44
from typing import Optional
55

6-
from chia_rs.sized_ints import uint64
7-
86
from chia.cmds.cmd_classes import ChiaCliContext
97
from chia.cmds.cmds_util import get_any_service_client
108
from chia.solver.solver_rpc_client import SolverRpcClient
@@ -21,18 +19,3 @@ async def get_state(
2119
print(json.dumps(response, indent=2))
2220
except Exception as e:
2321
print(f"Failed to get solver state: {e}")
24-
25-
26-
async def solve_partial_proof(
27-
ctx: ChiaCliContext,
28-
solver_rpc_port: Optional[int],
29-
partial_proof: str,
30-
plot_strength: int,
31-
) -> None:
32-
"""Solve a partial proof via RPC."""
33-
try:
34-
async with get_any_service_client(SolverRpcClient, ctx.root_path, solver_rpc_port) as (client, _):
35-
response = await client.solve(partial_proof, plot_strength=uint64(plot_strength))
36-
print(json.dumps(response, indent=2))
37-
except Exception as e:
38-
print(f"Failed to solve partial proof: {e}")

chia/harvester/harvester_api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from chia_rs import AugSchemeMPL, G1Element, G2Element, ProofOfSpace
1111
from chia_rs.sized_bytes import bytes32
12-
from chia_rs.sized_ints import uint32, uint64
12+
from chia_rs.sized_ints import uint8, uint32, uint64
1313

1414
from chia.consensus.pos_quality import quality_for_partial_proof
1515
from chia.consensus.pot_iterations import (
@@ -181,37 +181,37 @@ def blocking_lookup_v2_partial_proofs(filename: Path, plot_info: PlotInfo) -> Op
181181
break
182182

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

187187
for partial_proof in partial_proofs:
188188
quality_str = quality_for_partial_proof(partial_proof, new_challenge.challenge_hash)
189189
required_iters: uint64 = calculate_iterations_quality(
190190
self.harvester.constants,
191191
quality_str,
192-
plot_info.prover.get_size(), # TODO: todo_v2_plots update for V2
192+
plot_info.prover.get_size(),
193193
difficulty,
194194
new_challenge.sp_hash,
195195
sub_slot_iters,
196196
new_challenge.last_tx_height,
197197
)
198198

199199
if required_iters < sp_interval_iters:
200-
good_qualities.append(partial_proof)
200+
good_partial_proofs.append(partial_proof)
201201

202-
if len(good_qualities) == 0:
202+
if len(good_partial_proofs) == 0:
203203
return None
204204

205205
size = plot_info.prover.get_size().size_v2
206206
assert size is not None
207207
return PartialProofsData(
208208
new_challenge.challenge_hash,
209209
new_challenge.sp_hash,
210-
good_qualities[0].hex() + str(filename.resolve()),
211-
good_qualities,
210+
good_partial_proofs[0].hex() + str(filename.resolve()),
211+
good_partial_proofs,
212212
new_challenge.signage_point_index,
213213
size,
214-
difficulty,
214+
uint8(0), # TODO todo_v2_plots Plot strength currently stubbed to 0
215215
plot_info.pool_public_key,
216216
plot_info.pool_contract_puzzle_hash,
217217
plot_info.plot_public_key,

chia/protocols/harvester_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ 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-
plot_strength: uint64
75+
plot_strength: uint8
7676
pool_public_key: Optional[G1Element]
7777
pool_contract_puzzle_hash: Optional[bytes32]
7878
plot_public_key: G1Element

chia/protocols/solver_protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from dataclasses import dataclass
44

5-
from chia_rs.sized_ints import uint64
5+
from chia_rs.sized_ints import uint8
66

77
from chia.util.streamable import Streamable, streamable
88

@@ -11,7 +11,7 @@
1111
@dataclass(frozen=True)
1212
class SolverInfo(Streamable):
1313
partial_proof: bytes # 16 * k bits blob, k (plot size) can be derived from this
14-
plot_strength: uint64
14+
plot_strength: uint8
1515

1616

1717
@streamable

0 commit comments

Comments
 (0)