You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.8 KiB

  1. # ADR 005: Consensus Params
  2. ## Context
  3. Consensus critical parameters controlling blockchain capacity have until now been hard coded, loaded from a local config, or neglected.
  4. Since they may be need to be different in different networks, and potentially to evolve over time within
  5. networks, we seek to initialize them in a genesis file, and expose them through the ABCI.
  6. While we have some specific parameters now, like maximum block and transaction size, we expect to have more in the future,
  7. such as a period over which evidence is valid, or the frequency of checkpoints.
  8. ## Decision
  9. ### ConsensusParams
  10. No consensus critical parameters should ever be found in the `config.toml`.
  11. A new `ConsensusParams` is optionally included in the `genesis.json` file,
  12. and loaded into the `State`. Any items not included are set to their default value.
  13. A value of 0 is undefined (see ABCI, below). A value of -1 is used to indicate the parameter does not apply.
  14. The parameters are used to determine the validity of a block (and tx) via the union of all relevant parameters.
  15. ```
  16. type ConsensusParams struct {
  17. BlockSize
  18. TxSize
  19. BlockGossip
  20. }
  21. type BlockSize struct {
  22. MaxBytes int
  23. MaxTxs int
  24. MaxGas int
  25. }
  26. type TxSize struct {
  27. MaxBytes int
  28. MaxGas int
  29. }
  30. type BlockGossip struct {
  31. BlockPartSizeBytes int
  32. }
  33. ```
  34. The `ConsensusParams` can evolve over time by adding new structs that cover different aspects of the consensus rules.
  35. The `BlockPartSizeBytes` and the `BlockSize.MaxBytes` are enforced to be greater than 0.
  36. The former because we need a part size, the latter so that we always have at least some sanity check over the size of blocks.
  37. ### ABCI
  38. #### InitChain
  39. InitChain currently takes the initial validator set. It should be extended to also take parts of the ConsensusParams.
  40. There is some case to be made for it to take the entire Genesis, except there may be things in the genesis,
  41. like the BlockPartSize, that the app shouldn't really know about.
  42. #### EndBlock
  43. The EndBlock response includes a `ConsensusParams`, which includes BlockSize and TxSize, but not BlockGossip.
  44. Other param struct can be added to `ConsensusParams` in the future.
  45. The `0` value is used to denote no change.
  46. Any other value will update that parameter in the `State.ConsensusParams`, to be applied for the next block.
  47. Tendermint should have hard-coded upper limits as sanity checks.
  48. ## Status
  49. Implemented
  50. ## Consequences
  51. ### Positive
  52. - Alternative capacity limits and consensus parameters can be specified without re-compiling the software.
  53. - They can also change over time under the control of the application
  54. ### Negative
  55. - More exposed parameters is more complexity
  56. - Different rules at different heights in the blockchain complicates fast sync
  57. ### Neutral
  58. - The TxSize, which checks validity, may be in conflict with the config's `max_block_size_tx`, which determines proposal sizes