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.

127 lines
5.1 KiB

  1. package e2e
  2. import (
  3. "fmt"
  4. "github.com/BurntSushi/toml"
  5. )
  6. // Manifest represents a TOML testnet manifest.
  7. type Manifest struct {
  8. // IPv6 uses IPv6 networking instead of IPv4. Defaults to IPv4.
  9. IPv6 bool `toml:"ipv6"`
  10. // InitialHeight specifies the initial block height, set in genesis. Defaults to 1.
  11. InitialHeight int64 `toml:"initial_height"`
  12. // InitialState is an initial set of key/value pairs for the application,
  13. // set in genesis. Defaults to nothing.
  14. InitialState map[string]string `toml:"initial_state"`
  15. // Validators is the initial validator set in genesis, given as node names
  16. // and power:
  17. //
  18. // validators = { validator01 = 10; validator02 = 20; validator03 = 30 }
  19. //
  20. // Defaults to all nodes that have mode=validator at power 100. Explicitly
  21. // specifying an empty set will start with no validators in genesis, and
  22. // the application must return the validator set in InitChain via the
  23. // setting validator_update.0 (see below).
  24. Validators *map[string]int64
  25. // ValidatorUpdates is a map of heights to validator names and their power,
  26. // and will be returned by the ABCI application. For example, the following
  27. // changes the power of validator01 and validator02 at height 1000:
  28. //
  29. // [validator_update.1000]
  30. // validator01 = 20
  31. // validator02 = 10
  32. //
  33. // Specifying height 0 returns the validator update during InitChain. The
  34. // application returns the validator updates as-is, i.e. removing a
  35. // validator must be done by returning it with power 0, and any validators
  36. // not specified are not changed.
  37. ValidatorUpdates map[string]map[string]int64 `toml:"validator_update"`
  38. // Nodes specifies the network nodes. At least one node must be given.
  39. Nodes map[string]ManifestNode `toml:"node"`
  40. }
  41. // ManifestNode represents a node in a testnet manifest.
  42. type ManifestNode struct {
  43. // Mode specifies the type of node: "validator", "full", or "seed". Defaults to
  44. // "validator". Full nodes do not get a signing key (a dummy key is generated),
  45. // and seed nodes run in seed mode with the PEX reactor enabled.
  46. Mode string
  47. // Seeds is the list of node names to use as P2P seed nodes. Defaults to none.
  48. Seeds []string
  49. // PersistentPeers is a list of node names to maintain persistent P2P
  50. // connections to. If neither seeds nor persistent peers are specified,
  51. // this defaults to all other nodes in the network.
  52. PersistentPeers []string `toml:"persistent_peers"`
  53. // Database specifies the database backend: "goleveldb", "cleveldb",
  54. // "rocksdb", "boltdb", or "badgerdb". Defaults to goleveldb.
  55. Database string
  56. // ABCIProtocol specifies the protocol used to communicate with the ABCI
  57. // application: "unix", "tcp", "grpc", or "builtin". Defaults to unix.
  58. // builtin will build a complete Tendermint node into the application and
  59. // launch it instead of launching a separate Tendermint process.
  60. ABCIProtocol string `toml:"abci_protocol"`
  61. // PrivvalProtocol specifies the protocol used to sign consensus messages:
  62. // "file", "unix", or "tcp". Defaults to "file". For unix and tcp, the ABCI
  63. // application will launch a remote signer client in a separate goroutine.
  64. // Only nodes with mode=validator will actually make use of this.
  65. PrivvalProtocol string `toml:"privval_protocol"`
  66. // StartAt specifies the block height at which the node will be started. The
  67. // runner will wait for the network to reach at least this block height.
  68. StartAt int64 `toml:"start_at"`
  69. // FastSync specifies the fast sync mode: "" (disable), "v0", "v1", or "v2".
  70. // Defaults to disabled.
  71. FastSync string `toml:"fast_sync"`
  72. // StateSync enables state sync. The runner automatically configures trusted
  73. // block hashes and RPC servers. At least one node in the network must have
  74. // SnapshotInterval set to non-zero, and the state syncing node must have
  75. // StartAt set to an appropriate height where a snapshot is available.
  76. StateSync bool `toml:"state_sync"`
  77. // PersistInterval specifies the height interval at which the application
  78. // will persist state to disk. Defaults to 1 (every height), setting this to
  79. // 0 disables state persistence.
  80. PersistInterval *uint64 `toml:"persist_interval"`
  81. // SnapshotInterval specifies the height interval at which the application
  82. // will take state sync snapshots. Defaults to 0 (disabled).
  83. SnapshotInterval uint64 `toml:"snapshot_interval"`
  84. // RetainBlocks specifies the number of recent blocks to retain. Defaults to
  85. // 0, which retains all blocks. Must be greater that PersistInterval and
  86. // SnapshotInterval.
  87. RetainBlocks uint64 `toml:"retain_blocks"`
  88. // Perturb lists perturbations to apply to the node after it has been
  89. // started and synced with the network:
  90. //
  91. // disconnect: temporarily disconnects the node from the network
  92. // kill: kills the node with SIGKILL then restarts it
  93. // pause: temporarily pauses (freezes) the node
  94. // restart: restarts the node, shutting it down with SIGTERM
  95. Perturb []string
  96. }
  97. // LoadManifest loads a testnet manifest from a file.
  98. func LoadManifest(file string) (Manifest, error) {
  99. manifest := Manifest{}
  100. _, err := toml.DecodeFile(file, &manifest)
  101. if err != nil {
  102. return manifest, fmt.Errorf("failed to load testnet manifest %q: %w", file, err)
  103. }
  104. return manifest, nil
  105. }