Skip to content

Commit b586943

Browse files
committed
handle table serialization condition properly
1 parent 6919d35 commit b586943

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

beacon_chain/sync/column_syncer.nim

+26-13
Original file line numberDiff line numberDiff line change
@@ -378,22 +378,35 @@ func serializeColumnTable*[A, B](
378378
# Iterate through the column syncer table
379379
for k, v in man.column_syncer_table.pairs():
380380
# Checking if the table has all the required columns
381-
if v.columns.len >= (NUMBER_OF_COLUMNS div 2) and v.columns.isSome():
382-
let
383-
recovered_cps =
384-
recover_cells_and_proofs(v.columns.get().mapIt(it[]))
385-
reconstructed_columns =
386-
get_data_column_sidecars(v.blk[], recovered_cps.get()).mapIt(newClone it)
381+
if man.amIsupernode:
382+
if v.columns.len >= (man.cfg.NUMBER_OF_COLUMNS div 2) and
383+
v.columns.isSome():
384+
let
385+
recovered_cps =
386+
recover_cells_and_proofs(v.columns.get().mapIt(it[]))
387+
reconstructed_columns =
388+
get_data_column_sidecars(v.blk[], recovered_cps.get()).mapIt(newClone it)
389+
390+
391+
# Populate that particular entry with reconstructed columns
392+
man.column_syncer_table[k] =
393+
ColumnAndBlockResponse(
394+
blk: v.blk,
395+
columns: Opt.some(reconstructed_columns))
396+
397+
elif v.columns.len < (NUMBER_OF_COLUMNS div 2) and v.columns.isSome():
398+
return err ("Requisite number of columns not yet reached")
387399

400+
elif man.amIsupernode == false:
401+
if v.columns.len == max(man.cfg.CUSTODY_REQUIREMENT, man.cfg.SAMPLES_PER_SLOT) and
402+
v.columns.isSome:
388403

389-
# Populate that particular entry with reconstructed columns
390-
man.column_syncer_table[k] =
391-
ColumnAndBlockResponse(
392-
blk: v.blk,
393-
columns: Opt.some(reconstructed_columns))
404+
# Do nothing, table entry is fine
405+
elif v.columns.len == max(man.cfg.CUSTODY_REQUIREMENT, man.cfg.SAMPLES_PER_SLOT) and
406+
v.columns.isSome:
394407

395-
elif v.columns.len < (NUMBER_OF_COLUMNS div 2) and v.columns.isSome():
396-
return err ("Requisite number of columns not yet reached")
408+
# Retry as custody has not been reached yet
409+
return err ("Requisite number of columns not yet reached")
397410

398411
else:
399412
discard

0 commit comments

Comments
 (0)