Skip to content

Commit

Permalink
chore: regenerate addrbook.json for in-place-testnet (#21941)
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic authored Sep 27, 2024
1 parent cb0fcf3 commit dc09671
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (internal) [#21412](https://github.com/cosmos/cosmos-sdk/pull/21412) Using unsafe.String and unsafe.SliceData.
* (client) [#21436](https://github.com/cosmos/cosmos-sdk/pull/21436) Use `address.Codec` from client.Context in `tx.Sign`.
* (x/genutil) [#21249](https://github.com/cosmos/cosmos-sdk/pull/21249) Incremental JSON parsing for AppGenesis where possible.
* (testnet) [#21941](https://github.com/cosmos/cosmos-sdk/pull/21941) Regenerate addrbook.json for in place testnet.

### Bug Fixes

Expand Down
12 changes: 12 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"net"
"os"
"path/filepath"
"runtime/pprof"
"strings"
"time"
Expand Down Expand Up @@ -780,6 +781,17 @@ func testnetify[T types.Application](ctx *Context, testnetAppCreator types.AppCr
return nil, err
}

// Regenerate addrbook.json to prevent peers on old network from causing error logs.
addrBookPath := filepath.Join(config.RootDir, "config", "addrbook.json")
if err := os.Remove(addrBookPath); err != nil && !os.IsNotExist(err) {
return nil, fmt.Errorf("failed to remove existing addrbook.json: %w", err)
}

emptyAddrBook := []byte("{}")
if err := os.WriteFile(addrBookPath, emptyAddrBook, 0o600); err != nil {
return nil, fmt.Errorf("failed to create empty addrbook.json: %w", err)
}

// Load the comet genesis doc provider.
genDocProvider := node.DefaultGenesisDocProviderFunc(config)

Expand Down

0 comments on commit dc09671

Please sign in to comment.