pub struct ProposedBatch { /* private fields */ }
Expand description
A proposed batch of transactions with all necessary data to validate it.
See ProposedBatch::new
for what a proposed batch expects and guarantees.
This type is fairly large, so consider boxing it.
Implementations§
Source§impl ProposedBatch
impl ProposedBatch
Sourcepub fn new(
transactions: Vec<Arc<ProvenTransaction>>,
reference_block_header: BlockHeader,
partial_blockchain: PartialBlockchain,
unauthenticated_note_proofs: BTreeMap<NoteId, NoteInclusionProof>,
) -> Result<Self, ProposedBatchError>
pub fn new( transactions: Vec<Arc<ProvenTransaction>>, reference_block_header: BlockHeader, partial_blockchain: PartialBlockchain, unauthenticated_note_proofs: BTreeMap<NoteId, NoteInclusionProof>, ) -> Result<Self, ProposedBatchError>
Creates a new ProposedBatch
from the provided parts.
§Inputs
- The given transactions must be correctly ordered. That is, if two transactions A and B update the same account in this order, meaning A’s initial account state commitment matches the account state before any transactions are executed and B’s initial account state commitment matches the final account state commitment of A, then A must come before B.
- The partial blockchain’s hashed peaks must match the reference block’s
chain_commitment
and it must contain all block headers:- that are referenced by note inclusion proofs in
unauthenticated_note_proofs
. - that are referenced by a transaction in the batch.
- that are referenced by note inclusion proofs in
- The
unauthenticated_note_proofs
should containNoteInclusionProof
s for any unauthenticated note consumed by the transaction’s in the batch which can be authenticated. This means it is not required that every unauthenticated note has an entry in this map for two reasons.- Unauthenticated note authentication can be delayed to the block kernel.
- Another transaction in the batch creates an output note matching an unauthenticated input note, in which case inclusion in the chain does not need to be proven.
- The reference block of a batch must satisfy the following requirement: Its block number must be greater or equal to the highest block number referenced by any transaction. This is not verified explicitly, but will implicitly cause an error during the validation that each reference block of a transaction is in the partial blockchain.
§Errors
Returns an error if:
- The number of input notes exceeds
MAX_INPUT_NOTES_PER_BATCH
.- Note that unauthenticated notes that are created in the same batch do not count. Any other input notes, unauthenticated or not, do count.
- The number of output notes exceeds
MAX_OUTPUT_NOTES_PER_BATCH
.- Note that output notes that are consumed in the same batch as unauthenticated input notes do not count.
- Any note is consumed more than once.
- Any note is created more than once.
- The number of account updates exceeds
MAX_ACCOUNTS_PER_BATCH
.- Note that any number of transactions against the same account count as one update.
- The partial blockchains chain length does not match the block header’s block number. This means the partial blockchain should not contain the block header itself as it is added to the MMR in the batch kernel.
- The partial blockchains hashed peaks do not match the block header’s chain commitment.
- The reference block of any transaction is not in the partial blockchain.
- The note inclusion proof for an unauthenticated note fails to verify.
- The block referenced by a note inclusion proof for an unauthenticated note is missing from the partial blockchain.
- The transactions in the proposed batch which update the same account are not correctly ordered.
- The provided list of transactions is empty. An empty batch is pointless and would
potentially result in the same
BatchId
for two empty batches which would mean batch IDs are no longer unique. - There are duplicate transactions.
- If any transaction’s expiration block number is less than or equal to the batch’s reference block.
Sourcepub fn transactions(&self) -> &[Arc<ProvenTransaction>]
pub fn transactions(&self) -> &[Arc<ProvenTransaction>]
Returns a slice of the ProvenTransaction
s in the batch.
Sourcepub fn transaction_headers(&self) -> OrderedTransactionHeaders
pub fn transaction_headers(&self) -> OrderedTransactionHeaders
Returns the ordered set of transactions in the batch.
Sourcepub fn account_updates(&self) -> &BTreeMap<AccountId, BatchAccountUpdate>
pub fn account_updates(&self) -> &BTreeMap<AccountId, BatchAccountUpdate>
Returns the map of account IDs mapped to their BatchAccountUpdate
s.
If an account was updated by multiple transactions, the BatchAccountUpdate
is the result
of merging the individual updates.
For example, suppose an account’s state before this batch is A
and the batch contains two
transactions that updated it. Applying the first transaction results in intermediate state
B
, and applying the second one results in state C
. Then the returned update represents
the state transition from A
to C
.
Sourcepub fn id(&self) -> BatchId
pub fn id(&self) -> BatchId
The ID of this batch. See BatchId
for details on how it is computed.
Sourcepub fn batch_expiration_block_num(&self) -> BlockNumber
pub fn batch_expiration_block_num(&self) -> BlockNumber
Returns the block number at which the batch will expire.
Sourcepub fn input_notes(&self) -> &InputNotes<InputNoteCommitment>
pub fn input_notes(&self) -> &InputNotes<InputNoteCommitment>
Returns the InputNotes
of this batch.
Sourcepub fn output_notes(&self) -> &[OutputNote]
pub fn output_notes(&self) -> &[OutputNote]
Returns the output notes of the batch.
This is the aggregation of all output notes by the transactions in the batch, except the ones that were consumed within the batch itself.
Sourcepub fn into_parts(
self,
) -> (Vec<Arc<ProvenTransaction>>, BlockHeader, PartialBlockchain, BTreeMap<NoteId, NoteInclusionProof>, BatchId, BTreeMap<AccountId, BatchAccountUpdate>, InputNotes<InputNoteCommitment>, Vec<OutputNote>, BlockNumber)
pub fn into_parts( self, ) -> (Vec<Arc<ProvenTransaction>>, BlockHeader, PartialBlockchain, BTreeMap<NoteId, NoteInclusionProof>, BatchId, BTreeMap<AccountId, BatchAccountUpdate>, InputNotes<InputNoteCommitment>, Vec<OutputNote>, BlockNumber)
Consumes the proposed batch and returns its underlying parts.
Trait Implementations§
Source§impl Clone for ProposedBatch
impl Clone for ProposedBatch
Source§fn clone(&self) -> ProposedBatch
fn clone(&self) -> ProposedBatch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ProposedBatch
impl Debug for ProposedBatch
Source§impl Deserializable for ProposedBatch
impl Deserializable for ProposedBatch
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 ProposedBatch
impl Serializable for ProposedBatch
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 ProposedBatch
impl RefUnwindSafe for ProposedBatch
impl Send for ProposedBatch
impl Sync for ProposedBatch
impl Unpin for ProposedBatch
impl UnwindSafe for ProposedBatch
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