Skip to content

Commit

Permalink
clean up XDeclaredButNotUsed for light client (#5606)
Browse files Browse the repository at this point in the history
Handle remaining `XDeclaredButNotUsed` warnings for light client.
  • Loading branch information
etan-status authored Nov 17, 2023
1 parent dfd7b9b commit b179cb7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type

pendingBest*:
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,
## hash_tree_root(current_sync_committee | next_sync_committee)`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
`name _ ptr`: ptr[data_fork.LightClientHeader]
`name _ ok` = true
template `assign _ name`(
obj: var SomeForkyLightClientObject, bid: BlockId): untyped =
obj: var SomeForkyLightClientObject, bid: BlockId): untyped {.used.} =
if `name _ ptr` != nil:
obj.name = `name _ ptr`[]
elif `name _ ok`:
Expand All @@ -472,7 +472,7 @@ template lazy_header(name: untyped): untyped {.dirty.} =
`name _ ptr` = addr obj.name
`name _ ok`
template `assign _ name _ with_migration`(
obj: var SomeForkedLightClientObject, bid: BlockId): untyped =
obj: var SomeForkedLightClientObject, bid: BlockId): untyped {.used.} =
if `name _ ptr` != nil:
obj.migrateToDataFork(data_fork)
obj.forky(data_fork).name = `name _ ptr`[]
Expand Down
1 change: 1 addition & 0 deletions beacon_chain/spec/forks_light_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ func toFull*(
update: SomeForkyLightClientUpdate): auto =
type ResultType = typeof(update).kind.LightClientUpdate
when update is ForkyLightClientUpdate:
static: doAssert update is ResultType
update
elif update is SomeForkyLightClientUpdateWithFinality:
ResultType(
Expand Down
5 changes: 3 additions & 2 deletions beacon_chain/spec/light_client_sync.nim
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ proc validate_light_client_update*(
return err(VerifierError.MissingParent)

# Verify update is relevant
let attested_period = update.attested_header.beacon.slot.sync_committee_period
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:
when update is SomeForkyLightClientUpdateWithSyncCommittee:
if is_next_sync_committee_known:
Expand Down

0 comments on commit b179cb7

Please sign in to comment.