From bddd9e4dcc3c6507fe9200d69134aaaaed2740dd Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 6 Oct 2023 18:05:30 -0400 Subject: [PATCH 01/20] feat: tool to generate addrbook.json --- tools/addrbook/README.md | 14 +++++++ tools/addrbook/main.go | 80 ++++++++++++++++++++++++++++++++++++++++ tools/addrbook/peers.txt | 4 ++ 3 files changed, 98 insertions(+) create mode 100644 tools/addrbook/README.md create mode 100644 tools/addrbook/main.go create mode 100644 tools/addrbook/peers.txt diff --git a/tools/addrbook/README.md b/tools/addrbook/README.md new file mode 100644 index 0000000000..a3f57809f6 --- /dev/null +++ b/tools/addrbook/README.md @@ -0,0 +1,14 @@ +# Addrbook + +This directory contains a small tool to convert a peer address txt file into an address book JSON file. + +## Example Usage + +1. Modify `peers.txt` to contain the addresses you want to include in the address book. +1. Run the tool: + + ```shell + go run main.go + ``` + +This should generate a file called `addrbook.json` in the current directory. Next, manually verify the contents of `output.json` and if everything looks good, publish it. diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go new file mode 100644 index 0000000000..747d71177d --- /dev/null +++ b/tools/addrbook/main.go @@ -0,0 +1,80 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "strings" +) + +type Address struct { + ID string `json:"id"` + IP string `json:"ip"` + Port int `json:"port"` +} + +type Entry struct { + Addr Address `json:"addr"` + Src Address `json:"src"` +} + +type Output struct { + Key string `json:"key"` + Addrs []Entry `json:"addrs"` +} + +func main() { + data, err := os.ReadFile("peers.txt") + if err != nil { + panic(err) + } + + lines := strings.Split(string(data), "\n") + + var addrs []Entry + for _, line := range lines { + if line == "" { + continue + } + parts := strings.Split(line, "@") + id := parts[0] + ipPort := strings.Split(parts[1], ":") + ip := ipPort[0] + port := ipPort[1] + + addr := Address{ + ID: id, + IP: ip, + Port: stringToInt(port), + } + + entry := Entry{ + Addr: addr, + Src: addr, + } + + addrs = append(addrs, entry) + } + + output := Output{ + Key: "075f251a11c6b2cef94f3d61", // This is hard-coded, change as needed + Addrs: addrs, + } + + jsonData, err := json.MarshalIndent(output, "", "\t") + if err != nil { + panic(err) + } + + // Save the output to addrbook.json + if err := os.WriteFile("addrbook.json", jsonData, 0644); err != nil { + panic(err) + } + fmt.Println("Conversion completed. Check addrbook.json.") +} + +func stringToInt(s string) int { + var result int + fmt.Sscanf(s, "%d", &result) + return result +} diff --git a/tools/addrbook/peers.txt b/tools/addrbook/peers.txt new file mode 100644 index 0000000000..8cc104a161 --- /dev/null +++ b/tools/addrbook/peers.txt @@ -0,0 +1,4 @@ +34499b1ac473fbb03894c883178ecc83f0d6eaf6@64.227.18.169:26656 +43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656 +f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656 +daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656 From 7d2afc207a4696d662b21eec75dd323bae3d67a6 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 6 Oct 2023 18:18:31 -0400 Subject: [PATCH 02/20] feat: convert domains to IP addresses --- tools/addrbook/addrbook.json | 53 ++++++++++++++++++++++++++++++++++++ tools/addrbook/main.go | 19 ++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tools/addrbook/addrbook.json diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json new file mode 100644 index 0000000000..b01e54d8ac --- /dev/null +++ b/tools/addrbook/addrbook.json @@ -0,0 +1,53 @@ +{ + "key": "075f251a11c6b2cef94f3d61", + "addrs": [ + { + "addr": { + "id": "34499b1ac473fbb03894c883178ecc83f0d6eaf6", + "ip": "64.227.18.169", + "port": 26656 + }, + "src": { + "id": "34499b1ac473fbb03894c883178ecc83f0d6eaf6", + "ip": "64.227.18.169", + "port": 26656 + } + }, + { + "addr": { + "id": "43e9da043318a4ea0141259c17fcb06ecff816af", + "ip": "141.94.73.39", + "port": 43656 + }, + "src": { + "id": "43e9da043318a4ea0141259c17fcb06ecff816af", + "ip": "141.94.73.39", + "port": 43656 + } + }, + { + "addr": { + "id": "f9e950870eccdb40e2386896d7b6a7687a103c99", + "ip": "88.99.219.120", + "port": 43656 + }, + "src": { + "id": "f9e950870eccdb40e2386896d7b6a7687a103c99", + "ip": "88.99.219.120", + "port": 43656 + } + }, + { + "addr": { + "id": "daf2cecee2bd7f1b3bf94839f993f807c6b15fbf", + "ip": "65.109.92.79", + "port": 11656 + }, + "src": { + "id": "daf2cecee2bd7f1b3bf94839f993f807c6b15fbf", + "ip": "65.109.92.79", + "port": 11656 + } + } + ] +} \ No newline at end of file diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go index 747d71177d..18eed63a19 100644 --- a/tools/addrbook/main.go +++ b/tools/addrbook/main.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "fmt" + "net" "os" "strings" ) @@ -39,9 +40,14 @@ func main() { parts := strings.Split(line, "@") id := parts[0] ipPort := strings.Split(parts[1], ":") - ip := ipPort[0] + domain := ipPort[0] port := ipPort[1] + ip, err := resolveDomain(domain) + if err != nil { + panic(err) + } + addr := Address{ ID: id, IP: ip, @@ -73,6 +79,17 @@ func main() { fmt.Println("Conversion completed. Check addrbook.json.") } +func resolveDomain(domain string) (string, error) { + addresses, err := net.LookupHost(domain) + if err != nil { + return "", err + } + if len(addresses) == 0 { + return "", fmt.Errorf("no IP found for domain: %s", domain) + } + return addresses[0], nil // use the first IP found +} + func stringToInt(s string) int { var result int fmt.Sscanf(s, "%d", &result) From 1718d01a4903eedd633a0db037bfcbaa994b80d7 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 6 Oct 2023 18:28:34 -0400 Subject: [PATCH 03/20] debug: attempt to add seeds to peers list still hangs --- tools/addrbook/addrbook.json | 48 ++++++++++++++++++++++++++++++++++++ tools/addrbook/peers.txt | 4 +++ 2 files changed, 52 insertions(+) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index b01e54d8ac..a696d4fa6f 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -48,6 +48,54 @@ "ip": "65.109.92.79", "port": 11656 } + }, + { + "addr": { + "id": "3314051954fc072a0678ec0cbac690ad8676ab98", + "ip": "65.108.66.220", + "port": 26656 + }, + "src": { + "id": "3314051954fc072a0678ec0cbac690ad8676ab98", + "ip": "65.108.66.220", + "port": 26656 + } + }, + { + "addr": { + "id": "258f523c96efde50d5fe0a9faeea8a3e83be22ca", + "ip": "173.249.24.244", + "port": 20279 + }, + "src": { + "id": "258f523c96efde50d5fe0a9faeea8a3e83be22ca", + "ip": "173.249.24.244", + "port": 20279 + } + }, + { + "addr": { + "id": "5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e", + "ip": "65.108.231.124", + "port": 11656 + }, + "src": { + "id": "5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e", + "ip": "65.108.231.124", + "port": 11656 + } + }, + { + "addr": { + "id": "7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee", + "ip": "185.225.232.196", + "port": 443 + }, + "src": { + "id": "7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee", + "ip": "185.225.232.196", + "port": 443 + } } ] } \ No newline at end of file diff --git a/tools/addrbook/peers.txt b/tools/addrbook/peers.txt index 8cc104a161..f7d46dfc58 100644 --- a/tools/addrbook/peers.txt +++ b/tools/addrbook/peers.txt @@ -2,3 +2,7 @@ 43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656 f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656 daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656 +3314051954fc072a0678ec0cbac690ad8676ab98@65.108.66.220:26656 +258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.mocha-4.celestia.aviaone.com:20279 +5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e@celestia-testnet-seed.itrocket.net:11656 +7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee@celest-test-seed.theamsolutions.info:443 From 25afcf3f2e69f23d7ab23b24c5d9d7c82b62a625 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 6 Oct 2023 18:41:24 -0400 Subject: [PATCH 04/20] fix: need to populate remainder of Entry with empty fields --- tools/addrbook/addrbook.json | 66 +++++++++++++++++++++++++++++++----- tools/addrbook/main.go | 11 ++++-- 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index a696d4fa6f..8ceafe0335 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -11,7 +11,13 @@ "id": "34499b1ac473fbb03894c883178ecc83f0d6eaf6", "ip": "64.227.18.169", "port": 26656 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { @@ -23,7 +29,13 @@ "id": "43e9da043318a4ea0141259c17fcb06ecff816af", "ip": "141.94.73.39", "port": 43656 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { @@ -35,7 +47,13 @@ "id": "f9e950870eccdb40e2386896d7b6a7687a103c99", "ip": "88.99.219.120", "port": 43656 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { @@ -47,7 +65,13 @@ "id": "daf2cecee2bd7f1b3bf94839f993f807c6b15fbf", "ip": "65.109.92.79", "port": 11656 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { @@ -59,7 +83,13 @@ "id": "3314051954fc072a0678ec0cbac690ad8676ab98", "ip": "65.108.66.220", "port": 26656 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { @@ -71,7 +101,13 @@ "id": "258f523c96efde50d5fe0a9faeea8a3e83be22ca", "ip": "173.249.24.244", "port": 20279 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { @@ -83,7 +119,13 @@ "id": "5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e", "ip": "65.108.231.124", "port": 11656 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { @@ -95,7 +137,13 @@ "id": "7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee", "ip": "185.225.232.196", "port": 443 - } + }, + "buckets": null, + "attempts": 0, + "bucket_type": 0, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" } ] -} \ No newline at end of file +} diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go index 18eed63a19..7cd6aa1aea 100644 --- a/tools/addrbook/main.go +++ b/tools/addrbook/main.go @@ -6,6 +6,7 @@ import ( "net" "os" "strings" + "time" ) type Address struct { @@ -15,8 +16,14 @@ type Address struct { } type Entry struct { - Addr Address `json:"addr"` - Src Address `json:"src"` + Addr Address `json:"addr"` + Src Address `json:"src"` + Buckets []int `json:"buckets"` + Attempts int32 `json:"attempts"` + BucketType byte `json:"bucket_type"` + LastAttempt time.Time `json:"last_attempt"` + LastSuccess time.Time `json:"last_success"` + LastBanTime time.Time `json:"last_ban_time"` } type Output struct { From 9e141a030951203eb47d5f1babffa5bc65477fb2 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 6 Oct 2023 18:44:08 -0400 Subject: [PATCH 05/20] debug: attempt to populate empty buckets --- tools/addrbook/addrbook.json | 18 +++++++++--------- tools/addrbook/main.go | 5 +++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index 8ceafe0335..86758cd224 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -12,7 +12,7 @@ "ip": "64.227.18.169", "port": 26656 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -30,7 +30,7 @@ "ip": "141.94.73.39", "port": 43656 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -48,7 +48,7 @@ "ip": "88.99.219.120", "port": 43656 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -66,7 +66,7 @@ "ip": "65.109.92.79", "port": 11656 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -84,7 +84,7 @@ "ip": "65.108.66.220", "port": 26656 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -102,7 +102,7 @@ "ip": "173.249.24.244", "port": 20279 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -120,7 +120,7 @@ "ip": "65.108.231.124", "port": 11656 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -138,7 +138,7 @@ "ip": "185.225.232.196", "port": 443 }, - "buckets": null, + "buckets": [], "attempts": 0, "bucket_type": 0, "last_attempt": "0001-01-01T00:00:00Z", @@ -146,4 +146,4 @@ "last_ban_time": "0001-01-01T00:00:00Z" } ] -} +} \ No newline at end of file diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go index 7cd6aa1aea..b9346b9c72 100644 --- a/tools/addrbook/main.go +++ b/tools/addrbook/main.go @@ -62,8 +62,9 @@ func main() { } entry := Entry{ - Addr: addr, - Src: addr, + Addr: addr, + Src: addr, + Buckets: []int{}, } addrs = append(addrs, entry) From 00af9c9e07cce083430f0e08b243118094e5c64c Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 6 Oct 2023 18:49:08 -0400 Subject: [PATCH 06/20] debug: check mocha-4 script into version control --- scripts/mocha-4.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/mocha-4.sh diff --git a/scripts/mocha-4.sh b/scripts/mocha-4.sh new file mode 100755 index 0000000000..66f3b6533f --- /dev/null +++ b/scripts/mocha-4.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# This script builds the celestia-app repo and attempts to connect to mocha-4. +# This script assumes that it is executed from the root of the celestia-app repo. +# ./scripts/mocha-4.sh + +set -o errexit -o nounset + +CELESTIA_APP_HOME="$HOME/.celestia-app" +NETWORKS_PATH="$HOME/git/rootulp/celestia/networks" +BINARY_PATH="./build/celestia-appd" +CHAIN_ID="mocha-4" +NODE_NAME="node-name" + +# echo "Building celestia-appd" +# make build + +echo "Deleting existing celestia-app home" +rm -rf ${CELESTIA_APP_HOME} + +echo "Initializing new celestia-app home" +# redirect the output to /dev/null to avoid polluting the terminal output +${BINARY_PATH} init ${NODE_NAME} --chain-id ${CHAIN_ID} --home ${CELESTIA_APP_HOME} &> /dev/null + +echo "Copying genesis.json from networks repo to celestia-app config" +cp ${NETWORKS_PATH}/${CHAIN_ID}/genesis.json ${CELESTIA_APP_HOME}/config + +echo "Copying addrbook.json to celestia-app config" +cp /Users/rootulp/git/rootulp/celestia/celestia-app/tools/addrbook/addrbook.json ${CELESTIA_APP_HOME}/config/ + +echo "Setting seeds" +SEEDS="3314051954fc072a0678ec0cbac690ad8676ab98@65.108.66.220:26656,258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.mocha-4.celestia.aviaone.com:20279,5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e@celestia-testnet-seed.itrocket.net:11656,7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee@celest-test-seed.theamsolutions.info:443" +sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" ${CELESTIA_APP_HOME}/config/config.toml + +echo "Setting persistent peers" +PERSISTENT_PEERS="34499b1ac473fbb03894c883178ecc83f0d6eaf6@64.227.18.169:26656,43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656,f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656,daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656" +sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PERSISTENT_PEERS\"/" ${CELESTIA_APP_HOME}/config/config.toml + +echo "Starting celestia-appd" +${BINARY_PATH} start --home ${CELESTIA_APP_HOME} --api.enable From d171f0f318a389039d3c4c8dd7d17561e838cee7 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 10 Oct 2023 11:12:01 -0400 Subject: [PATCH 07/20] feat: rand bucket index + bucket type new --- tools/addrbook/addrbook.json | 96 ++++++------------------------------ tools/addrbook/main.go | 23 +++++++-- tools/addrbook/peers.txt | 4 -- 3 files changed, 36 insertions(+), 87 deletions(-) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index 86758cd224..bb5969728e 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -12,9 +12,11 @@ "ip": "64.227.18.169", "port": 26656 }, - "buckets": [], + "buckets": [ + 193 + ], "attempts": 0, - "bucket_type": 0, + "bucket_type": 1, "last_attempt": "0001-01-01T00:00:00Z", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" @@ -30,9 +32,11 @@ "ip": "141.94.73.39", "port": 43656 }, - "buckets": [], + "buckets": [ + 3 + ], "attempts": 0, - "bucket_type": 0, + "bucket_type": 1, "last_attempt": "0001-01-01T00:00:00Z", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" @@ -48,9 +52,11 @@ "ip": "88.99.219.120", "port": 43656 }, - "buckets": [], + "buckets": [ + 49 + ], "attempts": 0, - "bucket_type": 0, + "bucket_type": 1, "last_attempt": "0001-01-01T00:00:00Z", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" @@ -66,81 +72,11 @@ "ip": "65.109.92.79", "port": 11656 }, - "buckets": [], + "buckets": [ + 139 + ], "attempts": 0, - "bucket_type": 0, - "last_attempt": "0001-01-01T00:00:00Z", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, - { - "addr": { - "id": "3314051954fc072a0678ec0cbac690ad8676ab98", - "ip": "65.108.66.220", - "port": 26656 - }, - "src": { - "id": "3314051954fc072a0678ec0cbac690ad8676ab98", - "ip": "65.108.66.220", - "port": 26656 - }, - "buckets": [], - "attempts": 0, - "bucket_type": 0, - "last_attempt": "0001-01-01T00:00:00Z", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, - { - "addr": { - "id": "258f523c96efde50d5fe0a9faeea8a3e83be22ca", - "ip": "173.249.24.244", - "port": 20279 - }, - "src": { - "id": "258f523c96efde50d5fe0a9faeea8a3e83be22ca", - "ip": "173.249.24.244", - "port": 20279 - }, - "buckets": [], - "attempts": 0, - "bucket_type": 0, - "last_attempt": "0001-01-01T00:00:00Z", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, - { - "addr": { - "id": "5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e", - "ip": "65.108.231.124", - "port": 11656 - }, - "src": { - "id": "5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e", - "ip": "65.108.231.124", - "port": 11656 - }, - "buckets": [], - "attempts": 0, - "bucket_type": 0, - "last_attempt": "0001-01-01T00:00:00Z", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, - { - "addr": { - "id": "7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee", - "ip": "185.225.232.196", - "port": 443 - }, - "src": { - "id": "7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee", - "ip": "185.225.232.196", - "port": 443 - }, - "buckets": [], - "attempts": 0, - "bucket_type": 0, + "bucket_type": 1, "last_attempt": "0001-01-01T00:00:00Z", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go index b9346b9c72..1000485656 100644 --- a/tools/addrbook/main.go +++ b/tools/addrbook/main.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "fmt" + "math/rand" "net" "os" "strings" @@ -26,6 +27,11 @@ type Entry struct { LastBanTime time.Time `json:"last_ban_time"` } +// BucketTypeNew is the byte value CometBFT uses to represent a new bucket. +// +// Ref: https://github.com/celestiaorg/celestia-core/blob/f7635ef65de901906b4f63aa9cc7ac9fbd7d5223/p2p/pex/addrbook.go#L29 +const BucketTypeNew = 0x01 + type Output struct { Key string `json:"key"` Addrs []Entry `json:"addrs"` @@ -62,9 +68,10 @@ func main() { } entry := Entry{ - Addr: addr, - Src: addr, - Buckets: []int{}, + Addr: addr, + Src: addr, + Buckets: []int{randBucketIndex()}, + BucketType: BucketTypeNew, } addrs = append(addrs, entry) @@ -103,3 +110,13 @@ func stringToInt(s string) int { fmt.Sscanf(s, "%d", &result) return result } + +// randBucketIndex generates a random bucket index between 0 and 255 (inclusive). +func randBucketIndex() int { + // CometBFT's addressbook doesn't appear to enforce a range for bucket + // indexes but this Cosmos Hub address book has bucket indexes between 0 + // and 255. + // + // Ref: https://dl2.quicksync.io/json/addrbook.cosmos.json + return rand.Intn(256) +} diff --git a/tools/addrbook/peers.txt b/tools/addrbook/peers.txt index f7d46dfc58..8cc104a161 100644 --- a/tools/addrbook/peers.txt +++ b/tools/addrbook/peers.txt @@ -2,7 +2,3 @@ 43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656 f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656 daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656 -3314051954fc072a0678ec0cbac690ad8676ab98@65.108.66.220:26656 -258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.mocha-4.celestia.aviaone.com:20279 -5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e@celestia-testnet-seed.itrocket.net:11656 -7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee@celest-test-seed.theamsolutions.info:443 From 1ead5b7b781bf5be3643ffcad2ffa24c71805302 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 10 Oct 2023 11:22:37 -0400 Subject: [PATCH 08/20] debug: add AlexToTheMoon peer Inspired by https://github.com/celestiaorg/networks/pull/351 --- scripts/mocha-4.sh | 2 +- tools/addrbook/addrbook.json | 28 ++++++++++++++++++++++++---- tools/addrbook/peers.txt | 1 + 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/mocha-4.sh b/scripts/mocha-4.sh index 66f3b6533f..fccb949a20 100755 --- a/scripts/mocha-4.sh +++ b/scripts/mocha-4.sh @@ -33,7 +33,7 @@ SEEDS="3314051954fc072a0678ec0cbac690ad8676ab98@65.108.66.220:26656,258f523c96ef sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" ${CELESTIA_APP_HOME}/config/config.toml echo "Setting persistent peers" -PERSISTENT_PEERS="34499b1ac473fbb03894c883178ecc83f0d6eaf6@64.227.18.169:26656,43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656,f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656,daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656" +PERSISTENT_PEERS="34499b1ac473fbb03894c883178ecc83f0d6eaf6@64.227.18.169:26656,43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656,f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656,daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656,f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9@65.108.238.61:13656" sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PERSISTENT_PEERS\"/" ${CELESTIA_APP_HOME}/config/config.toml echo "Starting celestia-appd" diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index bb5969728e..cb26f57d61 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -13,7 +13,7 @@ "port": 26656 }, "buckets": [ - 193 + 255 ], "attempts": 0, "bucket_type": 1, @@ -33,7 +33,7 @@ "port": 43656 }, "buckets": [ - 3 + 228 ], "attempts": 0, "bucket_type": 1, @@ -53,7 +53,7 @@ "port": 43656 }, "buckets": [ - 49 + 119 ], "attempts": 0, "bucket_type": 1, @@ -73,7 +73,27 @@ "port": 11656 }, "buckets": [ - 139 + 132 + ], + "attempts": 0, + "bucket_type": 1, + "last_attempt": "0001-01-01T00:00:00Z", + "last_success": "0001-01-01T00:00:00Z", + "last_ban_time": "0001-01-01T00:00:00Z" + }, + { + "addr": { + "id": "f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9", + "ip": "65.108.238.61", + "port": 13656 + }, + "src": { + "id": "f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9", + "ip": "65.108.238.61", + "port": 13656 + }, + "buckets": [ + 94 ], "attempts": 0, "bucket_type": 1, diff --git a/tools/addrbook/peers.txt b/tools/addrbook/peers.txt index 8cc104a161..227bb57812 100644 --- a/tools/addrbook/peers.txt +++ b/tools/addrbook/peers.txt @@ -2,3 +2,4 @@ 43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656 f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656 daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656 +f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9@65.108.238.61:13656 From 71aab84d8369060cce206985dcfd0476be141204 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 10 Oct 2023 13:50:11 -0400 Subject: [PATCH 09/20] debug: arabica-10 script --- scripts/arabica-10.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 scripts/arabica-10.sh diff --git a/scripts/arabica-10.sh b/scripts/arabica-10.sh new file mode 100755 index 0000000000..2af6dbab8f --- /dev/null +++ b/scripts/arabica-10.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +# This script builds the celestia-app repo and attempts to connect to arabica-10. +# This script assumes that it is executed from the root of the celestia-app repo. +# ./scripts/arabica-10 + +set -o errexit -o nounset + +CELESTIA_APP_HOME="$HOME/.celestia-app" +NETWORKS_PATH="$HOME/git/rootulp/celestia/networks" +BINARY_PATH="./build/celestia-appd" +CHAIN_ID="arabica-10" +NODE_NAME="node-name" + +# echo "Building celestia-appd" +# make build + +echo "Deleting existing celestia-app home" +rm -rf ${CELESTIA_APP_HOME} + +echo "Initializing new celestia-app home" +# redirect the output to /dev/null to avoid polluting the terminal output +${BINARY_PATH} init ${NODE_NAME} --chain-id ${CHAIN_ID} --home ${CELESTIA_APP_HOME} &> /dev/null + +echo "Copying genesis.json from networks repo to celestia-app config" +cp ${NETWORKS_PATH}/${CHAIN_ID}/genesis.json ${CELESTIA_APP_HOME}/config + +echo "Copying addrbook.json to celestia-app config" +cp /Users/rootulp/git/rootulp/celestia/celestia-app/tools/addrbook/addrbook.json ${CELESTIA_APP_HOME}/config/ + +echo "Getting persistent peers from networks repo" +PERSISTENT_PEERS=$(curl -X GET "https://raw.githubusercontent.com/celestiaorg/networks/master/${CHAIN_ID}/peers.txt" | tr '\n' ',') + +echo "Setting persistent peers to ${PERSISTENT_PEERS}" +sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PERSISTENT_PEERS\"/" ${CELESTIA_APP_HOME}/config/config.toml + +echo "Starting celestia-appd" +${BINARY_PATH} start --home ${CELESTIA_APP_HOME} --api.enable From ea78914ad503878f4f7648d506456b01ac252fdf Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 10 Oct 2023 13:59:24 -0400 Subject: [PATCH 10/20] debug: works for arabica-10 --- tools/addrbook/addrbook.json | 78 +++++++++--------------------------- tools/addrbook/peers.txt | 8 ++-- 2 files changed, 22 insertions(+), 64 deletions(-) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index cb26f57d61..45ba80e508 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -3,57 +3,17 @@ "addrs": [ { "addr": { - "id": "34499b1ac473fbb03894c883178ecc83f0d6eaf6", - "ip": "64.227.18.169", + "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", + "ip": "79.125.3.26", "port": 26656 }, "src": { - "id": "34499b1ac473fbb03894c883178ecc83f0d6eaf6", - "ip": "64.227.18.169", + "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", + "ip": "79.125.3.26", "port": 26656 }, "buckets": [ - 255 - ], - "attempts": 0, - "bucket_type": 1, - "last_attempt": "0001-01-01T00:00:00Z", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, - { - "addr": { - "id": "43e9da043318a4ea0141259c17fcb06ecff816af", - "ip": "141.94.73.39", - "port": 43656 - }, - "src": { - "id": "43e9da043318a4ea0141259c17fcb06ecff816af", - "ip": "141.94.73.39", - "port": 43656 - }, - "buckets": [ - 228 - ], - "attempts": 0, - "bucket_type": 1, - "last_attempt": "0001-01-01T00:00:00Z", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, - { - "addr": { - "id": "f9e950870eccdb40e2386896d7b6a7687a103c99", - "ip": "88.99.219.120", - "port": 43656 - }, - "src": { - "id": "f9e950870eccdb40e2386896d7b6a7687a103c99", - "ip": "88.99.219.120", - "port": 43656 - }, - "buckets": [ - 119 + 154 ], "attempts": 0, "bucket_type": 1, @@ -63,17 +23,17 @@ }, { "addr": { - "id": "daf2cecee2bd7f1b3bf94839f993f807c6b15fbf", - "ip": "65.109.92.79", - "port": 11656 + "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", + "ip": "34.243.20.90", + "port": 26656 }, "src": { - "id": "daf2cecee2bd7f1b3bf94839f993f807c6b15fbf", - "ip": "65.109.92.79", - "port": 11656 + "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", + "ip": "34.243.20.90", + "port": 26656 }, "buckets": [ - 132 + 255 ], "attempts": 0, "bucket_type": 1, @@ -83,17 +43,17 @@ }, { "addr": { - "id": "f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9", - "ip": "65.108.238.61", - "port": 13656 + "id": "25c2e83bde060c51bb117c6526e14053bd4a83ec", + "ip": "52.51.103.181", + "port": 26656 }, "src": { - "id": "f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9", - "ip": "65.108.238.61", - "port": 13656 + "id": "25c2e83bde060c51bb117c6526e14053bd4a83ec", + "ip": "52.51.103.181", + "port": 26656 }, "buckets": [ - 94 + 181 ], "attempts": 0, "bucket_type": 1, diff --git a/tools/addrbook/peers.txt b/tools/addrbook/peers.txt index 227bb57812..ef08fb8fe0 100644 --- a/tools/addrbook/peers.txt +++ b/tools/addrbook/peers.txt @@ -1,5 +1,3 @@ -34499b1ac473fbb03894c883178ecc83f0d6eaf6@64.227.18.169:26656 -43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656 -f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656 -daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656 -f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9@65.108.238.61:13656 +ad8e16b0b78cd44239590c49da75ba074c02e1c4@consensus-full.celestia-arabica-10.com:26656 +4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1@full.consensus.celestia-arabica-10.com:26656 +25c2e83bde060c51bb117c6526e14053bd4a83ec@consensus-validator.celestia-arabica-10.com:26656 From 6bac3f41fbf39ef954f08b520a828efbfc13c766 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 10 Oct 2023 14:02:26 -0400 Subject: [PATCH 11/20] fix: name of output file --- tools/addrbook/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/addrbook/README.md b/tools/addrbook/README.md index a3f57809f6..0c2d5eba7e 100644 --- a/tools/addrbook/README.md +++ b/tools/addrbook/README.md @@ -11,4 +11,4 @@ This directory contains a small tool to convert a peer address txt file into an go run main.go ``` -This should generate a file called `addrbook.json` in the current directory. Next, manually verify the contents of `output.json` and if everything looks good, publish it. +This should generate a file called `addrbook.json` in the current directory. Next, manually verify the contents of `addrbook.json` and if everything looks good, publish it. From ff1b2fc8be381e8a56c715ef96fd7db1ca5fde29 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 10 Oct 2023 14:02:36 -0400 Subject: [PATCH 12/20] remove scripts used for testing --- scripts/arabica-10.sh | 38 -------------------------------------- scripts/mocha-4.sh | 40 ---------------------------------------- 2 files changed, 78 deletions(-) delete mode 100755 scripts/arabica-10.sh delete mode 100755 scripts/mocha-4.sh diff --git a/scripts/arabica-10.sh b/scripts/arabica-10.sh deleted file mode 100755 index 2af6dbab8f..0000000000 --- a/scripts/arabica-10.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# This script builds the celestia-app repo and attempts to connect to arabica-10. -# This script assumes that it is executed from the root of the celestia-app repo. -# ./scripts/arabica-10 - -set -o errexit -o nounset - -CELESTIA_APP_HOME="$HOME/.celestia-app" -NETWORKS_PATH="$HOME/git/rootulp/celestia/networks" -BINARY_PATH="./build/celestia-appd" -CHAIN_ID="arabica-10" -NODE_NAME="node-name" - -# echo "Building celestia-appd" -# make build - -echo "Deleting existing celestia-app home" -rm -rf ${CELESTIA_APP_HOME} - -echo "Initializing new celestia-app home" -# redirect the output to /dev/null to avoid polluting the terminal output -${BINARY_PATH} init ${NODE_NAME} --chain-id ${CHAIN_ID} --home ${CELESTIA_APP_HOME} &> /dev/null - -echo "Copying genesis.json from networks repo to celestia-app config" -cp ${NETWORKS_PATH}/${CHAIN_ID}/genesis.json ${CELESTIA_APP_HOME}/config - -echo "Copying addrbook.json to celestia-app config" -cp /Users/rootulp/git/rootulp/celestia/celestia-app/tools/addrbook/addrbook.json ${CELESTIA_APP_HOME}/config/ - -echo "Getting persistent peers from networks repo" -PERSISTENT_PEERS=$(curl -X GET "https://raw.githubusercontent.com/celestiaorg/networks/master/${CHAIN_ID}/peers.txt" | tr '\n' ',') - -echo "Setting persistent peers to ${PERSISTENT_PEERS}" -sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PERSISTENT_PEERS\"/" ${CELESTIA_APP_HOME}/config/config.toml - -echo "Starting celestia-appd" -${BINARY_PATH} start --home ${CELESTIA_APP_HOME} --api.enable diff --git a/scripts/mocha-4.sh b/scripts/mocha-4.sh deleted file mode 100755 index fccb949a20..0000000000 --- a/scripts/mocha-4.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -# This script builds the celestia-app repo and attempts to connect to mocha-4. -# This script assumes that it is executed from the root of the celestia-app repo. -# ./scripts/mocha-4.sh - -set -o errexit -o nounset - -CELESTIA_APP_HOME="$HOME/.celestia-app" -NETWORKS_PATH="$HOME/git/rootulp/celestia/networks" -BINARY_PATH="./build/celestia-appd" -CHAIN_ID="mocha-4" -NODE_NAME="node-name" - -# echo "Building celestia-appd" -# make build - -echo "Deleting existing celestia-app home" -rm -rf ${CELESTIA_APP_HOME} - -echo "Initializing new celestia-app home" -# redirect the output to /dev/null to avoid polluting the terminal output -${BINARY_PATH} init ${NODE_NAME} --chain-id ${CHAIN_ID} --home ${CELESTIA_APP_HOME} &> /dev/null - -echo "Copying genesis.json from networks repo to celestia-app config" -cp ${NETWORKS_PATH}/${CHAIN_ID}/genesis.json ${CELESTIA_APP_HOME}/config - -echo "Copying addrbook.json to celestia-app config" -cp /Users/rootulp/git/rootulp/celestia/celestia-app/tools/addrbook/addrbook.json ${CELESTIA_APP_HOME}/config/ - -echo "Setting seeds" -SEEDS="3314051954fc072a0678ec0cbac690ad8676ab98@65.108.66.220:26656,258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.mocha-4.celestia.aviaone.com:20279,5d0bf034d6e6a8b5ee31a2f42f753f1107b3a00e@celestia-testnet-seed.itrocket.net:11656,7da0fb48d6ef0823bc9770c0c8068dd7c89ed4ee@celest-test-seed.theamsolutions.info:443" -sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" ${CELESTIA_APP_HOME}/config/config.toml - -echo "Setting persistent peers" -PERSISTENT_PEERS="34499b1ac473fbb03894c883178ecc83f0d6eaf6@64.227.18.169:26656,43e9da043318a4ea0141259c17fcb06ecff816af@rpc-1.celestia.nodes.guru:43656,f9e950870eccdb40e2386896d7b6a7687a103c99@rpc-2.celestia.nodes.guru:43656,daf2cecee2bd7f1b3bf94839f993f807c6b15fbf@celestia-testnet-peer.itrocket.net:11656,f0c7ef0af1c3557dc05509ba6dff2a22bdc705e9@65.108.238.61:13656" -sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PERSISTENT_PEERS\"/" ${CELESTIA_APP_HOME}/config/config.toml - -echo "Starting celestia-appd" -${BINARY_PATH} start --home ${CELESTIA_APP_HOME} --api.enable From 84429b489f9ae41263eb79383b5128f3ff4b945c Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 10 Oct 2023 14:15:29 -0400 Subject: [PATCH 13/20] fix: lint --- tools/addrbook/addrbook.json | 14 ++++++------ tools/addrbook/main.go | 43 +++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index 45ba80e508..4d711bfd74 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -4,16 +4,16 @@ { "addr": { "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "79.125.3.26", + "ip": "34.243.20.90", "port": 26656 }, "src": { "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "79.125.3.26", + "ip": "34.243.20.90", "port": 26656 }, "buckets": [ - 154 + 112 ], "attempts": 0, "bucket_type": 1, @@ -24,16 +24,16 @@ { "addr": { "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", - "ip": "34.243.20.90", + "ip": "79.125.3.26", "port": 26656 }, "src": { "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", - "ip": "34.243.20.90", + "ip": "79.125.3.26", "port": 26656 }, "buckets": [ - 255 + 223 ], "attempts": 0, "bucket_type": 1, @@ -53,7 +53,7 @@ "port": 26656 }, "buckets": [ - 181 + 36 ], "attempts": 0, "bucket_type": 1, diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go index 1000485656..17cb27bf72 100644 --- a/tools/addrbook/main.go +++ b/tools/addrbook/main.go @@ -10,6 +10,22 @@ import ( "time" ) +const ( + // bucketTypeNew is the byte value CometBFT uses to represent a new bucket. + // + // Ref: https://github.com/celestiaorg/celestia-core/blob/f7635ef65de901906b4f63aa9cc7ac9fbd7d5223/p2p/pex/addrbook.go#L29 + bucketTypeNew = 0x01 + + // inputFile is the filename of the input file containing the list of peers. + inputFile = "peers.txt" + + // outputFile is the filename of the output file that will be generated. + outputFile = "addrbook.json" + + // key is a hard-coded key for the address book. + key = "075f251a11c6b2cef94f3d61" +) + type Address struct { ID string `json:"id"` IP string `json:"ip"` @@ -27,34 +43,30 @@ type Entry struct { LastBanTime time.Time `json:"last_ban_time"` } -// BucketTypeNew is the byte value CometBFT uses to represent a new bucket. -// -// Ref: https://github.com/celestiaorg/celestia-core/blob/f7635ef65de901906b4f63aa9cc7ac9fbd7d5223/p2p/pex/addrbook.go#L29 -const BucketTypeNew = 0x01 - type Output struct { Key string `json:"key"` Addrs []Entry `json:"addrs"` } func main() { - data, err := os.ReadFile("peers.txt") + data, err := os.ReadFile(inputFile) if err != nil { panic(err) } lines := strings.Split(string(data), "\n") - var addrs []Entry + // var addrs []Entry + addrs := make([]Entry, 0, len(lines)) for _, line := range lines { if line == "" { continue } parts := strings.Split(line, "@") id := parts[0] - ipPort := strings.Split(parts[1], ":") - domain := ipPort[0] - port := ipPort[1] + domainAndPort := strings.Split(parts[1], ":") + domain := domainAndPort[0] + port := domainAndPort[1] ip, err := resolveDomain(domain) if err != nil { @@ -71,14 +83,14 @@ func main() { Addr: addr, Src: addr, Buckets: []int{randBucketIndex()}, - BucketType: BucketTypeNew, + BucketType: bucketTypeNew, } addrs = append(addrs, entry) } output := Output{ - Key: "075f251a11c6b2cef94f3d61", // This is hard-coded, change as needed + Key: key, Addrs: addrs, } @@ -87,13 +99,14 @@ func main() { panic(err) } - // Save the output to addrbook.json - if err := os.WriteFile("addrbook.json", jsonData, 0644); err != nil { + if err := os.WriteFile(outputFile, jsonData, 0o644); err != nil { panic(err) } - fmt.Println("Conversion completed. Check addrbook.json.") + + fmt.Printf("Converted %s into %s\n", inputFile, outputFile) } +// resolveDomain returns the first IP address found for the given domain. func resolveDomain(domain string) (string, error) { addresses, err := net.LookupHost(domain) if err != nil { From a93f9f7183760b57df62064fecbcee1c26bba2fe Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 19 Oct 2023 10:38:11 -0400 Subject: [PATCH 14/20] refactor: use addrbook from celestia-core --- tools/addrbook/addrbook.json | 26 ++++---- tools/addrbook/main.go | 111 ++++------------------------------- 2 files changed, 25 insertions(+), 112 deletions(-) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index 4d711bfd74..8639decfb0 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -1,63 +1,63 @@ { - "key": "075f251a11c6b2cef94f3d61", + "key": "d4e71e1a059d01b34fcdcbcc", "addrs": [ { "addr": { "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "34.243.20.90", + "ip": "52.211.5.83", "port": 26656 }, "src": { "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "34.243.20.90", + "ip": "52.211.5.83", "port": 26656 }, "buckets": [ - 112 + 100 ], "attempts": 0, "bucket_type": 1, - "last_attempt": "0001-01-01T00:00:00Z", + "last_attempt": "2023-10-19T11:10:29.9758-04:00", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", - "ip": "79.125.3.26", + "ip": "52.213.59.247", "port": 26656 }, "src": { "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", - "ip": "79.125.3.26", + "ip": "52.213.59.247", "port": 26656 }, "buckets": [ - 223 + 169 ], "attempts": 0, "bucket_type": 1, - "last_attempt": "0001-01-01T00:00:00Z", + "last_attempt": "2023-10-19T11:10:29.976665-04:00", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { "id": "25c2e83bde060c51bb117c6526e14053bd4a83ec", - "ip": "52.51.103.181", + "ip": "34.247.208.165", "port": 26656 }, "src": { "id": "25c2e83bde060c51bb117c6526e14053bd4a83ec", - "ip": "52.51.103.181", + "ip": "34.247.208.165", "port": 26656 }, "buckets": [ - 36 + 96 ], "attempts": 0, "bucket_type": 1, - "last_attempt": "0001-01-01T00:00:00Z", + "last_attempt": "2023-10-19T11:10:29.977399-04:00", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" } diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go index 17cb27bf72..8d01da46c1 100644 --- a/tools/addrbook/main.go +++ b/tools/addrbook/main.go @@ -1,135 +1,48 @@ package main import ( - "encoding/json" "fmt" - "math/rand" - "net" "os" "strings" - "time" + + "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/p2p/pex" ) const ( - // bucketTypeNew is the byte value CometBFT uses to represent a new bucket. - // - // Ref: https://github.com/celestiaorg/celestia-core/blob/f7635ef65de901906b4f63aa9cc7ac9fbd7d5223/p2p/pex/addrbook.go#L29 - bucketTypeNew = 0x01 - // inputFile is the filename of the input file containing the list of peers. inputFile = "peers.txt" // outputFile is the filename of the output file that will be generated. outputFile = "addrbook.json" - // key is a hard-coded key for the address book. - key = "075f251a11c6b2cef94f3d61" + // routabilityStrict is a hard-coded config value for the address book. + // See https://github.com/celestiaorg/celestia-core/blob/793ece9bbd732aec3e09018e37dc31f4bfe122d9/config/config.go#L540-L542 + routabilityStrict = true ) -type Address struct { - ID string `json:"id"` - IP string `json:"ip"` - Port int `json:"port"` -} - -type Entry struct { - Addr Address `json:"addr"` - Src Address `json:"src"` - Buckets []int `json:"buckets"` - Attempts int32 `json:"attempts"` - BucketType byte `json:"bucket_type"` - LastAttempt time.Time `json:"last_attempt"` - LastSuccess time.Time `json:"last_success"` - LastBanTime time.Time `json:"last_ban_time"` -} - -type Output struct { - Key string `json:"key"` - Addrs []Entry `json:"addrs"` -} - func main() { data, err := os.ReadFile(inputFile) if err != nil { panic(err) } - lines := strings.Split(string(data), "\n") - // var addrs []Entry - addrs := make([]Entry, 0, len(lines)) + book := pex.NewAddrBook(outputFile, routabilityStrict) for _, line := range lines { if line == "" { continue } - parts := strings.Split(line, "@") - id := parts[0] - domainAndPort := strings.Split(parts[1], ":") - domain := domainAndPort[0] - port := domainAndPort[1] - - ip, err := resolveDomain(domain) + address, err := p2p.NewNetAddressString(line) if err != nil { panic(err) } - - addr := Address{ - ID: id, - IP: ip, - Port: stringToInt(port), - } - - entry := Entry{ - Addr: addr, - Src: addr, - Buckets: []int{randBucketIndex()}, - BucketType: bucketTypeNew, + err = book.AddAddress(address, address) + if err != nil { + panic(err) } - - addrs = append(addrs, entry) - } - - output := Output{ - Key: key, - Addrs: addrs, - } - - jsonData, err := json.MarshalIndent(output, "", "\t") - if err != nil { - panic(err) - } - - if err := os.WriteFile(outputFile, jsonData, 0o644); err != nil { - panic(err) } + book.Save() fmt.Printf("Converted %s into %s\n", inputFile, outputFile) } - -// resolveDomain returns the first IP address found for the given domain. -func resolveDomain(domain string) (string, error) { - addresses, err := net.LookupHost(domain) - if err != nil { - return "", err - } - if len(addresses) == 0 { - return "", fmt.Errorf("no IP found for domain: %s", domain) - } - return addresses[0], nil // use the first IP found -} - -func stringToInt(s string) int { - var result int - fmt.Sscanf(s, "%d", &result) - return result -} - -// randBucketIndex generates a random bucket index between 0 and 255 (inclusive). -func randBucketIndex() int { - // CometBFT's addressbook doesn't appear to enforce a range for bucket - // indexes but this Cosmos Hub address book has bucket indexes between 0 - // and 255. - // - // Ref: https://dl2.quicksync.io/json/addrbook.cosmos.json - return rand.Intn(256) -} From 754404c4284c3e6bf3ce99bdb63e0cd4a2287d41 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 19 Oct 2023 11:38:28 -0400 Subject: [PATCH 15/20] debug: remove validator from peers.txt I see logs of the form ``` 11:24AM ERR Stopping peer for error err="error with peer 25c2e83bde060c51bb117c6526e14053bd4a83ec: invalid peer" module=p2p peer={"Data":{},"Logger":{}} ``` even though the validator seems to be up: http://consensus-validator.celestia-arabica-10.com:26657/net_info? --- tools/addrbook/addrbook.json | 38 +++++++++--------------------------- tools/addrbook/peers.txt | 1 - 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/tools/addrbook/addrbook.json b/tools/addrbook/addrbook.json index 8639decfb0..dad9585144 100644 --- a/tools/addrbook/addrbook.json +++ b/tools/addrbook/addrbook.json @@ -1,26 +1,6 @@ { - "key": "d4e71e1a059d01b34fcdcbcc", + "key": "b2d2a799a4a029ce15d0ed27", "addrs": [ - { - "addr": { - "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "52.211.5.83", - "port": 26656 - }, - "src": { - "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "52.211.5.83", - "port": 26656 - }, - "buckets": [ - 100 - ], - "attempts": 0, - "bucket_type": 1, - "last_attempt": "2023-10-19T11:10:29.9758-04:00", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, { "addr": { "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", @@ -33,31 +13,31 @@ "port": 26656 }, "buckets": [ - 169 + 22 ], "attempts": 0, "bucket_type": 1, - "last_attempt": "2023-10-19T11:10:29.976665-04:00", + "last_attempt": "2023-10-19T11:36:16.996293-04:00", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" }, { "addr": { - "id": "25c2e83bde060c51bb117c6526e14053bd4a83ec", - "ip": "34.247.208.165", + "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", + "ip": "52.213.59.247", "port": 26656 }, "src": { - "id": "25c2e83bde060c51bb117c6526e14053bd4a83ec", - "ip": "34.247.208.165", + "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", + "ip": "52.213.59.247", "port": 26656 }, "buckets": [ - 96 + 22 ], "attempts": 0, "bucket_type": 1, - "last_attempt": "2023-10-19T11:10:29.977399-04:00", + "last_attempt": "2023-10-19T11:36:16.844033-04:00", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" } diff --git a/tools/addrbook/peers.txt b/tools/addrbook/peers.txt index ef08fb8fe0..da71b73aa1 100644 --- a/tools/addrbook/peers.txt +++ b/tools/addrbook/peers.txt @@ -1,3 +1,2 @@ ad8e16b0b78cd44239590c49da75ba074c02e1c4@consensus-full.celestia-arabica-10.com:26656 4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1@full.consensus.celestia-arabica-10.com:26656 -25c2e83bde060c51bb117c6526e14053bd4a83ec@consensus-validator.celestia-arabica-10.com:26656 From 3cfc4f337eb5903b82a65ecedadfc20259d32cf7 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 19 Oct 2023 15:22:39 -0400 Subject: [PATCH 16/20] refactor: move tool to celestia-appd command --- tools/addrbook/addrbook.json => addrbook.json | 10 ++-- cmd/celestia-appd/cmd/addrbook.go | 56 +++++++++++++++++++ cmd/celestia-appd/cmd/root.go | 1 + tools/addrbook/README.md | 14 ----- tools/addrbook/main.go | 48 ---------------- tools/addrbook/peers.txt | 2 - 6 files changed, 62 insertions(+), 69 deletions(-) rename tools/addrbook/addrbook.json => addrbook.json (83%) create mode 100644 cmd/celestia-appd/cmd/addrbook.go delete mode 100644 tools/addrbook/README.md delete mode 100644 tools/addrbook/main.go delete mode 100644 tools/addrbook/peers.txt diff --git a/tools/addrbook/addrbook.json b/addrbook.json similarity index 83% rename from tools/addrbook/addrbook.json rename to addrbook.json index dad9585144..b2cfc88ac0 100644 --- a/tools/addrbook/addrbook.json +++ b/addrbook.json @@ -1,5 +1,5 @@ { - "key": "b2d2a799a4a029ce15d0ed27", + "key": "259cb9ff04003abb6905135f", "addrs": [ { "addr": { @@ -13,11 +13,11 @@ "port": 26656 }, "buckets": [ - 22 + 1 ], "attempts": 0, "bucket_type": 1, - "last_attempt": "2023-10-19T11:36:16.996293-04:00", + "last_attempt": "2023-10-19T15:20:28.503483-04:00", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" }, @@ -33,11 +33,11 @@ "port": 26656 }, "buckets": [ - 22 + 1 ], "attempts": 0, "bucket_type": 1, - "last_attempt": "2023-10-19T11:36:16.844033-04:00", + "last_attempt": "2023-10-19T15:20:28.444543-04:00", "last_success": "0001-01-01T00:00:00Z", "last_ban_time": "0001-01-01T00:00:00Z" } diff --git a/cmd/celestia-appd/cmd/addrbook.go b/cmd/celestia-appd/cmd/addrbook.go new file mode 100644 index 0000000000..a879b197ba --- /dev/null +++ b/cmd/celestia-appd/cmd/addrbook.go @@ -0,0 +1,56 @@ +package cmd + +import ( + "fmt" + "os" + "strings" + + "github.com/spf13/cobra" + "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/p2p/pex" +) + +const ( + // routabilityStrict is a hard-coded config value for the address book. + // See https://github.com/celestiaorg/celestia-core/blob/793ece9bbd732aec3e09018e37dc31f4bfe122d9/config/config.go#L540-L542 + routabilityStrict = true +) + +func addrbookCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "addrbook peers.txt addrbook.json", + Short: "Convert a list of peers into an address book", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + inputFile := args[0] + outputFile := args[1] + + data, err := os.ReadFile(inputFile) + if err != nil { + return err + } + lines := strings.Split(string(data), "\n") + + book := pex.NewAddrBook(outputFile, routabilityStrict) + for _, line := range lines { + if line == "" { + continue + } + address, err := p2p.NewNetAddressString(line) + if err != nil { + return err + } + err = book.AddAddress(address, address) + if err != nil { + return err + } + } + + book.Save() + fmt.Printf("Converted %s into %s\n", inputFile, outputFile) + return nil + }, + } + + return cmd +} diff --git a/cmd/celestia-appd/cmd/root.go b/cmd/celestia-appd/cmd/root.go index 63584c279c..be95396665 100644 --- a/cmd/celestia-appd/cmd/root.go +++ b/cmd/celestia-appd/cmd/root.go @@ -135,6 +135,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig encoding.Config) { debugCmd, config.Cmd(), commands.CompactGoLevelDBCmd, + addrbookCommand(), ) server.AddCommands(rootCmd, app.DefaultNodeHome, NewAppServer, createAppAndExport, addModuleInitFlags) diff --git a/tools/addrbook/README.md b/tools/addrbook/README.md deleted file mode 100644 index 0c2d5eba7e..0000000000 --- a/tools/addrbook/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Addrbook - -This directory contains a small tool to convert a peer address txt file into an address book JSON file. - -## Example Usage - -1. Modify `peers.txt` to contain the addresses you want to include in the address book. -1. Run the tool: - - ```shell - go run main.go - ``` - -This should generate a file called `addrbook.json` in the current directory. Next, manually verify the contents of `addrbook.json` and if everything looks good, publish it. diff --git a/tools/addrbook/main.go b/tools/addrbook/main.go deleted file mode 100644 index 8d01da46c1..0000000000 --- a/tools/addrbook/main.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strings" - - "github.com/tendermint/tendermint/p2p" - "github.com/tendermint/tendermint/p2p/pex" -) - -const ( - // inputFile is the filename of the input file containing the list of peers. - inputFile = "peers.txt" - - // outputFile is the filename of the output file that will be generated. - outputFile = "addrbook.json" - - // routabilityStrict is a hard-coded config value for the address book. - // See https://github.com/celestiaorg/celestia-core/blob/793ece9bbd732aec3e09018e37dc31f4bfe122d9/config/config.go#L540-L542 - routabilityStrict = true -) - -func main() { - data, err := os.ReadFile(inputFile) - if err != nil { - panic(err) - } - lines := strings.Split(string(data), "\n") - - book := pex.NewAddrBook(outputFile, routabilityStrict) - for _, line := range lines { - if line == "" { - continue - } - address, err := p2p.NewNetAddressString(line) - if err != nil { - panic(err) - } - err = book.AddAddress(address, address) - if err != nil { - panic(err) - } - } - - book.Save() - fmt.Printf("Converted %s into %s\n", inputFile, outputFile) -} diff --git a/tools/addrbook/peers.txt b/tools/addrbook/peers.txt deleted file mode 100644 index da71b73aa1..0000000000 --- a/tools/addrbook/peers.txt +++ /dev/null @@ -1,2 +0,0 @@ -ad8e16b0b78cd44239590c49da75ba074c02e1c4@consensus-full.celestia-arabica-10.com:26656 -4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1@full.consensus.celestia-arabica-10.com:26656 From a5ab820a75a66a755bb4fb09c7400602a57b9a0f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 19 Oct 2023 15:24:34 -0400 Subject: [PATCH 17/20] fix: remove generated addrbook.json --- addrbook.json | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 addrbook.json diff --git a/addrbook.json b/addrbook.json deleted file mode 100644 index b2cfc88ac0..0000000000 --- a/addrbook.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "key": "259cb9ff04003abb6905135f", - "addrs": [ - { - "addr": { - "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", - "ip": "52.213.59.247", - "port": 26656 - }, - "src": { - "id": "4686b0b70a8d1a2b24cbe0f856ba2b52a38a02b1", - "ip": "52.213.59.247", - "port": 26656 - }, - "buckets": [ - 1 - ], - "attempts": 0, - "bucket_type": 1, - "last_attempt": "2023-10-19T15:20:28.503483-04:00", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - }, - { - "addr": { - "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "52.213.59.247", - "port": 26656 - }, - "src": { - "id": "ad8e16b0b78cd44239590c49da75ba074c02e1c4", - "ip": "52.213.59.247", - "port": 26656 - }, - "buckets": [ - 1 - ], - "attempts": 0, - "bucket_type": 1, - "last_attempt": "2023-10-19T15:20:28.444543-04:00", - "last_success": "0001-01-01T00:00:00Z", - "last_ban_time": "0001-01-01T00:00:00Z" - } - ] -} \ No newline at end of file From dc49124251289e69a856f08596960a2e9262bd33 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 20 Oct 2023 13:32:01 -0400 Subject: [PATCH 18/20] docs: add more docs to command --- cmd/celestia-appd/cmd/addrbook.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/celestia-appd/cmd/addrbook.go b/cmd/celestia-appd/cmd/addrbook.go index a879b197ba..b9b076d1c2 100644 --- a/cmd/celestia-appd/cmd/addrbook.go +++ b/cmd/celestia-appd/cmd/addrbook.go @@ -20,7 +20,10 @@ func addrbookCommand() *cobra.Command { cmd := &cobra.Command{ Use: "addrbook peers.txt addrbook.json", Short: "Convert a list of peers into an address book", - Args: cobra.ExactArgs(2), + Long: "Convert a list of peers into an address book.\n" + + "The first argument (peers.txt) should contain a new line separated list of peers. The format for a peer is `id@ip:port` or `id@domain:port`.\n" + + "The second argument (addrbook.json) should be the output filename. The address book is saved to the output file in JSON format.\n", + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { inputFile := args[0] outputFile := args[1] From f51ece63ebaf703f147f90f465248224d1e8642f Mon Sep 17 00:00:00 2001 From: Rootul P Date: Fri, 20 Oct 2023 16:16:33 -0400 Subject: [PATCH 19/20] Update cmd/celestia-appd/cmd/addrbook.go Co-authored-by: Sanaz Taheri <35961250+staheri14@users.noreply.github.com> --- cmd/celestia-appd/cmd/addrbook.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/celestia-appd/cmd/addrbook.go b/cmd/celestia-appd/cmd/addrbook.go index b9b076d1c2..6d6b456eef 100644 --- a/cmd/celestia-appd/cmd/addrbook.go +++ b/cmd/celestia-appd/cmd/addrbook.go @@ -22,7 +22,7 @@ func addrbookCommand() *cobra.Command { Short: "Convert a list of peers into an address book", Long: "Convert a list of peers into an address book.\n" + "The first argument (peers.txt) should contain a new line separated list of peers. The format for a peer is `id@ip:port` or `id@domain:port`.\n" + - "The second argument (addrbook.json) should be the output filename. The address book is saved to the output file in JSON format.\n", + "The second argument (addrbook.json) should contain the complete file path, including both the directory path and the desired output file name, in the following format: `path/to/filename`. The address book is saved to the output file in JSON format.\n", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { inputFile := args[0] From 6a9f28e0eb6d6ce02fbc7b09f66d016272a4c162 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 20 Oct 2023 16:33:34 -0400 Subject: [PATCH 20/20] refactor: use default config for routabilityStrict --- cmd/celestia-appd/cmd/addrbook.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/celestia-appd/cmd/addrbook.go b/cmd/celestia-appd/cmd/addrbook.go index 6d6b456eef..f363ed3626 100644 --- a/cmd/celestia-appd/cmd/addrbook.go +++ b/cmd/celestia-appd/cmd/addrbook.go @@ -5,17 +5,12 @@ import ( "os" "strings" + "github.com/celestiaorg/celestia-app/app" "github.com/spf13/cobra" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p/pex" ) -const ( - // routabilityStrict is a hard-coded config value for the address book. - // See https://github.com/celestiaorg/celestia-core/blob/793ece9bbd732aec3e09018e37dc31f4bfe122d9/config/config.go#L540-L542 - routabilityStrict = true -) - func addrbookCommand() *cobra.Command { cmd := &cobra.Command{ Use: "addrbook peers.txt addrbook.json", @@ -34,6 +29,7 @@ func addrbookCommand() *cobra.Command { } lines := strings.Split(string(data), "\n") + routabilityStrict := app.DefaultConsensusConfig().P2P.AddrBookStrict book := pex.NewAddrBook(outputFile, routabilityStrict) for _, line := range lines { if line == "" {