-
Notifications
You must be signed in to change notification settings - Fork 2.1k
PoS2-prover #20159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
PoS2-prover #20159
Conversation
most of the uncovered lines will be covered once we've completed support for v2 plots, and have the test plots and test chains in place |
Pull Request Test Coverage Report for Build 18665417613Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
constants: ConsensusConstants, | ||
quality_string: bytes32, | ||
quality_string: bytes, | ||
size: PlotSize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think in the case of v1 we need to make sure its bytes32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you're suggesting. the quality string is not 32 bytes for v2 plots, but it is for v1 plots. This function supports both, so it has to take bytes
.
are you suggesting this function assert len(quality_string) == 32
for the case of v1 plots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes thats what im suggesting asserting the correct length for the v1 case
|
||
try: | ||
proof = self.solver.solve(request.partial_proof) | ||
proof = self.solver.solve(request.partial_proof, request.plot_id, request.strength, request.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the plot_id and size for solving ? (i couldn't find any mention of this in the channel)
you can know the size from the partial iirc
i have vague memory of us talking about encoding the strength in the partial did we decide not to ? (i prefer separating it from the partial as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the predictions we made about this API were mostly right. With the concrete implementation, it's just simpler to preserve the partial proof as a list and the strength as a separate variable. This format is not sensitive to size, as opposed to the full proof, which is included in full blocks. That's where we compact the proof and (currently) encode strength as well.
But there's a chance now that we'll lock down the k-size to just a single one, which means we can use the size
-field on ProofOfSpace
to store the strength for v2 plots, which simplifies the full-proof format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but here as well size should correspond to the partial length right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we definitely need the plot ID. It's used for the ProofParams
here: https://github.com/Chia-Network/pos2-chip/blob/main/src/api.cpp#L98
Looking over this again, I'm not sure we can deduce k from partial_proof
. I think partial proof is always 64 integers. Each integer is at most
k` bits though, but I don't think that's enough. This is the C-function:
https://github.com/Chia-Network/pos2-chip/blob/main/src/api.cpp#L91-L116
This is the rust function:
https://github.com/Chia-Network/pos2-chip/blob/main/crates/chia-pos2/src/lib.rs#L107-L126
required_plot_strength = calculate_required_plot_strength(constants, height) | ||
return validate_proof_v2(plot_id, plot_size.size_v2, required_plot_strength, pos.challenge, bytes(pos.proof)) | ||
return validate_proof_v2( | ||
plot_id, plot_size.size_v2, constants.PLOT_STRENGTH_INITIAL, pos.challenge, bytes(pos.proof) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are we doing now for required strength ?
its supposed to be dependent on the current state from the chain right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was discussed in a PoS call a few weeks ago. We don't need a pre-determined schedule for increasing strength, since those are soft-forks. We do need a schedule for tightening the plot-filter though, since changing that is a hard fork.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so the soft fork would just change the strength we are passing to validate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct. It would make some plots ineligible for making proofs (ones with low stregnth)
partial_proof: list[uint64] # 16 * k bits blob, k (plot size) can be derived from this | ||
plot_id: bytes32 | ||
strength: uint8 | ||
size: uint8 # k-size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need size if partial proof is k length ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right that we could (probably) calculate k
by len(partial_proof)/16
. It would make me a little bit uneasy to not specify the k-size explicitly. Would you prefer omitting k
? There's a good chance we'll lock down k
to be a constant as well, in which case we don't need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont like having extra fields in our context that usually just means extra validation, meaning we would anyway need to assert that the size and the length match so i rather just drop the extra field if thats the case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After having another look at this, I think this comment is left-over and no longer right. I'll change it. The number of items in partial_proof
is always 64. We can't (reliably) deduce k
from it.
chia/harvester/harvester_api.py
Outdated
required_iters: uint64 = calculate_iterations_quality( | ||
self.harvester.constants, | ||
quality_str, | ||
quality.get_quality(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i would change the var name to quality_proof or something, i think its a bit strange to have quality.get_quality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it to get_string()
. In the rust API I called it serialize()
, but that only applies to the v2 version. The v1 quality is just the quality string, in serialized form.
if required_iters >= sp_interval_iters: | ||
continue | ||
|
||
assert isinstance(plot_info.prover, V2Prover) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be possible we are checking the type before calling
blocking_lookup_v2_partial_proofs
if we want to be defensive then i would put assert isinstance(plot_info.prover, V2Prover) at the start of blocking_lookup_v2_partial_proofs
i think assert isinstance(quality, V2Quality) is redundant especially if you validate the type of the prover
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both of these asserts are primarily to appease mypy
who can't tell that the prover is guaranteed to be V2Prover
. I think all assert
s are defensive and not supposed to be possible by their nature though.
mypy
can't tell that just because the prover
has the type V2Prover
that also the qualities object it returned is necessarily V2Quality
|
Purpose:
This PR bumps the
chia_rs
dependency to the latest version. The first commit is limited to updating the version and updating usage of it accordingly. The second PR updates theV2Prover
class to use the new functionality exposed bychia_rs
.It's recommended to review the commits separately.
Current Behavior:
bytes
New Behavior:
list[uint64]
, and sometimes need to be serialized to form a key for a dictionary