pub trait Application: Send + Sync {
// Required method
fn on_commit(&self, block: &Block, ctx: &BlockContext<'_>) -> Result<()>;
// Provided methods
fn create_payload(&self, _ctx: &BlockContext<'_>) -> Vec<u8> ⓘ { ... }
fn validate_block(&self, _block: &Block, _ctx: &BlockContext<'_>) -> bool { ... }
fn validate_tx(&self, _tx: &[u8]) -> bool { ... }
fn begin_block(&self, _ctx: &BlockContext<'_>) -> Result<()> { ... }
fn deliver_tx(&self, _tx: &[u8]) -> Result<()> { ... }
fn end_block(&self, _ctx: &BlockContext<'_>) -> Result<EndBlockResponse> { ... }
fn on_evidence(&self, _proof: &EquivocationProof) -> Result<()> { ... }
fn query(&self, _path: &str, _data: &[u8]) -> Result<Vec<u8>> { ... }
}Expand description
ABCI-like application interface for the consensus engine.
The lifecycle for each committed block:
begin_block— called at the start of block executiondeliver_tx— called for each transaction in the payloadend_block— called after all transactions; may return validator updateson_commit— called when the block is finalized
For block validation (before voting, not yet committed):
validate_block— full block validationvalidate_tx— individual transaction validation for mempool
For evidence:
on_evidence— called when equivocation (double-voting) is detected
Required Methods§
Provided Methods§
Sourcefn create_payload(&self, _ctx: &BlockContext<'_>) -> Vec<u8> ⓘ
fn create_payload(&self, _ctx: &BlockContext<'_>) -> Vec<u8> ⓘ
Create a payload for a new block proposal. Typically pulls transactions from the mempool.
Sourcefn validate_block(&self, _block: &Block, _ctx: &BlockContext<'_>) -> bool
fn validate_block(&self, _block: &Block, _ctx: &BlockContext<'_>) -> bool
Validate a proposed block before voting.
Sourcefn validate_tx(&self, _tx: &[u8]) -> bool
fn validate_tx(&self, _tx: &[u8]) -> bool
Validate a single transaction for mempool admission.
Sourcefn begin_block(&self, _ctx: &BlockContext<'_>) -> Result<()>
fn begin_block(&self, _ctx: &BlockContext<'_>) -> Result<()>
Called at the beginning of block execution (during commit).
Sourcefn deliver_tx(&self, _tx: &[u8]) -> Result<()>
fn deliver_tx(&self, _tx: &[u8]) -> Result<()>
Called for each transaction in the block payload (during commit).
Sourcefn end_block(&self, _ctx: &BlockContext<'_>) -> Result<EndBlockResponse>
fn end_block(&self, _ctx: &BlockContext<'_>) -> Result<EndBlockResponse>
Called after all transactions in the block are delivered (during commit).
Return EndBlockResponse with validator_updates to trigger an epoch transition.
Sourcefn on_evidence(&self, _proof: &EquivocationProof) -> Result<()>
fn on_evidence(&self, _proof: &EquivocationProof) -> Result<()>
Called when equivocation (double-voting) is detected. The application can use this to implement slashing.