github.com/aakash4dev/cometbft@v0.38.2/spec/consensus/wal.md (about)

     1  # WAL
     2  
     3  Consensus module writes every message to the WAL (write-ahead log).
     4  
     5  It also issues fsync syscall through
     6  [File#Sync](https://golang.org/pkg/os/#File.Sync) for messages signed by this
     7  node (to prevent double signing).
     8  
     9  Under the hood, it uses
    10  [autofile.Group](https://github.com/aakash4dev/cometbft/blob/af3bc47df982e271d4d340a3c5e0d773e440466d/libs/autofile/group.go#L54),
    11  which rotates files when those get too big (> 10MB).
    12  
    13  The total maximum size is 1GB. We only need the latest block and the block before it,
    14  but if the former is dragging on across many rounds, we want all those rounds.
    15  
    16  ## Replay
    17  
    18  Consensus module will replay all the messages of the last height written to WAL
    19  before a crash (if such occurs).
    20  
    21  The private validator may try to sign messages during replay because it runs
    22  somewhat autonomously and does not know about replay process.
    23  
    24  For example, if we got all the way to precommit in the WAL and then crash,
    25  after we replay the proposal message, the private validator will try to sign a
    26  prevote. But it will fail. That's ok because we’ll see the prevote later in the
    27  WAL. Then it will go to precommit, and that time it will work because the
    28  private validator contains the `LastSignBytes` and then we’ll replay the
    29  precommit from the WAL.
    30  
    31  Make sure to read about [WAL corruption](https://github.com/aakash4dev/cometbft/blob/main/docs/core/running-in-production.md#wal-corruption)
    32  and recovery strategies.