pub trait Application: Send + Sync {
// 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], _ctx: Option<&TxContext>) -> bool { ... }
fn execute_block(
&self,
_txs: &[&[u8]],
_ctx: &BlockContext<'_>,
) -> Result<EndBlockResponse> { ... }
fn on_commit(&self, _block: &Block, _ctx: &BlockContext<'_>) -> Result<()> { ... }
fn on_evidence(&self, _proof: &EquivocationProof) -> Result<()> { ... }
fn query(&self, _path: &str, _data: &[u8]) -> Result<Vec<u8>> { ... }
fn tracks_app_hash(&self) -> bool { ... }
}Expand description
Application interface for the consensus engine.
The lifecycle for each committed block:
execute_block— receives all decoded transactions at once; returns validator updates and eventson_commit— notification after the block is finalized
For block proposal:
create_payload— build the payload bytes for a new block
For validation (before voting):
validate_block— full block validationvalidate_tx— individual transaction validation for mempool
For evidence:
on_evidence— called when equivocation is detected
All methods have default no-op implementations.
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.
If your mempool is async, use tokio::runtime::Handle::current().block_on(..)
to bridge into this synchronous callback.
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], _ctx: Option<&TxContext>) -> bool
fn validate_tx(&self, _tx: &[u8], _ctx: Option<&TxContext>) -> bool
Validate a single transaction for mempool admission.
An optional TxContext provides the current chain height and epoch,
which can be useful for state-dependent validation (nonce checks, etc.).
Sourcefn execute_block(
&self,
_txs: &[&[u8]],
_ctx: &BlockContext<'_>,
) -> Result<EndBlockResponse>
fn execute_block( &self, _txs: &[&[u8]], _ctx: &BlockContext<'_>, ) -> Result<EndBlockResponse>
Execute an entire block in one call.
Receives all decoded transactions from the block payload at once, allowing batch-optimised processing (bulk DB writes, parallel signature verification, etc.).
Return EndBlockResponse with validator_updates to schedule an
epoch transition, and/or events to emit application-defined events.
Sourcefn on_commit(&self, _block: &Block, _ctx: &BlockContext<'_>) -> Result<()>
fn on_commit(&self, _block: &Block, _ctx: &BlockContext<'_>) -> Result<()>
Called when a block is committed to the chain (notification).
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.
Sourcefn query(&self, _path: &str, _data: &[u8]) -> Result<Vec<u8>>
fn query(&self, _path: &str, _data: &[u8]) -> Result<Vec<u8>>
Query application state (returns opaque bytes).
Sourcefn tracks_app_hash(&self) -> bool
fn tracks_app_hash(&self) -> bool
Whether this application produces and verifies app_hash state roots.
Applications that do not maintain a deterministic state root (e.g. the
embedded NoopApplication used by fullnodes without an ABCI backend)
should return false. Sync will then bypass the app_hash equality
check and accept the chain’s authoritative value, allowing the node to
follow a chain produced by peers running a real application.