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.

99 lines
3.9 KiB

  1. # ADR 017: Chain Versions
  2. ## TODO
  3. - clarify how to handle slashing when ChainID changes
  4. ## Changelog
  5. - 28-07-2018: Updates from review
  6. - split into two ADRs - one for protocol, one for chains
  7. - 16-07-2018: Initial draft - was originally joint ADR for protocol and chain
  8. versions
  9. ## Context
  10. Software and Protocol versions are covered in a separate ADR.
  11. Here we focus on chain versions.
  12. ## Requirements
  13. We need to version blockchains across protocols, networks, forks, etc.
  14. We need chain identifiers and descriptions so we can talk about a multitude of chains,
  15. and especially the differences between them, in a meaningful way.
  16. ### Networks
  17. We need to support many independent networks running the same version of the software,
  18. even possibly starting from the same initial state.
  19. They must have distinct identifiers so that peers know which one they are joining and so
  20. validators and users can prevent replay attacks.
  21. Call this the `NetworkName` (note we currently call this `ChainID` in the software. In this
  22. ADR, ChainID has a different meaning).
  23. It represents both the application being run and the community or intention
  24. of running it.
  25. Peers only connect to other peers with the same NetworkName.
  26. ### Forks
  27. We need to support existing networks upgrading and forking, wherein they may do any of:
  28. - revert back to some height, continue with the same versions but new blocks
  29. - arbitrarily mutate state at some height, continue with the same versions (eg. Dao Fork)
  30. - change the AppVersion at some height
  31. Note because of Tendermint's voting power threshold rules, a chain can only be extended under the "original" rules and under the new rules
  32. if 1/3 or more is double signing, which is expressly prohibited, and is supposed to result in their punishment on both chains. Since they can censor
  33. the punishment, the chain is expected to be hardforked to remove the validators. Thus, if both branches are to continue after a fork,
  34. they will each require a new identifier, and the old chain identifier will be retired (ie. only useful for syncing history, not for new blocks)..
  35. TODO: explain how to handle slashing when chain id changed!
  36. We need a consistent way to describe forks.
  37. ## Proposal
  38. ### ChainDescription
  39. ChainDescription is a complete immutable description of a blockchain. It takes the following form:
  40. ```
  41. ChainDescription = <NetworkName>/<BlockVersion>/<AppVersion>/<StateHash>/<ValHash>/<ConsensusParamsHash>
  42. ```
  43. Here, StateHash is the merkle root of the initial state, ValHash is the merkle root of the initial Tendermint validator set,
  44. and ConsensusParamsHash is the merkle root of the initial Tendermint consensus parameters.
  45. The `genesis.json` file must contain enough information to compute this value. It need not contain the StateHash or ValHash itself,
  46. but contain the state from which they can be computed with the given protocol versions.
  47. NOTE: consider splitting NetworkName into NetworkName and AppName - this allows
  48. folks to independently use the same application for different networks (ie we
  49. could imagine multiple communities of validators wanting to put up a Hub using
  50. the same app but having a distinct network name. Arguably not needed if
  51. differences will come via different initial state / validators).
  52. #### ChainID
  53. Define `ChainID = TMHASH(ChainDescriptor)`. It's the unique ID of a blockchain.
  54. It should be Bech32 encoded when handled by users, eg. with `cosmoschain` prefix.
  55. #### Forks and Uprades
  56. When a chain forks or upgrades but continues the same history, it takes a new ChainDescription as follows:
  57. ```
  58. ChainDescription = <ChainID>/x/<Height>/<ForkDescription>
  59. ```
  60. Where
  61. - ChainID is the ChainID from the previous ChainDescription (ie. its hash)
  62. - `x` denotes that a change occured
  63. - `Height` is the height the change occured
  64. - ForkDescription has the same form as ChainDescription but for the fork
  65. - this allows forks to specify new versions for tendermint or the app, as well as arbitrary changes to the state or validator set