Portal BeaconLightClientNetwork -> BeaconNetwork renaming (#1832)

This commit is contained in:
Kim De Mey 2023-10-20 12:06:25 +02:00 committed by GitHub
parent 7169c846a3
commit 436ef0e40e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 140 additions and 144 deletions

View File

@ -23,8 +23,8 @@ import
rpc_portal_debug_api], rpc_portal_debug_api],
./network/state/[state_network, state_content], ./network/state/[state_network, state_content],
./network/history/[history_network, history_content], ./network/history/[history_network, history_content],
./network/beacon_light_client/[ ./network/beacon/[
beacon_light_client_init_loader, beacon_init_loader,
beacon_light_client, beacon_light_client,
], ],
./network/wire/[portal_stream, portal_protocol_config], ./network/wire/[portal_stream, portal_protocol_config],
@ -173,30 +173,30 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
let let
# Portal works only over mainnet data currently # Portal works only over mainnet data currently
networkData = loadNetworkData("mainnet") networkData = loadNetworkData("mainnet")
beaconLightClientDb = LightClientDb.new( beaconDb = BeaconDb.new(
networkData, config.dataDir / "db" / "beacon_lc_db") networkData, config.dataDir / "db" / "beacon_db")
lightClientNetwork = LightClientNetwork.new( beaconNetwork = BeaconNetwork.new(
d, d,
beaconLightClientDb, beaconDb,
streamManager, streamManager,
networkData.forks, networkData.forks,
bootstrapRecords = bootstrapRecords, bootstrapRecords = bootstrapRecords,
portalConfig = portalConfig) portalConfig = portalConfig)
let lc = LightClient.new( let beaconLightClient = LightClient.new(
lightClientNetwork, rng, networkData, beaconNetwork, rng, networkData,
LightClientFinalizationMode.Optimistic) LightClientFinalizationMode.Optimistic)
lc.onFinalizedHeader = onFinalizedHeader beaconLightClient.onFinalizedHeader = onFinalizedHeader
lc.onOptimisticHeader = onOptimisticHeader beaconLightClient.onOptimisticHeader = onOptimisticHeader
lc.trustedBlockRoot = config.trustedBlockRoot beaconLightClient.trustedBlockRoot = config.trustedBlockRoot
# TODO: # TODO:
# Quite dirty. Use register validate callbacks instead. Or, revisit # Quite dirty. Use register validate callbacks instead. Or, revisit
# the object relationships regarding the beacon light client. # the object relationships regarding the beacon light client.
lightClientNetwork.processor = lc.processor beaconNetwork.processor = beaconLightClient.processor
Opt.some(lc) Opt.some(beaconLightClient)
else: else:
Opt.none(LightClient) Opt.none(LightClient)
@ -273,7 +273,7 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
historyNetwork.get().portalProtocol, "history") historyNetwork.get().portalProtocol, "history")
if beaconLightClient.isSome(): if beaconLightClient.isSome():
rpcHttpServerWithProxy.installPortalApiHandlers( rpcHttpServerWithProxy.installPortalApiHandlers(
beaconLightClient.get().network.portalProtocol, "beaconLightClient") beaconLightClient.get().network.portalProtocol, "beacon")
# TODO: Test proxy with remote node over HTTPS # TODO: Test proxy with remote node over HTTPS
waitFor rpcHttpServerWithProxy.start() waitFor rpcHttpServerWithProxy.start()

View File

@ -19,8 +19,8 @@ import
beacon_chain/spec/datatypes/[phase0, altair, bellatrix], beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
beacon_chain/spec/forks, beacon_chain/spec/forks,
beacon_chain/spec/forks_light_client, beacon_chain/spec/forks_light_client,
./beacon_light_client_content, ./beacon_content,
./beacon_light_client_init_loader, ./beacon_init_loader,
../wire/portal_protocol ../wire/portal_protocol
from beacon_chain/spec/helpers import is_better_update, toMeta from beacon_chain/spec/helpers import is_better_update, toMeta
@ -34,7 +34,7 @@ type
putStmt: SqliteStmt[(int64, seq[byte]), void] putStmt: SqliteStmt[(int64, seq[byte]), void]
delStmt: SqliteStmt[int64, void] delStmt: SqliteStmt[int64, void]
LightClientDb* = ref object BeaconDb* = ref object
backend: SqStoreRef backend: SqStoreRef
kv: KvStoreRef kv: KvStoreRef
bestUpdates: BestLightClientUpdateStore bestUpdates: BestLightClientUpdateStore
@ -108,9 +108,9 @@ func close(store: var BestLightClientUpdateStore) =
store.delStmt.disposeSafe() store.delStmt.disposeSafe()
proc new*( proc new*(
T: type LightClientDb, networkData: NetworkInitData, T: type BeaconDb, networkData: NetworkInitData,
path: string, inMemory = false): path: string, inMemory = false):
LightClientDb = BeaconDb =
let let
db = db =
if inMemory: if inMemory:
@ -122,7 +122,7 @@ proc new*(
kvStore = kvStore db.openKvStore().expectDb() kvStore = kvStore db.openKvStore().expectDb()
bestUpdates = initBestUpdatesStore(db, "lcu").expectDb() bestUpdates = initBestUpdatesStore(db, "lcu").expectDb()
LightClientDb( BeaconDb(
backend: db, backend: db,
kv: kvStore, kv: kvStore,
bestUpdates: bestUpdates, bestUpdates: bestUpdates,
@ -139,24 +139,24 @@ proc get(kv: KvStoreRef, key: openArray[byte]): results.Opt[seq[byte]] =
return res return res
## Private LightClientDb calls ## Private BeaconDb calls
proc get(db: LightClientDb, key: openArray[byte]): results.Opt[seq[byte]] = proc get(db: BeaconDb, key: openArray[byte]): results.Opt[seq[byte]] =
db.kv.get(key) db.kv.get(key)
proc put(db: LightClientDb, key, value: openArray[byte]) = proc put(db: BeaconDb, key, value: openArray[byte]) =
db.kv.put(key, value).expectDb() db.kv.put(key, value).expectDb()
## Public ContentId based ContentDB calls ## Public ContentId based ContentDB calls
proc get*(db: LightClientDb, key: ContentId): results.Opt[seq[byte]] = proc get*(db: BeaconDb, key: ContentId): results.Opt[seq[byte]] =
# TODO: Here it is unfortunate that ContentId is a uint256 instead of Digest256. # TODO: Here it is unfortunate that ContentId is a uint256 instead of Digest256.
db.get(key.toBytesBE()) db.get(key.toBytesBE())
proc put*(db: LightClientDb, key: ContentId, value: openArray[byte]) = proc put*(db: BeaconDb, key: ContentId, value: openArray[byte]) =
db.put(key.toBytesBE(), value) db.put(key.toBytesBE(), value)
# TODO Add checks that uint64 can be safely casted to int64 # TODO Add checks that uint64 can be safely casted to int64
proc getLightClientUpdates( proc getLightClientUpdates(
db: LightClientDb, start: uint64, to: uint64): db: BeaconDb, start: uint64, to: uint64):
ForkedLightClientUpdateBytesList = ForkedLightClientUpdateBytesList =
## Get multiple consecutive LightClientUpdates for given periods ## Get multiple consecutive LightClientUpdates for given periods
var updates: ForkedLightClientUpdateBytesList var updates: ForkedLightClientUpdateBytesList
@ -168,7 +168,7 @@ proc getLightClientUpdates(
return updates return updates
proc getBestUpdate*( proc getBestUpdate*(
db: LightClientDb, period: SyncCommitteePeriod): db: BeaconDb, period: SyncCommitteePeriod):
Result[ForkedLightClientUpdate, string] = Result[ForkedLightClientUpdate, string] =
## Get the best ForkedLightClientUpdate for given period ## Get the best ForkedLightClientUpdate for given period
## Note: Only the best one for a given period is being stored. ## Note: Only the best one for a given period is being stored.
@ -181,7 +181,7 @@ proc getBestUpdate*(
return decodeLightClientUpdateForked(db.forkDigests, update) return decodeLightClientUpdateForked(db.forkDigests, update)
proc putBootstrap*( proc putBootstrap*(
db: LightClientDb, db: BeaconDb,
blockRoot: Digest, bootstrap: ForkedLightClientBootstrap) = blockRoot: Digest, bootstrap: ForkedLightClientBootstrap) =
# Put a ForkedLightClientBootstrap in the db. # Put a ForkedLightClientBootstrap in the db.
withForkyBootstrap(bootstrap): withForkyBootstrap(bootstrap):
@ -196,13 +196,13 @@ proc putBootstrap*(
db.put(contentId, encodedBootstrap) db.put(contentId, encodedBootstrap)
func putLightClientUpdate*( func putLightClientUpdate*(
db: LightClientDb, period: uint64, update: seq[byte]) = db: BeaconDb, period: uint64, update: seq[byte]) =
# Put an encoded ForkedLightClientUpdate in the db. # Put an encoded ForkedLightClientUpdate in the db.
let res = db.bestUpdates.putStmt.exec((period.int64, update)) let res = db.bestUpdates.putStmt.exec((period.int64, update))
res.expect("SQL query OK") res.expect("SQL query OK")
func putBestUpdate*( func putBestUpdate*(
db: LightClientDb, period: SyncCommitteePeriod, db: BeaconDb, period: SyncCommitteePeriod,
update: ForkedLightClientUpdate) = update: ForkedLightClientUpdate) =
# Put a ForkedLightClientUpdate in the db. # Put a ForkedLightClientUpdate in the db.
doAssert not db.backend.readOnly # All `stmt` are non-nil doAssert not db.backend.readOnly # All `stmt` are non-nil
@ -225,7 +225,7 @@ func putBestUpdate*(
db.bestUpdates.delStmt.exec(period.int64).expect("SQL query OK") db.bestUpdates.delStmt.exec(period.int64).expect("SQL query OK")
proc putUpdateIfBetter*( proc putUpdateIfBetter*(
db: LightClientDb, db: BeaconDb,
period: SyncCommitteePeriod, update: ForkedLightClientUpdate) = period: SyncCommitteePeriod, update: ForkedLightClientUpdate) =
let currentUpdate = db.getBestUpdate(period).valueOr: let currentUpdate = db.getBestUpdate(period).valueOr:
# No current update for that period so we can just put this one # No current update for that period so we can just put this one
@ -236,7 +236,7 @@ proc putUpdateIfBetter*(
db.putBestUpdate(period, update) db.putBestUpdate(period, update)
proc putUpdateIfBetter*( proc putUpdateIfBetter*(
db: LightClientDb, period: SyncCommitteePeriod, update: seq[byte]) = db: BeaconDb, period: SyncCommitteePeriod, update: seq[byte]) =
let newUpdate = decodeLightClientUpdateForked(db.forkDigests, update).valueOr: let newUpdate = decodeLightClientUpdateForked(db.forkDigests, update).valueOr:
# TODO: # TODO:
# Need to go over the usage in offer/accept vs findcontent/content # Need to go over the usage in offer/accept vs findcontent/content
@ -245,7 +245,7 @@ proc putUpdateIfBetter*(
db.putUpdateIfBetter(period, newUpdate) db.putUpdateIfBetter(period, newUpdate)
proc createGetHandler*(db: LightClientDb): DbGetHandler = proc createGetHandler*(db: BeaconDb): DbGetHandler =
return ( return (
proc(contentKey: ByteList, contentId: ContentId): results.Opt[seq[byte]] = proc(contentKey: ByteList, contentId: ContentId): results.Opt[seq[byte]] =
let contentKey = contentKey.decode().valueOr: let contentKey = contentKey.decode().valueOr:
@ -299,7 +299,7 @@ proc createGetHandler*(db: LightClientDb): DbGetHandler =
Opt.none(seq[byte]) Opt.none(seq[byte])
) )
proc createStoreHandler*(db: LightClientDb): DbStoreHandler = proc createStoreHandler*(db: BeaconDb): DbStoreHandler =
return (proc( return (proc(
contentKey: ByteList, contentKey: ByteList,
contentId: ContentId, contentId: ContentId,

View File

@ -13,14 +13,13 @@ import
beacon_chain/gossip_processing/light_client_processor, beacon_chain/gossip_processing/light_client_processor,
beacon_chain/spec/datatypes/altair, beacon_chain/spec/datatypes/altair,
beacon_chain/beacon_clock, beacon_chain/beacon_clock,
"."/[beacon_light_client_network, beacon_light_client_manager, "."/[beacon_init_loader, beacon_network, beacon_light_client_manager]
beacon_light_client_init_loader]
export export
LightClientFinalizationMode, LightClientFinalizationMode,
beacon_light_client_network, beacon_light_client_manager beacon_network, beacon_light_client_manager
logScope: topics = "portal_beacon_lc" logScope: topics = "beacon_lc"
type type
LightClientHeaderCallback* = LightClientHeaderCallback* =
@ -28,7 +27,7 @@ type
gcsafe, raises: [].} gcsafe, raises: [].}
LightClient* = ref object LightClient* = ref object
network*: LightClientNetwork network*: BeaconNetwork
cfg: RuntimeConfig cfg: RuntimeConfig
forkDigests: ref ForkDigests forkDigests: ref ForkDigests
getBeaconTime*: GetBeaconTimeFn getBeaconTime*: GetBeaconTimeFn
@ -60,7 +59,7 @@ func optimisticHeader*(
proc new*( proc new*(
T: type LightClient, T: type LightClient,
network: LightClientNetwork, network: BeaconNetwork,
rng: ref HmacDrbgContext, rng: ref HmacDrbgContext,
dumpEnabled: bool, dumpEnabled: bool,
dumpDirInvalid, dumpDirIncoming: string, dumpDirInvalid, dumpDirIncoming: string,
@ -147,7 +146,7 @@ proc new*(
proc new*( proc new*(
T: type LightClient, T: type LightClient,
network: LightClientNetwork, network: BeaconNetwork,
rng: ref HmacDrbgContext, rng: ref HmacDrbgContext,
networkData: NetworkInitData, networkData: NetworkInitData,
finalizationMode: LightClientFinalizationMode): T = finalizationMode: LightClientFinalizationMode): T =

View File

@ -15,8 +15,7 @@ import
beacon_chain/spec/[forks_light_client, digest], beacon_chain/spec/[forks_light_client, digest],
beacon_chain/beacon_clock, beacon_chain/beacon_clock,
beacon_chain/sync/light_client_sync_helpers, beacon_chain/sync/light_client_sync_helpers,
"."/[beacon_light_client_network, beacon_light_client_content, "."/[beacon_network, beacon_content, beacon_db]
beacon_light_client_db]
from beacon_chain/consensus_object_pools/block_pools_types import VerifierError from beacon_chain/consensus_object_pools/block_pools_types import VerifierError
@ -60,7 +59,7 @@ type
proc(): Slot {.gcsafe, raises: [].} proc(): Slot {.gcsafe, raises: [].}
LightClientManager* = object LightClientManager* = object
network: LightClientNetwork network: BeaconNetwork
rng: ref HmacDrbgContext rng: ref HmacDrbgContext
getTrustedBlockRoot: GetTrustedBlockRootCallback getTrustedBlockRoot: GetTrustedBlockRootCallback
bootstrapVerifier: BootstrapVerifier bootstrapVerifier: BootstrapVerifier
@ -76,7 +75,7 @@ type
func init*( func init*(
T: type LightClientManager, T: type LightClientManager,
network: LightClientNetwork, network: BeaconNetwork,
rng: ref HmacDrbgContext, rng: ref HmacDrbgContext,
getTrustedBlockRoot: GetTrustedBlockRootCallback, getTrustedBlockRoot: GetTrustedBlockRootCallback,
bootstrapVerifier: BootstrapVerifier, bootstrapVerifier: BootstrapVerifier,
@ -114,7 +113,7 @@ proc getOptimisticPeriod(self: LightClientManager): SyncCommitteePeriod =
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
proc doRequest( proc doRequest(
e: typedesc[Bootstrap], e: typedesc[Bootstrap],
n: LightClientNetwork, n: BeaconNetwork,
blockRoot: Eth2Digest blockRoot: Eth2Digest
): Future[NetRes[ForkedLightClientBootstrap]] = ): Future[NetRes[ForkedLightClientBootstrap]] =
n.getLightClientBootstrap(blockRoot) n.getLightClientBootstrap(blockRoot)
@ -123,7 +122,7 @@ proc doRequest(
type LightClientUpdatesByRangeResponse = NetRes[ForkedLightClientUpdateList] type LightClientUpdatesByRangeResponse = NetRes[ForkedLightClientUpdateList]
proc doRequest( proc doRequest(
e: typedesc[UpdatesByRange], e: typedesc[UpdatesByRange],
n: LightClientNetwork, n: BeaconNetwork,
key: tuple[startPeriod: SyncCommitteePeriod, count: uint64] key: tuple[startPeriod: SyncCommitteePeriod, count: uint64]
): Future[LightClientUpdatesByRangeResponse] {.async.} = ): Future[LightClientUpdatesByRangeResponse] {.async.} =
let (startPeriod, count) = key let (startPeriod, count) = key
@ -139,7 +138,7 @@ proc doRequest(
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
proc doRequest( proc doRequest(
e: typedesc[FinalityUpdate], e: typedesc[FinalityUpdate],
n: LightClientNetwork, n: BeaconNetwork,
finalizedSlot: Slot finalizedSlot: Slot
): Future[NetRes[ForkedLightClientFinalityUpdate]] = ): Future[NetRes[ForkedLightClientFinalityUpdate]] =
n.getLightClientFinalityUpdate( n.getLightClientFinalityUpdate(
@ -149,7 +148,7 @@ proc doRequest(
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
proc doRequest( proc doRequest(
e: typedesc[OptimisticUpdate], e: typedesc[OptimisticUpdate],
n: LightClientNetwork, n: BeaconNetwork,
optimisticSlot: Slot optimisticSlot: Slot
): Future[NetRes[ForkedLightClientOptimisticUpdate]] = ): Future[NetRes[ForkedLightClientOptimisticUpdate]] =
n.getLightClientOptimisticUpdate(distinctBase(optimisticSlot)) n.getLightClientOptimisticUpdate(distinctBase(optimisticSlot))
@ -233,7 +232,7 @@ proc workerTask[E](
when E.V is ForkedLightClientBootstrap: when E.V is ForkedLightClientBootstrap:
withForkyObject(val): withForkyObject(val):
when lcDataFork > LightClientDataFork.None: when lcDataFork > LightClientDataFork.None:
self.network.lightClientDb.putBootstrap(key, val) self.network.beaconDb.putBootstrap(key, val)
else: else:
notice "Received value from an unviable fork", notice "Received value from an unviable fork",
endpoint = E.name endpoint = E.name
@ -242,7 +241,7 @@ proc workerTask[E](
when lcDataFork > LightClientDataFork.None: when lcDataFork > LightClientDataFork.None:
let period = let period =
forkyObject.attested_header.beacon.slot.sync_committee_period forkyObject.attested_header.beacon.slot.sync_committee_period
self.network.lightClientDb.putUpdateIfBetter(period, val) self.network.beaconDb.putUpdateIfBetter(period, val)
else: else:
notice "Received value from an unviable fork", notice "Received value from an unviable fork",
endpoint = E.name endpoint = E.name

View File

@ -15,20 +15,20 @@ import
beacon_chain/gossip_processing/light_client_processor, beacon_chain/gossip_processing/light_client_processor,
../../../nimbus/constants, ../../../nimbus/constants,
../wire/[portal_protocol, portal_stream, portal_protocol_config], ../wire/[portal_protocol, portal_stream, portal_protocol_config],
"."/[beacon_light_client_content, beacon_light_client_db] "."/[beacon_content, beacon_db]
export beacon_light_client_content, beacon_light_client_db export beacon_content, beacon_db
logScope: logScope:
topics = "portal_beacon_network" topics = "beacon_network"
const const
lightClientProtocolId* = [byte 0x50, 0x1A] lightClientProtocolId* = [byte 0x50, 0x1A]
type type
LightClientNetwork* = ref object BeaconNetwork* = ref object
portalProtocol*: PortalProtocol portalProtocol*: PortalProtocol
lightClientDb*: LightClientDb beaconDb*: BeaconDb
processor*: ref LightClientProcessor processor*: ref LightClientProcessor
contentQueue*: AsyncQueue[(Opt[NodeId], ContentKeysList, seq[seq[byte]])] contentQueue*: AsyncQueue[(Opt[NodeId], ContentKeysList, seq[seq[byte]])]
forkDigests*: ForkDigests forkDigests*: ForkDigests
@ -38,7 +38,7 @@ func toContentIdHandler(contentKey: ByteList): results.Opt[ContentId] =
ok(toContentId(contentKey)) ok(toContentId(contentKey))
proc getContent( proc getContent(
n: LightClientNetwork, contentKey: ContentKey): n: BeaconNetwork, contentKey: ContentKey):
Future[results.Opt[seq[byte]]] {.async.} = Future[results.Opt[seq[byte]]] {.async.} =
let let
contentKeyEncoded = encode(contentKey) contentKeyEncoded = encode(contentKey)
@ -59,7 +59,7 @@ proc getContent(
return Opt.some(contentRes.value().content) return Opt.some(contentRes.value().content)
proc getLightClientBootstrap*( proc getLightClientBootstrap*(
n: LightClientNetwork, n: BeaconNetwork,
trustedRoot: Digest): trustedRoot: Digest):
Future[results.Opt[ForkedLightClientBootstrap]] {.async.} = Future[results.Opt[ForkedLightClientBootstrap]] {.async.} =
let let
@ -82,7 +82,7 @@ proc getLightClientBootstrap*(
return Opt.some(decodingResult.value()) return Opt.some(decodingResult.value())
proc getLightClientUpdatesByRange*( proc getLightClientUpdatesByRange*(
n: LightClientNetwork, n: BeaconNetwork,
startPeriod: SyncCommitteePeriod, startPeriod: SyncCommitteePeriod,
count: uint64): count: uint64):
Future[results.Opt[ForkedLightClientUpdateList]] {.async.} = Future[results.Opt[ForkedLightClientUpdateList]] {.async.} =
@ -106,7 +106,7 @@ proc getLightClientUpdatesByRange*(
return Opt.some(decodingResult.value()) return Opt.some(decodingResult.value())
proc getLightClientFinalityUpdate*( proc getLightClientFinalityUpdate*(
n: LightClientNetwork, n: BeaconNetwork,
finalizedSlot: uint64 finalizedSlot: uint64
): Future[results.Opt[ForkedLightClientFinalityUpdate]] {.async.} = ): Future[results.Opt[ForkedLightClientFinalityUpdate]] {.async.} =
let let
@ -127,7 +127,7 @@ proc getLightClientFinalityUpdate*(
return Opt.some(decodingResult.value()) return Opt.some(decodingResult.value())
proc getLightClientOptimisticUpdate*( proc getLightClientOptimisticUpdate*(
n: LightClientNetwork, n: BeaconNetwork,
optimisticSlot: uint64 optimisticSlot: uint64
): Future[results.Opt[ForkedLightClientOptimisticUpdate]] {.async.} = ): Future[results.Opt[ForkedLightClientOptimisticUpdate]] {.async.} =
@ -149,9 +149,9 @@ proc getLightClientOptimisticUpdate*(
return Opt.some(decodingResult.value()) return Opt.some(decodingResult.value())
proc new*( proc new*(
T: type LightClientNetwork, T: type BeaconNetwork,
baseProtocol: protocol.Protocol, baseProtocol: protocol.Protocol,
lightClientDb: LightClientDb, beaconDb: BeaconDb,
streamManager: StreamManager, streamManager: StreamManager,
forkDigests: ForkDigests, forkDigests: ForkDigests,
bootstrapRecords: openArray[Record] = [], bootstrapRecords: openArray[Record] = [],
@ -173,20 +173,20 @@ proc new*(
portalProtocol = PortalProtocol.new( portalProtocol = PortalProtocol.new(
baseProtocol, lightClientProtocolId, baseProtocol, lightClientProtocolId,
toContentIdHandler, toContentIdHandler,
createGetHandler(lightClientDb), stream, bootstrapRecords, createGetHandler(beaconDb), stream, bootstrapRecords,
config = portalConfigAdjusted) config = portalConfigAdjusted)
portalProtocol.dbPut = createStoreHandler(lightClientDb) portalProtocol.dbPut = createStoreHandler(beaconDb)
LightClientNetwork( BeaconNetwork(
portalProtocol: portalProtocol, portalProtocol: portalProtocol,
lightClientDb: lightClientDb, beaconDb: beaconDb,
contentQueue: contentQueue, contentQueue: contentQueue,
forkDigests: forkDigests forkDigests: forkDigests
) )
proc validateContent( proc validateContent(
n: LightClientNetwork, content: seq[byte], contentKey: ByteList): n: BeaconNetwork, content: seq[byte], contentKey: ByteList):
Result[void, string] = Result[void, string] =
let key = contentKey.decode().valueOr: let key = contentKey.decode().valueOr:
return err("Error decoding content key") return err("Error decoding content key")
@ -248,7 +248,7 @@ proc validateContent(
ok() ok()
proc validateContent( proc validateContent(
n: LightClientNetwork, n: BeaconNetwork,
contentKeys: ContentKeysList, contentKeys: ContentKeysList,
contentItems: seq[seq[byte]]): Future[bool] {.async.} = contentItems: seq[seq[byte]]): Future[bool] {.async.} =
# content passed here can have less items then contentKeys, but not more. # content passed here can have less items then contentKeys, but not more.
@ -274,7 +274,7 @@ proc validateContent(
return true return true
proc processContentLoop(n: LightClientNetwork) {.async.} = proc processContentLoop(n: BeaconNetwork) {.async.} =
try: try:
while true: while true:
let (srcNodeId, contentKeys, contentItems) = let (srcNodeId, contentKeys, contentItems) =
@ -292,12 +292,12 @@ proc processContentLoop(n: LightClientNetwork) {.async.} =
except CancelledError: except CancelledError:
trace "processContentLoop canceled" trace "processContentLoop canceled"
proc start*(n: LightClientNetwork) = proc start*(n: BeaconNetwork) =
info "Starting portal beacon chain network" info "Starting portal beacon chain network"
n.portalProtocol.start() n.portalProtocol.start()
n.processContentLoop = processContentLoop(n) n.processContentLoop = processContentLoop(n)
proc stop*(n: LightClientNetwork) = proc stop*(n: BeaconNetwork) =
n.portalProtocol.stop() n.portalProtocol.stop()
if not n.processContentLoop.isNil: if not n.processContentLoop.isNil:

View File

@ -39,22 +39,22 @@ proc portal_historyLocalContent(contentKey: string): string
proc portal_historyGossip(contentKey: string, contentValue: string): int proc portal_historyGossip(contentKey: string, contentValue: string): int
## Portal Beacon Light Client Network json-rpc calls ## Portal Beacon Light Client Network json-rpc calls
proc portal_beaconLightClientNodeInfo(): NodeInfo proc portal_beaconNodeInfo(): NodeInfo
proc portal_beaconLightClientRoutingTableInfo(): RoutingTableInfo proc portal_beaconRoutingTableInfo(): RoutingTableInfo
proc portal_beaconLightClientAddEnr(enr: Record): bool proc portal_beaconAddEnr(enr: Record): bool
proc portal_beaconLightClientAddEnrs(enrs: seq[Record]): bool proc portal_beaconAddEnrs(enrs: seq[Record]): bool
proc portal_beaconLightClientGetEnr(nodeId: NodeId): Record proc portal_beaconGetEnr(nodeId: NodeId): Record
proc portal_beaconLightClientDeleteEnr(nodeId: NodeId): bool proc portal_beaconDeleteEnr(nodeId: NodeId): bool
proc portal_beaconLightClientLookupEnr(nodeId: NodeId): Record proc portal_beaconLookupEnr(nodeId: NodeId): Record
proc portal_beaconLightClientPing(enr: Record): tuple[ proc portal_beaconPing(enr: Record): tuple[
enrSeq: uint64, customPayload: string] enrSeq: uint64, customPayload: string]
proc portal_beaconLightClientFindNodes(enr: Record): seq[Record] proc portal_beaconFindNodes(enr: Record): seq[Record]
proc portal_beaconLightClientFindContent(enr: Record, contentKey: string): JsonNode proc portal_beaconFindContent(enr: Record, contentKey: string): JsonNode
proc portal_beaconLightClientOffer( proc portal_beaconOffer(
enr: Record, contentKey: string, contentValue: string): string enr: Record, contentKey: string, contentValue: string): string
proc portal_beaconLightClientRecursiveFindNodes(nodeId: NodeId): seq[Record] proc portal_beaconRecursiveFindNodes(nodeId: NodeId): seq[Record]
proc portal_beaconLightClientRecursiveFindContent(contentKey: string): string proc portal_beaconRecursiveFindContent(contentKey: string): string
proc portal_beaconLightClientStore(contentKey: string, contentValue: string): bool proc portal_beaconStore(contentKey: string, contentValue: string): bool
proc portal_beaconLightClientLocalContent(contentKey: string): string proc portal_beaconLocalContent(contentKey: string): string
proc portal_beaconLightClientGossip(contentKey: string, contentValue: string): int proc portal_beaconGossip(contentKey: string, contentValue: string): int
proc portal_beaconLightClientRandomGossip(contentKey: string, contentValue: string): int proc portal_beaconRandomGossip(contentKey: string, contentValue: string): int

View File

@ -21,7 +21,7 @@ import
# caused by `readValue` clashing ? # caused by `readValue` clashing ?
# ../../nimbus/common/chain_config # ../../nimbus/common/chain_config
../network/history/[history_network, history_content], ../network/history/[history_network, history_content],
../network/beacon_light_client/beacon_light_client ../network/beacon/beacon_light_client
# Subset of Eth JSON-RPC API: https://eth.wiki/json-rpc/API # Subset of Eth JSON-RPC API: https://eth.wiki/json-rpc/API
# Supported subset will eventually be found here: # Supported subset will eventually be found here:

View File

@ -19,4 +19,4 @@ import
./test_beacon_chain_block_proof_capella, ./test_beacon_chain_block_proof_capella,
./test_beacon_chain_historical_roots, ./test_beacon_chain_historical_roots,
./test_beacon_chain_historical_summaries, ./test_beacon_chain_historical_summaries,
./beacon_light_client_tests/all_beacon_light_client_tests ./beacon_network_tests/all_beacon_network_tests

View File

@ -8,6 +8,6 @@
{. warning[UnusedImport]:off .} {. warning[UnusedImport]:off .}
import import
./test_beacon_light_client_content, ./test_beacon_content,
./test_beacon_light_client_network, ./test_beacon_network,
./test_beacon_light_client ./test_beacon_light_client

View File

@ -10,40 +10,40 @@ import
eth/p2p/discoveryv5/protocol as discv5_protocol, eth/p2p/discoveryv5/protocol as discv5_protocol,
beacon_chain/spec/forks, beacon_chain/spec/forks,
../../network/wire/[portal_protocol, portal_stream], ../../network/wire/[portal_protocol, portal_stream],
../../network/beacon_light_client/[ ../../network/beacon/[
beacon_light_client_init_loader, beacon_init_loader,
beacon_light_client_network beacon_network
], ],
../test_helpers ../test_helpers
type LightClientNode* = ref object type BeaconNode* = ref object
discoveryProtocol*: discv5_protocol.Protocol discoveryProtocol*: discv5_protocol.Protocol
lightClientNetwork*: LightClientNetwork beaconNetwork*: BeaconNetwork
proc newLCNode*( proc newLCNode*(
rng: ref HmacDrbgContext, rng: ref HmacDrbgContext,
port: int, port: int,
networkData: NetworkInitData): LightClientNode = networkData: NetworkInitData): BeaconNode =
let let
node = initDiscoveryNode(rng, PrivateKey.random(rng[]), localAddress(port)) node = initDiscoveryNode(rng, PrivateKey.random(rng[]), localAddress(port))
db = LightClientDb.new(networkData, "", inMemory = true) db = BeaconDb.new(networkData, "", inMemory = true)
streamManager = StreamManager.new(node) streamManager = StreamManager.new(node)
network = LightClientNetwork.new(node, db, streamManager, networkData.forks) network = BeaconNetwork.new(node, db, streamManager, networkData.forks)
return LightClientNode(discoveryProtocol: node, lightClientNetwork: network) return BeaconNode(discoveryProtocol: node, beaconNetwork: network)
func portalProtocol*(n: LightClientNode): PortalProtocol = func portalProtocol*(n: BeaconNode): PortalProtocol =
n.lightClientNetwork.portalProtocol n.beaconNetwork.portalProtocol
func localNode*(n: LightClientNode): Node = func localNode*(n: BeaconNode): Node =
n.discoveryProtocol.localNode n.discoveryProtocol.localNode
proc start*(n: LightClientNode) = proc start*(n: BeaconNode) =
n.lightClientNetwork.start() n.beaconNetwork.start()
proc stop*(n: LightClientNode) {.async.} = proc stop*(n: BeaconNode) {.async.} =
n.lightClientNetwork.stop() n.beaconNetwork.stop()
await n.discoveryProtocol.closeWait() await n.discoveryProtocol.closeWait()
proc containsId*(n: LightClientNode, contentId: ContentId): bool = proc containsId*(n: BeaconNode, contentId: ContentId): bool =
n.lightClientNetwork.lightClientDb.get(contentId).isSome() n.beaconNetwork.beaconDb.get(contentId).isSome()

View File

@ -13,10 +13,10 @@ import
beacon_chain/spec/forks, beacon_chain/spec/forks,
beacon_chain/spec/datatypes/altair, beacon_chain/spec/datatypes/altair,
../../eth_data/[history_data_ssz_e2s, history_data_json_store], ../../eth_data/[history_data_ssz_e2s, history_data_json_store],
../../network/beacon_light_client/beacon_light_client_content, ../../network/beacon/beacon_content,
"."/[light_client_test_data, beacon_light_client_test_helpers] "."/light_client_test_data
suite "Beacon Light Client Content Encodings - Mainnet": suite "Beacon Content Encodings - Mainnet":
# These test vectors are generated by eth_data_exporter. The content is taken # These test vectors are generated by eth_data_exporter. The content is taken
# from mainnet and encoded as it would be transmitted on Portal Network, # from mainnet and encoded as it would be transmitted on Portal Network,
# including also the content key. # including also the content key.
@ -179,7 +179,7 @@ suite "Beacon Light Client Content Encodings - Mainnet":
check encoded == contentValueEncoded check encoded == contentValueEncoded
check encode(key).asSeq() == contentKeyEncoded check encode(key).asSeq() == contentKeyEncoded
suite "Beacon Light Client Content Encodings": suite "Beacon Content Encodings":
# TODO: These tests are less useful now and should instead be altered to # TODO: These tests are less useful now and should instead be altered to
# use the consensus test vectors to simply test if encoding / decoding works # use the consensus test vectors to simply test if encoding / decoding works
# fine for the different forks. # fine for the different forks.

View File

@ -14,9 +14,8 @@ import
beacon_chain/spec/datatypes/altair, beacon_chain/spec/datatypes/altair,
beacon_chain/spec/helpers, beacon_chain/spec/helpers,
../../network/wire/[portal_protocol, portal_stream], ../../network/wire/[portal_protocol, portal_stream],
../../network/beacon_light_client/[beacon_light_client, ../../network/beacon/[beacon_init_loader, beacon_light_client],
beacon_light_client_init_loader], "."/[light_client_test_data, beacon_test_helpers]
"."/[light_client_test_data, beacon_light_client_test_helpers]
procSuite "Portal Beacon Light Client": procSuite "Portal Beacon Light Client":
let rng = newRng() let rng = newRng()
@ -71,7 +70,7 @@ procSuite "Portal Beacon Light Client":
) )
let lc = LightClient.new( let lc = LightClient.new(
lcNode1.lightClientNetwork, rng, networkData, lcNode1.beaconNetwork, rng, networkData,
LightClientFinalizationMode.Optimistic) LightClientFinalizationMode.Optimistic)
lc.onFinalizedHeader = headerCallback(finalizedHeaders) lc.onFinalizedHeader = headerCallback(finalizedHeaders)

View File

@ -11,11 +11,10 @@ import
beacon_chain/spec/forks, beacon_chain/spec/forks,
beacon_chain/spec/datatypes/altair, beacon_chain/spec/datatypes/altair,
../../network/wire/portal_protocol, ../../network/wire/portal_protocol,
../../network/beacon_light_client/[beacon_light_client_network, ../../network/beacon/[beacon_network, beacon_init_loader],
beacon_light_client_init_loader], "."/[light_client_test_data, beacon_test_helpers]
"."/[light_client_test_data, beacon_light_client_test_helpers]
procSuite "Beacon Light Client Content Network": procSuite "Beacon Content Network":
let rng = newRng() let rng = newRng()
asyncTest "Get bootstrap by trusted block hash": asyncTest "Get bootstrap by trusted block hash":
@ -55,7 +54,7 @@ procSuite "Beacon Light Client Content Network":
) )
let bootstrapFromNetworkResult = let bootstrapFromNetworkResult =
await lcNode1.lightClientNetwork.getLightClientBootstrap( await lcNode1.beaconNetwork.getLightClientBootstrap(
bootstrapHeaderHash bootstrapHeaderHash
) )
@ -123,11 +122,11 @@ procSuite "Beacon Light Client Content Network":
let let
finalityResult = finalityResult =
await lcNode1.lightClientNetwork.getLightClientFinalityUpdate( await lcNode1.beaconNetwork.getLightClientFinalityUpdate(
distinctBase(finalizedHeaderSlot), distinctBase(finalizedHeaderSlot),
) )
optimisticResult = optimisticResult =
await lcNode1.lightClientNetwork.getLightClientOptimisticUpdate( await lcNode1.beaconNetwork.getLightClientOptimisticUpdate(
distinctBase(optimisticHeaderSlot) distinctBase(optimisticHeaderSlot)
) )
@ -182,7 +181,7 @@ procSuite "Beacon Light Client Content Network":
) )
let updatesResult = let updatesResult =
await lcNode1.lightClientNetwork.getLightClientUpdatesByRange( await lcNode1.beaconNetwork.getLightClientUpdatesByRange(
startPeriod, startPeriod,
uint64(2) uint64(2)
) )

View File

@ -31,7 +31,7 @@ import
stew/byteutils, stew/byteutils,
eth/async_utils, eth/async_utils,
beacon_chain/spec/eth2_apis/rest_beacon_client, beacon_chain/spec/eth2_apis/rest_beacon_client,
../../network/beacon_light_client/beacon_light_client_content, ../../network/beacon/beacon_content,
../../rpc/portal_rpc_client, ../../rpc/portal_rpc_client,
../../logging, ../../logging,
../eth_data_exporter/cl_data_exporter, ../eth_data_exporter/cl_data_exporter,
@ -79,7 +79,7 @@ proc gossipLCBootstrapUpdate*(
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientRandomGossip( peers = await portalRpcClient.portal_beaconRandomGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC bootstrap gossiped", peers, info "Beacon LC bootstrap gossiped", peers,
@ -133,7 +133,7 @@ proc gossipLCUpdates*(
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientRandomGossip( peers = await portalRpcClient.portal_beaconRandomGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC update gossiped", peers, info "Beacon LC update gossiped", peers,
@ -189,7 +189,7 @@ proc gossipLCFinalityUpdate*(
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientRandomGossip( peers = await portalRpcClient.portal_beaconRandomGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC finality update gossiped", peers, info "Beacon LC finality update gossiped", peers,
@ -239,7 +239,7 @@ proc gossipLCOptimisticUpdate*(
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientRandomGossip( peers = await portalRpcClient.portal_beaconRandomGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC optimistic update gossiped", peers, info "Beacon LC optimistic update gossiped", peers,

View File

@ -85,7 +85,7 @@ import
../../../nimbus/rpc/rpc_types, ../../../nimbus/rpc/rpc_types,
../../rpc/[portal_rpc_client, eth_rpc_client], ../../rpc/[portal_rpc_client, eth_rpc_client],
../../network/history/[history_content, history_network], ../../network/history/[history_content, history_network],
../../network/beacon_light_client/beacon_light_client_content, ../../network/beacon/beacon_content,
../../common/common_types, ../../common/common_types,
../../nimbus/db/core_db, ../../nimbus/db/core_db,
./beacon_lc_bridge_conf ./beacon_lc_bridge_conf
@ -545,7 +545,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
let let
root = hash_tree_root(forkyObject.header) root = hash_tree_root(forkyObject.header)
contentKey = encode(bootstrapContentKey(root)) contentKey = encode(bootstrapContentKey(root))
contentId = beacon_light_client_content.toContentId(contentKey) contentId = beacon_content.toContentId(contentKey)
forkDigest = forkDigestAtEpoch( forkDigest = forkDigestAtEpoch(
forkDigests[], epoch(forkyObject.header.beacon.slot), cfg) forkDigests[], epoch(forkyObject.header.beacon.slot), cfg)
content = encodeBootstrapForked( content = encodeBootstrapForked(
@ -557,7 +557,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientGossip( peers = await portalRpcClient.portal_beaconGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC bootstrap gossiped", peers, info "Beacon LC bootstrap gossiped", peers,
@ -578,7 +578,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
let let
period = forkyObject.attested_header.beacon.slot.sync_committee_period period = forkyObject.attested_header.beacon.slot.sync_committee_period
contentKey = encode(updateContentKey(period.uint64, uint64(1))) contentKey = encode(updateContentKey(period.uint64, uint64(1)))
contentId = beacon_light_client_content.toContentId(contentKey) contentId = beacon_content.toContentId(contentKey)
forkDigest = forkDigestAtEpoch( forkDigest = forkDigestAtEpoch(
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg) forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
content = encodeLightClientUpdatesForked( content = encodeLightClientUpdatesForked(
@ -590,7 +590,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientGossip( peers = await portalRpcClient.portal_beaconGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC bootstrap gossiped", peers, info "Beacon LC bootstrap gossiped", peers,
@ -613,7 +613,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
let let
slot = forkyObject.signature_slot slot = forkyObject.signature_slot
contentKey = encode(optimisticUpdateContentKey(slot.uint64)) contentKey = encode(optimisticUpdateContentKey(slot.uint64))
contentId = beacon_light_client_content.toContentId(contentKey) contentId = beacon_content.toContentId(contentKey)
forkDigest = forkDigestAtEpoch( forkDigest = forkDigestAtEpoch(
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg) forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
content = encodeOptimisticUpdateForked( content = encodeOptimisticUpdateForked(
@ -625,7 +625,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientGossip( peers = await portalRpcClient.portal_beaconGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC bootstrap gossiped", peers, info "Beacon LC bootstrap gossiped", peers,
@ -647,7 +647,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
let let
finalizedSlot = forkyObject.finalized_header.beacon.slot finalizedSlot = forkyObject.finalized_header.beacon.slot
contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64)) contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64))
contentId = beacon_light_client_content.toContentId(contentKey) contentId = beacon_content.toContentId(contentKey)
forkDigest = forkDigestAtEpoch( forkDigest = forkDigestAtEpoch(
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg) forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
content = encodeFinalityUpdateForked( content = encodeFinalityUpdateForked(
@ -659,7 +659,7 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
try: try:
let let
contentKeyHex = contentKey.asSeq().toHex() contentKeyHex = contentKey.asSeq().toHex()
peers = await portalRpcClient.portal_beaconLightClientGossip( peers = await portalRpcClient.portal_beaconGossip(
contentKeyHex, contentKeyHex,
content.toHex()) content.toHex())
info "Beacon LC bootstrap gossiped", peers, info "Beacon LC bootstrap gossiped", peers,

View File

@ -14,7 +14,7 @@ import
beacon_chain/networking/network_metadata, beacon_chain/networking/network_metadata,
beacon_chain/spec//eth2_apis/rest_beacon_client, beacon_chain/spec//eth2_apis/rest_beacon_client,
beacon_chain/beacon_clock, beacon_chain/beacon_clock,
../../network/beacon_light_client/beacon_light_client_content, ../../network/beacon/beacon_content,
./exporter_common ./exporter_common
export beacon_clock export beacon_clock
@ -205,7 +205,7 @@ proc exportLCFinalityUpdate*(
let let
finalizedSlot = forkyObject.finalized_header.beacon.slot finalizedSlot = forkyObject.finalized_header.beacon.slot
contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64)) contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64))
contentId = beacon_light_client_content.toContentId(contentKey) contentId = beacon_content.toContentId(contentKey)
forkDigest = forkDigestAtEpoch( forkDigest = forkDigestAtEpoch(
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg) forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
content = encodeFinalityUpdateForked( content = encodeFinalityUpdateForked(
@ -262,7 +262,7 @@ proc exportLCOptimisticUpdate*(
let let
slot = forkyObject.signature_slot slot = forkyObject.signature_slot
contentKey = encode(optimisticUpdateContentKey(slot.uint64)) contentKey = encode(optimisticUpdateContentKey(slot.uint64))
contentId = beacon_light_client_content.toContentId(contentKey) contentId = beacon_content.toContentId(contentKey)
forkDigest = forkDigestAtEpoch( forkDigest = forkDigestAtEpoch(
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg) forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
content = encodeOptimisticUpdateForked( content = encodeOptimisticUpdateForked(