pub struct BlockBuilder<T: NodeType> {Show 19 fields
instance: Arc<T::InstanceState>,
membership: EpochMembershipCoordinator<T>,
retry_pending: HashMap<Commitment<T::Transaction>, RetryEntry<T>>,
retry_order: BTreeSet<(ViewNumber, Commitment<T::Transaction>)>,
retry_total_bytes: u64,
leader_buffer: HashMap<Commitment<T::Transaction>, PoolEntry<T>>,
leader_order: BTreeSet<(ViewNumber, Commitment<T::Transaction>)>,
leader_total_bytes: u64,
dedups: BTreeMap<ViewNumber, HashSet<Commitment<T::Transaction>>>,
undecided: BTreeMap<(ViewNumber, VidCommitment2), Vec<Commitment<T::Transaction>>>,
decided: BTreeSet<(ViewNumber, VidCommitment2)>,
config: BlockBuilderConfig,
upgrade_lock: UpgradeLock<T>,
current_view: ViewNumber,
calculations: BTreeMap<(ViewNumber, Commitment<Leaf2<T>>), AbortHandle>,
view_transactions: BTreeMap<ViewNumber, PooledBlock<T>>,
tasks: JoinSet<Result<BlockBuilderOutput<T>, BlockError>>,
commitments_duration_metric: Option<Arc<dyn Histogram>>,
tracer: Option<LeaderTracerHandle>,
}Fields§
§instance: Arc<T::InstanceState>§membership: EpochMembershipCoordinator<T>§retry_pending: HashMap<Commitment<T::Transaction>, RetryEntry<T>>§retry_order: BTreeSet<(ViewNumber, Commitment<T::Transaction>)>§retry_total_bytes: u64§leader_buffer: HashMap<Commitment<T::Transaction>, PoolEntry<T>>§leader_order: BTreeSet<(ViewNumber, Commitment<T::Transaction>)>§leader_total_bytes: u64§dedups: BTreeMap<ViewNumber, HashSet<Commitment<T::Transaction>>>§undecided: BTreeMap<(ViewNumber, VidCommitment2), Vec<Commitment<T::Transaction>>>§decided: BTreeSet<(ViewNumber, VidCommitment2)>§config: BlockBuilderConfig§upgrade_lock: UpgradeLock<T>§current_view: ViewNumber§calculations: BTreeMap<(ViewNumber, Commitment<Leaf2<T>>), AbortHandle>§view_transactions: BTreeMap<ViewNumber, PooledBlock<T>>The transactions taken for the first block of each view, with their hashes.
Every later block for the view is built from exactly these. A leader disperses a block as soon as it is built, and peers keep one share per leader and view, so a second block for the view is votable only if its payload is the same. It is the same whenever the new parent does not change how the payload is built.
tasks: JoinSet<Result<BlockBuilderOutput<T>, BlockError>>§commitments_duration_metric: Option<Arc<dyn Histogram>>§tracer: Option<LeaderTracerHandle>Records the four block-builder events (request, payload start, commitments start/end), when set.
Implementations§
Source§impl<T: NodeType> BlockBuilder<T>
impl<T: NodeType> BlockBuilder<T>
pub fn new( instance: Arc<T::InstanceState>, membership: EpochMembershipCoordinator<T>, config: BlockBuilderConfig, upgrade_lock: UpgradeLock<T>, ) -> Self
Sourcepub fn with_tracer(self, tracer: Option<LeaderTracerHandle>) -> Self
pub fn with_tracer(self, tracer: Option<LeaderTracerHandle>) -> Self
Registers the leader tracer; builder-style like with_metrics.
pub fn with_metrics( self, commitments_duration: Option<Arc<dyn Histogram>>, ) -> Self
pub fn request_block(&mut self, request: BlockAndHeaderRequest<T>)
fn transactions_for(&mut self, view: ViewNumber) -> PooledBlock<T>
Sourcefn take_block(
&mut self,
view: ViewNumber,
) -> (Vec<T::Transaction>, Vec<Commitment<T::Transaction>>)
fn take_block( &mut self, view: ViewNumber, ) -> (Vec<T::Transaction>, Vec<Commitment<T::Transaction>>)
Removes up to one block of pooled transactions, those sent for the earliest views first, and returns them with their hashes.
fn remove_pooled( &mut self, hash: &Commitment<T::Transaction>, ) -> Option<T::Transaction>
pub async fn next( &mut self, ) -> Option<Result<BlockBuilderOutput<T>, BlockError>>
pub fn gc(&mut self, view_number: ViewNumber)
pub fn fanout(&self) -> NonZeroU64
Sourcepub fn start_at(&mut self, view: ViewNumber)
pub fn start_at(&mut self, view: ViewNumber)
Starts the builder at view instead of genesis. Transactions can be submitted before
the first on_view_changed, and would otherwise target the leaders of the first views
and expire at the first view change.
pub fn outstanding_transactions(&self) -> (usize, usize)
Sourcepub fn on_submit_transaction(
&mut self,
tx: T::Transaction,
) -> Result<Option<TransactionMessage<T>>, SubmitError>
pub fn on_submit_transaction( &mut self, tx: T::Transaction, ) -> Result<Option<TransactionMessage<T>>, SubmitError>
Returns the message for the upcoming leaders, addressed to the view SEND_LEAD ahead,
which the coordinator sends on to the leaders of the fanout views from there.
Resubmitting a queued transaction succeeds without queueing or sending it twice.
pub fn on_transactions(&mut self, msg: TransactionMessage<T>)
pub fn on_dedup_manifest(&mut self, manifest: DedupManifest<T>)
Sourcepub fn on_view_changed(
&mut self,
view: ViewNumber,
) -> Option<TransactionMessage<T>>
pub fn on_view_changed( &mut self, view: ViewNumber, ) -> Option<TransactionMessage<T>>
Returns the pending transactions to send again, within one block and one message,
addressed like on_submit_transaction. A transaction is sent again only once every
leader it went to has had its turn without including it.
fn resend_batch(&mut self, view: ViewNumber) -> Vec<T::Transaction>
Sourcefn expire_pooled(&mut self, view: ViewNumber)
fn expire_pooled(&mut self, view: ViewNumber)
Drops pooled transactions sent for views more than ttl behind view: their senders
have stopped retrying them.
Sourcefn expire_block_records(&mut self, view: ViewNumber)
fn expire_block_records(&mut self, view: ViewNumber)
Drops the records of blocks more than ttl views behind view: everything
submitted before such a block was built has expired by now, so its record can no
longer clear anything from retry_pending.
fn remove_pending(&mut self, hash: &Commitment<T::Transaction>)
Sourcefn block_size(&self, view: ViewNumber) -> u64
fn block_size(&self, view: ViewNumber) -> u64
The block size of the protocol version running at view.
Sourcepub fn on_block_reconstructed(
&mut self,
view: ViewNumber,
payload_commitment: VidCommitment2,
tx_commitments: Vec<Commitment<T::Transaction>>,
)
pub fn on_block_reconstructed( &mut self, view: ViewNumber, payload_commitment: VidCommitment2, tx_commitments: Vec<Commitment<T::Transaction>>, )
Call for every block this node proposes or reconstructs, so it drops copies of the
block’s transactions that reach it later. It keeps forwarding its own submissions
until Self::on_blocks_decided confirms the block: a proposed, or even locked,
block can still be abandoned, and its transactions would otherwise be lost.
Sourcepub fn on_blocks_decided(
&mut self,
blocks: impl IntoIterator<Item = (ViewNumber, VidCommitment2)>,
)
pub fn on_blocks_decided( &mut self, blocks: impl IntoIterator<Item = (ViewNumber, VidCommitment2)>, )
Call with every decided block. Its transactions leave retry_pending. The records
of older blocks stay: a view that decides after a newer one is a gap fill, not an
abandoned branch, and records expire with the retry TTL anyway.
fn mark_included( &mut self, view: ViewNumber, hashes: Vec<Commitment<T::Transaction>>, )
Auto Trait Implementations§
impl<T> !RefUnwindSafe for BlockBuilder<T>
impl<T> !UnwindSafe for BlockBuilder<T>
impl<T> Freeze for BlockBuilder<T>
impl<T> Send for BlockBuilder<T>
impl<T> Sync for BlockBuilder<T>
impl<T> Unpin for BlockBuilder<T>
impl<T> UnsafeUnpin for BlockBuilder<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.