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

Function testnetify

cmd/akash/cmd/testnetify/testnetify.go:279–579  ·  view source on GitHub ↗

testnetify modifies both state and blockStore, allowing the provided operator address and local validator key to control the network that the state in the data folder represents. The chainID of the local genesis file is modified to match the provided chainID.

(sctx *sdksrv.Context, tcfg TestnetConfig, testnetAppCreator types.AppCreator, db dbm.DB, traceWriter io.WriteCloser)

Source from the content-addressed store, hash-verified

277// testnetify modifies both state and blockStore, allowing the provided operator address and local validator key to control the network
278// that the state in the data folder represents. The chainID of the local genesis file is modified to match the provided chainID.
279func testnetify(sctx *sdksrv.Context, tcfg TestnetConfig, testnetAppCreator types.AppCreator, db dbm.DB, traceWriter io.WriteCloser) (types.Application, error) {
280 config := sctx.Config
281
282 thisVal := config.PrivValidatorKeyFile()
283 sort.Slice(tcfg.Validators, func(i, _ int) bool {
284 return thisVal == tcfg.Validators[i].Home
285 })
286
287 // Modify app genesis chain ID and save to a genesis file.
288 genFilePath := config.GenesisFile()
289 appGen, err := genutiltypes.AppGenesisFromFile(genFilePath)
290 if err != nil {
291 return nil, err
292 }
293
294 newChainID := tcfg.ChainID
295
296 appGen.ChainID = newChainID
297 if err := appGen.ValidateAndComplete(); err != nil {
298 return nil, err
299 }
300 if err := appGen.SaveAs(genFilePath); err != nil {
301 return nil, err
302 }
303
304 // Load the comet genesis doc provider.
305 genDocProvider := sdksrv.GetGenDocProvider(config)
306
307 // Initialize blockStore and stateDB.
308 blockStoreDB, err := cmtcfg.DefaultDBProvider(&cmtcfg.DBContext{ID: "blockstore", Config: config})
309 if err != nil {
310 return nil, err
311 }
312 blockStore := store.NewBlockStore(blockStoreDB)
313
314 defer func() {
315 _ = blockStore.Close()
316 }()
317
318 stateDB, err := cmtcfg.DefaultDBProvider(&cmtcfg.DBContext{ID: "state", Config: config})
319 if err != nil {
320 return nil, err
321 }
322
323 defer func() {
324 _ = stateDB.Close()
325 }()
326
327 var updatedChecksum []byte
328 {
329 genDoc, err := genDocProvider()
330 if err != nil {
331 return nil, err
332 }
333
334 updatedChecksum = genDoc.Sha256Checksum
335 }
336

Callers 1

GetCmdFunction · 0.85

Calls 7

NewCometABCIWrapperFunction · 0.85
getCtxFunction · 0.85
AddressMethod · 0.80
QueryMethod · 0.80
CloseMethod · 0.65
DeleteMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected