Struct hotshot_types::data::Leaf2
source · pub struct Leaf2<TYPES: NodeType> {
view_number: TYPES::View,
epoch: TYPES::Epoch,
justify_qc: QuorumCertificate2<TYPES>,
next_epoch_justify_qc: Option<NextEpochQuorumCertificate2<TYPES>>,
parent_commitment: Commitment<Self>,
block_header: TYPES::BlockHeader,
upgrade_certificate: Option<UpgradeCertificate<TYPES>>,
block_payload: Option<TYPES::BlockPayload>,
pub view_change_evidence: Option<ViewChangeEvidence<TYPES>>,
pub drb_seed: DrbSeedInput,
pub drb_result: DrbResult,
}
Expand description
This is the consensus-internal analogous concept to a block, and it contains the block proper,
as well as the hash of its parent Leaf
.
Fields§
§view_number: TYPES::View
CurView from leader when proposing leaf
epoch: TYPES::Epoch
An epoch to which the data belongs to. Relevant for validating against the correct stake table
justify_qc: QuorumCertificate2<TYPES>
Per spec, justification
next_epoch_justify_qc: Option<NextEpochQuorumCertificate2<TYPES>>
certificate that the proposal is chaining from formed by the next epoch nodes
parent_commitment: Commitment<Self>
The hash of the parent Leaf
So we can ask if it extends
block_header: TYPES::BlockHeader
Block header.
upgrade_certificate: Option<UpgradeCertificate<TYPES>>
Optional upgrade certificate, if one was attached to the quorum proposal for this view.
block_payload: Option<TYPES::BlockPayload>
Optional block payload.
It may be empty for nodes not in the DA committee.
view_change_evidence: Option<ViewChangeEvidence<TYPES>>
Possible timeout or view sync certificate. If the justify_qc
is not for a proposal in the immediately preceding view, then either a timeout or view sync certificate must be attached.
drb_seed: DrbSeedInput
The DRB seed for the next epoch.
The DRB computation using this seed was started in the previous epoch.
drb_result: DrbResult
The DRB result for the current epoch.
The DRB computation with this result was started two epochs ago.
Implementations§
source§impl<TYPES: NodeType> Leaf2<TYPES>
impl<TYPES: NodeType> Leaf2<TYPES>
sourcepub async fn genesis(
validated_state: &TYPES::ValidatedState,
instance_state: &TYPES::InstanceState,
) -> Self
pub async fn genesis( validated_state: &TYPES::ValidatedState, instance_state: &TYPES::InstanceState, ) -> Self
Create a new leaf from its components.
§Panics
Panics if the genesis payload (TYPES::BlockPayload::genesis()
) is malformed (unable to be
interpreted as bytes).
sourcepub fn view_number(&self) -> TYPES::View
pub fn view_number(&self) -> TYPES::View
Time when this leaf was created.
sourcepub fn height(&self) -> u64
pub fn height(&self) -> u64
Height of this leaf in the chain.
Equivalently, this is the number of leaves before this one in the chain.
sourcepub fn justify_qc(&self) -> QuorumCertificate2<TYPES>
pub fn justify_qc(&self) -> QuorumCertificate2<TYPES>
The QC linking this leaf to its parent in the chain.
sourcepub fn upgrade_certificate(&self) -> Option<UpgradeCertificate<TYPES>>
pub fn upgrade_certificate(&self) -> Option<UpgradeCertificate<TYPES>>
The QC linking this leaf to its parent in the chain.
sourcepub fn parent_commitment(&self) -> Commitment<Self>
pub fn parent_commitment(&self) -> Commitment<Self>
Commitment to this leaf’s parent.
sourcepub fn block_header(&self) -> &<TYPES as NodeType>::BlockHeader
pub fn block_header(&self) -> &<TYPES as NodeType>::BlockHeader
The block header contained in this leaf.
sourcepub fn block_header_mut(&mut self) -> &mut <TYPES as NodeType>::BlockHeader
pub fn block_header_mut(&mut self) -> &mut <TYPES as NodeType>::BlockHeader
Get a mutable reference to the block header contained in this leaf.
sourcepub fn fill_block_payload(
&mut self,
block_payload: TYPES::BlockPayload,
num_storage_nodes: usize,
) -> Result<(), BlockError>
pub fn fill_block_payload( &mut self, block_payload: TYPES::BlockPayload, num_storage_nodes: usize, ) -> Result<(), BlockError>
Fill this leaf with the block payload.
§Errors
Fails if the payload commitment doesn’t match self.block_header.payload_commitment()
or if the transactions are of invalid length
sourcepub fn unfill_block_payload(&mut self) -> Option<TYPES::BlockPayload>
pub fn unfill_block_payload(&mut self) -> Option<TYPES::BlockPayload>
Take the block payload from the leaf and return it if it is present
sourcepub fn fill_block_payload_unchecked(
&mut self,
block_payload: TYPES::BlockPayload,
)
pub fn fill_block_payload_unchecked( &mut self, block_payload: TYPES::BlockPayload, )
Fill this leaf with the block payload, without checking header and payload consistency
sourcepub fn block_payload(&self) -> Option<TYPES::BlockPayload>
pub fn block_payload(&self) -> Option<TYPES::BlockPayload>
Optional block payload.
sourcepub fn payload_commitment(&self) -> VidCommitment
pub fn payload_commitment(&self) -> VidCommitment
A commitment to the block payload contained in this leaf.
sourcepub async fn extends_upgrade(
&self,
parent: &Self,
decided_upgrade_certificate: &Arc<RwLock<Option<UpgradeCertificate<TYPES>>>>,
) -> Result<()>
pub async fn extends_upgrade( &self, parent: &Self, decided_upgrade_certificate: &Arc<RwLock<Option<UpgradeCertificate<TYPES>>>>, ) -> Result<()>
Validate that a leaf has the right upgrade certificate to be the immediate child of another leaf
This may not be a complete function. Please double-check that it performs the checks you expect before substituting validation logic with it.
§Errors
Returns an error if the certificates are not identical, or that when we no longer see a cert, it’s for the right reason.
source§impl<TYPES: NodeType> Leaf2<TYPES>
impl<TYPES: NodeType> Leaf2<TYPES>
sourcepub fn from_quorum_proposal(quorum_proposal: &QuorumProposal2<TYPES>) -> Self
pub fn from_quorum_proposal(quorum_proposal: &QuorumProposal2<TYPES>) -> Self
Constructs a leaf from a given quorum proposal.
Trait Implementations§
source§impl<TYPES: Clone + NodeType> Clone for Leaf2<TYPES>where
TYPES::View: Clone,
TYPES::Epoch: Clone,
TYPES::BlockHeader: Clone,
TYPES::BlockPayload: Clone,
impl<TYPES: Clone + NodeType> Clone for Leaf2<TYPES>where
TYPES::View: Clone,
TYPES::Epoch: Clone,
TYPES::BlockHeader: Clone,
TYPES::BlockPayload: Clone,
source§impl<TYPES: Debug + NodeType> Debug for Leaf2<TYPES>where
TYPES::View: Debug,
TYPES::Epoch: Debug,
TYPES::BlockHeader: Debug,
TYPES::BlockPayload: Debug,
impl<TYPES: Debug + NodeType> Debug for Leaf2<TYPES>where
TYPES::View: Debug,
TYPES::Epoch: Debug,
TYPES::BlockHeader: Debug,
TYPES::BlockPayload: Debug,
source§impl<'de, TYPES: NodeType> Deserialize<'de> for Leaf2<TYPES>
impl<'de, TYPES: NodeType> Deserialize<'de> for Leaf2<TYPES>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<TYPES: NodeType> TestableLeaf for Leaf2<TYPES>
impl<TYPES: NodeType> TestableLeaf for Leaf2<TYPES>
source§fn create_random_transaction(
&self,
rng: &mut dyn RngCore,
padding: u64,
) -> <<Self::NodeType as NodeType>::BlockPayload as BlockPayload<Self::NodeType>>::Transaction
fn create_random_transaction( &self, rng: &mut dyn RngCore, padding: u64, ) -> <<Self::NodeType as NodeType>::BlockPayload as BlockPayload<Self::NodeType>>::Transaction
impl<TYPES: Eq + NodeType> Eq for Leaf2<TYPES>
Auto Trait Implementations§
impl<TYPES> Freeze for Leaf2<TYPES>where
<TYPES as NodeType>::View: Freeze,
<TYPES as NodeType>::Epoch: Freeze,
<TYPES as NodeType>::BlockHeader: Freeze,
<TYPES as NodeType>::BlockPayload: Freeze,
<<TYPES as NodeType>::SignatureKey as SignatureKey>::QcType: Freeze,
impl<TYPES> RefUnwindSafe for Leaf2<TYPES>where
<TYPES as NodeType>::View: RefUnwindSafe,
<TYPES as NodeType>::Epoch: RefUnwindSafe,
<TYPES as NodeType>::BlockHeader: RefUnwindSafe,
<TYPES as NodeType>::BlockPayload: RefUnwindSafe,
<<TYPES as NodeType>::SignatureKey as SignatureKey>::QcType: RefUnwindSafe,
TYPES: RefUnwindSafe,
impl<TYPES> Send for Leaf2<TYPES>
impl<TYPES> Sync for Leaf2<TYPES>
impl<TYPES> Unpin for Leaf2<TYPES>where
<TYPES as NodeType>::View: Unpin,
<TYPES as NodeType>::Epoch: Unpin,
<TYPES as NodeType>::BlockHeader: Unpin,
<TYPES as NodeType>::BlockPayload: Unpin,
<<TYPES as NodeType>::SignatureKey as SignatureKey>::QcType: Unpin,
TYPES: Unpin,
impl<TYPES> UnwindSafe for Leaf2<TYPES>where
<TYPES as NodeType>::View: UnwindSafe,
<TYPES as NodeType>::Epoch: UnwindSafe,
<TYPES as NodeType>::BlockHeader: UnwindSafe,
<TYPES as NodeType>::BlockPayload: UnwindSafe,
<<TYPES as NodeType>::SignatureKey as SignatureKey>::QcType: UnwindSafe,
TYPES: UnwindSafe,
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<T> CallHasher for T
impl<T> CallHasher for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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> 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.