Attestation validator now populates list of missing blocks. (#1211)
This commit is contained in:
parent
eb48c05b7f
commit
f60235b3e9
|
@ -76,7 +76,7 @@ proc aggregate_attestations*(
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/p2p-interface.md#attestation-subnets
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/p2p-interface.md#attestation-subnets
|
||||||
proc isValidAttestation*(
|
proc isValidAttestation*(
|
||||||
pool: AttestationPool, attestation: Attestation, current_slot: Slot,
|
pool: var AttestationPool, attestation: Attestation, current_slot: Slot,
|
||||||
topicCommitteeIndex: uint64): bool =
|
topicCommitteeIndex: uint64): bool =
|
||||||
logScope:
|
logScope:
|
||||||
topics = "att_aggr valid_att"
|
topics = "att_aggr valid_att"
|
||||||
|
@ -135,6 +135,7 @@ proc isValidAttestation*(
|
||||||
# therefore propagate faster, thus reordering their arrival in some nodes
|
# therefore propagate faster, thus reordering their arrival in some nodes
|
||||||
if pool.blockPool.get(attestation.data.beacon_block_root).isNone():
|
if pool.blockPool.get(attestation.data.beacon_block_root).isNone():
|
||||||
debug "block doesn't exist in block pool"
|
debug "block doesn't exist in block pool"
|
||||||
|
pool.blockPool.addMissing(attestation.data.beacon_block_root)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# The signature of attestation is valid.
|
# The signature of attestation is valid.
|
||||||
|
|
|
@ -127,6 +127,9 @@ proc latestJustifiedBlock*(pool: BlockPool): BlockSlot =
|
||||||
## as the latest finalized block
|
## as the latest finalized block
|
||||||
latestJustifiedBlock(pool.dag)
|
latestJustifiedBlock(pool.dag)
|
||||||
|
|
||||||
|
proc addMissing*(pool: var BlockPool, broot: Eth2Digest) {.inline.} =
|
||||||
|
pool.quarantine.addMissing(broot)
|
||||||
|
|
||||||
proc isInitialized*(T: type BlockPool, db: BeaconChainDB): bool =
|
proc isInitialized*(T: type BlockPool, db: BeaconChainDB): bool =
|
||||||
isInitialized(CandidateChains, db)
|
isInitialized(CandidateChains, db)
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@ func checkMissing*(quarantine: var Quarantine): seq[FetchRecord] =
|
||||||
if countOnes(v.tries.uint64) == 1:
|
if countOnes(v.tries.uint64) == 1:
|
||||||
result.add(FetchRecord(root: k))
|
result.add(FetchRecord(root: k))
|
||||||
|
|
||||||
|
func addMissing*(quarantine: var Quarantine, broot: Eth2Digest) {.inline.} =
|
||||||
|
discard quarantine.missing.hasKeyOrPut(broot, MissingBlock())
|
||||||
|
|
||||||
func add*(quarantine: var Quarantine, dag: CandidateChains,
|
func add*(quarantine: var Quarantine, dag: CandidateChains,
|
||||||
sblck: SignedBeaconBlock,
|
sblck: SignedBeaconBlock,
|
||||||
broot: Option[Eth2Digest] = none[Eth2Digest]()) =
|
broot: Option[Eth2Digest] = none[Eth2Digest]()) =
|
||||||
|
@ -51,5 +54,4 @@ func add*(quarantine: var Quarantine, dag: CandidateChains,
|
||||||
quarantine.orphans[blockRoot] = sblck
|
quarantine.orphans[blockRoot] = sblck
|
||||||
|
|
||||||
let parentRoot = sblck.message.parent_root
|
let parentRoot = sblck.message.parent_root
|
||||||
if parentRoot notin quarantine.missing:
|
quarantine.addMissing(parentRoot)
|
||||||
quarantine.missing[parentRoot] = MissingBlock()
|
|
||||||
|
|
Loading…
Reference in New Issue