Skip to content

ColumnSyncer #7029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 35 commits into
base: column-syncer
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cc20062
save progress
agnxsh Feb 28, 2025
34cb63f
save progress
agnxsh Mar 4, 2025
7aaae36
save more progress
agnxsh Mar 6, 2025
7346545
save work
agnxsh Mar 8, 2025
d1b0e6a
save progress
agnxsh Mar 10, 2025
032d42e
init impartial column sync
agnxsh Mar 11, 2025
5b9b032
save work
agnxsh Mar 11, 2025
39ae834
column table handling logic for impartial syncer
agnxsh Mar 12, 2025
372916f
revamped syncer direction
agnxsh Mar 17, 2025
0392590
save column syncer assist progress
agnxsh Mar 18, 2025
7774990
almost done
agnxsh Mar 21, 2025
3010892
added e2e flow
agnxsh Mar 21, 2025
d560050
fix conf string
agnxsh Mar 21, 2025
0377cb4
fixes
agnxsh Mar 21, 2025
4abeaae
refine
agnxsh Mar 21, 2025
d038fb1
fix other issues
agnxsh Mar 23, 2025
8e8615d
copyright year
agnxsh Mar 23, 2025
0167ca4
fix other things and remove unecessary imports/exports
agnxsh Mar 24, 2025
ead9ce7
more fixes
agnxsh Mar 24, 2025
e777991
fix limit
agnxsh Mar 24, 2025
2b160dd
make column syncer configurable as well
agnxsh Mar 26, 2025
3257d9a
handle table serialization condition properly
agnxsh Mar 26, 2025
e6047f8
oops
agnxsh Mar 26, 2025
6bec6e4
other fixes
agnxsh Mar 26, 2025
84a14e0
improve logging
agnxsh Apr 1, 2025
0eb0227
further cleanups
agnxsh Apr 4, 2025
f40c1a7
make debug-column-syncer flag hidden
agnxsh Apr 4, 2025
38aad54
cleanup pointless whitespaces
agnxsh Apr 4, 2025
56565cb
fixes
agnxsh Apr 4, 2025
80f77a8
cleanup redundant overloads
agnxsh Apr 4, 2025
06c581b
column syncer group columns fix
agnxsh Apr 7, 2025
5990eef
fix logging more
agnxsh Apr 16, 2025
87e8085
fix
agnxsh Apr 18, 2025
5bbfe4b
added more logging, changed some strategy
agnxsh Apr 22, 2025
3404fae
added column sync status
agnxsh Apr 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion beacon_chain/beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import
./spec/datatypes/[base, altair],
./spec/eth2_apis/dynamic_fee_recipients,
./spec/signatures_batch,
./sync/[sync_manager, request_manager, sync_types],
./sync/[sync_manager, request_manager, sync_types, column_syncer],
./validators/[
action_tracker, message_router, validator_monitor, validator_pool,
keystore_management],
Expand Down Expand Up @@ -96,6 +96,7 @@ type
vcProcess*: Process
requestManager*: RequestManager
syncManager*: SyncManager[Peer, PeerId]
columnManager*: ColumnManager[Peer, PeerId]
backfiller*: SyncManager[Peer, PeerId]
untrustedManager*: SyncManager[Peer, PeerId]
syncOverseer*: SyncOverseerRef
Expand Down
12 changes: 12 additions & 0 deletions beacon_chain/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ type
Light = "light",
Lenient = "lenient"

ColumnSyncerStrategy* {.pure.} = enum
Greedy = "greedy"
Impartial = "impartial"

BeaconNodeConf* = object
configFile* {.
desc: "Loads the configuration from a TOML file"
Expand Down Expand Up @@ -559,6 +563,14 @@ type
desc: "Maximum number of sync committee periods to retain light client data"
name: "light-client-data-max-periods" .}: Option[uint64]

columnSyncerStrategy* {.
hidden
desc: "Choose how to sync columns, " &
" 1) Greedy would make the BN actively filter peers based on higher column custody. " &
" 2) Impartial would rely on every peer for columns till requisite column count is reached. "
defaultValue: ColumnSyncerStrategy.Impartial
name: "debug-column-syncer".}: ColumnSyncerStrategy

longRangeSync* {.
hidden
desc: "Enable long-range syncing (genesis sync)",
Expand Down
7 changes: 6 additions & 1 deletion beacon_chain/networking/peer_scores.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
Expand All @@ -14,6 +14,11 @@ const
## Score after which peer will be kicked
PeerScoreHighLimit* = 1000
## Max value of peer's score
PeerScoreSupernode* = 700
## Score assigned to a supernode in order to prevent disconnection
PeerScoreIntersectingColumns* = 200
## Score assigned to a node with intersecting columns
## to the local BN in order to prevent disconnection
PeerScorePoorRequest* = -50
## This peer is not responding on time or behaving improperly otherwise
PeerScoreInvalidRequest* = -500
Expand Down
66 changes: 64 additions & 2 deletions beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import
./spec/[
deposit_snapshots, engine_authentication, weak_subjectivity,
peerdas_helpers],
./sync/[sync_protocol, light_client_protocol, sync_overseer],
./sync/[
column_syncer, sync_protocol, light_client_protocol,
sync_overseer, column_syncer_assist],
./validators/[keystore_management, beacon_validators],
"."/[
beacon_node, beacon_node_light_client, deposits,
Expand Down Expand Up @@ -445,7 +447,16 @@ proc initFullNode(
config.dumpEnabled, config.dumpDirInvalid, config.dumpDirIncoming,
batchVerifier, consensusManager, node.validatorMonitor,
blobQuarantine, dataColumnQuarantine, getBeaconTime)

peerdasBlockVerifier = proc(signedBlock: ForkedSignedBeaconBlock,
columns: Opt[DataColumnSidecars], maybeFinalized: bool):
Future[Result[void, VerifierError]] {.async: (raises: [CancelledError], raw: true).} =
# The design with a callback for block verification is unusual compared
# to the rest of the application, but fits with the general approach
# taken in the sync/request managers - this is an architectural compromise
# that should probably be reimagined more holistically in the future.
blockProcessor[].addBlock(
MsgSource.gossip, signedBlock, Opt.none(BlobSidecars), columns,
maybeFinalized = maybeFinalized)
blockVerifier = proc(signedBlock: ForkedSignedBeaconBlock,
blobs: Opt[BlobSidecars], maybeFinalized: bool):
Future[Result[void, VerifierError]] {.async: (raises: [CancelledError], raw: true).} =
Expand Down Expand Up @@ -536,6 +547,29 @@ proc initFullNode(
{SyncManagerFlag.NoGenesisSync}
else:
{}
columnManagerModes =
if node.config.longRangeSync != LongRangeSyncMode.Lenient:
{ColumnSyncerMode.NoGenesisSync}
else:
{}
columnSyncerFlags =
if node.config.columnSyncerStrategy == ColumnSyncerStrategy.Impartial:
{ColumnSyncerFlag.Impartial}
else:
{ColumnSyncerFlag.Greedy}

columnManager = newColumnManager[Peer, PeerId](
node.network.peerPool, dag.cfg, supernode, custody_columns_set,
custody_columns_list, dag.cfg.FULU_FORK_EPOCH,
dag.cfg.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
dag.cfg.MAX_BLOBS_PER_BLOCK_ELECTRA,
ColumnSyncerDirection.Forward, getLocalHeadSlot,
getLocalWallSlot, getFirstSlotAtFinalizedEpoch, getBackfillSlot,
getFrontfillSlot, isWithinWeakSubjectivityPeriod,
dag.tail.slot, peerdasBlockVerifier,
shutdownEvent = node.shutdownEvent,
flags = columnSyncerFlags,
modes = columnManagerModes)
syncManager = newSyncManager[Peer, PeerId](
node.network.peerPool,
dag.cfg.DENEB_FORK_EPOCH,
Expand Down Expand Up @@ -645,6 +679,7 @@ proc initFullNode(
node.blockProcessor = blockProcessor
node.consensusManager = consensusManager
node.requestManager = requestManager
node.columnManager = columnManager
node.syncManager = syncManager
node.backfiller = backfiller
node.untrustedManager = untrustedManager
Expand Down Expand Up @@ -1895,6 +1930,28 @@ func formatNextConsensusFork(
(if withVanityArt: nextConsensusFork.getVanityMascot & " " else: "") &
$nextConsensusFork & ":" & $nextForkEpoch)

func columnSyncStatus(node: BeaconNode, wallSlot: Slot): string =
let optimisticHead = not node.dag.head.executionValid
if node.columnManager.inProgress:
let
optimisticSuffix =
if optimisticHead:
"/opt"
else:
""
lightClientSuffix =
if node.consensusManager[].shouldSyncOptimistically(wallSlot):
" - lc: " & $shortLog(node.consensusManager[].optimisticHead)
else:
""
node.columnManager.syncStatus & optimisticSuffix & lightClientSuffix
elif node.backfiller.inProgress:
"backfill: " & node.backfiller.syncStatus
elif optimistic_head:
"synced/opt"
else:
"synced"

func syncStatus(node: BeaconNode, wallSlot: Slot): string =
node.syncOverseer.statusMsg.valueOr:
let optimisticHead = not node.dag.head.executionValid
Expand Down Expand Up @@ -1946,6 +2003,7 @@ proc onSlotStart(node: BeaconNode, wallTime: BeaconTime,
slot = shortLog(wallSlot)
epoch = shortLog(wallSlot.epoch)
sync = node.syncStatus(wallSlot)
columnSync = node.columnSyncStatus(wallSlot)
peers = len(node.network.peerPool)
head = shortLog(node.dag.head)
finalized = shortLog(getStateField(
Expand Down Expand Up @@ -2256,6 +2314,7 @@ proc run(node: BeaconNode) {.raises: [CatchableError].} =
node.network.cfg.FULU_FORK_EPOCH:
node.requestManager.switchToColumnLoop()
node.syncOverseer.start()
node.columnManager.start()

waitFor node.updateGossipStatus(wallSlot)

Expand Down Expand Up @@ -2438,6 +2497,9 @@ when not defined(windows):

of "sync_status":
node.syncStatus(node.currentSlot)

of "column_sync_status":
node.columnSyncStatus(node.currentSlot)
else:
# We ignore typos for now and just render the expression
# as it was written. TODO: come up with a good way to show
Expand Down
Loading
Loading