Proposer/BlockBuilder: Accept proof recorder & extensions#9947
Proposer/BlockBuilder: Accept proof recorder & extensions#9947
Conversation
This pull request fundamentally changes how `Proposer` and `BlockBuilder` are handling the proof recorder and extensions. Before this pull request the proof recorder was initialized by the `BlockBuilder` and the proposer statically enabled proof recording or disabled it. With this pull request the proof recorder is passed from the the caller down to the block builder. This also moves the responsibility for extracting the final storage proof to the caller and is not part of the block builder logic anymore. The extensions are now also configurable by the caller and are not longer "guessed" by the block builder. This pull request also remvoes the `cumulus-client-proposer` crate as it is not really required anymore.
|
/cmd fmt |
|
|
||
| let storage_proof_recorder = params.storage_proof_recorder.unwrap_or_default(); | ||
|
|
||
| if !params.extra_extensions.is_registered(ProofSizeExt::type_id()) { |
There was a problem hiding this comment.
Nit: Situation here is not so nice. If this check is triggered it means that the proof recorder provided via the args needs to be registered here also in the ProofSizeExt. Otherwise there might be bugs.
There was a problem hiding this comment.
But I'm doing this? The recorder passed via the params is registered here.
There was a problem hiding this comment.
I think that if other ProofSizeExt is already registered, it may not use storage_proof_recorder passed in params? Maybe we should overwrite extension here?
There was a problem hiding this comment.
I am not sure if I read the code correctly - but I see "implicit" assumption that storage_proof_recorder is exactly the same instance that shall be registered in extensions. From what I see it is not enforced - potentially causing some troubles in future.
The code overall looks fine, so this potential discrepancy is only the minor that could be improved. Maybe we don't need to pass extra_extension, and we could create the one down in the block-builder/src/lib.rs? Not sure if there are other use cases for extra_extensions.
There was a problem hiding this comment.
I added this as some kind of backwards compatibility here, but you are right. I will return an error if the extension exists, but the storage_proof_recorder is None.
|
For other reviewers who might wonder what the context of this change is: Before this PR, the block-builder and basic-authorship where conttrolling the proof recording. Users of these components where just telling it to record a proof, and they would handle it. However, this only works well for single blocks. Since we will be interested in bundling multiple blocks into a single PoV, the storage proof needs to be recorded "incrementally". With the changes introduced here, higher level components can instantiate the proof recorder and define ignored nodes based on previous blocks for the same PoV. The block-builder itself does not need to know anything about the bundling itself. |
Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com>
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
| ], | ||
| parachain_inherent_data, | ||
| extra_inherent_data: other_inherent_data, | ||
| proposal_duration: authoring_duration, |
There was a problem hiding this comment.
nit: Should we utilize the adjusted_authoring_duration instead here?
| /// If the proof recording was requested, but `None` is given, this will return | ||
| /// `Err(NoProofRecorded)`. | ||
| fn into_proof(storage_proof: Option<StorageProof>) -> Result<Self::Proof, NoProofRecorded>; | ||
| /// When `Some`, a storage proof will be recorded and included in the proposal. |
There was a problem hiding this comment.
DQ: How exactly will it be included? Proposal does not have dedicated field for recorder proof.
There was a problem hiding this comment.
Yeah I will change the wording here.
There was a problem hiding this comment.
Could P be removed?
| C::Api: BabeApi<B>, | ||
| P: Send + Sync, | ||
| { | ||
| type Proof = P; |
There was a problem hiding this comment.
same here: P is no longer needed.
|
|
||
| let BuiltBlock { block, proof, .. } = builder.build()?; | ||
| let BuiltBlock { block, .. } = builder.build()?; | ||
|
|
| max_duration: std::time::Duration::from_secs(1), | ||
| block_size_limit: None, | ||
| storage_proof_recorder: None, | ||
| extra_extensions: Default::default(), |
| call_api_at: self.call_api_at, | ||
| proof_recorder: None, | ||
| inherent_digests: Default::default(), | ||
| parent_block: self.parent_block, | ||
| parent_number, | ||
| extra_extensions: Extensions::new(), |
There was a problem hiding this comment.
nit: ..Default::default() could be used
| inherent_digests: Default::default(), | ||
| parent_block: self.parent_block, | ||
| parent_number, | ||
| extra_extensions: Extensions::new(), |
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
|
/cmd prdoc --audience node_dev --bum major |
This pull request fundamentally changes how `Proposer` and `BlockBuilder` are handling the proof recorder and extensions. Before this pull request the proof recorder was initialized by the `BlockBuilder` and the proposer statically enabled proof recording or disabled it. With this pull request the proof recorder is passed from the the caller down to the block builder. This also moves the responsibility for extracting the final storage proof to the caller and is not part of the block builder logic anymore. The extensions are now also configurable by the caller and are not longer "guessed" by the block builder. This pull request also remvoes the `cumulus-client-proposer` crate as it is not really required anymore. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
This pull request fundamentally changes how
ProposerandBlockBuilderare handling the proof recorder and extensions. Before this pull request the proof recorder was initialized by theBlockBuilderand the proposer statically enabled proof recording or disabled it. With this pull request the proof recorder is passed from the the caller down to the block builder. This also moves the responsibility for extracting the final storage proof to the caller and is not part of the block builder logic anymore. The extensions are now also configurable by the caller and are not longer "guessed" by the block builder.This pull request also remvoes the
cumulus-client-proposercrate as it is not really required anymore.