From 4462f08ccfd224c91544c6f1b4a5f70670035f37 Mon Sep 17 00:00:00 2001
From: Agnish Ghosh <iamagnix@gmail.com>
Date: Sun, 13 Oct 2024 15:07:18 +0530
Subject: [PATCH] db management for data columns improved

---
 beacon_chain/gossip_processing/block_processor.nim | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim
index 6de06e2bd..0f5e276c2 100644
--- a/beacon_chain/gossip_processing/block_processor.nim
+++ b/beacon_chain/gossip_processing/block_processor.nim
@@ -581,7 +581,17 @@ proc storeBlock(
           withBlck(parentBlck.get()):
             when consensusFork >= ConsensusFork.Deneb:
               var data_column_sidecars: DataColumnSidecars
-              for i in 0..<NUMBER_OF_COLUMNS:
+              let
+                localSubnetCount = 
+                  if self.dataColumnQuarantine[].supernode:
+                    DATA_COLUMN_SIDECAR_SUBNET_COUNT.uint64
+                  else:
+                    CUSTODY_REQUIREMENT.uint64
+                localCustodyColumns =
+                  get_custody_columns(self.dataColumnQuarantine[].nodeid,
+                                      max(SAMPLES_PER_SLOT.uint64,
+                                          localSubnetCount))
+              for i in localCustodyColumns:
                 let data_column = DataColumnSidecar.new()
                 if not dag.db.getDataColumnSidecar(parent_root, i.ColumnIndex, data_column[]):
                   columnsOk = false