pub struct ProposedBlock { /* private fields */ }Expand description
A proposed block with many, but not all constraints of a
ProvenBlock enforced.
See ProposedBlock::new_at for details on the checks.
Implementations§
Source§impl ProposedBlock
impl ProposedBlock
Sourcepub fn new_at(
block_inputs: BlockInputs,
batches: Vec<ProvenBatch>,
timestamp: u32,
) -> Result<Self, ProposedBlockError>
pub fn new_at( block_inputs: BlockInputs, batches: Vec<ProvenBatch>, timestamp: u32, ) -> Result<Self, ProposedBlockError>
Creates a new proposed block from the provided BlockInputs, transaction batches and
timestamp.
This checks most of the constraints of a block and computes most of the data structure updates except for the more expensive tree updates (nullifier, account and chain commitment).
§Errors
Returns an error if any of the following conditions are met.
§Batches
- The number of batches exceeds
MAX_BATCHES_PER_BLOCK. - There are duplicate batches, i.e. they have the same
BatchId. - The expiration block number of any batch is less than the block number of the currently proposed block.
§Chain
- The length of the
ChainMmrin the block inputs is not equal to the previous block header in the block inputs. - The
ChainMmr’s chain commitment is not equal to theBlockHeader::chain_commitmentof the previous block header.
§Notes
Note that, in the following, the set of authenticated notes includes unauthenticated notes that have been authenticated.
- The union of all input notes across all batches contain duplicates.
- The union of all output notes across all batches contain duplicates.
- There is an unauthenticated input note and an output note with the same note ID but their note commitments are different (i.e. their metadata is different).
- There is a note inclusion proof for an unauthenticated note whose referenced block is not
in the
ChainMmr. - The note inclusion proof for an unauthenticated is invalid.
- There are any unauthenticated notes for which no note inclusion proof is provided.
- A
NullifierWitnessis missing for an authenticated note. - If the
NullifierWitnessfor an authenticated note proves that the note was already consumed.
§Accounts
- An
AccountWitnessis missing for an account updated by a batch. - Any two batches update the same account from the same state. For example, if batch 1 updates some account from state A to B and batch 2 updates it from A to F, then those batches conflict as they both start from the same initial state but produce a fork in the account’s state.
- Account updates from different batches cannot be brought in a contiguous order. For example, if a batch 1 updates an account from state A to C, and a batch 2 updates it from D to F, then the state transition from C to D is missing. Note that this does not mean, that batches must be provided in an order where account updates chain together in the order of the batches, which would generally be an impossible requirement to fulfill.
- Account updates cannot be merged, i.e. if
AccountUpdateDetails::mergefails on the updates from two batches.
§Time
- The given
timestampdoes not increase monotonically compared to the previous block header’ timestamp.
Sourcepub fn new(
block_inputs: BlockInputs,
batches: Vec<ProvenBatch>,
) -> Result<Self, ProposedBlockError>
pub fn new( block_inputs: BlockInputs, batches: Vec<ProvenBatch>, ) -> Result<Self, ProposedBlockError>
Creates a new proposed block from the provided BlockInputs and transaction batches.
Equivalent to ProposedBlock::new_at except that the timestamp of the proposed block is
set to the current system time or the previous block header’s timestamp + 1, whichever
is greater. This guarantees that the timestamp increases monotonically.
See the ProposedBlock::new_at for details on errors and other constraints.
Sourcepub fn affected_accounts(
&self,
) -> impl Iterator<Item = (TransactionId, AccountId)> + '_
pub fn affected_accounts( &self, ) -> impl Iterator<Item = (TransactionId, AccountId)> + '_
Returns an iterator over all transactions which affected accounts in the block with corresponding account IDs.
Sourcepub fn block_num(&self) -> BlockNumber
pub fn block_num(&self) -> BlockNumber
Returns the block number of this proposed block.
Sourcepub fn batches(&self) -> &[ProvenBatch]
pub fn batches(&self) -> &[ProvenBatch]
Returns a reference to the slice of batches in this block.
Sourcepub fn created_nullifiers(&self) -> &BTreeMap<Nullifier, NullifierWitness>
pub fn created_nullifiers(&self) -> &BTreeMap<Nullifier, NullifierWitness>
Returns the map of nullifiers to their proofs from the proposed block.
Sourcepub fn prev_block_header(&self) -> &BlockHeader
pub fn prev_block_header(&self) -> &BlockHeader
Returns a reference to the previous block header that this block builds on top of.
Sourcepub fn updated_accounts(&self) -> &[(AccountId, AccountUpdateWitness)]
pub fn updated_accounts(&self) -> &[(AccountId, AccountUpdateWitness)]
Returns a reference to the slice of accounts updated in this block.
Sourcepub fn output_note_batches(&self) -> &[OutputNoteBatch]
pub fn output_note_batches(&self) -> &[OutputNoteBatch]
Returns a slice of the OutputNoteBatch of each batch in this block.
Sourcepub fn into_parts(
self,
) -> (Vec<ProvenBatch>, Vec<(AccountId, AccountUpdateWitness)>, Vec<OutputNoteBatch>, BTreeMap<Nullifier, NullifierWitness>, ChainMmr, BlockHeader)
pub fn into_parts( self, ) -> (Vec<ProvenBatch>, Vec<(AccountId, AccountUpdateWitness)>, Vec<OutputNoteBatch>, BTreeMap<Nullifier, NullifierWitness>, ChainMmr, BlockHeader)
Consumes self and returns the non-Copy parts of the block.
Trait Implementations§
Source§impl Clone for ProposedBlock
impl Clone for ProposedBlock
Source§fn clone(&self) -> ProposedBlock
fn clone(&self) -> ProposedBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProposedBlock
impl Debug for ProposedBlock
Source§impl Deserializable for ProposedBlock
impl Deserializable for ProposedBlock
Source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
source, attempts to deserialize these bytes
into Self, and returns the result. Read moreSource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
Source§impl Serializable for ProposedBlock
impl Serializable for ProposedBlock
Source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self into bytes and writes these bytes into the target.Source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Auto Trait Implementations§
impl Freeze for ProposedBlock
impl RefUnwindSafe for ProposedBlock
impl Send for ProposedBlock
impl Sync for ProposedBlock
impl Unpin for ProposedBlock
impl UnwindSafe for ProposedBlock
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more