|
| 1 | +//! Consensus-facing wrapper that manages pending state on behalf of a |
| 2 | +//! stateful application. |
| 3 | +//! |
| 4 | +//! [`Stateful`] implements the consensus [`Application`](ConsensusApplication) |
| 5 | +//! and [`VerifyingApplication`](ConsensusVerifyingApplication) traits by |
| 6 | +//! delegating execution to the inner [`Application`] while managing the |
| 7 | +//! pending-tip DAG of merkleized batches: |
| 8 | +//! |
| 9 | +//! - Before each `propose` or `verify`, the wrapper forks unmerkleized |
| 10 | +//! batches from the parent block's pending state (or from the committed |
| 11 | +//! database state if the parent has been finalized). |
| 12 | +//! - After execution, the wrapper stores the resulting merkleized batches |
| 13 | +//! as a new pending tip keyed by the block's payload. |
| 14 | +//! - On finalization, the wrapper applies the winning tip's changesets to |
| 15 | +//! the underlying databases and prunes dead forks. |
| 16 | +//! |
| 17 | +//! # Lazy Recovery |
| 18 | +//! |
| 19 | +//! Pending state lives entirely in memory. After a restart the map is empty, |
| 20 | +//! but the wrapper recovers lazily: when a parent's state is missing, it |
| 21 | +//! walks back through the block DAG via a [`BlockProvider`] to the nearest |
| 22 | +//! known ancestor, then replays forward via [`Application::replay`]. Each |
| 23 | +//! replayed block is inserted into the pending map immediately so that |
| 24 | +//! partial progress survives timeouts. |
| 25 | +
|
1 | 26 | use super::{db::DatabaseSet, Application}; |
2 | 27 | use commonware_consensus::{ |
3 | 28 | marshal::ancestry::{AncestorStream, BlockProvider}, |
|
0 commit comments