From 4bd6ead294064ba21d0627a3552daee5693c3bfb Mon Sep 17 00:00:00 2001
From: Agnish Ghosh <iamagnix@gmail.com>
Date: Tue, 1 Oct 2024 20:43:30 +0530
Subject: [PATCH] disable peer quota

---
 beacon_chain/spec/datatypes/eip7594.nim | 2 ++
 beacon_chain/sync/sync_manager.nim      | 6 ++++--
 beacon_chain/sync/sync_protocol.nim     | 9 ++++++---
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/beacon_chain/spec/datatypes/eip7594.nim b/beacon_chain/spec/datatypes/eip7594.nim
index 70390ba2b..99fce6238 100644
--- a/beacon_chain/spec/datatypes/eip7594.nim
+++ b/beacon_chain/spec/datatypes/eip7594.nim
@@ -66,6 +66,8 @@ type
 
   DataColumnSidecars* = seq[ref DataColumnSidecar]
 
+  DataColumnSidecarList* = List[ColumnIndex, NUMBER_OF_COLUMNS]
+
   DataColumnIdentifier* = object
     block_root*: Eth2Digest
     index*: ColumnIndex
diff --git a/beacon_chain/sync/sync_manager.nim b/beacon_chain/sync/sync_manager.nim
index f4a10e33a..93c016243 100644
--- a/beacon_chain/sync/sync_manager.nim
+++ b/beacon_chain/sync/sync_manager.nim
@@ -336,7 +336,6 @@ proc getDataColumnSidecars[A, B](man: SyncManager[A, B], peer: A,
       localNodeId.get_custody_column_list(max(SAMPLES_PER_SLOT.uint64,
                                                localCustodySubnetCount))
 
-  debug "Checking valid custody peers before range request", request = req
   doAssert(not(req.isEmpty()), "Request must not be empty!")
 
   debug "Requesting data column sidecars from peer", request = req
@@ -372,6 +371,9 @@ func groupDataColumns*[T](req: SyncRequest[T],
           grouped[block_idx].add(data_column_sidecar)
           inc column_cursor
 
+          debugEcho "Column Cursor"
+          debugEcho column_cursor
+
   if column_cursor != len(data_columns):
     # we reached end of blocks without consuming all data columns so either
     # the peer we got too few blocks in the paired request, or the
@@ -642,7 +644,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A)
       let groupedDataColumns = groupDataColumns(req, blockData, dataColumnData)
       if groupedDataColumns.isErr():
         # peer.updateScore(PeerScoreNoValues)
-        man.queue.push(req)
+        # man.queue.push(req)
         # warn "Received data columns is inconsistent",
         #   data_columns_map = getShortMap(req, dataColumnData), request = req, msg=groupedDataColumns.error()
         return
diff --git a/beacon_chain/sync/sync_protocol.nim b/beacon_chain/sync/sync_protocol.nim
index 788d855a8..b0ce4c182 100644
--- a/beacon_chain/sync/sync_protocol.nim
+++ b/beacon_chain/sync/sync_protocol.nim
@@ -24,7 +24,7 @@ const
     ## Allow syncing ~64 blocks/sec (minus request costs)
   blobResponseCost = allowedOpsPerSecondCost(1000)
     ## Multiple can exist per block, they are much smaller than blocks
-  dataColumnResponseCost = allowedOpsPerSecondCost(1000)
+  dataColumnResponseCost = allowedOpsPerSecondCost(8000)
     ## 1 blob has an equivalent memory of 8 data columns
 
 type
@@ -484,12 +484,15 @@ p2pProtocol BeaconSync(version = 1,
             if blockIds[i].slot.epoch >= dag.cfg.DENEB_FORK_EPOCH and
                 not dag.head.executionValid:
               continue
+
             let uncompressedLen = uncompressedLenFramed(bytes).valueOr:
               warn "Cannot read data column sidecar size, database, corrupt",
                 bytes = bytes.len(), blck = shortLog(blockIds[i])
               continue
-            peer.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1")
-            peer.network.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1")
+
+            # peer.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1")
+            # peer.network.awaitQuota(dataColumnResponseCost, "data_column_sidecars_by_range/1")
+
             await response.writeBytesSZ(
               uncompressedLen, bytes,
               peer.network.forkDigestAtEpoch(blockIds[i].slot.epoch).data)