rename light client config parameters (#3740)

For consistency with other options, use a common prefix for light client
data configuration options.

* `--serve-light-client-data` --> `--light-client-data-serve`
* `--import-light-client-data` --> `--light-client-data-import-mode`

No deprecation of the old identifiers as they were only sparingly used
and all usage can be easily updated without interferance.
This commit is contained in:
Etan Kissling 2022-06-14 11:03:39 +02:00 committed by GitHub
parent 21a1f7eeb7
commit 52ba4f7999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 58 additions and 58 deletions

View File

@ -310,8 +310,8 @@ define CONNECT_TO_NETWORK_IN_DEV_MODE
--log-level="DEBUG; TRACE:discv5,networking; REQUIRED:none; DISABLED:none" \
--data-dir=build/data/shared_$(1)_$(NODE_ID) \
--light-client-enable=on \
--serve-light-client-data=on \
--import-light-client-data=only-new \
--light-client-data-serve=on \
--light-client-data-import-mode=only-new \
--dump $(NODE_PARAMS)
endef

View File

@ -98,7 +98,7 @@ proc startLightClient*(node: BeaconNode) =
proc installLightClientMessageValidators*(node: BeaconNode) =
let eth2Processor =
if node.config.serveLightClientData.get:
if node.config.lightClientDataServe.get:
# Process gossip using both full node and light client
node.processor
elif node.config.lightClientEnable.get:
@ -113,7 +113,7 @@ proc installLightClientMessageValidators*(node: BeaconNode) =
proc updateLightClientGossipStatus*(
node: BeaconNode, slot: Slot, dagIsBehind: bool) =
let isBehind =
if node.config.serveLightClientData.get:
if node.config.lightClientDataServe.get:
# Forward DAG's readiness to handle light client gossip
dagIsBehind
else:

View File

@ -29,7 +29,7 @@ import
./filepath
from consensus_object_pools/block_pools_types_light_client
import ImportLightClientData
import LightClientDataImportMode
export
uri, nat, enr,
@ -445,16 +445,16 @@ type
desc: "A file specifying the authorization token required for accessing the keymanager API"
name: "keymanager-token-file" }: Option[InputFile]
serveLightClientData* {.
lightClientDataServe* {.
hidden
desc: "BETA: Serve data for enabling light clients to stay in sync with the network"
name: "serve-light-client-data"}: Option[bool]
name: "light-client-data-serve"}: Option[bool]
importLightClientData* {.
lightClientDataImportMode* {.
hidden
desc: "BETA: Which classes of light client data to import. " &
"Must be one of: none, only-new, full (slow startup), on-demand (may miss validator duties)"
name: "import-light-client-data"}: Option[ImportLightClientData]
name: "light-client-data-import-mode"}: Option[LightClientDataImportMode]
inProcessValidators* {.
desc: "Disable the push model (the beacon node tells a signing process with the private keys of the validators what to sign and when) and load the validators in the beacon node itself"

View File

@ -185,10 +185,10 @@ type
cfg*: RuntimeConfig
serveLightClientData*: bool
lightClientDataServe*: bool
## Whether to make local light client data available or not
importLightClientData*: ImportLightClientData
lightClientDataImportMode*: LightClientDataImportMode
## Which classes of light client data to import
epochRefs*: array[32, EpochRef]

View File

@ -23,7 +23,7 @@ type
OnLightClientOptimisticUpdateCallback* =
proc(data: altair.LightClientOptimisticUpdate) {.gcsafe, raises: [Defect].}
ImportLightClientData* {.pure.} = enum
LightClientDataImportMode* {.pure.} = enum
## Controls which classes of light client data are imported.
None = "none"
## Import no light client data.

View File

@ -682,8 +682,8 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
onReorgCb: OnReorgCallback = nil, onFinCb: OnFinalizedCallback = nil,
onLCFinalityUpdateCb: OnLightClientFinalityUpdateCallback = nil,
onLCOptimisticUpdateCb: OnLightClientOptimisticUpdateCallback = nil,
serveLightClientData = false,
importLightClientData = ImportLightClientData.None,
lightClientDataServe = false,
lightClientDataImportMode = LightClientDataImportMode.None,
vanityLogs = default(VanityLogs)): ChainDAGRef =
cfg.checkForkConsistency()
@ -720,8 +720,8 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
vanityLogs: vanityLogs,
serveLightClientData: serveLightClientData,
importLightClientData: importLightClientData,
lightClientDataServe: lightClientDataServe,
lightClientDataImportMode: lightClientDataImportMode,
onBlockAdded: onBlockCb,
onHeadChanged: onHeadCb,

View File

@ -178,7 +178,7 @@ proc cacheLightClientData*(
proc deleteLightClientData*(dag: ChainDAGRef, bid: BlockId) =
## Delete cached light client data for a given block. This needs to be called
## when a block becomes unreachable due to finalization of a different fork.
if dag.importLightClientData == ImportLightClientData.None:
if dag.lightClientDataImportMode == LightClientDataImportMode.None:
return
dag.lightClientCache.data.del bid
@ -346,7 +346,7 @@ proc processNewBlockForLightClient*(
signedBlock: ForkyTrustedSignedBeaconBlock,
parentBid: BlockId) =
## Update light client data with information from a new block.
if dag.importLightClientData == ImportLightClientData.None:
if dag.lightClientDataImportMode == LightClientDataImportMode.None:
return
if signedBlock.message.slot < dag.computeEarliestLightClientSlot:
return
@ -365,7 +365,7 @@ proc processNewBlockForLightClient*(
proc processHeadChangeForLightClient*(dag: ChainDAGRef) =
## Update light client data to account for a new head block.
## Note that `dag.finalizedHead` is not yet updated when this is called.
if dag.importLightClientData == ImportLightClientData.None:
if dag.lightClientDataImportMode == LightClientDataImportMode.None:
return
if dag.head.slot < dag.computeEarliestLightClientSlot:
return
@ -397,7 +397,7 @@ proc processFinalizationForLightClient*(
## Prune cached data that is no longer useful for creating future
## `LightClientUpdate` and `LightClientBootstrap` instances.
## This needs to be called whenever `finalized_checkpoint` changes.
if dag.importLightClientData == ImportLightClientData.None:
if dag.lightClientDataImportMode == LightClientDataImportMode.None:
return
let
earliestSlot = dag.computeEarliestLightClientSlot
@ -653,10 +653,10 @@ proc initLightClientUpdateForPeriod(
proc initLightClientCache*(dag: ChainDAGRef) =
## Initialize cached light client data
if dag.importLightClientData == ImportLightClientData.None:
if dag.lightClientDataImportMode == LightClientDataImportMode.None:
return
dag.lightClientCache.importTailSlot = dag.tail.slot
if dag.importLightClientData == ImportLightClientData.OnlyNew:
if dag.lightClientDataImportMode == LightClientDataImportMode.OnlyNew:
dag.lightClientCache.importTailSlot = dag.head.slot
var earliestSlot = dag.computeEarliestLightClientSlot
if dag.head.slot < earliestSlot:
@ -729,7 +729,7 @@ proc initLightClientCache*(dag: ChainDAGRef) =
initDur = lightClientEndTick - lightClientStartTick
# Import historic data
if dag.importLightClientData == ImportLightClientData.Full:
if dag.lightClientDataImportMode == LightClientDataImportMode.Full:
let earliestPeriod = earliestSlot.sync_committee_period
for period in earliestPeriod ..< finalizedPeriod:
dag.initLightClientBootstrapForPeriod(period)
@ -738,7 +738,7 @@ proc initLightClientCache*(dag: ChainDAGRef) =
proc getLightClientBootstrap*(
dag: ChainDAGRef,
blockRoot: Eth2Digest): Opt[altair.LightClientBootstrap] =
if not dag.serveLightClientData:
if not dag.lightClientDataServe:
return err()
let bdata = dag.getForkedBlock(blockRoot).valueOr:
@ -757,7 +757,7 @@ proc getLightClientBootstrap*(
return err()
var cachedBootstrap = dag.lightClientCache.bootstrap.getOrDefault(slot)
if cachedBootstrap.current_sync_committee_branch.isZeroMemory:
if dag.importLightClientData == ImportLightClientData.OnDemand:
if dag.lightClientDataImportMode == LightClientDataImportMode.OnDemand:
let bsi = ? dag.getExistingBlockIdAtSlot(slot)
var tmpState = assignClone(dag.headState)
dag.withUpdatedExistingState(tmpState[], bsi) do:
@ -790,10 +790,10 @@ proc getLightClientBootstrap*(
proc getLightClientUpdateForPeriod*(
dag: ChainDAGRef,
period: SyncCommitteePeriod): Option[altair.LightClientUpdate] =
if not dag.serveLightClientData:
if not dag.lightClientDataServe:
return
if dag.importLightClientData == ImportLightClientData.OnDemand:
if dag.lightClientDataImportMode == LightClientDataImportMode.OnDemand:
dag.initLightClientUpdateForPeriod(period)
result = some(dag.lightClientCache.best.getOrDefault(period))
let numParticipants = countOnes(result.get.sync_aggregate.sync_committee_bits)
@ -802,7 +802,7 @@ proc getLightClientUpdateForPeriod*(
proc getLightClientFinalityUpdate*(
dag: ChainDAGRef): Option[altair.LightClientFinalityUpdate] =
if not dag.serveLightClientData:
if not dag.lightClientDataServe:
return
result = some(dag.lightClientCache.latest)
@ -812,7 +812,7 @@ proc getLightClientFinalityUpdate*(
proc getLightClientOptimisticUpdate*(
dag: ChainDAGRef): Option[altair.LightClientOptimisticUpdate] =
if not dag.serveLightClientData:
if not dag.lightClientDataServe:
return
result = some(dag.lightClientCache.latest.toOptimistic)

View File

@ -1706,7 +1706,7 @@ proc new*(T: type Eth2Node,
for msg in proto.messages:
when config is BeaconNodeConf:
if msg.isLightClientRequest and not config.serveLightClientData.get:
if msg.isLightClientRequest and not config.lightClientDataServe.get:
continue
elif config is LightClientConf:
if not msg.isRequired:

View File

@ -19,7 +19,7 @@ import
../spec/datatypes/phase0
from ../consensus_object_pools/block_pools_types_light_client
import ImportLightClientData
import LightClientDataImportMode
# ATTENTION! This file will produce a large C file, because we are inlining
# genesis states as C literals in the generated code (and blobs in the final
@ -44,8 +44,8 @@ type
Eth2NetworkConfigDefaults* = object
## Network specific config defaults
lightClientEnable*: bool
serveLightClientData*: bool
importLightClientData*: ImportLightClientData
lightClientDataServe*: bool
lightClientDataImportMode*: LightClientDataImportMode
Eth2NetworkMetadata* = object
case incompatible*: bool
@ -197,13 +197,13 @@ proc loadEth2NetworkMetadata*(path: string, eth1Network = none(Eth1Network)): Et
Eth2NetworkConfigDefaults(
lightClientEnable:
false, # Only produces debug logs so far
serveLightClientData:
lightClientDataServe:
shouldSupportLightClient,
importLightClientData:
lightClientDataImportMode:
if shouldSupportLightClient:
ImportLightClientData.OnlyNew
LightClientDataImportMode.OnlyNew
else:
ImportLightClientData.None
LightClientDataImportMode.None
)
Eth2NetworkMetadata(

View File

@ -170,18 +170,18 @@ proc loadChainDag(
if config.verifyFinalization: {verifyFinalization}
else: {}
onLightClientFinalityUpdateCb =
if config.serveLightClientData.get: onLightClientFinalityUpdate
if config.lightClientDataServe.get: onLightClientFinalityUpdate
else: nil
onLightClientOptimisticUpdateCb =
if config.serveLightClientData.get: onLightClientOptimisticUpdate
if config.lightClientDataServe.get: onLightClientOptimisticUpdate
else: nil
dag = ChainDAGRef.init(
cfg, db, validatorMonitor, chainDagFlags, config.eraDir,
onBlockAdded, onHeadChanged, onChainReorg,
onLCFinalityUpdateCb = onLightClientFinalityUpdateCb,
onLCOptimisticUpdateCb = onLightClientOptimisticUpdateCb,
serveLightClientData = config.serveLightClientData.get,
importLightClientData = config.importLightClientData.get,
lightClientDataServe = config.lightClientDataServe.get,
lightClientDataImportMode = config.lightClientDataImportMode.get,
vanityLogs = getPandas(detectTTY(config.logStdout)))
databaseGenesisValidatorsRoot =
getStateField(dag.headState, genesis_validators_root)
@ -1707,8 +1707,8 @@ proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref BrHmacDrbgContext) {.r
config.`field` = some metadata.configDefaults.`field`
applyConfigDefault(lightClientEnable)
applyConfigDefault(serveLightClientData)
applyConfigDefault(importLightClientData)
applyConfigDefault(lightClientDataServe)
applyConfigDefault(lightClientDataImportMode)
let node = BeaconNode.init(
metadata.cfg,

View File

@ -535,7 +535,7 @@ p2pProtocol BeaconSync(version = 1,
isLightClientRequest = true).} =
trace "Received LC bootstrap request", peer, blockRoot
let dag = peer.networkState.dag
doAssert dag.serveLightClientData
doAssert dag.lightClientDataServe
peer.updateRequestQuota(lightClientBootstrapLookupCost)
peer.awaitNonNegativeRequestQuota()
@ -565,7 +565,7 @@ p2pProtocol BeaconSync(version = 1,
isLightClientRequest = true).} =
trace "Received LC updates by range request", peer, startPeriod, reqCount
let dag = peer.networkState.dag
doAssert dag.serveLightClientData
doAssert dag.lightClientDataServe
let
headPeriod = dag.head.slot.sync_committee_period
@ -605,7 +605,7 @@ p2pProtocol BeaconSync(version = 1,
isLightClientRequest = true).} =
trace "Received LC finality update request", peer
let dag = peer.networkState.dag
doAssert dag.serveLightClientData
doAssert dag.lightClientDataServe
peer.awaitNonNegativeRequestQuota()
@ -632,7 +632,7 @@ p2pProtocol BeaconSync(version = 1,
isLightClientRequest = true).} =
trace "Received LC optimistic update request", peer
let dag = peer.networkState.dag
doAssert dag.serveLightClientData
doAssert dag.lightClientDataServe
peer.awaitNonNegativeRequestQuota()

View File

@ -282,7 +282,7 @@ proc handleLightClientUpdates(node: BeaconNode, slot: Slot) {.async.} =
notice "LC optimistic update sent", message = shortLog(msg)
proc scheduleSendingLightClientUpdates(node: BeaconNode, slot: Slot) =
if not node.config.serveLightClientData.get:
if not node.config.lightClientDataServe.get:
return
if node.lightClientPool[].broadcastGossipFut != nil:
return

View File

@ -684,8 +684,8 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
--rest-port="$(( BASE_REST_PORT + NUM_NODE ))" \
--metrics-port="$(( BASE_METRICS_PORT + NUM_NODE ))" \
--light-client-enable=on \
--serve-light-client-data=on \
--import-light-client-data=only-new \
--light-client-data-serve=on \
--light-client-data-import-mode=only-new \
${EXTRA_ARGS} \
&> "${DATA_DIR}/log${NUM_NODE}.txt" &

View File

@ -160,8 +160,8 @@ proc startSingleNodeNetwork {.raises: [CatchableError, Defect].} =
"--keymanager-port=" & $keymanagerPort,
"--keymanager-token-file=" & tokenFilePath,
"--light-client-enable=off",
"--serve-light-client-data=off",
"--import-light-client-data=none",
"--light-client-data-serve=off",
"--light-client-data-import-mode=none",
"--doppelganger-detection=off"], it))
except Exception as exc: # TODO fix confutils exceptions
raiseAssert exc.msg

View File

@ -79,8 +79,8 @@ suite "Light client" & preset():
validatorMonitor = newClone(ValidatorMonitor.init())
dag = ChainDAGRef.init(
cfg, makeTestDB(num_validators), validatorMonitor, {},
serveLightClientData = true,
importLightClientData = ImportLightClientData.OnlyNew)
lightClientDataServe = true,
lightClientDataImportMode = LightClientDataImportMode.OnlyNew)
quarantine = newClone(Quarantine.init())
taskpool = Taskpool.new()
var verifier = BatchVerifier(rng: keys.newRng(), taskpool: taskpool)
@ -185,8 +185,8 @@ suite "Light client" & preset():
dag.headState, dag.getForkedBlock(dag.head.bid).get)
let cpDag = ChainDAGRef.init(
cfg, cpDb, validatorMonitor, {},
serveLightClientData = true,
importLightClientData = ImportLightClientData.Full)
lightClientDataServe = true,
lightClientDataImportMode = LightClientDataImportMode.Full)
# Advance by a couple epochs
for i in 1'u64 .. 10:

View File

@ -30,8 +30,8 @@ suite "Light client processor" & preset():
validatorMonitor = newClone(ValidatorMonitor.init())
dag = ChainDAGRef.init(
cfg, makeTestDB(numValidators), validatorMonitor, {},
serveLightClientData = true,
importLightClientData = ImportLightClientData.OnlyNew)
lightClientDataServe = true,
lightClientDataImportMode = LightClientDataImportMode.OnlyNew)
quarantine = newClone(Quarantine.init())
taskpool = Taskpool.new()
var verifier = BatchVerifier(rng: keys.newRng(), taskpool: taskpool)