Skip to content

Commit 9e68503

Browse files
authored
simplify column quarantine check (#7076)
* simplify column quarantine check * lint
1 parent c1f0880 commit 9e68503

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

beacon_chain/consensus_object_pools/data_column_quarantine.nim

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# beacon_chain
2-
# Copyright (c) 2018-2024 Status Research & Development GmbH
2+
# Copyright (c) 2018-2025 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -131,21 +131,12 @@ func hasMissingDataColumns*(quarantine: DataColumnQuarantine,
131131

132132
# This method shall be actively used by the `RequestManager` to
133133
# root request columns over RPC.
134-
var col_counter = 0
135-
for idx in quarantine.custody_columns:
136-
let dc_identifier =
137-
DataColumnIdentifier(
138-
block_root: blck.root,
139-
index: idx)
140-
if dc_identifier notin quarantine.data_columns:
141-
inc col_counter
142-
if quarantine.supernode and col_counter != NUMBER_OF_COLUMNS:
143-
return false
144-
elif quarantine.supernode == false and
145-
col_counter != max(SAMPLES_PER_SLOT, CUSTODY_REQUIREMENT):
146-
return false
134+
let collected_columns =
135+
quarantine.gatherDataColumns(blck.root)
136+
if collected_columns.len == quarantine.custody_columns.len:
137+
true
147138
else:
148-
return true
139+
false
149140

150141
func hasEnoughDataColumns*(quarantine: DataColumnQuarantine,
151142
blck: fulu.SignedBeaconBlock): bool =
@@ -157,21 +148,18 @@ func hasEnoughDataColumns*(quarantine: DataColumnQuarantine,
157148
# check it, and thereby check column reconstructability, right from
158149
# gossip validation, consequently populating the quarantine with
159150
# rest of the data columns.
151+
let
152+
collectedColumns = quarantine.gatherDataColumns(blck.root)
160153
if quarantine.supernode:
161-
let
162-
collectedColumns = quarantine.gatherDataColumns(blck.root)
163154
if collectedColumns.len >= (quarantine.custody_columns.len div 2):
164-
return true
155+
true
156+
else:
157+
false
165158
else:
166-
for i in quarantine.custody_columns:
167-
let dc_identifier =
168-
DataColumnIdentifier(
169-
block_root: blck.root,
170-
index: i)
171-
if dc_identifier notin quarantine.data_columns:
172-
return false
173-
else:
174-
return true
159+
if collectedColumns.len == quarantine.custody_columns.len:
160+
true
161+
else:
162+
false
175163

176164
func dataColumnFetchRecord*(quarantine: DataColumnQuarantine,
177165
blck: fulu.SignedBeaconBlock):

0 commit comments

Comments
 (0)