Make beacon LC adjustements to support capella in light clients (#1545)

- Bump nimbus-eth2 repo
- Beacon LC adjustements in fluffy
- Beacon LC adjustements in nimbus_verified_proxy
This commit is contained in:
Kim De Mey 2023-04-13 18:40:01 +02:00 committed by GitHub
parent b195f0893b
commit 3eafb15d7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 10 deletions

View File

@ -160,10 +160,10 @@ func decodeForkedLightClientObject(
let let
forkDigest = ForkDigest(array[4, byte].initCopyFrom(data)) forkDigest = ForkDigest(array[4, byte].initCopyFrom(data))
contextFork = forkDigests.stateForkForDigest(forkDigest).valueOr: contextFork = forkDigests.consensusForkForDigest(forkDigest).valueOr:
return Result[ObjType, string].err("Unknown fork") return Result[ObjType, string].err("Unknown fork")
withLcDataFork(lcDataForkAtStateFork(contextFork)): withLcDataFork(lcDataForkAtConsensusFork(contextFork)):
when lcDataFork > LightClientDataFork.None: when lcDataFork > LightClientDataFork.None:
let res = decodeSsz(data.toOpenArray(4, len(data) - 1), ObjType.Forky(lcDataFork)) let res = decodeSsz(data.toOpenArray(4, len(data) - 1), ObjType.Forky(lcDataFork))
if res.isOk: if res.isOk:

View File

@ -25,7 +25,7 @@ const testForkDigests* =
altair: ForkDigest([0'u8, 0, 0, 2]), altair: ForkDigest([0'u8, 0, 0, 2]),
bellatrix: ForkDigest([0'u8, 0, 0, 3]), bellatrix: ForkDigest([0'u8, 0, 0, 3]),
capella: ForkDigest([0'u8, 0, 0, 4]), capella: ForkDigest([0'u8, 0, 0, 4]),
eip4844: ForkDigest([0'u8, 0, 0, 5]) deneb: ForkDigest([0'u8, 0, 0, 5])
) )
proc newLCNode*( proc newLCNode*(

View File

@ -396,7 +396,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
wallSlot = getBeaconTime().slotOrZero wallSlot = getBeaconTime().slotOrZero
withBlck(signedBlock): withBlck(signedBlock):
when stateFork >= ConsensusFork.Bellatrix: when consensusFork >= ConsensusFork.Bellatrix:
if blck.message.is_execution_block: if blck.message.is_execution_block:
template payload(): auto = blck.message.body.execution_payload template payload(): auto = blck.message.body.execution_payload
@ -648,6 +648,16 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
proc (signedBlock: bellatrix.SignedBeaconBlock): errors.ValidationResult = proc (signedBlock: bellatrix.SignedBeaconBlock): errors.ValidationResult =
toValidationResult( toValidationResult(
optimisticProcessor.processSignedBeaconBlock(signedBlock))) optimisticProcessor.processSignedBeaconBlock(signedBlock)))
network.addValidator(
getBeaconBlocksTopic(forkDigests.capella),
proc (signedBlock: capella.SignedBeaconBlock): errors.ValidationResult =
toValidationResult(
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
network.addValidator(
getBeaconBlocksTopic(forkDigests.deneb),
proc (signedBlock: deneb.SignedBeaconBlock): errors.ValidationResult =
toValidationResult(
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
lightClient.installMessageValidators() lightClient.installMessageValidators()
waitFor network.startListening() waitFor network.startListening()
@ -716,11 +726,11 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
oldGossipForks = currentGossipState - targetGossipState oldGossipForks = currentGossipState - targetGossipState
for gossipFork in oldGossipForks: for gossipFork in oldGossipForks:
let forkDigest = forkDigests[].atStateFork(gossipFork) let forkDigest = forkDigests[].atConsensusFork(gossipFork)
network.unsubscribe(getBeaconBlocksTopic(forkDigest)) network.unsubscribe(getBeaconBlocksTopic(forkDigest))
for gossipFork in newGossipForks: for gossipFork in newGossipForks:
let forkDigest = forkDigests[].atStateFork(gossipFork) let forkDigest = forkDigests[].atConsensusFork(gossipFork)
network.subscribe( network.subscribe(
getBeaconBlocksTopic(forkDigest), blocksTopicParams, getBeaconBlocksTopic(forkDigest), blocksTopicParams,
enableTopicMetrics = true) enableTopicMetrics = true)

View File

@ -107,7 +107,7 @@ proc run(config: VerifiedProxyConf) {.raises: [CatchableError].} =
opt = signedBlock.toBlockId(), opt = signedBlock.toBlockId(),
wallSlot = getBeaconTime().slotOrZero wallSlot = getBeaconTime().slotOrZero
withBlck(signedBlock): withBlck(signedBlock):
when stateFork >= ConsensusFork.Bellatrix: when consensusFork >= ConsensusFork.Bellatrix:
if blck.message.is_execution_block: if blck.message.is_execution_block:
template payload(): auto = blck.message.body.execution_payload template payload(): auto = blck.message.body.execution_payload
blockCache.add(asExecutionData(payload.asEngineExecutionPayload())) blockCache.add(asExecutionData(payload.asEngineExecutionPayload()))
@ -140,6 +140,16 @@ proc run(config: VerifiedProxyConf) {.raises: [CatchableError].} =
proc (signedBlock: bellatrix.SignedBeaconBlock): ValidationResult = proc (signedBlock: bellatrix.SignedBeaconBlock): ValidationResult =
toValidationResult( toValidationResult(
optimisticProcessor.processSignedBeaconBlock(signedBlock))) optimisticProcessor.processSignedBeaconBlock(signedBlock)))
network.addValidator(
getBeaconBlocksTopic(forkDigests.capella),
proc (signedBlock: capella.SignedBeaconBlock): ValidationResult =
toValidationResult(
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
network.addValidator(
getBeaconBlocksTopic(forkDigests.deneb),
proc (signedBlock: deneb.SignedBeaconBlock): ValidationResult =
toValidationResult(
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
lightClient.installMessageValidators() lightClient.installMessageValidators()
waitFor network.startListening() waitFor network.startListening()
@ -204,11 +214,11 @@ proc run(config: VerifiedProxyConf) {.raises: [CatchableError].} =
oldGossipForks = currentGossipState - targetGossipState oldGossipForks = currentGossipState - targetGossipState
for gossipFork in oldGossipForks: for gossipFork in oldGossipForks:
let forkDigest = forkDigests[].atStateFork(gossipFork) let forkDigest = forkDigests[].atConsensusFork(gossipFork)
network.unsubscribe(getBeaconBlocksTopic(forkDigest)) network.unsubscribe(getBeaconBlocksTopic(forkDigest))
for gossipFork in newGossipForks: for gossipFork in newGossipForks:
let forkDigest = forkDigests[].atStateFork(gossipFork) let forkDigest = forkDigests[].atConsensusFork(gossipFork)
network.subscribe( network.subscribe(
getBeaconBlocksTopic(forkDigest), blocksTopicParams, getBeaconBlocksTopic(forkDigest), blocksTopicParams,
enableTopicMetrics = true) enableTopicMetrics = true)

2
vendor/nimbus-eth2 vendored

@ -1 +1 @@
Subproject commit 8771e91d53072373cde1b2241092c5d6b2e5f3ab Subproject commit 6c0d756d54998cf30edd1678cbf121c8052a378a