-
Notifications
You must be signed in to change notification settings - Fork 247
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
Proof of time changes #1767
Proof of time changes #1767
Conversation
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.
Mostly nits, I feel like we have some technical debt already and need to do some simplifications based on recent discussions with Dariia before moving forward.
crates/subspace-service/src/lib.rs
Outdated
); | ||
task_manager.spawn_essential_handle().spawn_blocking( | ||
"subspace-proof-of-time-clock-master", | ||
Some("subspace-proof-of-time-clock-master"), |
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.
Group in this case would be pot
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 didn't mean to change subspace-proof-of-time
to pot
, even though it makes sense. spawn_blocking
takes two arguments, second of which is called group
and is meant to group multiple tasks corresponding to the same thing. So all tasks related to PoT should have Some("pot")
rather than copying the name of the task.
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 fine either ways(as this group really has one task), changed as you suggested
PotVerifyError::ParentMissingPotDigest { | ||
block_number, | ||
parent_slot_number: parent_pre_digest.slot.into(), | ||
slot_number: pre_digest.slot.into(), | ||
} |
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 have a special case for block 1 in slow worker, but this doesn't take that into account and will error right away.
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.
As we discussed, once we have the global randomness from PoT in next change, the slot worker will block until the local chain catches up. Then we won't be producing blocks without PoT in them
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 mean my assumption was that you can test something with this PR, but according to this check you wouldn't be able to produce second block (wouldn't be able to import it to be more specific). Am I 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.
Sorry I take this back. claim_slot() currently errors out if proof creation fails, so we won't be creating blocks with no PoT proof. But this will be changed to block if the chain is behind
self.chain_info_fn.clone(), | ||
) | ||
.await | ||
.expect("Consensus tip info should be available"); |
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 is not a proof that it will be though. I expect proofs in .expect()
. The same not proof is also used in other places.
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.
The expectation is it should be available, but it is not. Not sure what you mean here, pls explain
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.
Expectations are not proofs. .expect()
must contain a proof why it will never ever panic. I have explained this many times at this point.
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.
If it crashes here because of any of the 3 reasons that should not happen (unable to read hdr from backend, etc), this is what I would want to see: reason why it crashed, other things are cosmetic. I don't understand your notion of "proof" at this point (I also checked the other instances, this looks consistent). Dragging this further is not productive, I can do this as a follow up if needed.
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.
It shouldn't happen, but it doesn't mean it will not happen and there is nothing this function can prove it will not happen. If you can't prove it - .expect()
is not appropriate for this situation. I'm just concerned with increased number of .expect()
that are not proofs in our codebase. I think I'll have to go through all of them in proof of time crates and either fix or add TODOs to fix.
If there could be error, fn initialize
should return Result<T, E>
. There are a few invalid proofs in sc-consensus-subspace
I'm aware of that I have added too, some might even have TODOs, but we should be very careful with these in the code.
Please add TODOs to handle these properly in the future.
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 that makes sense. I tend to add expect()
only when a precondition fails and we cannot proceed further (e.g) failed to read from client backend, failed to create thread, etc or it is something we would address in an immediate future PR.
I reviewed the expect()
in the crate, think there is only one instance (the config could be bad and PoT instance could not be created) that can be handled, for rest it is better to halt IMO. But added TODOs so we don't lose track
while sync_oracle.is_major_syncing() { | ||
tokio::time::sleep(delay).await; | ||
}; | ||
} |
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.
Will work as a hack, but I think you should subscribe to block import notifications instead of doing sleeps here and after each block checking if it is still syncing. Though this whole function looks suspicious to me right now.
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, this would change further, but seems to work well in testing so far. The block import is coming (soonish) anyways for the randomness injection fro m consensus
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 having a hard time following everything that is happening, but it looks in line with the specs apart from the bootstrap discussion.
})?; | ||
|
||
proof_of_time | ||
.get_block_proofs(block_number.into(), slot_number, parent_pot_digest) |
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.
Logically you can't be building the block unless you had proof for that slot (because it serves as a challenge) and all previous slots (because you cant verify without all previous proofs). Not sure that's exactly how it's implemented
d1b91fc
to
7c71020
Compare
Talking about ease of review. Please don't introduce changes and rebase on Otherwise I get this: https://github.com/subspace/subspace/compare/d1b91fc906260a94aa09e32e5f6aa89731aefc05..7c71020cddf90e592b9571c2a026b1fa7dc61bee
And no idea which commits are old and which are new and what exactly has changed comparing to previous revision. If you need to rebase on main and add a few more things, you can do rebase first, push it and comment that nothing has changed, just rebase on |
For now I'll assume you have added two commits on top and didn't change anything else |
Sure, sorry about that as I did everything one shot. |
5b134d7
to
44e1da0
Compare
…pace#1791 autonomys/subspace#1786 autonomys/subspace#1787 autonomys/subspace#1785 autonomys/subspace#1783 autonomys/subspace#1761 autonomys/subspace#1782 autonomys/subspace#1784 autonomys/subspace#1778 autonomys/subspace#1776 autonomys/subspace#1762 autonomys/subspace#1772 autonomys/subspace#1777 autonomys/subspace#1767 autonomys/subspace#1775 autonomys/subspace#1768 autonomys/subspace#1771 autonomys/subspace#1760 autonomys/subspace#1766 autonomys/subspace#1742 autonomys/subspace#1765 autonomys/subspace#1770 autonomys/subspace#1764
…pace#1791 autonomys/subspace#1786 autonomys/subspace#1787 autonomys/subspace#1785 autonomys/subspace#1783 autonomys/subspace#1761 autonomys/subspace#1782 autonomys/subspace#1784 autonomys/subspace#1778 autonomys/subspace#1776 autonomys/subspace#1762 autonomys/subspace#1772 autonomys/subspace#1777 autonomys/subspace#1767 autonomys/subspace#1775 autonomys/subspace#1768 autonomys/subspace#1771 autonomys/subspace#1760 autonomys/subspace#1766 autonomys/subspace#1742 autonomys/subspace#1765 autonomys/subspace#1770 autonomys/subspace#1764
Next batch of changes:
--pot_role
(default off)--pot_bootstrap
cmd line flag is introduced for immediate testing purposes. This designates a node to be responsible for building block 1. This will be replaced by specifyingAllowAuthoringBy::RootFarmer
in chain spec later. The clock master/node client changes include corresponding initializationNext step: consensus derives randomness from the proof of time
Testing: brought up two nodes: node client and clock master, one of them responsible for bootstrapping. Verified the boot strapping works as expected, the proofs are gossiped/included in blocks/verified as expected.
Code contributor checklist: