github.com/badrootd/celestia-core@v0.0.0-20240305091328-aa4207a4b25d/test/e2e/pkg/manifest.go (about) 1 package e2e 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/BurntSushi/toml" 8 ) 9 10 // Manifest represents a TOML testnet manifest. 11 type Manifest struct { 12 // IPv6 uses IPv6 networking instead of IPv4. Defaults to IPv4. 13 IPv6 bool `toml:"ipv6"` 14 15 // InitialHeight specifies the initial block height, set in genesis. Defaults to 1. 16 InitialHeight int64 `toml:"initial_height"` 17 18 // InitialState is an initial set of key/value pairs for the application, 19 // set in genesis. Defaults to nothing. 20 InitialState map[string]string `toml:"initial_state"` 21 22 // Validators is the initial validator set in genesis, given as node names 23 // and power: 24 // 25 // validators = { validator01 = 10; validator02 = 20; validator03 = 30 } 26 // 27 // Defaults to all nodes that have mode=validator at power 100. Explicitly 28 // specifying an empty set will start with no validators in genesis, and 29 // the application must return the validator set in InitChain via the 30 // setting validator_update.0 (see below). 31 Validators *map[string]int64 `toml:"validators"` 32 33 // ValidatorUpdates is a map of heights to validator names and their power, 34 // and will be returned by the ABCI application. For example, the following 35 // changes the power of validator01 and validator02 at height 1000: 36 // 37 // [validator_update.1000] 38 // validator01 = 20 39 // validator02 = 10 40 // 41 // Specifying height 0 returns the validator update during InitChain. The 42 // application returns the validator updates as-is, i.e. removing a 43 // validator must be done by returning it with power 0, and any validators 44 // not specified are not changed. 45 ValidatorUpdates map[string]map[string]int64 `toml:"validator_update"` 46 47 // Nodes specifies the network nodes. At least one node must be given. 48 Nodes map[string]*ManifestNode `toml:"node"` 49 50 // KeyType sets the curve that will be used by validators. 51 // Options are ed25519 & secp256k1 52 KeyType string `toml:"key_type"` 53 54 // ABCIProtocol specifies the protocol used to communicate with the ABCI 55 // application: "unix", "tcp", "grpc", or "builtin". Defaults to builtin. 56 // builtin will build a complete CometBFT node into the application and 57 // launch it instead of launching a separate CometBFT process. 58 ABCIProtocol string `toml:"abci_protocol"` 59 60 // MaxInboundConnections and MaxOutboundConnection are the maximum number 61 // of connections a node has. This can be used to throttle the degree of 62 // connectivity of the network. If not specified, the default is taken 63 // from config/config.go 64 MaxInboundConnections int `toml:"max_inbound_connections"` 65 MaxOutboundConnections int `toml:"max_outbound_connections"` 66 67 // UpgradeVersion specifies to which version this nodes need to upgrade. 68 // Currently only uncoordinated upgrade is supported 69 UpgradeVersion string `toml:"upgrade_version"` 70 71 LoadTxSizeBytes int `toml:"load_tx_size_bytes"` 72 LoadTxBatchSize int `toml:"load_tx_batch_size"` 73 LoadTxConnections int `toml:"load_tx_connections"` 74 75 // Enable or disable Prometheus metrics on all nodes. 76 // Defaults to false (disabled). 77 Prometheus bool `toml:"prometheus"` 78 } 79 80 // ManifestNode represents a node in a testnet manifest. 81 type ManifestNode struct { 82 // Mode specifies the type of node: "validator", "full", "light" or "seed". 83 // Defaults to "validator". Full nodes do not get a signing key (a dummy key 84 // is generated), and seed nodes run in seed mode with the PEX reactor enabled. 85 Mode string `toml:"mode"` 86 87 // Version specifies which version of CometBFT this node is. Specifying different 88 // versions for different nodes allows for testing the interaction of different 89 // node's compatibility. Note that in order to use a node at a particular version, 90 // there must be a docker image of the test app tagged with this version present 91 // on the machine where the test is being run. 92 Version string `toml:"version"` 93 94 // Seeds is the list of node names to use as P2P seed nodes. Defaults to none. 95 Seeds []string `toml:"seeds"` 96 97 // PersistentPeers is a list of node names to maintain persistent P2P 98 // connections to. If neither seeds nor persistent peers are specified, 99 // this defaults to all other nodes in the network. For light clients, 100 // this relates to the providers the light client is connected to. 101 PersistentPeers []string `toml:"persistent_peers"` 102 103 // Database specifies the database backend: "goleveldb", "cleveldb", 104 // "rocksdb", "boltdb", or "badgerdb". Defaults to goleveldb. 105 Database string `toml:"database"` 106 107 // PrivvalProtocol specifies the protocol used to sign consensus messages: 108 // "file", "unix", or "tcp". Defaults to "file". For unix and tcp, the ABCI 109 // application will launch a remote signer client in a separate goroutine. 110 // Only nodes with mode=validator will actually make use of this. 111 PrivvalProtocol string `toml:"privval_protocol"` 112 113 // StartAt specifies the block height at which the node will be started. The 114 // runner will wait for the network to reach at least this block height. 115 StartAt int64 `toml:"start_at"` 116 117 // FastSync specifies the fast sync mode: "" (disable), "v0", "v1", or "v2". 118 // Defaults to disabled. 119 FastSync string `toml:"fast_sync"` 120 121 // Mempool specifies which version of mempool to use. Either "v0" or "v1", or "v2" 122 // (cat). This defaults to v2. 123 Mempool string `toml:"mempool_version"` 124 125 // StateSync enables state sync. The runner automatically configures trusted 126 // block hashes and RPC servers. At least one node in the network must have 127 // SnapshotInterval set to non-zero, and the state syncing node must have 128 // StartAt set to an appropriate height where a snapshot is available. 129 StateSync bool `toml:"state_sync"` 130 131 // PersistInterval specifies the height interval at which the application 132 // will persist state to disk. Defaults to 1 (every height), setting this to 133 // 0 disables state persistence. 134 PersistInterval *uint64 `toml:"persist_interval"` 135 136 // SnapshotInterval specifies the height interval at which the application 137 // will take state sync snapshots. Defaults to 0 (disabled). 138 SnapshotInterval uint64 `toml:"snapshot_interval"` 139 140 // RetainBlocks specifies the number of recent blocks to retain. Defaults to 141 // 0, which retains all blocks. Must be greater that PersistInterval and 142 // SnapshotInterval. 143 RetainBlocks uint64 `toml:"retain_blocks"` 144 145 // Perturb lists perturbations to apply to the node after it has been 146 // started and synced with the network: 147 // 148 // disconnect: temporarily disconnects the node from the network 149 // kill: kills the node with SIGKILL then restarts it 150 // pause: temporarily pauses (freezes) the node 151 // restart: restarts the node, shutting it down with SIGTERM 152 Perturb []string `toml:"perturb"` 153 154 // Misbehaviors sets how a validator behaves during consensus at a 155 // certain height. Multiple misbehaviors at different heights can be used 156 // 157 // An example of misbehaviors 158 // { 10 = "double-prevote", 20 = "double-prevote"} 159 // 160 // For more information, look at the readme in the maverick folder. 161 // A list of all behaviors can be found in ../maverick/consensus/behavior.go 162 Misbehaviors map[string]string `toml:"misbehaviors"` 163 164 // SendNoLoad determines if the e2e test should send load to this node. 165 // It defaults to false so unless the configured, the node will 166 // receive load. 167 SendNoLoad bool `toml:"send_no_load"` 168 } 169 170 // Save saves the testnet manifest to a file. 171 func (m Manifest) Save(file string) error { 172 f, err := os.Create(file) 173 if err != nil { 174 return fmt.Errorf("failed to create manifest file %q: %w", file, err) 175 } 176 return toml.NewEncoder(f).Encode(m) 177 } 178 179 // LoadManifest loads a testnet manifest from a file. 180 func LoadManifest(file string) (Manifest, error) { 181 manifest := Manifest{} 182 _, err := toml.DecodeFile(file, &manifest) 183 if err != nil { 184 return manifest, fmt.Errorf("failed to load testnet manifest %q: %w", file, err) 185 } 186 return manifest, nil 187 }