Skip to content

Commit b33a946

Browse files
fix(p2p): use connection remote addr as fallback when peerstore is empty
1 parent bc41184 commit b33a946

4 files changed

Lines changed: 7 additions & 11 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/ethereum/go-ethereum v1.15.11
1414
github.com/ethersphere/batch-archive v0.0.5
1515
github.com/ethersphere/go-price-oracle-abi v0.6.9
16-
github.com/ethersphere/go-storage-incentives-abi v0.9.3-rc4
16+
github.com/ethersphere/go-storage-incentives-abi v0.9.4
1717
github.com/ethersphere/go-sw3-abi v0.6.9
1818
github.com/ethersphere/langos v1.0.0
1919
github.com/go-playground/validator/v10 v10.19.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ github.com/ethersphere/batch-archive v0.0.5 h1:SM3g7Tuge4KhOn+NKgPcg2Uz2p8a/MLKZ
240240
github.com/ethersphere/batch-archive v0.0.5/go.mod h1:41BPb192NoK9CYjNB8BAE1J2MtiI/5aq0Wtas5O7A7Q=
241241
github.com/ethersphere/go-price-oracle-abi v0.6.9 h1:bseen6he3PZv5GHOm+KD6s4awaFmVSD9LFx+HpB6rCU=
242242
github.com/ethersphere/go-price-oracle-abi v0.6.9/go.mod h1:sI/Qj4/zJ23/b1enzwMMv0/hLTpPNVNacEwCWjo6yBk=
243-
github.com/ethersphere/go-storage-incentives-abi v0.9.3-rc4 h1:YK9FpiQz29ctU5V46CuwMt+4X5Xn8FTBwy6E2v/ix8s=
244-
github.com/ethersphere/go-storage-incentives-abi v0.9.3-rc4/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc=
243+
github.com/ethersphere/go-storage-incentives-abi v0.9.4 h1:mSIWXQXg5OQmH10QvXMV5w0vbSibFMaRlBL37gPLTM0=
244+
github.com/ethersphere/go-storage-incentives-abi v0.9.4/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc=
245245
github.com/ethersphere/go-sw3-abi v0.6.9 h1:TnWLnYkWE5UvC17mQBdUmdkzhPhO8GcqvWy4wvd1QJQ=
246246
github.com/ethersphere/go-sw3-abi v0.6.9/go.mod h1:BmpsvJ8idQZdYEtWnvxA8POYQ8Rl/NhyCdF0zLMOOJU=
247247
github.com/ethersphere/langos v1.0.0 h1:NBtNKzXTTRSue95uOlzPN4py7Aofs0xWPzyj4AI1Vcc=

pkg/p2p/libp2p/internal/handshake/handshake.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ func (s *Service) Handle(ctx context.Context, stream p2p.Stream, peerMultiaddrs
306306
return a.Equal(b)
307307
})
308308

309-
s.logger.Debug("INVESTIGATION", "advertisableUnderlays", advertisableUnderlays)
310-
311309
advertisableUnderlays = p2p.FilterBee260CompatibleUnderlays(o.bee260compatibility, advertisableUnderlays)
312310

313311
bzzAddress, err := bzz.NewAddress(s.signer, advertisableUnderlays, s.overlay, s.networkID, s.nonce)
@@ -317,8 +315,6 @@ func (s *Service) Handle(ctx context.Context, stream p2p.Stream, peerMultiaddrs
317315

318316
welcomeMessage := s.GetWelcomeMessage()
319317

320-
s.logger.Debug("INVESTIGATION", "peerMultiaddrs", peerMultiaddrs)
321-
322318
peerMultiaddrs = p2p.FilterBee260CompatibleUnderlays(o.bee260compatibility, peerMultiaddrs)
323319

324320
if err := w.WriteMsgWithContext(ctx, &pb.SynAck{

pkg/p2p/libp2p/libp2p.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,17 +1466,17 @@ func (s *Service) determineCurrentNetworkStatus(err error) error {
14661466
}
14671467

14681468
// peerMultiaddrs builds full multiaddresses for a peer given information from
1469-
// libp2p host peerstore and falling back to the remote address from the
1470-
// connection.
1469+
// the libp2p host peerstore. If the peerstore doesn't have addresses yet,
1470+
// it falls back to using the remote address from the active connection.
14711471
func (s *Service) peerMultiaddrs(ctx context.Context, remoteAddr ma.Multiaddr, peerID libp2ppeer.ID) ([]ma.Multiaddr, error) {
14721472
waitPeersCtx, cancel := context.WithTimeout(ctx, peerstoreWaitAddrsTimeout)
14731473
defer cancel()
14741474

14751475
mas := waitPeerAddrs(waitPeersCtx, s.host.Peerstore(), peerID)
1476-
if len(mas) == 0 {
1477-
// fallback to remote address from the connection
1476+
if len(mas) == 0 && remoteAddr != nil {
14781477
mas = []ma.Multiaddr{remoteAddr}
14791478
}
1479+
14801480
return buildFullMAs(mas, peerID)
14811481
}
14821482

0 commit comments

Comments
 (0)