Skip to main content

thruput_node_types/
proposal.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: 6ab835b07c234abb4b0b50b61d687904727a4f32
5
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#![allow(non_upper_case_globals)]
9#![allow(unused_imports)]
10#![allow(dead_code)]
11#![allow(unused_variables)]
12#![allow(clippy::unnecessary_cast)]
13
14use crate::*;
15use core::option::Option;
16use core::ops::{Deref, DerefMut};
17
18#[cfg(feature = "std")]
19use std::io::{Read, Write};
20use xdrs::*;
21
22
23#[cfg(feature = "serde")]
24use ::serde::{{Serialize, Deserialize}};
25
26
27
28// clang-format on
29
30/// Transaction-side payload for a proposal.
31///
32/// This is the payload a `ConsensusValue` commits to through
33/// `ProposalTxsHash`. The signed transactions travel separately, since nodes
34/// usually already hold them from transaction dissemination. Because the
35/// payload names each transaction by its [`SignedTransactionHash`], a node
36/// that holds a different signing of a body treats that transaction as
37/// missing and fetches the proposer's encoding.
38///
39/// Travels on network.
40#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
41#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
42#[derive(schemars::JsonSchema)]
43#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44#[repr(C)]
45pub struct ProposalTxs {
46    pub ext: ExtensionPoint,
47    /// Signed hashes of the block's transactions, in execution order: the
48    /// exact encodings the block executes.
49    pub signed_hash: ParallelSignedTransactionHashBatch,
50    /// Nondeterministic choices captured by the proposer, replayed by
51    /// validators so re-execution reproduces the header outputs exactly.
52    pub nondeterministic_data: ParallelNondeterministicProposalDataBatch,
53}
54
55/// Compatibility commitment over `ProposalTxs`.
56///
57/// This is not SHA-256 of the complete canonical XDR. It XORs the hash of a
58/// base value with empty batches, the hashes of each raw batch segment, and
59/// the XDR hash of each batch index with its raw bytes removed.
60// 
61#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
62#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
63#[derive(schemars::JsonSchema)]
64#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
65#[repr(transparent)]
66#[cfg_attr(feature = "serde", serde(transparent))]
67pub struct ProposalTxsHash {
68    inner: SHA256Hash,
69}
70impl From<SHA256Hash> for ProposalTxsHash {
71    fn from(_inner: SHA256Hash) -> Self {
72        Self { inner: _inner }
73    }
74}
75impl ProposalTxsHash {
76    pub fn into_inner(self) -> SHA256Hash {
77        self.inner
78    }
79    pub const fn new(_inner: SHA256Hash) -> Self {
80        Self { inner: _inner }
81    }
82}
83
84impl Deref for ProposalTxsHash {
85    type Target = SHA256Hash;
86
87    fn deref(&self) -> &Self::Target {
88        &self.inner
89    }
90}
91impl DerefMut for ProposalTxsHash {
92    fn deref_mut(&mut self) -> &mut Self::Target {
93        &mut self.inner
94    }
95}
96
97/// A candidate block: header plus the transaction metadata needed to
98/// re-execute it.
99///
100/// Does not travel on network: nodes reconstruct it from a `ConsensusValue`
101/// and its `ProposalTxs`.
102#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
103#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
104#[derive(schemars::JsonSchema)]
105#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
106#[repr(C)]
107pub struct Proposal {
108    pub header: ProposalHeader,
109    pub transactions: ProposalTxs,
110}
111
112pub type OptProposal = Option::<Proposal>;
113
114/// Summary of the previous finalized proposal, used by SCP leader selection.
115///
116/// Intentionally carries only the `ConsensusValueHash`: leader-election
117/// pseudorandomness must not depend on transaction-payload availability.
118#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
119#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
120#[derive(schemars::JsonSchema)]
121#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
122#[repr(C)]
123pub struct PrevProposalSummary {
124    pub value_hash: ConsensusValueHash,
125}
126
127
128//
129// XDR internals below this point
130//
131
132