mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 13:51:11 +00:00
Introduce a "dynamic" block size limit for proposing (#8588)
* Introduce a "dynamic" block size limit for proposing This adds support for using a dynamic block size limit per call to `propose`. This is required for Cumulus/Parachains to always use stay in the limits of the maximum allowed PoV size. As described in the docs, the block limit is only checked in the process of pushing transactions. As we normally do some other operations in `on_finalize`, it can happen that the block size still grows when there is some proof being collected (as we do for parachains). This means, that the given block limit needs to be rather conservative on the actual value and should not be the upper limit. * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: Andronik Ordian <write@reusable.software> * More future proof encoded size updating * Use `ProofRecorderInner` * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/slots/src/lib.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/slots/src/slots.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -313,6 +313,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
logs,
|
||||
},
|
||||
proposing_remaining_duration.mul_f32(0.98),
|
||||
None,
|
||||
).map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e)));
|
||||
|
||||
let proposal = match futures::future::select(proposing, proposing_remaining).await {
|
||||
@@ -535,7 +536,7 @@ pub enum Error<T> where T: Debug {
|
||||
SlotDurationInvalid(SlotDuration<T>),
|
||||
}
|
||||
|
||||
/// A slot duration. Create with `get_or_compute`.
|
||||
/// A slot duration. Create with [`get_or_compute`](Self::get_or_compute).
|
||||
// The internal member should stay private here to maintain invariants of
|
||||
// `get_or_compute`.
|
||||
#[derive(Clone, Copy, Debug, Encode, Decode, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||
@@ -793,6 +794,7 @@ mod test {
|
||||
timestamp: Default::default(),
|
||||
inherent_data: Default::default(),
|
||||
ends_at: Instant::now(),
|
||||
block_size_limit: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@ pub struct SlotInfo {
|
||||
pub inherent_data: InherentData,
|
||||
/// Slot duration.
|
||||
pub duration: Duration,
|
||||
/// Some potential block size limit for the block to be authored at this slot.
|
||||
///
|
||||
/// For more information see [`Proposer::propose`](sp_consensus::Proposer::propose).
|
||||
pub block_size_limit: Option<usize>,
|
||||
}
|
||||
|
||||
impl SlotInfo {
|
||||
@@ -69,12 +73,14 @@ impl SlotInfo {
|
||||
timestamp: sp_timestamp::Timestamp,
|
||||
inherent_data: InherentData,
|
||||
duration: Duration,
|
||||
block_size_limit: Option<usize>,
|
||||
) -> Self {
|
||||
Self {
|
||||
slot,
|
||||
timestamp,
|
||||
inherent_data,
|
||||
duration,
|
||||
block_size_limit,
|
||||
ends_at: Instant::now() + time_until_next(timestamp.as_duration(), duration),
|
||||
}
|
||||
}
|
||||
@@ -147,6 +153,7 @@ impl<SC: SlotCompatible> Slots<SC> {
|
||||
timestamp,
|
||||
inherent_data,
|
||||
self.slot_duration,
|
||||
None,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user