From 44531ad23f9c8d6e367cff40efc7d5a10d6780c8 Mon Sep 17 00:00:00 2001
From: Agnish Ghosh <iamagnix@gmail.com>
Date: Fri, 8 Nov 2024 12:27:36 +0700
Subject: [PATCH] addressed reviews

---
 beacon_chain/beacon_chain_db.nim              | 36 ++++++++++++++-----
 .../consensus_manager.nim                     |  1 +
 .../gossip_processing/block_processor.nim     |  1 +
 beacon_chain/spec/keystore.nim                |  1 +
 4 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/beacon_chain/beacon_chain_db.nim b/beacon_chain/beacon_chain_db.nim
index 64d2fb3a9..747777bf6 100644
--- a/beacon_chain/beacon_chain_db.nim
+++ b/beacon_chain/beacon_chain_db.nim
@@ -508,7 +508,7 @@ proc new*(T: type BeaconChainDB,
 
     # V1 - expected-to-be small rows get without rowid optimizations
     keyValues = kvStore db.openKvStore("key_values", true).expectDb()
-    blocks = [
+    blocks = if cfg.FULU_FORK_EPOCH != FAR_FUTURE_EPOCH: [
       kvStore db.openKvStore("blocks").expectDb(),
       kvStore db.openKvStore("altair_blocks").expectDb(),
       kvStore db.openKvStore("bellatrix_blocks").expectDb(),
@@ -517,16 +517,34 @@ proc new*(T: type BeaconChainDB,
       kvStore db.openKvStore("electra_blocks").expectDb(),
       kvStore db.openKvStore("fulu_blocks").expectDb()]
 
+      else: [
+      kvStore db.openKvStore("blocks").expectDb(),
+      kvStore db.openKvStore("altair_blocks").expectDb(),
+      kvStore db.openKvStore("bellatrix_blocks").expectDb(),
+      kvStore db.openKvStore("capella_blocks").expectDb(),
+      kvStore db.openKvStore("deneb_blocks").expectDb(),
+      kvStore db.openKvStore("electra_blocks").expectDb(),
+      kvStore db.openKvStore("").expectDb()]
+
     stateRoots = kvStore db.openKvStore("state_roots", true).expectDb()
 
-    statesNoVal = [
-      kvStore db.openKvStore("state_no_validators2").expectDb(),
-      kvStore db.openKvStore("altair_state_no_validators").expectDb(),
-      kvStore db.openKvStore("bellatrix_state_no_validators").expectDb(),
-      kvStore db.openKvStore("capella_state_no_validator_pubkeys").expectDb(),
-      kvStore db.openKvStore("deneb_state_no_validator_pubkeys").expectDb(),
-      kvStore db.openKvStore("electra_state_no_validator_pubkeys").expectDb(),
-      kvStore db.openKvStore("fulu_state_no_validator_pubkeys").expectDb()]
+    statesNoVal = if cfg.FULU_FORK_EPOCH != FAR_FUTURE_EPOCH: [
+        kvStore db.openKvStore("state_no_validators").expectDb(),
+        kvStore db.openKvStore("altair_state_no_validators").expectDb(),
+        kvStore db.openKvStore("bellatrix_state_no_validators").expectDb(),
+        kvStore db.openKvStore("capella_state_no_validator_pubkeys").expectDb(),
+        kvStore db.openKvStore("deneb_state_no_validator_pubkeys").expectDb(),
+        kvStore db.openKvStore("electra_state_no_validator_pubkeys").expectDb(),
+        kvStore db.openKvStore("fulu_state_no_validator_pubkeys").expectDb()]
+
+      else: [
+        kvStore db.openKvStore("state_no_validators").expectDb(),
+        kvStore db.openKvStore("altair_state_no_validators").expectDb(),
+        kvStore db.openKvStore("bellatrix_state_no_validators").expectDb(),
+        kvStore db.openKvStore("capella_state_no_validator_pubkeys").expectDb(),
+        kvStore db.openKvStore("deneb_state_no_validator_pubkeys").expectDb(),
+        kvStore db.openKvStore("electra_state_no_validator_pubkeys").expectDb(),
+        kvStore db.openKvStore("").expectDb()]
 
     stateDiffs = kvStore db.openKvStore("state_diffs").expectDb()
     summaries = kvStore db.openKvStore("beacon_block_summaries", true).expectDb()
diff --git a/beacon_chain/consensus_object_pools/consensus_manager.nim b/beacon_chain/consensus_object_pools/consensus_manager.nim
index d54f88caf..d6261b62b 100644
--- a/beacon_chain/consensus_object_pools/consensus_manager.nim
+++ b/beacon_chain/consensus_object_pools/consensus_manager.nim
@@ -379,6 +379,7 @@ proc runProposalForkchoiceUpdated*(
       debug "Fork-choice updated for proposal", status
 
     static: doAssert high(ConsensusFork) == ConsensusFork.Fulu
+    debugFuluComment "Will Fulu need fcuV4? Or there shall be a new fcuV introduced in Fulu? We don't know"
     when consensusFork >= ConsensusFork.Deneb:
       # https://github.com/ethereum/execution-apis/blob/90a46e9137c89d58e818e62fa33a0347bba50085/src/engine/prague.md
       # does not define any new forkchoiceUpdated, so reuse V3 from Dencun
diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim
index 6e24dd585..c8a009c7e 100644
--- a/beacon_chain/gossip_processing/block_processor.nim
+++ b/beacon_chain/gossip_processing/block_processor.nim
@@ -772,6 +772,7 @@ proc storeBlock(
             deadlineObj = deadlineObj,
             maxRetriesCount = getRetriesCount())
 
+        debugFuluComment "We don't know yet if there'd be new PayloadAttributes version in Fulu."
         template callForkChoiceUpdated: auto =
           case self.consensusManager.dag.cfg.consensusForkAtEpoch(
               newHead.get.blck.bid.slot.epoch)
diff --git a/beacon_chain/spec/keystore.nim b/beacon_chain/spec/keystore.nim
index 4f2006615..80dd1c786 100644
--- a/beacon_chain/spec/keystore.nim
+++ b/beacon_chain/spec/keystore.nim
@@ -727,6 +727,7 @@ template writeValue*(w: var JsonWriter,
 
 func parseProvenBlockProperty*(propertyPath: string): Result[ProvenProperty, string] =
   if propertyPath == ".execution_payload.fee_recipient":
+    debugFuluComment "We don't know yet if `GeneralizedIndex` will stay same in Fulu yet."
     ok ProvenProperty(
       path: propertyPath,
       capellaIndex: some GeneralizedIndex(401),