rename `lcDataForkAtStateFork` > `lcDataForkAtConsensusFork` (#4726)

This commit is contained in:
Etan Kissling 2023-03-11 21:09:21 +01:00 committed by GitHub
parent 3e872bec86
commit fd8e86972d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 16 deletions

View File

@ -151,7 +151,7 @@ proc updateLightClientFromDag*(node: BeaconNode) =
return
var header {.noinit.}: ForkedLightClientHeader
withBlck(bdata):
const lcDataFork = lcDataForkAtStateFork(consensusFork)
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
when lcDataFork > LightClientDataFork.None:
header = ForkedLightClientHeader(kind: lcDataFork)
header.forky(lcDataFork) = blck.toLightClientHeader(lcDataFork)

View File

@ -214,7 +214,7 @@ proc initLightClientBootstrapForPeriod(
continue
withStateAndBlck(tmpState[], bdata):
when consensusFork >= ConsensusFork.Altair:
const lcDataFork = lcDataForkAtStateFork(consensusFork)
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
if not dag.lcDataStore.db.hasSyncCommittee(period):
dag.lcDataStore.db.putSyncCommittee(
period, forkyState.data.current_sync_committee)
@ -365,7 +365,7 @@ proc initLightClientUpdateForPeriod(
return err()
withStateAndBlck(updatedState, bdata):
when consensusFork >= ConsensusFork.Altair:
const lcDataFork = lcDataForkAtStateFork(consensusFork)
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
update = ForkedLightClientUpdate(kind: lcDataFork)
template forkyUpdate: untyped = update.forky(lcDataFork)
forkyUpdate.attested_header = blck.toLightClientHeader(lcDataFork)
@ -386,7 +386,7 @@ proc initLightClientUpdateForPeriod(
withBlck(bdata):
withForkyUpdate(update):
when lcDataFork > LightClientDataFork.None:
when lcDataFork >= lcDataForkAtStateFork(consensusFork):
when lcDataFork >= lcDataForkAtConsensusFork(consensusFork):
forkyUpdate.finalized_header = blck.toLightClientHeader(lcDataFork)
else: raiseAssert "Unreachable"
let bdata = dag.getExistingForkedBlock(signatureBid).valueOr:
@ -477,7 +477,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
`name _ ok` = false
else:
withBlck(bdata.get):
when data_fork >= lcDataForkAtStateFork(consensusFork):
when data_fork >= lcDataForkAtConsensusFork(consensusFork):
obj.name = blck.toLightClientHeader(data_fork)
else: raiseAssert "Unreachable"
`name _ ptr` = addr obj.name
@ -495,7 +495,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
else:
obj.migrateToDataFork(data_fork)
withBlck(bdata.get):
when data_fork >= lcDataForkAtStateFork(consensusFork):
when data_fork >= lcDataForkAtConsensusFork(consensusFork):
obj.forky(data_fork).name = blck.toLightClientHeader(data_fork)
else: raiseAssert "Unreachable"
`name _ ptr` = addr obj.forky(data_fork).name
@ -881,7 +881,7 @@ proc processFinalizationForLightClient*(
dag.lcDataStore.db.putSyncCommittee(period, syncCommittee)
withBlck(bdata):
when consensusFork >= ConsensusFork.Altair:
const lcDataFork = lcDataForkAtStateFork(consensusFork)
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
dag.lcDataStore.db.putHeader(blck.toLightClientHeader(lcDataFork))
else: raiseAssert "Unreachable"
dag.lcDataStore.db.putCurrentSyncCommitteeBranch(
@ -1004,7 +1004,7 @@ proc getLightClientBootstrap*(
return default(ForkedLightClientBootstrap)
withBlck(bdata):
when consensusFork >= ConsensusFork.Altair:
const lcDataFork = lcDataForkAtStateFork(consensusFork)
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
let
header = blck.toLightClientHeader(lcDataFork)
bootstrap = dag.getLightClientBootstrap(header)

View File

@ -344,7 +344,7 @@ proc installMessageValidators*(
let forkDigests = lightClient.forkDigests
for consensusFork in ConsensusFork:
withLcDataFork(lcDataForkAtStateFork(consensusFork)):
withLcDataFork(lcDataForkAtConsensusFork(consensusFork)):
when lcDataFork > LightClientDataFork.None:
let
contextFork = consensusFork # Avoid capturing `Deneb` (Nim 1.6)

View File

@ -903,7 +903,8 @@ func forkVersion*(cfg: RuntimeConfig, consensusFork: ConsensusFork): Version =
of ConsensusFork.Capella: cfg.CAPELLA_FORK_VERSION
of ConsensusFork.Deneb: cfg.DENEB_FORK_VERSION
func lcDataForkAtStateFork*(consensusFork: ConsensusFork): LightClientDataFork =
func lcDataForkAtConsensusFork*(
consensusFork: ConsensusFork): LightClientDataFork =
static: doAssert LightClientDataFork.high == LightClientDataFork.Deneb
if consensusFork >= ConsensusFork.Deneb:
LightClientDataFork.Deneb

View File

@ -150,7 +150,7 @@ proc readChunkPayload*(
peer.network.forkDigests[].consensusForkForDigest(contextBytes).valueOr:
return neterr InvalidContextBytes
withLcDataFork(lcDataForkAtStateFork(contextFork)):
withLcDataFork(lcDataForkAtConsensusFork(contextFork)):
when lcDataFork > LightClientDataFork.None:
let res = await eth2_network.readChunkPayload(
conn, peer, MsgType.Forky(lcDataFork))

View File

@ -92,7 +92,7 @@ proc loadSteps(path: string, fork_digests: ForkDigests): seq[TestStep] =
update_filename = s["update"].getStr()
var update {.noinit.}: ForkedLightClientUpdate
withLcDataFork(lcDataForkAtStateFork(update_state_fork)):
withLcDataFork(lcDataForkAtConsensusFork(update_state_fork)):
when lcDataFork > LightClientDataFork.None:
update = ForkedLightClientUpdate(kind: lcDataFork)
update.forky(lcDataFork) = parseTest(
@ -117,7 +117,7 @@ proc loadSteps(path: string, fork_digests: ForkDigests): seq[TestStep] =
result.add TestStep(
kind: TestStepKind.UpgradeStore,
store_data_fork: lcDataForkAtStateFork(store_state_fork),
store_data_fork: lcDataForkAtConsensusFork(store_state_fork),
checks: s["checks"].getChecks())
else:
doAssert false, "Unknown test step: " & $step
@ -172,7 +172,7 @@ proc runTest(path: string) =
meta.fork_digests.consensusForkForDigest(meta.bootstrap_fork_digest)
.expect("Unknown bootstrap fork " & $meta.bootstrap_fork_digest)
var bootstrap {.noinit.}: ForkedLightClientBootstrap
withLcDataFork(lcDataForkAtStateFork(bootstrap_state_fork)):
withLcDataFork(lcDataForkAtConsensusFork(bootstrap_state_fork)):
when lcDataFork > LightClientDataFork.None:
bootstrap = ForkedLightClientBootstrap(kind: lcDataFork)
bootstrap.forky(lcDataFork) = parseTest(
@ -189,7 +189,7 @@ proc runTest(path: string) =
meta.fork_digests.consensusForkForDigest(meta.store_fork_digest)
.expect("Unknown store fork " & $meta.store_fork_digest)
var store {.noinit.}: ForkedLightClientStore
withLcDataFork(lcDataForkAtStateFork(store_state_fork)):
withLcDataFork(lcDataForkAtConsensusFork(store_state_fork)):
when lcDataFork > LightClientDataFork.None:
store = ForkedLightClientStore(kind: lcDataFork)
bootstrap[].migrateToDataFork(lcDataFork)

View File

@ -62,7 +62,7 @@ suite "EF - Light client - Update ranking" & preset():
continue
for kind, path in walkDir(testsPath, relative = true, checkDir = true):
withConsensusFork(fork):
const lcDataFork = lcDataForkAtStateFork(consensusFork)
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
when lcDataFork > LightClientDataFork.None:
runTest(testsPath/path, lcDataFork)
else: raiseAssert "Unreachable"