diff --git a/beacon_chain/attestation_aggregation.nim b/beacon_chain/attestation_aggregation.nim index cceb30992..d3c964af2 100644 --- a/beacon_chain/attestation_aggregation.nim +++ b/beacon_chain/attestation_aggregation.nim @@ -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 proc isValidAttestation*( - pool: AttestationPool, attestation: Attestation, current_slot: Slot, + pool: var AttestationPool, attestation: Attestation, current_slot: Slot, topicCommitteeIndex: uint64): bool = logScope: topics = "att_aggr valid_att" @@ -135,6 +135,7 @@ proc isValidAttestation*( # therefore propagate faster, thus reordering their arrival in some nodes if pool.blockPool.get(attestation.data.beacon_block_root).isNone(): debug "block doesn't exist in block pool" + pool.blockPool.addMissing(attestation.data.beacon_block_root) return false # The signature of attestation is valid. diff --git a/beacon_chain/block_pool.nim b/beacon_chain/block_pool.nim index 987e01857..cfe896d9c 100644 --- a/beacon_chain/block_pool.nim +++ b/beacon_chain/block_pool.nim @@ -127,6 +127,9 @@ proc latestJustifiedBlock*(pool: BlockPool): BlockSlot = ## as the latest finalized block latestJustifiedBlock(pool.dag) +proc addMissing*(pool: var BlockPool, broot: Eth2Digest) {.inline.} = + pool.quarantine.addMissing(broot) + proc isInitialized*(T: type BlockPool, db: BeaconChainDB): bool = isInitialized(CandidateChains, db) diff --git a/beacon_chain/block_pools/quarantine.nim b/beacon_chain/block_pools/quarantine.nim index 08851a973..3c4265883 100644 --- a/beacon_chain/block_pools/quarantine.nim +++ b/beacon_chain/block_pools/quarantine.nim @@ -39,6 +39,9 @@ func checkMissing*(quarantine: var Quarantine): seq[FetchRecord] = if countOnes(v.tries.uint64) == 1: 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, sblck: SignedBeaconBlock, broot: Option[Eth2Digest] = none[Eth2Digest]()) = @@ -51,5 +54,4 @@ func add*(quarantine: var Quarantine, dag: CandidateChains, quarantine.orphans[blockRoot] = sblck let parentRoot = sblck.message.parent_root - if parentRoot notin quarantine.missing: - quarantine.missing[parentRoot] = MissingBlock() + quarantine.addMissing(parentRoot)