  The CAP theorem says that no blockchain can be live under dynamic
participation and safe under temporary network partitions. To resolve this
availability-finality dilemma, we formulate a new class of flexible consensus
protocols, ebb-and-flow protocols, which support a full dynamically available
ledger in conjunction with a finalized prefix ledger. The finalized ledger
falls behind the full ledger when the network partitions but catches up when
the network heals. Gasper, the current candidate protocol for Ethereum 2.0's
beacon chain, combines the finality gadget Casper FFG with the LMD GHOST fork
choice rule and aims to achieve this property. However, we discovered an attack
in the standard synchronous network model, highlighting a general difficulty
with existing finality-gadget-based designs. We present a construction of
provably secure ebb-and-flow protocols with optimal resilience. Nodes run an
off-the-shelf dynamically available protocol, take snapshots of the growing
available ledger, and input them into a separate off-the-shelf BFT protocol to
finalize a prefix. We explore connections with flexible BFT and improve upon
the state-of-the-art for that problem.
