clean up `XDeclaredButNotUsed` for light client (#5606)

Handle remaining `XDeclaredButNotUsed` warnings for light client.
This commit is contained in:
Etan Kissling 2023-11-17 15:03:27 -08:00 committed by GitHub
parent dfd7b9bc61
commit b179cb71a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -47,7 +47,7 @@ type
pendingBest*: pendingBest*:
Table[(SyncCommitteePeriod, Eth2Digest), ForkedLightClientUpdate] Table[(SyncCommitteePeriod, Eth2Digest), ForkedLightClientUpdate]
## Same as `bestUpdates`, but for `SyncCommitteePeriod` with not yet ## Same as `db.bestUpdates`, but for `SyncCommitteePeriod` with not yet
## finalized `next_sync_committee`. Key is `(attested_period, ## finalized `next_sync_committee`. Key is `(attested_period,
## hash_tree_root(current_sync_committee | next_sync_committee)`. ## hash_tree_root(current_sync_committee | next_sync_committee)`.

View File

@ -456,7 +456,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
`name _ ptr`: ptr[data_fork.LightClientHeader] `name _ ptr`: ptr[data_fork.LightClientHeader]
`name _ ok` = true `name _ ok` = true
template `assign _ name`( template `assign _ name`(
obj: var SomeForkyLightClientObject, bid: BlockId): untyped = obj: var SomeForkyLightClientObject, bid: BlockId): untyped {.used.} =
if `name _ ptr` != nil: if `name _ ptr` != nil:
obj.name = `name _ ptr`[] obj.name = `name _ ptr`[]
elif `name _ ok`: elif `name _ ok`:
@ -472,7 +472,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
`name _ ptr` = addr obj.name `name _ ptr` = addr obj.name
`name _ ok` `name _ ok`
template `assign _ name _ with_migration`( template `assign _ name _ with_migration`(
obj: var SomeForkedLightClientObject, bid: BlockId): untyped = obj: var SomeForkedLightClientObject, bid: BlockId): untyped {.used.} =
if `name _ ptr` != nil: if `name _ ptr` != nil:
obj.migrateToDataFork(data_fork) obj.migrateToDataFork(data_fork)
obj.forky(data_fork).name = `name _ ptr`[] obj.forky(data_fork).name = `name _ ptr`[]

View File

@ -501,6 +501,7 @@ func toFull*(
update: SomeForkyLightClientUpdate): auto = update: SomeForkyLightClientUpdate): auto =
type ResultType = typeof(update).kind.LightClientUpdate type ResultType = typeof(update).kind.LightClientUpdate
when update is ForkyLightClientUpdate: when update is ForkyLightClientUpdate:
static: doAssert update is ResultType
update update
elif update is SomeForkyLightClientUpdateWithFinality: elif update is SomeForkyLightClientUpdateWithFinality:
ResultType( ResultType(

View File

@ -78,9 +78,10 @@ proc validate_light_client_update*(
return err(VerifierError.MissingParent) return err(VerifierError.MissingParent)
# Verify update is relevant # Verify update is relevant
let attested_period = update.attested_header.beacon.slot.sync_committee_period
when update is SomeForkyLightClientUpdateWithSyncCommittee: when update is SomeForkyLightClientUpdateWithSyncCommittee:
let is_sync_committee_update = update.is_sync_committee_update let
attested_period = update.attested_header.beacon.slot.sync_committee_period
is_sync_committee_update = update.is_sync_committee_update
if update.attested_header.beacon.slot <= store.finalized_header.beacon.slot: if update.attested_header.beacon.slot <= store.finalized_header.beacon.slot:
when update is SomeForkyLightClientUpdateWithSyncCommittee: when update is SomeForkyLightClientUpdateWithSyncCommittee:
if is_next_sync_committee_known: if is_next_sync_committee_known: