mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-02 09:46:26 +00:00
handle one of the ProveField
warnings (#5013)
* handle one of the `ProveField` warnings When assigning between `ForkyHashedBeaconState`, suppress `ProveField` warning, as `tgt.kind == src.kind` was already checked, but compiler doesn't understand that (as we only `case tgt.kind`). * Update beacon_chain/spec/forks.nim * Update beacon_chain/spec/forks.nim
This commit is contained in:
parent
d7890ac013
commit
005a35597f
@ -578,6 +578,21 @@ template withState*(x: ForkedHashedBeaconState, body: untyped): untyped =
|
|||||||
template forkyState: untyped {.inject, used.} = x.phase0Data
|
template forkyState: untyped {.inject, used.} = x.phase0Data
|
||||||
body
|
body
|
||||||
|
|
||||||
|
template forky(
|
||||||
|
x: ForkedHashedBeaconState, kind: static ConsensusFork): untyped =
|
||||||
|
when kind == ConsensusFork.Deneb:
|
||||||
|
x.denebData
|
||||||
|
elif kind == ConsensusFork.Capella:
|
||||||
|
x.capellaData
|
||||||
|
elif kind == ConsensusFork.Bellatrix:
|
||||||
|
x.bellatrixData
|
||||||
|
elif kind == ConsensusFork.Altair:
|
||||||
|
x.altairData
|
||||||
|
elif kind == ConsensusFork.Phase0:
|
||||||
|
x.phase0Data
|
||||||
|
else:
|
||||||
|
static: raiseAssert "Unreachable"
|
||||||
|
|
||||||
template withEpochInfo*(x: ForkedEpochInfo, body: untyped): untyped =
|
template withEpochInfo*(x: ForkedEpochInfo, body: untyped): untyped =
|
||||||
case x.kind
|
case x.kind
|
||||||
of EpochInfoFork.Phase0:
|
of EpochInfoFork.Phase0:
|
||||||
@ -609,17 +624,10 @@ template withEpochInfo*(
|
|||||||
|
|
||||||
func assign*(tgt: var ForkedHashedBeaconState, src: ForkedHashedBeaconState) =
|
func assign*(tgt: var ForkedHashedBeaconState, src: ForkedHashedBeaconState) =
|
||||||
if tgt.kind == src.kind:
|
if tgt.kind == src.kind:
|
||||||
case tgt.kind
|
withState(tgt):
|
||||||
of ConsensusFork.Deneb:
|
{.push warning[ProveField]: off.}
|
||||||
assign(tgt.denebData, src.denebData):
|
assign(forkyState, src.forky(consensusFork))
|
||||||
of ConsensusFork.Capella:
|
{.pop.}
|
||||||
assign(tgt.capellaData, src.capellaData):
|
|
||||||
of ConsensusFork.Bellatrix:
|
|
||||||
assign(tgt.bellatrixData, src.bellatrixData):
|
|
||||||
of ConsensusFork.Altair:
|
|
||||||
assign(tgt.altairData, src.altairData):
|
|
||||||
of ConsensusFork.Phase0:
|
|
||||||
assign(tgt.phase0Data, src.phase0Data):
|
|
||||||
else:
|
else:
|
||||||
# Ensure case object and discriminator get updated simultaneously, even
|
# Ensure case object and discriminator get updated simultaneously, even
|
||||||
# with nimOldCaseObjects. This is infrequent.
|
# with nimOldCaseObjects. This is infrequent.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user