MCPcopy Create free account
hub / github.com/akash-network/node / InitTestnet

Function InitTestnet

cmd/akash/cmd/testnet.go:112–274  ·  view source on GitHub ↗

InitTestnet initializes the testnet.

(
	clientCtx client.Context,
	cmd *cobra.Command,
	nodeConfig *tmconfig.Config,
	mbm module.BasicManager,
	genBalIterator banktypes.GenesisBalancesIterator,
	genesisParams GenesisParams,
	chainID string,
	outputDir,
	minGasPrices,
	nodeDirPrefix,
	nodeDaemonHome,
	startingIPAddress,
	keyringBackend,
	algoStr string,
	numValidators int,
)

Source from the content-addressed store, hash-verified

110
111// InitTestnet initializes the testnet.
112func InitTestnet(
113 clientCtx client.Context,
114 cmd *cobra.Command,
115 nodeConfig *tmconfig.Config,
116 mbm module.BasicManager,
117 genBalIterator banktypes.GenesisBalancesIterator,
118 genesisParams GenesisParams,
119 chainID string,
120 outputDir,
121 minGasPrices,
122 nodeDirPrefix,
123 nodeDaemonHome,
124 startingIPAddress,
125 keyringBackend,
126 algoStr string,
127 numValidators int,
128) error {
129 nodeIDs := make([]string, numValidators)
130 valPubKeys := make([]cryptotypes.PubKey, numValidators)
131
132 simappConfig := srvconfig.DefaultConfig()
133 simappConfig.MinGasPrices = minGasPrices
134 simappConfig.API.Enable = true
135 simappConfig.Telemetry.Enabled = true
136 simappConfig.Telemetry.PrometheusRetentionTime = 60
137 simappConfig.Telemetry.EnableHostnameLabel = false
138 simappConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", chainID}}
139
140 var (
141 genAccounts []authtypes.GenesisAccount
142 genBalances []banktypes.Balance
143 genFiles []string
144 )
145
146 inBuf := bufio.NewReader(cmd.InOrStdin())
147 // generate private keys, node IDs, and initial transactions
148 for i := 0; i < numValidators; i++ {
149 nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
150 nodeDir := filepath.Join(outputDir, nodeDirName, nodeDaemonHome)
151 gentxsDir := filepath.Join(outputDir, "gentxs")
152
153 nodeConfig.SetRoot(nodeDir)
154 nodeConfig.RPC.ListenAddress = "tcp://0.0.0.0:26657"
155
156 if err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm); err != nil {
157 _ = os.RemoveAll(outputDir)
158 return err
159 }
160
161 nodeConfig.Moniker = nodeDirName
162
163 ip, err := getIP(i, startingIPAddress)
164 if err != nil {
165 _ = os.RemoveAll(outputDir)
166 return err
167 }
168
169 nodeIDs[i], valPubKeys[i], err = genutil.InitializeNodeValidatorFiles(nodeConfig)

Callers 1

testnetCmdFunction · 0.85

Calls 5

getIPFunction · 0.85
writeFileFunction · 0.70
initGenFilesFunction · 0.70
collectGenFilesFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected