Expand description
Wrapper for consensus applications that handles epochs and block dissemination.
§Overview
Marshaled is an adapter that wraps any VerifyingApplication implementation to handle epoch transitions automatically. It intercepts consensus operations (propose, verify) and ensures blocks are only produced within valid epoch boundaries.
§Epoch Boundaries
An epoch is a fixed number of blocks (the epoch_length). When the last block in an epoch
is reached, this wrapper prevents new blocks from being built & proposed until the next epoch begins.
Instead, it re-proposes the boundary block to avoid producing blocks that would be pruned
by the epoch transition.
§Usage
Wrap your application implementation with Marshaled::new and provide it to your consensus engine for the Automaton and Relay. The wrapper handles all epoch logic transparently.
let application = Marshaled::new(
context,
my_application,
marshal_mailbox,
BLOCKS_PER_EPOCH,
);§Implementation Notes
- Genesis blocks are handled specially: epoch 0 returns the application’s genesis block, while subsequent epochs use the last block of the previous epoch as genesis
- Blocks are automatically verified to be within the current epoch
Structs§
- Marshaled
- An Application adapter that handles epoch transitions and validates block ancestry.