pub struct ChunkStateWitness {
pub chunk_header: ShardChunkHeader,
pub main_state_transition: ChunkStateTransition,
pub source_receipt_proofs: HashMap<ChunkHash, ReceiptProof>,
pub exact_receipts_hash: CryptoHash,
pub transactions: Vec<SignedTransaction>,
pub implicit_transitions: Vec<ChunkStateTransition>,
pub new_transactions: Vec<SignedTransaction>,
pub new_transactions_validation_state: PartialState,
}Expand description
The state witness for a chunk; proves the state transition that the chunk attests to.
Fields§
§chunk_header: ShardChunkHeaderThe chunk header that this witness is for. While this is not needed to apply the state transition, it is needed for a chunk validator to produce a chunk endorsement while knowing what they are endorsing.
main_state_transition: ChunkStateTransitionThe base state and post-state-root of the main transition where we apply transactions and receipts. Corresponds to the state transition that takes us from the pre-state-root of the last new chunk of this shard to the post-state-root of that same chunk.
source_receipt_proofs: HashMap<ChunkHash, ReceiptProof>For the main state transition, we apply transactions and receipts. Exactly which of them must be applied is a deterministic property based on the blockchain history this chunk is based on.
The set of receipts is exactly Filter(R, |receipt| receipt.target_shard = S), where - R is the set of outgoing receipts included in the set of chunks C (defined below), - S is the shard of this chunk.
The set of chunks C, from which the receipts are sourced, is defined as all new chunks included in the set of blocks B.
The set of blocks B is defined as the contiguous subsequence of blocks B1 (EXCLUSIVE) to B2 (inclusive) in this chunk’s chain (i.e. the linear chain that this chunk’s parent block is on), where B1 is the block that contains the last new chunk of shard S before this chunk, and B1 is the block that contains the last new chunk of shard S before B2.
Furthermore, the set of transactions to apply is exactly the transactions included in the chunk of shard S at B2.
For the purpose of this text, a “new chunk” is defined as a chunk that is proposed by a chunk producer, not one that was copied from the previous block (commonly called a “missing chunk”).
This field, source_receipt_proofs, is a (non-strict) superset of the
receipts that must be applied, along with information that allows these
receipts to be verifiable against the blockchain history.
exact_receipts_hash: CryptoHashAn overall hash of the list of receipts that should be applied. This is
redundant information but is useful for diagnosing why a witness might
fail. This is the hash of the borsh encoding of the Vec
transactions: Vec<SignedTransaction>The transactions to apply. These must be in the correct order in which they are to be applied.
implicit_transitions: Vec<ChunkStateTransition>For each missing chunk after the last new chunk of the shard, we need to carry out an implicit state transition. Mostly, this is for distributing validator rewards. This list contains one for each such chunk, in forward chronological order.
After these are applied as well, we should arrive at the pre-state-root of the chunk that this witness is for.
new_transactions: Vec<SignedTransaction>Finally, we need to be able to verify that the new transitions proposed by the chunk (that this witness is for) are valid. For that, we need the transactions as well as another partial storage (based on the pre-state-root of this chunk) in order to verify that the sender accounts have appropriate balances, access keys, nonces, etc.
new_transactions_validation_state: PartialStateTrait Implementations§
source§impl BorshDeserialize for ChunkStateWitness
impl BorshDeserialize for ChunkStateWitness
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl BorshSerialize for ChunkStateWitness
impl BorshSerialize for ChunkStateWitness
source§impl Clone for ChunkStateWitness
impl Clone for ChunkStateWitness
source§fn clone(&self) -> ChunkStateWitness
fn clone(&self) -> ChunkStateWitness
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for ChunkStateWitness
impl Debug for ChunkStateWitness
source§impl PartialEq for ChunkStateWitness
impl PartialEq for ChunkStateWitness
source§fn eq(&self, other: &ChunkStateWitness) -> bool
fn eq(&self, other: &ChunkStateWitness) -> bool
self and other values to be equal, and is used
by ==.impl Eq for ChunkStateWitness
impl StructuralPartialEq for ChunkStateWitness
Auto Trait Implementations§
impl Freeze for ChunkStateWitness
impl RefUnwindSafe for ChunkStateWitness
impl Send for ChunkStateWitness
impl Sync for ChunkStateWitness
impl Unpin for ChunkStateWitness
impl UnwindSafe for ChunkStateWitness
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.