mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 23:04:26 +00:00
* address issue #1580 * Update beacon_chain/spec/beaconstate.nim Co-authored-by: Jacek Sieka <jacek@status.im>
This commit is contained in:
parent
bb83817c2a
commit
368bd7c057
@ -299,6 +299,7 @@ proc attestationValidator*(
|
||||
|
||||
logScope: wallSlot
|
||||
|
||||
# Potential under/overflows are fine; would just create odd metrics and logs
|
||||
let delay = wallTime - attestation.data.slot.toBeaconTime
|
||||
debug "Attestation received", delay
|
||||
let v = self.attestationPool[].validateAttestation(
|
||||
@ -339,6 +340,7 @@ proc aggregateValidator*(
|
||||
|
||||
logScope: wallSlot
|
||||
|
||||
# Potential under/overflows are fine; would just create odd logs
|
||||
let delay =
|
||||
wallTime - signedAggregateAndProof.message.aggregate.data.slot.toBeaconTime
|
||||
debug "Aggregate received", delay
|
||||
|
@ -322,6 +322,10 @@ func get_block_root_at_slot*(state: BeaconState,
|
||||
slot: Slot): Eth2Digest =
|
||||
# Return the block root at a recent ``slot``.
|
||||
|
||||
# Potential overflow/wrap shouldn't occur, as get_block_root_at_slot() called
|
||||
# from internally controlled sources, but flag this explicitly, in case.
|
||||
doAssert slot + SLOTS_PER_HISTORICAL_ROOT > slot
|
||||
|
||||
doAssert state.slot <= slot + SLOTS_PER_HISTORICAL_ROOT
|
||||
doAssert slot < state.slot
|
||||
state.block_roots[slot mod SLOTS_PER_HISTORICAL_ROOT]
|
||||
@ -538,6 +542,12 @@ func check_attestation_target_epoch*(
|
||||
|
||||
func check_attestation_inclusion*(data: AttestationData,
|
||||
current_slot: Slot): Result[void, cstring] =
|
||||
# Check for overflow
|
||||
static:
|
||||
doAssert SLOTS_PER_EPOCH >= MIN_ATTESTATION_INCLUSION_DELAY
|
||||
if data.slot + SLOTS_PER_EPOCH <= data.slot:
|
||||
return err("attestation data.slot overflow, malicious?")
|
||||
|
||||
if not (data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= current_slot):
|
||||
return err("Attestation too new")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user