Skip to content

Commit 11fada7

Browse files
committed
review
1 parent f589fd2 commit 11fada7

3 files changed

Lines changed: 17 additions & 19 deletions

File tree

beacon_chain/gossip_processing/gossip_validation.nim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,7 @@ proc validateAttestation*(
11951195
if attestation.data.index == 1:
11961196
template block_root: untyped = attestation.data.beacon_block_root
11971197
if not pool.dag.db.containsExecutionPayloadEnvelope(block_root) and
1198-
(envelopeQuarantine.isNil or
1199-
block_root notin envelopeQuarantine[].orphans):
1198+
block_root notin envelopeQuarantine[].orphans:
12001199
return errIgnore(
12011200
"SingleAttestation: execution payload not yet seen")
12021201
else:
@@ -1408,8 +1407,7 @@ proc validateAggregate*(
14081407
if aggregate.data.index == 1:
14091408
template block_root: untyped = aggregate.data.beacon_block_root
14101409
if not pool.dag.db.containsExecutionPayloadEnvelope(block_root) and
1411-
(envelopeQuarantine.isNil or
1412-
block_root notin envelopeQuarantine[].orphans):
1410+
block_root notin envelopeQuarantine[].orphans:
14131411
return errIgnore(
14141412
"Aggregate: execution payload not yet seen")
14151413
else:

beacon_chain/nimbus_beacon_node.nim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,7 @@ proc initFullNode(
557557
Quarantine.init(dag.cfg))
558558
envelopeQuarantine = newClone(EnvelopeQuarantine.init(onEnvelopeAdded))
559559
attestationPool = newClone(AttestationPool.init(
560-
dag, quarantine,
561-
getBeaconTime(), onSingleAttestationReceived))
560+
dag, quarantine, getBeaconTime(), onSingleAttestationReceived))
562561
syncCommitteeMsgPool = newClone(
563562
SyncCommitteeMsgPool.init(rng, dag.cfg, onSyncContribution))
564563
lightClientPool = newClone(

tests/test_gossip_validation.nim

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import
1919
../beacon_chain/fork_choice/fork_choice,
2020
../beacon_chain/consensus_object_pools/[
2121
block_quarantine, blockchain_dag, block_clearance, attestation_pool,
22-
sync_committee_msg_pool],
22+
envelope_quarantine, sync_committee_msg_pool],
2323
../beacon_chain/spec/datatypes/[phase0, altair],
2424
../beacon_chain/spec/[
2525
beaconstate, state_transition, helpers, network, validator],
@@ -48,6 +48,7 @@ suite "Gossip validation " & preset():
4848
taskpool = Taskpool.new()
4949
verifier {.used.} = BatchVerifier.init(rng, taskpool)
5050
quarantine = newClone(Quarantine.init(dag.cfg))
51+
envQuarantine = newClone(EnvelopeQuarantine.init())
5152
pool {.used.} = newClone(AttestationPool.init(dag, quarantine))
5253
state = newClone(dag.headState)
5354
cache = StateCache()
@@ -113,29 +114,29 @@ suite "Gossip validation " & preset():
113114
beaconTime = att_1_0.data.slot.start_beacon_time(cfg.timeParams)
114115

115116
check:
116-
validateAttestation(pool, batchCrypto, nil, att_1_0, beaconTime, subnet, true).waitFor().isOk
117+
validateAttestation(pool, batchCrypto, envQuarantine, att_1_0, beaconTime, subnet, true).waitFor().isOk
117118

118119
# Same validator again
119-
validateAttestation(pool, batchCrypto, nil, att_1_0, beaconTime, subnet, true).waitFor().error()[0] ==
120+
validateAttestation(pool, batchCrypto, envQuarantine, att_1_0, beaconTime, subnet, true).waitFor().error()[0] ==
120121
ValidationResult.Ignore
121122

122123
pool[].nextAttestationEpoch.setLen(0) # reset for test
123124
check:
124125
# Wrong subnet
125126
validateAttestation(
126-
pool, batchCrypto, nil, att_1_0, beaconTime, SubnetId(subnet.uint8 + 1), true).waitFor().isErr
127+
pool, batchCrypto, envQuarantine, att_1_0, beaconTime, SubnetId(subnet.uint8 + 1), true).waitFor().isErr
127128

128129
pool[].nextAttestationEpoch.setLen(0) # reset for test
129130
check:
130131
# Too far in the future
131132
validateAttestation(
132-
pool, batchCrypto, nil, att_1_0, beaconTime - 1.seconds, subnet, true).waitFor().isErr
133+
pool, batchCrypto, envQuarantine, att_1_0, beaconTime - 1.seconds, subnet, true).waitFor().isErr
133134

134135
pool[].nextAttestationEpoch.setLen(0) # reset for test
135136
check:
136137
# Too far in the past
137138
validateAttestation(
138-
pool, batchCrypto, nil, att_1_0, beaconTime -
139+
pool, batchCrypto, envQuarantine, att_1_0, beaconTime -
139140
cfg.timeParams.SLOT_DURATION * SLOTS_PER_EPOCH.int64 - 1.seconds,
140141
subnet, true).waitFor().isErr
141142

@@ -146,7 +147,7 @@ suite "Gossip validation " & preset():
146147
check:
147148
# Invalid signature
148149
validateAttestation(
149-
pool, batchCrypto, nil, broken, beaconTime, subnet, true).waitFor().
150+
pool, batchCrypto, envQuarantine, broken, beaconTime, subnet, true).waitFor().
150151
error()[0] == ValidationResult.Reject
151152

152153
block:
@@ -156,9 +157,9 @@ suite "Gossip validation " & preset():
156157
# One invalid, one valid (batched)
157158
let
158159
fut_1_0 = validateAttestation(
159-
pool, batchCrypto, nil, broken, beaconTime, subnet, true)
160+
pool, batchCrypto, envQuarantine, broken, beaconTime, subnet, true)
160161
fut_1_1 = validateAttestation(
161-
pool, batchCrypto, nil,att_1_1, beaconTime, subnet, true)
162+
pool, batchCrypto, envQuarantine, att_1_1, beaconTime, subnet, true)
162163

163164
check:
164165
fut_1_0.waitFor().error()[0] == ValidationResult.Reject
@@ -172,9 +173,9 @@ suite "Gossip validation " & preset():
172173
# One invalid, one valid (batched)
173174
let
174175
fut_1_0 = validateAttestation(
175-
pool, batchCrypto, nil, broken, beaconTime, subnet, true)
176+
pool, batchCrypto, envQuarantine, broken, beaconTime, subnet, true)
176177
fut_1_1 = validateAttestation(
177-
pool, batchCrypto, nil,att_1_1, beaconTime, subnet, true)
178+
pool, batchCrypto, envQuarantine, att_1_1, beaconTime, subnet, true)
178179

179180
check:
180181
fut_1_0.waitFor().error()[0] == ValidationResult.Reject
@@ -194,9 +195,9 @@ suite "Gossip validation " & preset():
194195
# the individual attestations are invalid but their aggregate validates!
195196
let
196197
fut_1_0 = validateAttestation(
197-
pool, batchCrypto, nil, broken_1_0, beaconTime, subnet, true)
198+
pool, batchCrypto, envQuarantine, broken_1_0, beaconTime, subnet, true)
198199
fut_1_1 = validateAttestation(
199-
pool, batchCrypto, nil, broken_1_1, beaconTime, subnet, true)
200+
pool, batchCrypto, envQuarantine, broken_1_1, beaconTime, subnet, true)
200201

201202
check:
202203
fut_1_0.waitFor().error()[0] == ValidationResult.Reject

0 commit comments

Comments
 (0)