dcrd/cmd
Dave Collins cdadd9874a
multi: Rework old fork rejection logic.
Historically, checkpoints have been manually specified and used both for
various optimizations and to protect against cheap DoS attacks by
rejecting forks deep in history.  The primary motivation for manually
specifying the checkpoints was said optimizations, however, those
optimization portions have now been decoupled from checkpoints in favor
of other methods, so the only remaining use of checkpoints is the
aforementioned rejection of forks deep in history.

Thus, this reworks the old fork rejection logic to make it automatic
based on an ancestor that is two weeks worth of blocks behind the
hard-coded assumevalid block (clamped to the genesis block if necessary)
that is manually specified at each release as opposed to needing to
additionally manually specify checkpoints.

Note the distinction here between the hard-coded assumevalid block
specified at each release and the potentially overridden value specified
by a user via CLI configuration options.  This is an important
distinction because old fork rejection affects consensus and thus must
not move around based on user configuration.

This approach means the user can still specify a more recent assume
valid hash or disable assume valid optimizations independently without
affecting the consensus logic while still removing the need to manually
specify additional checkpoints.

The following is a high level overview of the changes:
- Modifies the blockchain.Config struct as follows:
  - Removes the LastestCheckpoint option
  - Adds a AllowOldForks option
- Removes all code related to manually specified checkpoints and finding
  candidates
- Removes the following errors since they are no longer used:
  - ErrBadCheckpoint
  - ErrCheckpointTimeTooOld
- Renames checkpointNode to rejectForksCheckpoint to make it clear that
  is the only thing it applies to
- Adds logic to potentially reject forks deep in history as follows:
  - Do not reject old forks if they are manually allowed or the
    hard-coded assumevalid block is not specified for the network
  - Automatically choose an ancestor that is two weeks worth of blocks
    prior to the hard-coded assumevalid block (clamped to the genesis
    block if necessary)
- Replaces --nocheckpoints CLI option with --allowoldforks
  - Updates doc.go to match the changes to the CLI options
2022-05-19 13:03:29 -05:00
..
addblock multi: Rework old fork rejection logic. 2022-05-19 13:03:29 -05:00
gencerts multi: Don't use deprecated ioutil package. 2021-09-01 06:09:37 -05:00
promptsecret build: Replace deprecated terminal dep. 2022-03-10 11:17:56 -06:00