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

Function collectGenFiles

cmd/akash/cmd/testnet.go:328–371  ·  view source on GitHub ↗
(
	clientCtx client.Context, nodeConfig *tmconfig.Config, chainID string,
	nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int,
	outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
)

Source from the content-addressed store, hash-verified

326}
327
328func collectGenFiles(
329 clientCtx client.Context, nodeConfig *tmconfig.Config, chainID string,
330 nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int,
331 outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
332) error {
333 var appState json.RawMessage
334 genTime := tmtime.Now()
335
336 for i := 0; i < numValidators; i++ {
337 nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
338 nodeDir := filepath.Join(outputDir, nodeDirName, nodeDaemonHome)
339 gentxsDir := filepath.Join(outputDir, "gentxs")
340 nodeConfig.Moniker = nodeDirName
341
342 nodeConfig.SetRoot(nodeDir)
343
344 nodeID, valPubKey := nodeIDs[i], valPubKeys[i]
345 initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, valPubKey)
346
347 _, genDoc, err := genutiltypes.GenesisStateFromGenFile(nodeConfig.GenesisFile())
348 if err != nil {
349 return fmt.Errorf("failed to unmarshal genesis state: %w", err)
350 }
351
352 nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.Codec, clientCtx.TxConfig, nodeConfig, initCfg, genDoc, genBalIterator, genutiltypes.DefaultMessageValidator, clientCtx.TxConfig.SigningContext().ValidatorAddressCodec())
353 if err != nil {
354 return err
355 }
356
357 if appState == nil {
358 // set the canonical application state (they should not differ)
359 appState = nodeAppState
360 }
361
362 genFile := nodeConfig.GenesisFile()
363
364 // overwrite each validator's genesis file to have a canonical genesis time
365 if err := genutil.ExportGenesisFileWithTime(genFile, chainID, nil, appState, genTime); err != nil {
366 return err
367 }
368 }
369
370 return nil
371}
372
373func getIP(i int, startingIPAddr string) (ip string, err error) {
374 if len(startingIPAddr) == 0 {

Callers 1

InitTestnetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected