akash-network / cosmos-omnibus

112 stars 102 forks source link

Polkachu's live_peers API v2 is back! #684

Open andy108369 opened 7 months ago

andy108369 commented 7 months ago

As per Polkachu:

It is better than the old implementation. It only provides up to 5 random live peers plus a polkachu internal one. It is less likely to cause performance issues for nodes in the long run.

https://polkachu.com/docs/index.html#v2-public-GETapi-v2-chains--network--live_peers

$ curl -s "https://polkachu.com/api/v2/chains/akash/live_peers" | jq -r .
{
  "network": "akash",
  "polkachu_peer": "d1e47b071859497089c944dc082e920403484c1a@65.108.128.201:12856",
  "live_peers": [
    "9981156be9f73f5ff6219af6f5824b6eadd32c99@78.46.174.116:16656",
    "3c0a86d251e74aa9c439822e46e39d01bd145a82@62.131.218.3:26656",
    "5a37cdeebcdf30bda5aafed7a4f6badb4b5bddb2@51.158.233.73:26656",
    "e726816f42831689eab9378d5d577f1d06d25716@134.65.194.237:26656",
    "432078f1311838ca7df64f870de5512f1648db91@70.161.39.60:26656"
  ]
}

Hint: curl -s "https://polkachu.com/api/v2/chains/akash/live_peers" | jq -r '[.polkachu_peer, .live_peers[]] | @csv' | tr -d '"'

I think we should do the following:

  1. rename P2P_POLKACHU to P2P_POLKACHU_SEEDS
  2. introduce P2P_POLKACHU_PERSISTENT_PEERS (which would be getting 5 random live peers plus a polkachu internal one via https://polkachu.com/api/v2/chains/<CHAIN>/live_peers call)

Also need to think what to do with P2P_PERSISTENT_PEERS which come via CHAIN_JSON. There are plenty of them typically and less maintained. I'd say one should P2P_PERSISTENT_PEERS=0 (disable them) when using P2P_POLKACHU_PERSISTENT_PEERS=1 or have some switch to allow the combo.

Should also filter the duplicates. They often slip through.

andy108369 commented 7 months ago

I am currently running my node with these settings for the state-sync to work and have avoid adding bunch of p2p persistent peers which come through CHAIN_JSON by default (when P2P_PERSISTENT_PEERS isn't set to 0 and CHAIN_JSON is present with the p2p persistent peers in it):

      - STATESYNC_POLKACHU=1
      - P2P_POLKACHU=1
      # Discourage the use of p2p persistent peers (coming via CHAIN_JSON), to encourage the usage of p2p seeds instead.
      - P2P_PERSISTENT_PEERS=0
      # have to add Polkachu State-Sync Peer for Akash https://polkachu.com/live_peers/akash for the state-sync to work
      - AKASH_P2P_PERSISTENT_PEERS=d1e47b071859497089c944dc082e920403484c1a@65.108.128.201:12856

But even then this might fail:

INF Error reconnecting to peer. Trying again addr={"id":"d1e47b071859497089c944dc082e920403484c1a","ip":"65.108.128.201","port":12856} err="auth failure: secret conn failed: EOF" module=p2p tries=0

Whereas, state-sync works again when specifying more peers:

      # curl -s "https://polkachu.com/api/v2/chains/akash/live_peers" | jq -r '[.polkachu_peer, .live_peers[]] | @csv' | tr -d '"'
      - AKASH_P2P_PERSISTENT_PEERS=d1e47b071859497089c944dc082e920403484c1a@65.108.128.201:12856,e1b058e5cfa2b836ddaa496b10911da62dcf182e@169.155.44.150:26656,c908f3dca67111c21ce166d90042f2b898e526b5@35.230.84.227:26656,506002b391be8d653b14f0162325b14929cac72e@51.81.49.176:12856,ebc272824924ea1a27ea3183dd0b9ba713494f83@195.3.223.168:26696,9aa4c9097c818871e45aaca4118a9fe5e86c60e2@135.181.113.227:1506
INF Fetching snapshot chunk chunk=18 format=1 height=13764000 module=statesync total=34
...
INF Fetching snapshot chunk chunk=33 format=1 height=13764000 module=statesync total=34

Could probably also leverage the pre-seeded address book:

      - ADDRBOOK_URL=https://snapshots.polkachu.com/addrbook/akash/addrbook.json