Skip to content

Commit 45db8b1

Browse files
author
pmmiranda
committed
- Removed execution wrapper and give 'run' procedure public scope.
- Updated consensus wrapper with latest beacon node changes
1 parent 49417ec commit 45db8b1

File tree

4 files changed

+40
-372
lines changed

4 files changed

+40
-372
lines changed

execution_chain/nimbus_execution_client.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ proc preventLoadingDataDirForTheWrongNetwork(db: CoreDbRef; conf: NimbusConf) =
192192
expected=calculatedId
193193
quit(QuitFailure)
194194

195-
proc run(nimbus: NimbusNode, conf: NimbusConf) =
195+
proc run*(nimbus: NimbusNode, conf: NimbusConf) =
196196
info "Launching execution client",
197197
version = FullVersionStr,
198198
conf

nimbus/consensus/wrapper_consensus.nim

Lines changed: 37 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import
2121
beacon_chain/networking/[topic_params, network_metadata_downloads],
2222
beacon_chain/rpc/[rest_api, state_ttl_cache],
2323
beacon_chain/spec/datatypes/[altair, bellatrix, phase0],
24-
beacon_chain/spec/
25-
[deposit_snapshots, engine_authentication, weak_subjectivity, peerdas_helpers],
24+
beacon_chain/spec/[engine_authentication, weak_subjectivity, peerdas_helpers],
2625
beacon_chain/sync/[sync_protocol, light_client_protocol, sync_overseer],
2726
beacon_chain/validators/[keystore_management, beacon_validators],
2827
beacon_chain/[
@@ -110,7 +109,6 @@ proc doRunTrustedNodeSync(
110109
trustedBlockRoot: Option[Eth2Digest],
111110
backfill: bool,
112111
reindex: bool,
113-
downloadDepositSnapshot: bool,
114112
genesisState: ref ForkedHashedBeaconState,
115113
) {.async.} =
116114
let syncTarget =
@@ -128,7 +126,7 @@ proc doRunTrustedNodeSync(
128126

129127
await db.doTrustedNodeSync(
130128
metadata.cfg, databaseDir, eraDir, restUrl, syncTarget, backfill, reindex,
131-
downloadDepositSnapshot, genesisState,
129+
genesisState,
132130
)
133131

134132
func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs =
@@ -141,13 +139,17 @@ func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs =
141139
onUpgradeToDeneb: denebColor,
142140
onUpgradeToElectra: electraColor,
143141
onKnownCompoundingChange: electraBlink,
142+
onUpgradeToFulu: fuluColor,
143+
onBlobParametersUpdate: fuluColor,
144144
)
145145
of StdoutLogKind.NoColors:
146146
VanityLogs(
147147
onKnownBlsToExecutionChange: capellaMono,
148148
onUpgradeToDeneb: denebMono,
149149
onUpgradeToElectra: electraMono,
150150
onKnownCompoundingChange: electraMono,
151+
onUpgradeToFulu: fuluMono,
152+
onBlobParametersUpdate: fuluMono,
151153
)
152154
of StdoutLogKind.Json, StdoutLogKind.None:
153155
VanityLogs(
@@ -167,11 +169,19 @@ func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs =
167169
proc() =
168170
notice "🦒 Compounding is activated 🦒"
169171
),
172+
onUpgradeToFulu: (
173+
proc() =
174+
notice "🐅 Blobs columnized 🐅"
175+
),
176+
onBlobParametersUpdate: (
177+
proc() =
178+
notice "🐅 Blob parameters updated 🐅"
179+
),
170180
)
171181

172182
func getVanityMascot(consensusFork: ConsensusFork): string =
173183
case consensusFork
174-
of ConsensusFork.Fulu: ""
184+
of ConsensusFork.Fulu: "🐅"
175185
of ConsensusFork.Electra: "🦒"
176186
of ConsensusFork.Deneb: "🐟"
177187
of ConsensusFork.Capella: "🦉"
@@ -368,11 +378,6 @@ proc initFullNode(
368378
static:
369379
doAssert (elManager is ref)
370380
return proc(dag: ChainDAGRef, data: FinalizationInfoObject) =
371-
if elManager != nil:
372-
let finalizedEpochRef = dag.getFinalizedEpochRef()
373-
discard trackFinalizedState(
374-
elManager, finalizedEpochRef.eth1_data, finalizedEpochRef.eth1_deposit_index
375-
)
376381
node.updateLightClientFromDag()
377382
let eventData =
378383
if node.currentSlot().epoch() >= dag.cfg.BELLATRIX_FORK_EPOCH:
@@ -434,7 +439,9 @@ proc initFullNode(
434439
onElectraAttesterSlashingAdded,
435440
)
436441
)
437-
blobQuarantine = newClone(BlobQuarantine.init(dag.cfg, onBlobSidecarAdded))
442+
blobQuarantine = newClone(
443+
BlobQuarantine.init(dag.cfg, dag.db.getQuarantineDB(), 10, onBlobSidecarAdded)
444+
)
438445
dataColumnQuarantine = newClone(DataColumnQuarantine.init())
439446
supernode = node.config.peerdasSupernode
440447
localCustodyGroups =
@@ -457,6 +464,7 @@ proc initFullNode(
457464
blockProcessor = BlockProcessor.new(
458465
config.dumpEnabled, config.dumpDirInvalid, config.dumpDirIncoming, batchVerifier,
459466
consensusManager, node.validatorMonitor, blobQuarantine, getBeaconTime,
467+
config.invalidBlockRoots,
460468
)
461469

462470
blockVerifier = proc(
@@ -486,21 +494,18 @@ proc initFullNode(
486494
): Future[Result[void, VerifierError]] {.async: (raises: [CancelledError]).} =
487495
withBlck(signedBlock):
488496
when consensusFork >= ConsensusFork.Deneb:
489-
if not blobQuarantine[].hasBlobs(forkyBlck):
497+
let bres = blobQuarantine[].popSidecars(forkyBlck.root, forkyBlck)
498+
if bres.isSome():
499+
await blockProcessor[].addBlock(
500+
MsgSource.gossip, signedBlock, bres, maybeFinalized = maybeFinalized
501+
)
502+
else:
490503
# We don't have all the blobs for this block, so we have
491504
# to put it in blobless quarantine.
492505
if not quarantine[].addBlobless(dag.finalizedHead.slot, forkyBlck):
493506
err(VerifierError.UnviableFork)
494507
else:
495508
err(VerifierError.MissingParent)
496-
else:
497-
let blobs = blobQuarantine[].popBlobs(forkyBlck.root, forkyBlck)
498-
await blockProcessor[].addBlock(
499-
MsgSource.gossip,
500-
signedBlock,
501-
Opt.some(blobs),
502-
maybeFinalized = maybeFinalized,
503-
)
504509
else:
505510
await blockProcessor[].addBlock(
506511
MsgSource.gossip,
@@ -875,7 +880,6 @@ proc init*(
875880
trustedBlockRoot,
876881
backfill = false,
877882
reindex = false,
878-
downloadDepositSnapshot = false,
879883
genesisState,
880884
)
881885

@@ -908,24 +912,6 @@ proc init*(
908912
else:
909913
nil
910914

911-
if config.finalizedDepositTreeSnapshot.isSome:
912-
let
913-
depositTreeSnapshotPath = config.finalizedDepositTreeSnapshot.get.string
914-
snapshot =
915-
try:
916-
SSZ.loadFile(depositTreeSnapshotPath, DepositTreeSnapshot)
917-
except SszError as err:
918-
fatal "Deposit tree snapshot loading failed",
919-
err = formatMsg(err, depositTreeSnapshotPath)
920-
quit 1
921-
except CatchableError as err:
922-
fatal "Failed to read deposit tree snapshot file", err = err.msg
923-
quit 1
924-
depositContractSnapshot = DepositContractSnapshot.init(snapshot).valueOr:
925-
fatal "Invalid deposit tree snapshot file"
926-
quit 1
927-
db.putDepositContractSnapshot(depositContractSnapshot)
928-
929915
let engineApiUrls = config.engineApiUrls
930916

931917
if engineApiUrls.len == 0:
@@ -1033,10 +1019,7 @@ proc init*(
10331019
config.weakSubjectivityCheckpoint.get, beaconClock
10341020
)
10351021

1036-
let elManager = ELManager.new(
1037-
cfg, metadata.depositContractBlock, metadata.depositContractBlockHash, db,
1038-
engineApiUrls, eth1Network,
1039-
)
1022+
let elManager = ELManager.new(engineApiUrls, eth1Network)
10401023

10411024
if config.rpcEnabled.isSome:
10421025
warn "Nimbus's JSON-RPC server has been removed. This includes the --rpc, --rpc-port, and --rpc-address configuration options. https://nimbus.guide/rest-api.html shows how to enable and configure the REST Beacon API server which replaces it."
@@ -1535,6 +1518,7 @@ proc maybeUpdateActionTrackerNextEpoch(
15351518
shufflingRef = node.dag.getShufflingRef(node.dag.head, nextEpoch, false).valueOr:
15361519
# epochRefFallback() won't work in this case either
15371520
return
1521+
# using the separate method of proposer indices calculation in Fulu
15381522
nextEpochProposers = get_beacon_proposer_indices(
15391523
forkyState.data, shufflingRef.shuffled_active_validator_indices, nextEpoch
15401524
)
@@ -1753,6 +1737,9 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} =
17531737
node.attachedValidators[].slashingProtection
17541738
# pruning is only done if the DB is set to pruning mode.
17551739
.pruneAfterFinalization(node.dag.finalizedHead.slot.epoch())
1740+
node.processor.blobQuarantine[].pruneAfterFinalization(
1741+
node.dag.finalizedHead.slot.epoch()
1742+
)
17561743

17571744
# Delay part of pruning until latency critical duties are done.
17581745
# The other part of pruning, `pruneBlocksDAG`, is done eagerly.
@@ -1922,26 +1909,8 @@ func formatNextConsensusFork(node: BeaconNode, withVanityArt = false): Opt[strin
19221909
$nextConsensusFork & ":" & $nextForkEpoch
19231910
)
19241911

1925-
func syncStatus(node: BeaconNode, wallSlot: Slot): string =
1926-
node.syncOverseer.statusMsg.valueOr:
1927-
let optimisticHead = not node.dag.head.executionValid
1928-
if node.syncManager.inProgress:
1929-
let
1930-
optimisticSuffix = if optimisticHead: "/opt" else: ""
1931-
lightClientSuffix =
1932-
if node.consensusManager[].shouldSyncOptimistically(wallSlot):
1933-
" - lc: " & $shortLog(node.consensusManager[].optimisticHead)
1934-
else:
1935-
""
1936-
node.syncManager.syncStatus & optimisticSuffix & lightClientSuffix
1937-
elif node.untrustedManager.inProgress:
1938-
"untrusted: " & node.untrustedManager.syncStatus
1939-
elif node.backfiller.inProgress:
1940-
"backfill: " & node.backfiller.syncStatus
1941-
elif optimisticHead:
1942-
"synced/opt"
1943-
else:
1944-
"synced"
1912+
proc syncStatus(node: BeaconNode, wallSlot: Slot): string =
1913+
node.syncOverseer.syncStatusMessage()
19451914

19461915
when defined(windows):
19471916
from winservice import establishWindowsService, reportServiceStatusSuccess
@@ -2120,7 +2089,7 @@ proc installMessageValidators(node: BeaconNode) =
21202089
)
21212090

21222091
# beacon_aggregate_and_proof
2123-
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
2092+
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
21242093
when consensusFork >= ConsensusFork.Electra:
21252094
node.network.addAsyncValidator(
21262095
getAggregateAndProofsTopic(digest),
@@ -2530,6 +2499,7 @@ proc doRunBeaconNode(
25302499
ignoreDeprecatedOption optimistic
25312500
ignoreDeprecatedOption validatorMonitorTotals
25322501
ignoreDeprecatedOption web3ForcePolling
2502+
ignoreDeprecatedOption finalizedDepositTreeSnapshot
25332503

25342504
createPidFile(config.dataDir.string / "beacon_node.pid")
25352505

@@ -2640,12 +2610,8 @@ proc doWeb3Cmd(
26402610
) {.raises: [CatchableError].} =
26412611
case config.web3Cmd
26422612
of Web3Cmd.test:
2643-
let metadata = config.loadEth2Network()
2644-
26452613
waitFor testWeb3Provider(
2646-
config.web3TestUrl,
2647-
metadata.cfg.DEPOSIT_CONTRACT_ADDRESS,
2648-
rng.loadJwtSecret(config, allowCreate = true),
2614+
config.web3TestUrl, rng.loadJwtSecret(config, allowCreate = true)
26492615
)
26502616

26512617
proc doSlashingExport(conf: BeaconNodeConf) {.raises: [IOError].} =
@@ -2659,7 +2625,7 @@ proc doSlashingExport(conf: BeaconNodeConf) {.raises: [IOError].} =
26592625
db.exportSlashingInterchange(interchange, conf.exportedValidators)
26602626
echo "Export finished: '", dir / filetrunc & ".sqlite3", "' into '", interchange, "'"
26612627

2662-
proc doSlashingImport(conf: BeaconNodeConf) {.raises: [SerializationError, IOError].} =
2628+
proc doSlashingImport(conf: BeaconNodeConf) {.raises: [IOError].} =
26632629
let
26642630
dir = conf.validatorsDir()
26652631
filetrunc = SlashingDbName
@@ -2730,7 +2696,7 @@ proc handleStartUpCmd*(config: var BeaconNodeConf) {.raises: [CatchableError].}
27302696
waitFor db.doRunTrustedNodeSync(
27312697
metadata, config.databaseDir, config.eraDir, config.trustedNodeUrl,
27322698
config.stateId, config.lcTrustedBlockRoot, config.backfillBlocks, config.reindex,
2733-
config.downloadDepositSnapshot, genesisState,
2699+
genesisState,
27342700
)
27352701
db.close()
27362702

nimbus/execution/execution_layer.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
{.push raises: [].}
99

1010
import
11-
std/[atomics, os],
11+
std/[atomics],
1212
chronicles,
1313
results,
1414
../conf,
1515
../common/utils,
16-
./wrapper_execution,
16+
../../execution_chain/nimbus_execution_client,
1717
../../execution_chain/config,
1818
../../execution_chain/nimbus_desc
1919

0 commit comments

Comments
 (0)