Skip to content

Commit

Permalink
remove trusted node sync from default cli command
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-parmar committed Oct 5, 2024
1 parent ac32170 commit 0fec41b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 64 deletions.
32 changes: 20 additions & 12 deletions beacon_chain/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ type

requireEngineAPI* {.
hidden # Deprecated > 22.9
desc: "Require Nimbus to be configured with an Engine API end-point after the Bellatrix fork epoch"
desc: "Require Nimbus to be configured with an Engine API end-point after the Bellatrix fork epoch (deprecated)"
name: "require-engine-api-in-bellatrix" .}: Option[bool]

nonInteractive* {.
Expand Down Expand Up @@ -341,7 +341,8 @@ type
name: "weak-subjectivity-checkpoint" .}: Option[Checkpoint]

externalBeaconApiUrl* {.
desc: "External beacon API to use for syncing (on empty database)"
hidden
desc: "deprecated for removal. Use `build/nimbus_beacon_node trustedNodeSync` instead"
name: "external-beacon-api-url" .}: Option[string]

syncLightClient* {.
Expand All @@ -350,15 +351,13 @@ type
name: "sync-light-client" .}: bool

trustedBlockRoot* {.
desc: "Recent trusted finalized block root to sync from external " &
"beacon API (with `--external-beacon-api-url`). " &
"Uses the light client sync protocol to obtain the latest " &
"finalized checkpoint (LC is initialized from trusted block root)"
hidden
desc: "deprecated for removal. Use `build/nimbus_beacon_node trustedNodeSync` instead"
name: "trusted-block-root" .}: Option[Eth2Digest]

trustedStateRoot* {.
desc: "Recent trusted finalized state root to sync from external " &
"beacon API (with `--external-beacon-api-url`)"
hidden
desc: "deprecated for removal. Use `build/nimbus_beacon_node trustedNodeSync` instead"
name: "trusted-state-root" .}: Option[Eth2Digest]

finalizedCheckpointState* {.
Expand All @@ -379,7 +378,7 @@ type

finalizedCheckpointBlock* {.
hidden
desc: "SSZ file specifying a recent finalized block"
desc: "deprecated for removal"
name: "finalized-checkpoint-block" .}: Option[InputFile]

nodeName* {.
Expand Down Expand Up @@ -448,19 +447,28 @@ type
rpcEnabled* {.
# Deprecated > 1.7.0
hidden
desc: "Deprecated for removal"
desc: "Deprecated for removal. 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."
name: "rpc" .}: Option[bool]

rpcPort* {.
# Deprecated > 1.7.0
hidden
desc: "Deprecated for removal"
desc: "Deprecated for removal. 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."
name: "rpc-port" .}: Option[Port]

rpcAddress* {.
# Deprecated > 1.7.0
hidden
desc: "Deprecated for removal"
desc: "Deprecated for removal. 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."
name: "rpc-address" .}: Option[IpAddress]

restEnabled* {.
Expand Down
60 changes: 8 additions & 52 deletions beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -640,55 +640,6 @@ proc init*(T: type BeaconNode,
RestVersioned[ForkedLightClientOptimisticUpdate]]())
db = BeaconChainDB.new(config.databaseDir, cfg, inMemory = false)

if config.externalBeaconApiUrl.isSome and ChainDAGRef.isInitialized(db).isErr:
let trustedBlockRoot =
if config.trustedStateRoot.isSome or config.trustedBlockRoot.isSome:
config.trustedBlockRoot
elif cfg.ALTAIR_FORK_EPOCH == GENESIS_EPOCH:
# Sync can be bootstrapped from the genesis block root
if genesisState.isNil:
genesisState = await fetchGenesisState(
metadata, config.genesisState, config.genesisStateUrl)
if not genesisState.isNil:
let genesisBlockRoot = get_initial_beacon_block(genesisState[]).root
notice "Neither `--trusted-block-root` nor `--trusted-state-root` " &
"provided with `--external-beacon-api-url`, " &
"falling back to genesis block root",
externalBeaconApiUrl = config.externalBeaconApiUrl.get,
trustedBlockRoot = config.trustedBlockRoot,
trustedStateRoot = config.trustedStateRoot,
genesisBlockRoot = $genesisBlockRoot
some genesisBlockRoot
else:
none[Eth2Digest]()
else:
none[Eth2Digest]()
if config.trustedStateRoot.isNone and trustedBlockRoot.isNone:
warn "Ignoring `--external-beacon-api-url`, neither " &
"`--trusted-block-root` nor `--trusted-state-root` provided",
externalBeaconApiUrl = config.externalBeaconApiUrl.get,
trustedBlockRoot = config.trustedBlockRoot,
trustedStateRoot = config.trustedStateRoot
else:
if genesisState.isNil:
genesisState = await fetchGenesisState(
metadata, config.genesisState, config.genesisStateUrl)
await db.doRunTrustedNodeSync(
metadata,
config.databaseDir,
config.eraDir,
config.externalBeaconApiUrl.get,
config.trustedStateRoot.map do (x: Eth2Digest) -> string:
"0x" & x.data.toHex,
trustedBlockRoot,
backfill = false,
reindex = false,
downloadDepositSnapshot = false,
genesisState)

if config.finalizedCheckpointBlock.isSome:
warn "--finalized-checkpoint-block has been deprecated, ignoring"

let checkpointState = if config.finalizedCheckpointState.isSome:
let checkpointStatePath = config.finalizedCheckpointState.get.string
let tmp = try:
Expand Down Expand Up @@ -823,9 +774,6 @@ proc init*(T: type BeaconNode,
engineApiUrls,
eth1Network)

if config.rpcEnabled.isSome:
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."

let restServer = if config.restEnabled:
RestServerRef.init(config.restAddress, config.restPort,
config.restAllowedOrigin,
Expand Down Expand Up @@ -2231,12 +2179,20 @@ proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.rai
if config.option.isSome:
warn "Config option is deprecated",
option = config.option.get

ignoreDeprecatedOption requireEngineAPI
ignoreDeprecatedOption safeSlotsToImportOptimistically
ignoreDeprecatedOption terminalTotalDifficultyOverride
ignoreDeprecatedOption optimistic
ignoreDeprecatedOption validatorMonitorTotals
ignoreDeprecatedOption web3ForcePolling
ignoreDeprecatedOption externalBeaconApiUrl
ignoreDeprecatedOption trustedStateRoot
ignoreDeprecatedOption trustedBlockRoot
ignoreDeprecatedOption finalizedCheckpointBlock
ignoreDeprecatedOption rpcEnabled
ignoreDeprecatedOption rpcPort
ignoreDeprecatedOption rpcAddress

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

Expand Down

0 comments on commit 0fec41b

Please sign in to comment.