mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-17 00:47:03 +00:00
avoid casting types in LC data code (#3743)
Use `asSigned()` for type safety over `isomorphicCast` in LC data code.
This commit is contained in:
parent
6bf7d64680
commit
20e646a47f
@ -228,7 +228,7 @@ proc createLightClientUpdates(
|
|||||||
## post-state must be cached (`cacheLightClientData`) before calling this.
|
## post-state must be cached (`cacheLightClientData`) before calling this.
|
||||||
|
|
||||||
# Verify sync committee has sufficient participants
|
# Verify sync committee has sufficient participants
|
||||||
template sync_aggregate(): auto = blck.message.body.sync_aggregate
|
template sync_aggregate(): auto = blck.asSigned().message.body.sync_aggregate
|
||||||
template sync_committee_bits(): auto = sync_aggregate.sync_committee_bits
|
template sync_committee_bits(): auto = sync_aggregate.sync_committee_bits
|
||||||
let num_active_participants = countOnes(sync_committee_bits).uint64
|
let num_active_participants = countOnes(sync_committee_bits).uint64
|
||||||
if num_active_participants < MIN_SYNC_COMMITTEE_PARTICIPANTS:
|
if num_active_participants < MIN_SYNC_COMMITTEE_PARTICIPANTS:
|
||||||
@ -275,7 +275,7 @@ proc createLightClientUpdates(
|
|||||||
else:
|
else:
|
||||||
latest.finalized_header.reset()
|
latest.finalized_header.reset()
|
||||||
latest.finality_branch.reset()
|
latest.finality_branch.reset()
|
||||||
latest.sync_aggregate = isomorphicCast[SyncAggregate](sync_aggregate)
|
latest.sync_aggregate = sync_aggregate
|
||||||
latest.signature_slot = signature_slot
|
latest.signature_slot = signature_slot
|
||||||
newOptimistic = true
|
newOptimistic = true
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ proc createLightClientUpdates(
|
|||||||
else:
|
else:
|
||||||
best.finalized_header.reset()
|
best.finalized_header.reset()
|
||||||
best.finality_branch.reset()
|
best.finality_branch.reset()
|
||||||
best.sync_aggregate = isomorphicCast[SyncAggregate](sync_aggregate)
|
best.sync_aggregate = sync_aggregate
|
||||||
best.signature_slot = signature_slot
|
best.signature_slot = signature_slot
|
||||||
|
|
||||||
if isCommitteeFinalized:
|
if isCommitteeFinalized:
|
||||||
@ -645,8 +645,7 @@ proc initLightClientUpdateForPeriod(
|
|||||||
return
|
return
|
||||||
withBlck(bdata):
|
withBlck(bdata):
|
||||||
when stateFork >= BeaconStateFork.Altair:
|
when stateFork >= BeaconStateFork.Altair:
|
||||||
update.sync_aggregate =
|
update.sync_aggregate = blck.asSigned().message.body.sync_aggregate
|
||||||
isomorphicCast[SyncAggregate](blck.message.body.sync_aggregate)
|
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
update.signature_slot = signatureBid.slot
|
update.signature_slot = signatureBid.slot
|
||||||
dag.lightClientCache.best[period] = update
|
dag.lightClientCache.best[period] = update
|
||||||
|
Loading…
x
Reference in New Issue
Block a user