Fix and enable optimistic/finality update portal network test (#1794)

This commit is contained in:
Kim De Mey 2023-10-02 11:41:11 +02:00 committed by GitHub
parent 6253d2a456
commit 492543a007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 61 additions and 62 deletions

View File

@ -65,80 +65,79 @@ procSuite "Beacon Light Client Content Network":
await lcNode2.stop() await lcNode2.stop()
asyncTest "Get latest optimistic and finality updates": asyncTest "Get latest optimistic and finality updates":
skip() let
# let lcNode1 = newLCNode(rng, 20302)
# lcNode1 = newLCNode(rng, 20302) lcNode2 = newLCNode(rng, 20303)
# lcNode2 = newLCNode(rng, 20303) forkDigests = testForkDigests
# forkDigests = testForkDigests
# check: check:
# lcNode1.portalProtocol().addNode(lcNode2.localNode()) == Added lcNode1.portalProtocol().addNode(lcNode2.localNode()) == Added
# lcNode2.portalProtocol().addNode(lcNode1.localNode()) == Added lcNode2.portalProtocol().addNode(lcNode1.localNode()) == Added
# (await lcNode1.portalProtocol().ping(lcNode2.localNode())).isOk() (await lcNode1.portalProtocol().ping(lcNode2.localNode())).isOk()
# (await lcNode2.portalProtocol().ping(lcNode1.localNode())).isOk() (await lcNode2.portalProtocol().ping(lcNode1.localNode())).isOk()
# let let
# finalityUpdateData = SSZ.decode( finalityUpdateData = SSZ.decode(
# lightClientFinalityUpdateBytes, altair.LightClientFinalityUpdate) lightClientFinalityUpdateBytes, altair.LightClientFinalityUpdate)
# finalityUpdate = ForkedLightClientFinalityUpdate( finalityUpdate = ForkedLightClientFinalityUpdate(
# kind: LightClientDataFork.Altair, altairData: finalityUpdateData) kind: LightClientDataFork.Altair, altairData: finalityUpdateData)
# finalizedHeaderSlot = finalityUpdateData.finalized_header.beacon.slot finalizedHeaderSlot = finalityUpdateData.finalized_header.beacon.slot
# finalizedOptimisticHeaderSlot = finalizedOptimisticHeaderSlot =
# finalityUpdateData.attested_header.beacon.slot finalityUpdateData.attested_header.beacon.slot
# optimisticUpdateData = SSZ.decode( optimisticUpdateData = SSZ.decode(
# lightClientOptimisticUpdateBytes, altair.LightClientOptimisticUpdate) lightClientOptimisticUpdateBytes, altair.LightClientOptimisticUpdate)
# optimisticUpdate = ForkedLightClientOptimisticUpdate( optimisticUpdate = ForkedLightClientOptimisticUpdate(
# kind: LightClientDataFork.Altair, altairData: optimisticUpdateData) kind: LightClientDataFork.Altair, altairData: optimisticUpdateData)
# optimisticHeaderSlot = optimisticUpdateData.attested_header.beacon.slot optimisticHeaderSlot = optimisticUpdateData.attested_header.beacon.slot
# finalityUpdateKey = finalityUpdateContentKey( finalityUpdateKey = finalityUpdateContentKey(
# distinctBase(finalizedHeaderSlot), distinctBase(finalizedHeaderSlot),
# distinctBase(finalizedOptimisticHeaderSlot) distinctBase(finalizedOptimisticHeaderSlot)
# ) )
# finalityKeyEnc = encode(finalityUpdateKey) finalityKeyEnc = encode(finalityUpdateKey)
# finalityUpdateId = toContentId(finalityKeyEnc) finalityUpdateId = toContentId(finalityKeyEnc)
# optimistUpdateKey = optimisticUpdateContentKey( optimisticUpdateKey = optimisticUpdateContentKey(
# distinctBase(optimisticHeaderSlot)) distinctBase(optimisticHeaderSlot))
# optimisticKeyEnc = encode(optimistUpdateKey) optimisticKeyEnc = encode(optimisticUpdateKey)
# optimisticUpdateId = toContentId(optimisticKeyEnc) optimisticUpdateId = toContentId(optimisticKeyEnc)
# # This silently assumes that peer stores only one latest update, under # This silently assumes that peer stores only one latest update, under
# # the contentId coresponding to latest update content key # the contentId coresponding to latest update content key
# lcNode2.portalProtocol().storeContent( lcNode2.portalProtocol().storeContent(
# finalityKeyEnc, finalityKeyEnc,
# finalityUpdateId, finalityUpdateId,
# encodeForkedLightClientObject(finalityUpdate, forkDigests.altair) encodeForkedLightClientObject(finalityUpdate, forkDigests.altair)
# ) )
# lcNode2.portalProtocol().storeContent( lcNode2.portalProtocol().storeContent(
# optimisticKeyEnc, optimisticKeyEnc,
# optimisticUpdateId, optimisticUpdateId,
# encodeForkedLightClientObject(optimisticUpdate, forkDigests.altair) encodeForkedLightClientObject(optimisticUpdate, forkDigests.altair)
# ) )
# let let
# finalityResult = finalityResult =
# await lcNode1.lightClientNetwork.getLightClientFinalityUpdate( await lcNode1.lightClientNetwork.getLightClientFinalityUpdate(
# distinctBase(finalizedHeaderSlot) - 1, distinctBase(finalizedHeaderSlot),
# distinctBase(finalizedOptimisticHeaderSlot) - 1 distinctBase(finalizedOptimisticHeaderSlot)
# ) )
# optimisticResult = optimisticResult =
# await lcNode1.lightClientNetwork.getLightClientOptimisticUpdate( await lcNode1.lightClientNetwork.getLightClientOptimisticUpdate(
# distinctBase(optimisticHeaderSlot) - 1 distinctBase(optimisticHeaderSlot)
# ) )
# check: check:
# finalityResult.isOk() finalityResult.isOk()
# optimisticResult.isOk() optimisticResult.isOk()
# finalityResult.get().altairData == finalityUpdate.altairData finalityResult.get().altairData == finalityUpdate.altairData
# optimisticResult.get().altairData == optimisticUpdate.altairData optimisticResult.get().altairData == optimisticUpdate.altairData
# await lcNode1.stop() await lcNode1.stop()
# await lcNode2.stop() await lcNode2.stop()
asyncTest "Get range of light client updates": asyncTest "Get range of light client updates":
let let