mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-09 05:04:17 +00:00
rename lcDataForkAtStateFork
> lcDataForkAtConsensusFork
(#4726)
This commit is contained in:
parent
3e872bec86
commit
fd8e86972d
@ -151,7 +151,7 @@ proc updateLightClientFromDag*(node: BeaconNode) =
|
|||||||
return
|
return
|
||||||
var header {.noinit.}: ForkedLightClientHeader
|
var header {.noinit.}: ForkedLightClientHeader
|
||||||
withBlck(bdata):
|
withBlck(bdata):
|
||||||
const lcDataFork = lcDataForkAtStateFork(consensusFork)
|
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
header = ForkedLightClientHeader(kind: lcDataFork)
|
header = ForkedLightClientHeader(kind: lcDataFork)
|
||||||
header.forky(lcDataFork) = blck.toLightClientHeader(lcDataFork)
|
header.forky(lcDataFork) = blck.toLightClientHeader(lcDataFork)
|
||||||
|
@ -214,7 +214,7 @@ proc initLightClientBootstrapForPeriod(
|
|||||||
continue
|
continue
|
||||||
withStateAndBlck(tmpState[], bdata):
|
withStateAndBlck(tmpState[], bdata):
|
||||||
when consensusFork >= ConsensusFork.Altair:
|
when consensusFork >= ConsensusFork.Altair:
|
||||||
const lcDataFork = lcDataForkAtStateFork(consensusFork)
|
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
|
||||||
if not dag.lcDataStore.db.hasSyncCommittee(period):
|
if not dag.lcDataStore.db.hasSyncCommittee(period):
|
||||||
dag.lcDataStore.db.putSyncCommittee(
|
dag.lcDataStore.db.putSyncCommittee(
|
||||||
period, forkyState.data.current_sync_committee)
|
period, forkyState.data.current_sync_committee)
|
||||||
@ -365,7 +365,7 @@ proc initLightClientUpdateForPeriod(
|
|||||||
return err()
|
return err()
|
||||||
withStateAndBlck(updatedState, bdata):
|
withStateAndBlck(updatedState, bdata):
|
||||||
when consensusFork >= ConsensusFork.Altair:
|
when consensusFork >= ConsensusFork.Altair:
|
||||||
const lcDataFork = lcDataForkAtStateFork(consensusFork)
|
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
|
||||||
update = ForkedLightClientUpdate(kind: lcDataFork)
|
update = ForkedLightClientUpdate(kind: lcDataFork)
|
||||||
template forkyUpdate: untyped = update.forky(lcDataFork)
|
template forkyUpdate: untyped = update.forky(lcDataFork)
|
||||||
forkyUpdate.attested_header = blck.toLightClientHeader(lcDataFork)
|
forkyUpdate.attested_header = blck.toLightClientHeader(lcDataFork)
|
||||||
@ -386,7 +386,7 @@ proc initLightClientUpdateForPeriod(
|
|||||||
withBlck(bdata):
|
withBlck(bdata):
|
||||||
withForkyUpdate(update):
|
withForkyUpdate(update):
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
when lcDataFork >= lcDataForkAtStateFork(consensusFork):
|
when lcDataFork >= lcDataForkAtConsensusFork(consensusFork):
|
||||||
forkyUpdate.finalized_header = blck.toLightClientHeader(lcDataFork)
|
forkyUpdate.finalized_header = blck.toLightClientHeader(lcDataFork)
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
let bdata = dag.getExistingForkedBlock(signatureBid).valueOr:
|
let bdata = dag.getExistingForkedBlock(signatureBid).valueOr:
|
||||||
@ -477,7 +477,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
|
|||||||
`name _ ok` = false
|
`name _ ok` = false
|
||||||
else:
|
else:
|
||||||
withBlck(bdata.get):
|
withBlck(bdata.get):
|
||||||
when data_fork >= lcDataForkAtStateFork(consensusFork):
|
when data_fork >= lcDataForkAtConsensusFork(consensusFork):
|
||||||
obj.name = blck.toLightClientHeader(data_fork)
|
obj.name = blck.toLightClientHeader(data_fork)
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
`name _ ptr` = addr obj.name
|
`name _ ptr` = addr obj.name
|
||||||
@ -495,7 +495,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
|
|||||||
else:
|
else:
|
||||||
obj.migrateToDataFork(data_fork)
|
obj.migrateToDataFork(data_fork)
|
||||||
withBlck(bdata.get):
|
withBlck(bdata.get):
|
||||||
when data_fork >= lcDataForkAtStateFork(consensusFork):
|
when data_fork >= lcDataForkAtConsensusFork(consensusFork):
|
||||||
obj.forky(data_fork).name = blck.toLightClientHeader(data_fork)
|
obj.forky(data_fork).name = blck.toLightClientHeader(data_fork)
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
`name _ ptr` = addr obj.forky(data_fork).name
|
`name _ ptr` = addr obj.forky(data_fork).name
|
||||||
@ -881,7 +881,7 @@ proc processFinalizationForLightClient*(
|
|||||||
dag.lcDataStore.db.putSyncCommittee(period, syncCommittee)
|
dag.lcDataStore.db.putSyncCommittee(period, syncCommittee)
|
||||||
withBlck(bdata):
|
withBlck(bdata):
|
||||||
when consensusFork >= ConsensusFork.Altair:
|
when consensusFork >= ConsensusFork.Altair:
|
||||||
const lcDataFork = lcDataForkAtStateFork(consensusFork)
|
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
|
||||||
dag.lcDataStore.db.putHeader(blck.toLightClientHeader(lcDataFork))
|
dag.lcDataStore.db.putHeader(blck.toLightClientHeader(lcDataFork))
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
dag.lcDataStore.db.putCurrentSyncCommitteeBranch(
|
dag.lcDataStore.db.putCurrentSyncCommitteeBranch(
|
||||||
@ -1004,7 +1004,7 @@ proc getLightClientBootstrap*(
|
|||||||
return default(ForkedLightClientBootstrap)
|
return default(ForkedLightClientBootstrap)
|
||||||
withBlck(bdata):
|
withBlck(bdata):
|
||||||
when consensusFork >= ConsensusFork.Altair:
|
when consensusFork >= ConsensusFork.Altair:
|
||||||
const lcDataFork = lcDataForkAtStateFork(consensusFork)
|
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
|
||||||
let
|
let
|
||||||
header = blck.toLightClientHeader(lcDataFork)
|
header = blck.toLightClientHeader(lcDataFork)
|
||||||
bootstrap = dag.getLightClientBootstrap(header)
|
bootstrap = dag.getLightClientBootstrap(header)
|
||||||
|
@ -344,7 +344,7 @@ proc installMessageValidators*(
|
|||||||
|
|
||||||
let forkDigests = lightClient.forkDigests
|
let forkDigests = lightClient.forkDigests
|
||||||
for consensusFork in ConsensusFork:
|
for consensusFork in ConsensusFork:
|
||||||
withLcDataFork(lcDataForkAtStateFork(consensusFork)):
|
withLcDataFork(lcDataForkAtConsensusFork(consensusFork)):
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
let
|
let
|
||||||
contextFork = consensusFork # Avoid capturing `Deneb` (Nim 1.6)
|
contextFork = consensusFork # Avoid capturing `Deneb` (Nim 1.6)
|
||||||
|
@ -903,7 +903,8 @@ func forkVersion*(cfg: RuntimeConfig, consensusFork: ConsensusFork): Version =
|
|||||||
of ConsensusFork.Capella: cfg.CAPELLA_FORK_VERSION
|
of ConsensusFork.Capella: cfg.CAPELLA_FORK_VERSION
|
||||||
of ConsensusFork.Deneb: cfg.DENEB_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
|
static: doAssert LightClientDataFork.high == LightClientDataFork.Deneb
|
||||||
if consensusFork >= ConsensusFork.Deneb:
|
if consensusFork >= ConsensusFork.Deneb:
|
||||||
LightClientDataFork.Deneb
|
LightClientDataFork.Deneb
|
||||||
|
@ -150,7 +150,7 @@ proc readChunkPayload*(
|
|||||||
peer.network.forkDigests[].consensusForkForDigest(contextBytes).valueOr:
|
peer.network.forkDigests[].consensusForkForDigest(contextBytes).valueOr:
|
||||||
return neterr InvalidContextBytes
|
return neterr InvalidContextBytes
|
||||||
|
|
||||||
withLcDataFork(lcDataForkAtStateFork(contextFork)):
|
withLcDataFork(lcDataForkAtConsensusFork(contextFork)):
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
let res = await eth2_network.readChunkPayload(
|
let res = await eth2_network.readChunkPayload(
|
||||||
conn, peer, MsgType.Forky(lcDataFork))
|
conn, peer, MsgType.Forky(lcDataFork))
|
||||||
|
@ -92,7 +92,7 @@ proc loadSteps(path: string, fork_digests: ForkDigests): seq[TestStep] =
|
|||||||
update_filename = s["update"].getStr()
|
update_filename = s["update"].getStr()
|
||||||
|
|
||||||
var update {.noinit.}: ForkedLightClientUpdate
|
var update {.noinit.}: ForkedLightClientUpdate
|
||||||
withLcDataFork(lcDataForkAtStateFork(update_state_fork)):
|
withLcDataFork(lcDataForkAtConsensusFork(update_state_fork)):
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
update = ForkedLightClientUpdate(kind: lcDataFork)
|
update = ForkedLightClientUpdate(kind: lcDataFork)
|
||||||
update.forky(lcDataFork) = parseTest(
|
update.forky(lcDataFork) = parseTest(
|
||||||
@ -117,7 +117,7 @@ proc loadSteps(path: string, fork_digests: ForkDigests): seq[TestStep] =
|
|||||||
|
|
||||||
result.add TestStep(
|
result.add TestStep(
|
||||||
kind: TestStepKind.UpgradeStore,
|
kind: TestStepKind.UpgradeStore,
|
||||||
store_data_fork: lcDataForkAtStateFork(store_state_fork),
|
store_data_fork: lcDataForkAtConsensusFork(store_state_fork),
|
||||||
checks: s["checks"].getChecks())
|
checks: s["checks"].getChecks())
|
||||||
else:
|
else:
|
||||||
doAssert false, "Unknown test step: " & $step
|
doAssert false, "Unknown test step: " & $step
|
||||||
@ -172,7 +172,7 @@ proc runTest(path: string) =
|
|||||||
meta.fork_digests.consensusForkForDigest(meta.bootstrap_fork_digest)
|
meta.fork_digests.consensusForkForDigest(meta.bootstrap_fork_digest)
|
||||||
.expect("Unknown bootstrap fork " & $meta.bootstrap_fork_digest)
|
.expect("Unknown bootstrap fork " & $meta.bootstrap_fork_digest)
|
||||||
var bootstrap {.noinit.}: ForkedLightClientBootstrap
|
var bootstrap {.noinit.}: ForkedLightClientBootstrap
|
||||||
withLcDataFork(lcDataForkAtStateFork(bootstrap_state_fork)):
|
withLcDataFork(lcDataForkAtConsensusFork(bootstrap_state_fork)):
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
bootstrap = ForkedLightClientBootstrap(kind: lcDataFork)
|
bootstrap = ForkedLightClientBootstrap(kind: lcDataFork)
|
||||||
bootstrap.forky(lcDataFork) = parseTest(
|
bootstrap.forky(lcDataFork) = parseTest(
|
||||||
@ -189,7 +189,7 @@ proc runTest(path: string) =
|
|||||||
meta.fork_digests.consensusForkForDigest(meta.store_fork_digest)
|
meta.fork_digests.consensusForkForDigest(meta.store_fork_digest)
|
||||||
.expect("Unknown store fork " & $meta.store_fork_digest)
|
.expect("Unknown store fork " & $meta.store_fork_digest)
|
||||||
var store {.noinit.}: ForkedLightClientStore
|
var store {.noinit.}: ForkedLightClientStore
|
||||||
withLcDataFork(lcDataForkAtStateFork(store_state_fork)):
|
withLcDataFork(lcDataForkAtConsensusFork(store_state_fork)):
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
store = ForkedLightClientStore(kind: lcDataFork)
|
store = ForkedLightClientStore(kind: lcDataFork)
|
||||||
bootstrap[].migrateToDataFork(lcDataFork)
|
bootstrap[].migrateToDataFork(lcDataFork)
|
||||||
|
@ -62,7 +62,7 @@ suite "EF - Light client - Update ranking" & preset():
|
|||||||
continue
|
continue
|
||||||
for kind, path in walkDir(testsPath, relative = true, checkDir = true):
|
for kind, path in walkDir(testsPath, relative = true, checkDir = true):
|
||||||
withConsensusFork(fork):
|
withConsensusFork(fork):
|
||||||
const lcDataFork = lcDataForkAtStateFork(consensusFork)
|
const lcDataFork = lcDataForkAtConsensusFork(consensusFork)
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
runTest(testsPath/path, lcDataFork)
|
runTest(testsPath/path, lcDataFork)
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user