@@ -62,12 +62,19 @@ func (ps *PeerSet) AsCometPeerString(ctx context.Context, useExternal bool) (str
6262// AsLibP2PAddressBook returns a map of node IDs to addresses of chain nodes.
6363// Format it [{host: "1.2.3.4:26656", id: "<lib-p2p-peer-id>"}, {...}, ...]
6464// @see https://github.com/cometbft/cometbft/blob/608fe92cbc3774c6cdf36c59c56b6c8362489ef1/lp2p/addressbook.go#L16
65- func (ps * PeerSet ) AsLibP2PAddressBook (ctx context.Context , useExternal bool ) ([]any , error ) {
65+ func (ps * PeerSet ) AsLibP2PAddressBook (ctx context.Context , isDocker bool ) ([]any , error ) {
6666 peers := make ([]any , 0 , len (ps .peers ))
6767
6868 resolveHost := peerHostInternal
69- if useExternal {
70- resolveHost = peerHostExternal
69+ if ! isDocker {
70+ // This breaks geo-distributed testnet for go-libp2p.
71+ //
72+ // Currently DigitalOcean Droplet are configured via Tailscale, which
73+ // causes issues go-libp2p connection (tailscale's IP are fetched via peerHostExternal)
74+ // Thus, we use VMs private IPs.
75+ //
76+ // TODO: come up with a better solution that doesn't use Tailscale, but supports multiple regions.
77+ resolveHost = peerHostPrivate
7178 }
7279
7380 for _ , n := range ps .peers {
@@ -105,6 +112,15 @@ func peerHostInternal(ctx context.Context, n petri.NodeI) (string, error) {
105112 return fmt .Sprintf ("%s:%s" , ip , cometPort ), nil
106113}
107114
115+ func peerHostPrivate (ctx context.Context , n petri.NodeI ) (string , error ) {
116+ ip , err := n .GetPrivateIP (ctx )
117+ if err != nil {
118+ return "" , err
119+ }
120+
121+ return fmt .Sprintf ("%s:%s" , ip , cometPort ), nil
122+ }
123+
108124// used for digitalocean
109125func peerIDFromNode (ctx context.Context , n petri.NodeI ) (peer.ID , error ) {
110126 cometPubKey , err := n .PubKey (ctx )
0 commit comments