Fallback ping requests on metadata V2 (#2875)
Some clients disable their metadata V1 after the Altair fork, so we are unable to ping them correctly. This PR adds a fallback to try metadata V2 if V1 fails.
This commit is contained in:
parent
d1cb5b7220
commit
b9e9483c66
|
@ -1513,13 +1513,21 @@ proc updatePeerMetadata(node: Eth2Node, peerId: PeerID) {.async.} =
|
|||
trace "updating peer metadata", peerId
|
||||
|
||||
var peer = node.getPeer(peerId)
|
||||
let response = await peer.getMetaData()
|
||||
|
||||
if response.isErr:
|
||||
debug "Failed to retrieve metadata from peer!", peerId
|
||||
return
|
||||
#getMetaData can fail with an exception
|
||||
let newMetadata =
|
||||
try:
|
||||
tryGet(await peer.getMetaData())
|
||||
except CatchableError:
|
||||
let metadataV2 =
|
||||
try: tryGet(await peer.getMetadata_v2())
|
||||
except CatchableError as exc:
|
||||
debug "Failed to retrieve metadata from peer!", peerId, msg=exc.msg
|
||||
return
|
||||
|
||||
phase0.MetaData(seq_number: metadataV2.seq_number,
|
||||
attnets: metadataV2.attnets)
|
||||
|
||||
let newMetadata = response.get()
|
||||
peer.metadata = some(newMetadata)
|
||||
peer.lastMetadataTime = Moment.now()
|
||||
|
||||
|
|
Loading…
Reference in New Issue