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.

128 lines
6.4 KiB

  1. # RFC 009 : Consensus Parameter Upgrade Considerations
  2. ## Changelog
  3. - 06-Jan-2011: Initial draft (@williambanfield).
  4. ## Abstract
  5. This document discusses the challenges of adding additional consensus parameters
  6. to Tendermint and proposes a few solutions that can enable addition of consensus
  7. parameters in a backwards-compatible way.
  8. ## Background
  9. This section provides an overview of the issues of adding consensus parameters
  10. to Tendermint.
  11. ### Hash Compatibility
  12. Tendermint produces a hash of a subset of the consensus parameters. The values
  13. that are hashed currently are the `BlockMaxGas` and the `BlockMaxSize`. These
  14. are currently in the [HashedParams struct][hashed-params]. This hash is included
  15. in the block and validators use it to validate that their local view of the consensus
  16. parameters matches what the rest of the network is configured with.
  17. Any new consensus parameters added to Tendermint should be included in this
  18. hash. This presents a challenge for verification of historical blocks when consensus
  19. parameters are added. If a network produced blocks with a version of Tendermint that
  20. did not yet have the new consensus parameters, the parameter hash it produced will
  21. not reference the new parameters. Any nodes joining the network with the newer
  22. version of Tendermint will have the new consensus parameters. Tendermint will need
  23. to handle this case so that new versions of Tendermint with new consensus parameters
  24. can still validate old blocks correctly without having to do anything overly complex
  25. or hacky.
  26. ### Allowing Developer-Defined Values and the `EndBlock` Problem
  27. When new consensus parameters are added, application developers may wish to set
  28. values for them so that the developer-defined values may be used as soon as the
  29. software upgrades. We do not currently have a clean mechanism for handling this.
  30. Consensus parameter updates are communicated from the application to Tendermint
  31. within `EndBlock` of some height `H` and take effect at the next height, `H+1`.
  32. This means that for updates that add a consensus parameter, there is a single
  33. height where the new parameters cannot take effect. The parameters did not exist
  34. in the version of the software that emitted the `EndBlock` response for height `H-1`,
  35. so they cannot take effect at height `H`. The first height that the updated params
  36. can take effect is height `H+1`. As of now, height `H` must run with the defaults.
  37. ## Discussion
  38. ### Hash Compatibility
  39. This section discusses possible solutions to the problem of maintaining backwards-compatibility
  40. of hashed parameters while adding new parameters.
  41. #### Never Hash Defaults
  42. One solution to the problem of backwards-compatibility is to never include parameters
  43. in the hash if the are using the default value. This means that blocks produced
  44. before the parameters existed will have implicitly been created with the defaults.
  45. This works because any software with newer versions of Tendermint must be using the
  46. defaults for new parameters when validating old blocks since the defaults can not
  47. have been updated until a height at which the parameters existed.
  48. #### Only Update HashedParams on Hash-Breaking Releases
  49. An alternate solution to never hashing defaults is to not update the hashed
  50. parameters on non-hash-breaking releases. This means that when new consensus
  51. parameters are added to Tendermint, there may be a release that makes use of the
  52. parameters but does not verify that they are the same across all validators by
  53. referencing them in the hash. This seems reasonably safe given the fact that
  54. only a very far subset of the consensus parameters are currently verified at all.
  55. #### Version The Consensus Parameter Hash Scheme
  56. The upcoming work on [soft upgrades](https://github.com/tendermint/spec/pull/222)
  57. proposes applying different hashing rules depending on the active block version.
  58. The consensus parameter hash could be versioned in the same way. When different
  59. block versions are used, a different set of consensus parameters will be included
  60. in the hash.
  61. ### Developer Defined Values
  62. This section discusses possible solutions to the problem of allowing application
  63. developers to define values for the new parameters during the upgrade that adds
  64. the parameters.
  65. #### Using `InitChain` for New Values
  66. One solution to the problem of allowing application developers to define values
  67. for new consensus parameters is to call the `InitChain` ABCI method on application
  68. startup and fetch the value for any new consensus parameters. The [response object][init-chain-response]
  69. contains a field for `ConsensusParameter` updates so this may serve as a natural place
  70. to put this logic.
  71. This poses a few difficulties. Nodes replaying old blocks while running new
  72. software do not ever call `InitChain` after the initial time. They will therefore
  73. not have a way to determine that the parameters changed at some height by using a
  74. call to `InitChain`. The `EndBlock` response is how parameter changes at a height
  75. are currently communicated to Tendermint and conflating these cases seems risky.
  76. #### Force Defaults For Single Height
  77. An alternate option is to not use `InitChain` and instead require chains to use the
  78. default values of the new parameters for a single height.
  79. As documented in the upcoming [ADR-74][adr-74], popular chains often simply use the default
  80. values. Additionally, great care is being taken to ensure that logic governed by upcoming
  81. consensus parameters is not liveness-breaking. This means that, at worst-case,
  82. chains will experience a single slow height while waiting for the new values to
  83. by applied.
  84. #### Add a new `UpgradeChain` method
  85. An additional method for allowing chains to update the consensus parameters that
  86. do not yet exist is to add a new `UpgradeChain` method to `ABCI`. The upgrade chain
  87. method would be called when the chain detects that the version of block that it
  88. is about to produce does not match the previous block. This method would be called
  89. after `EndBlock` and would return the set of consensus parameters to use at the
  90. next height. It would therefore give an application the chance to set the new
  91. consensus parameters before running a height with these new parameter.
  92. ### References
  93. [hashed-params]: https://github.com/tendermint/tendermint/blob/0ae974e63911804d4a2007bd8a9b3ad81d6d2a90/types/params.go#L49
  94. [init-chain-response]: https://github.com/tendermint/tendermint/blob/0ae974e63911804d4a2007bd8a9b3ad81d6d2a90/abci/types/types.pb.go#L1616
  95. [adr-74]: https://github.com/tendermint/tendermint/pull/7503