pub struct RequestPrepareProposal {Show 13 fields
pub max_tx_bytes: i64,
pub txs: Vec<Vec<u8>>,
pub local_last_commit: Option<CommitInfo>,
pub misbehavior: Vec<Misbehavior>,
pub height: i64,
pub time: Option<Timestamp>,
pub next_validators_hash: Vec<u8>,
pub round: i32,
pub core_chain_locked_height: u32,
pub proposer_pro_tx_hash: Vec<u8>,
pub proposed_app_version: u64,
pub version: Option<Consensus>,
pub quorum_hash: Vec<u8>,
}Expand description
Prepare new block proposal, potentially altering list of transactions.
§Usage
-
The first six parameters of
RequestPrepareProposalare the same asRequestProcessProposalandRequestFinalizeBlock. -
The height and time values match the values from the header of the proposed block.
-
RequestPrepareProposalcontains a preliminary set of transactionstxsthat Tenderdash considers to be a good block proposal, called raw proposal. The Application can modify this set viaResponsePrepareProposal.tx_records(see TxRecord).- The Application can reorder, remove or add transactions to the raw proposal. Let
txbe a transaction intxs:- If the Application considers that
txshould not be proposed in this block, e.g., there are other transactions with higher priority, then it should not include it intx_records. In this case, Tenderdash won’t removetxfrom the mempool. The Application should be extra-careful, as abusing this feature may cause transactions to stay forever in the mempool. - If the Application considers that a
txshould not be included in the proposal and removed from the mempool, then the Application should include it intx_recordsand mark it asREMOVED. In this case, Tenderdash will removetxfrom the mempool. - If the Application wants to add a new transaction, then the Application should include it in
tx_recordsand mark it asADD. In this case, Tenderdash will add it to the mempool.
- If the Application considers that
- The Application should be aware that removing and adding transactions may compromise traceability.
Consider the following example: the Application transforms a client-submitted transaction
t1into a second transactiont2, i.e., the Application asks Tenderdash to removet1and addt2to the mempool. If a client wants to eventually check what happened tot1, it will discover thatt_1is not in the mempool or in a committed block, getting the wrong idea thatt_1did not make it into a block. Note thatt_2will be in a committed block, but unless the Application tracks this information, no component will be aware of it. Thus, if the Application wants traceability, it is its responsability to support it. For instance, the Application could attach to a transformed transaction a list with the hashes of the transactions it derives from.
- The Application can reorder, remove or add transactions to the raw proposal. Let
-
Tenderdash MAY include a list of transactions in
RequestPrepareProposal.txswhose total size in bytes exceedsRequestPrepareProposal.max_tx_bytes. Therefore, if the size ofRequestPrepareProposal.txsis greater thanRequestPrepareProposal.max_tx_bytes, the Application MUST make sure that theRequestPrepareProposal.max_tx_byteslimit is respected by those transaction records returned inResponsePrepareProposal.tx_recordsthat are marked asUNMODIFIEDorADDED. -
In same-block execution mode, the Application must provide values for
ResponsePrepareProposal.app_hash,ResponsePrepareProposal.tx_results,ResponsePrepareProposal.validator_updates,ResponsePrepareProposal.core_chain_lock_updateandResponsePrepareProposal.consensus_param_updates, as a result of fully executing the block.- The values for
ResponsePrepareProposal.validator_updates,ResponsePrepareProposal.core_chain_lock_updateorResponsePrepareProposal.consensus_param_updatesmay be empty. In this case, Tenderdash will keep the current values. ResponsePrepareProposal.validator_updates, triggered by blockH, affect validation for blocksH+1, andH+2. Heights following a validator update are affected in the following way:H:NextValidatorsHashincludes the newvalidator_updatesvalue.H+1: The validator set change takes effect andValidatorsHashis updated.H+2:local_last_commitnow includes the altered validator set.
ResponseFinalizeBlock.consensus_param_updatesreturned for blockHapply to the consensus params for blockH+1even if the change is agreed in blockH. For more information on the consensus parameters, see the application spec entry on consensus parameters.- It is the responsibility of the Application to set the right value for TimeoutPropose so that
the (synchronous) execution of the block does not cause other processes to prevote
nilbecause their propose timeout goes off.
- The values for
-
As a result of executing the prepared proposal, the Application may produce header events or transaction events. The Application must keep those events until a block is decided and then pass them on to Tenderdash via
ResponsePrepareProposal. -
As a sanity check, Tenderdash will check the returned parameters for validity if the Application modified them. In particular,
ResponsePrepareProposal.tx_recordswill be deemed invalid if- There is a duplicate transaction in the list.
- A new or modified transaction is marked as
UNMODIFIEDorREMOVED. - An unmodified transaction is marked as
ADDED. - A transaction is marked as
UNKNOWN.
-
ResponsePrepareProposal.tx_resultscontains only results ofUNMODIFIEDandADDEDtransactions.REMOVEDtransactions are omitted. The length oftx_resultscan be different than the length oftx_records. -
If Tenderdash fails to validate the
ResponsePrepareProposal, Tenderdash will assume the application is faulty and crash.- The implementation of
PrepareProposalcan be non-deterministic.
- The implementation of
§When does Tenderdash call it?
When a validator p enters Tenderdash consensus round r, height h, in which p is the proposer,
and p’s validValue is nil:
- p’s Tenderdash collects outstanding transactions from the mempool
- The transactions will be collected in order of priority
- Let $C$ the list of currently collected transactions
- The collection stops when any of the following conditions are met
- the mempool is empty
- the total size of transactions $\in C$ is greater than or equal to
consensusParams.block.max_bytes - the sum of
GasWantedfield of transactions $\in C$ is greater than or equal toconsensusParams.block.max_gas
- p’s Tenderdash creates a block header.
- p’s Tenderdash calls
RequestPrepareProposalwith the newly generated block. The call is synchronous: Tenderdash’s execution will block until the Application returns from the call. - The Application checks the block (hashes, transactions, commit info, misbehavior). Besides,
- in same-block execution mode, the Application can (and should) provide
ResponsePrepareProposal.app_hash,ResponsePrepareProposal.validator_updates, orResponsePrepareProposal.consensus_param_updates. - the Application can manipulate transactions
- leave transactions untouched -
TxAction = UNMODIFIED - add new transactions directly to the proposal -
TxAction = ADDED - remove transactions (invalid) from the proposal and from the mempool -
TxAction = REMOVED - remove transactions from the proposal but not from the mempool (effectively delaying them) - the Application removes the transaction from the list
- modify transactions (e.g. aggregate them) -
TxAction = ADDEDfollowed byTxAction = REMOVED. As explained above, this compromises client traceability, unless it is implemented at the Application level. - reorder transactions - the Application reorders transactions in the list
- leave transactions untouched -
- in same-block execution mode, the Application can (and should) provide
- If the block is modified, the Application includes the modified block in the return parameters (see the rules in section Usage). The Application returns from the call.
- p’s Tenderdash uses the (possibly) modified block as p’s proposal in round r, height h.
Note that, if p has a non-nil validValue, Tenderdash will use it as proposal and will not call RequestPrepareProposal.
Fields§
§max_tx_bytes: i64Currently configured maximum size in bytes taken by the modified transactions. The modified transactions cannot exceed this size.
txs: Vec<Vec<u8>>Preliminary list of transactions that have been picked as part of the block to propose. Sent to the app for possible modifications.
local_last_commit: Option<CommitInfo>Info about the last commit, obtained locally from Tenderdash’s data structures.
misbehavior: Vec<Misbehavior>List of information about validators that acted incorrectly.
height: i64The height of the block that will be proposed.
time: Option<Timestamp>Timestamp of the block that that will be proposed.
next_validators_hash: Vec<u8>Merkle root of the next validator set.
round: i32Round number for the block.
core_chain_locked_height: u32Core chain lock height to be used when signing this block.
proposer_pro_tx_hash: Vec<u8>ProTxHash of the original proposer of the block.
proposed_app_version: u64Proposer’s latest available app protocol version.
version: Option<Consensus>App and block version used to generate the block. App version included in the block can be modified by setting ResponsePrepareProposal.app_version.
quorum_hash: Vec<u8>quorum_hash contains hash of validator quorum that will sign the block
Trait Implementations§
Source§impl Clone for RequestPrepareProposal
impl Clone for RequestPrepareProposal
Source§fn clone(&self) -> RequestPrepareProposal
fn clone(&self) -> RequestPrepareProposal
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RequestPrepareProposal
impl Debug for RequestPrepareProposal
Source§impl Default for RequestPrepareProposal
impl Default for RequestPrepareProposal
Source§impl<'de> Deserialize<'de> for RequestPrepareProposal
impl<'de> Deserialize<'de> for RequestPrepareProposal
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 From<RequestPrepareProposal> for Value
impl From<RequestPrepareProposal> for Value
Source§fn from(value: RequestPrepareProposal) -> Self
fn from(value: RequestPrepareProposal) -> Self
Source§impl Message for RequestPrepareProposal
impl Message for RequestPrepareProposal
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl PartialEq for RequestPrepareProposal
impl PartialEq for RequestPrepareProposal
Source§impl Serialize for RequestPrepareProposal
impl Serialize for RequestPrepareProposal
impl StructuralPartialEq for RequestPrepareProposal
Auto Trait Implementations§
impl Freeze for RequestPrepareProposal
impl RefUnwindSafe for RequestPrepareProposal
impl Send for RequestPrepareProposal
impl Sync for RequestPrepareProposal
impl Unpin for RequestPrepareProposal
impl UnwindSafe for RequestPrepareProposal
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,
§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>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].