2021-03-26 06:52:01 +00:00
|
|
|
# beacon_chain
|
|
|
|
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
2020-10-27 09:00:57 +00:00
|
|
|
# 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).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2021-03-26 06:52:01 +00:00
|
|
|
{.push raises: [Defect].}
|
|
|
|
|
2020-10-27 09:00:57 +00:00
|
|
|
import
|
2022-01-08 20:06:34 +00:00
|
|
|
stew/[byteutils],
|
2021-03-26 14:11:06 +00:00
|
|
|
json_rpc/servers/httpserver,
|
2020-10-27 09:00:57 +00:00
|
|
|
chronicles,
|
2021-10-19 14:09:26 +00:00
|
|
|
../beacon_node,
|
2021-03-03 06:23:05 +00:00
|
|
|
../eth1/eth1_monitor,
|
2021-08-12 13:08:20 +00:00
|
|
|
../spec/forks
|
2020-10-27 09:00:57 +00:00
|
|
|
|
|
|
|
logScope: topics = "configapi"
|
|
|
|
|
|
|
|
type
|
|
|
|
RpcServer = RpcHttpServer
|
|
|
|
|
2021-03-26 06:52:01 +00:00
|
|
|
proc installConfigApiHandlers*(rpcServer: RpcServer, node: BeaconNode) {.
|
2021-08-27 09:00:06 +00:00
|
|
|
raises: [Defect, CatchableError].} =
|
2020-10-28 18:51:38 +00:00
|
|
|
rpcServer.rpc("get_v1_config_fork_schedule") do () -> seq[Fork]:
|
2022-03-16 07:20:40 +00:00
|
|
|
return @[getStateField(node.dag.headState, fork)]
|
2020-10-27 09:00:57 +00:00
|
|
|
|
|
|
|
rpcServer.rpc("get_v1_config_spec") do () -> JsonNode:
|
2020-11-24 19:50:42 +00:00
|
|
|
return %*{
|
2021-11-02 18:23:31 +00:00
|
|
|
# Note: This is intentionally only returning v1.0 config values.
|
|
|
|
# Please use the REST API /eth/v1/config/spec to retrieve the full config.
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/configs/mainnet/phase0.yaml
|
2020-11-24 18:16:29 +00:00
|
|
|
"MAX_COMMITTEES_PER_SLOT": $MAX_COMMITTEES_PER_SLOT,
|
|
|
|
"TARGET_COMMITTEE_SIZE": $TARGET_COMMITTEE_SIZE,
|
|
|
|
"MAX_VALIDATORS_PER_COMMITTEE": $MAX_VALIDATORS_PER_COMMITTEE,
|
2021-07-13 14:27:10 +00:00
|
|
|
"MIN_PER_EPOCH_CHURN_LIMIT": $node.dag.cfg.MIN_PER_EPOCH_CHURN_LIMIT,
|
|
|
|
"CHURN_LIMIT_QUOTIENT": $node.dag.cfg.CHURN_LIMIT_QUOTIENT,
|
2020-11-24 18:16:29 +00:00
|
|
|
"SHUFFLE_ROUND_COUNT": $SHUFFLE_ROUND_COUNT,
|
|
|
|
"MIN_GENESIS_ACTIVE_VALIDATOR_COUNT":
|
2021-07-13 14:27:10 +00:00
|
|
|
$node.dag.cfg.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT,
|
|
|
|
"MIN_GENESIS_TIME": $node.dag.cfg.MIN_GENESIS_TIME,
|
2020-11-24 18:16:29 +00:00
|
|
|
"HYSTERESIS_QUOTIENT": $HYSTERESIS_QUOTIENT,
|
|
|
|
"HYSTERESIS_DOWNWARD_MULTIPLIER": $HYSTERESIS_DOWNWARD_MULTIPLIER,
|
|
|
|
"HYSTERESIS_UPWARD_MULTIPLIER": $HYSTERESIS_UPWARD_MULTIPLIER,
|
|
|
|
"SAFE_SLOTS_TO_UPDATE_JUSTIFIED": $SAFE_SLOTS_TO_UPDATE_JUSTIFIED,
|
2021-07-13 14:27:10 +00:00
|
|
|
"ETH1_FOLLOW_DISTANCE": $node.dag.cfg.ETH1_FOLLOW_DISTANCE,
|
2020-11-24 18:16:29 +00:00
|
|
|
"TARGET_AGGREGATORS_PER_COMMITTEE": $TARGET_AGGREGATORS_PER_COMMITTEE,
|
|
|
|
"RANDOM_SUBNETS_PER_VALIDATOR": $RANDOM_SUBNETS_PER_VALIDATOR,
|
|
|
|
"EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION":
|
|
|
|
$EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION,
|
2021-07-13 14:27:10 +00:00
|
|
|
"SECONDS_PER_ETH1_BLOCK": $node.dag.cfg.SECONDS_PER_ETH1_BLOCK,
|
|
|
|
"DEPOSIT_CHAIN_ID": $node.dag.cfg.DEPOSIT_CHAIN_ID,
|
|
|
|
"DEPOSIT_NETWORK_ID": $node.dag.cfg.DEPOSIT_NETWORK_ID,
|
|
|
|
"DEPOSIT_CONTRACT_ADDRESS": $node.dag.cfg.DEPOSIT_CONTRACT_ADDRESS,
|
2020-11-24 18:16:29 +00:00
|
|
|
"MIN_DEPOSIT_AMOUNT": $MIN_DEPOSIT_AMOUNT,
|
|
|
|
"MAX_EFFECTIVE_BALANCE": $MAX_EFFECTIVE_BALANCE,
|
2021-07-13 14:27:10 +00:00
|
|
|
"EJECTION_BALANCE": $node.dag.cfg.EJECTION_BALANCE,
|
2020-11-24 18:16:29 +00:00
|
|
|
"EFFECTIVE_BALANCE_INCREMENT": $EFFECTIVE_BALANCE_INCREMENT,
|
|
|
|
"GENESIS_FORK_VERSION":
|
2021-07-13 14:27:10 +00:00
|
|
|
"0x" & $node.dag.cfg.GENESIS_FORK_VERSION,
|
2022-01-08 20:06:34 +00:00
|
|
|
"BLS_WITHDRAWAL_PREFIX": to0xHex([BLS_WITHDRAWAL_PREFIX]),
|
2021-07-13 14:27:10 +00:00
|
|
|
"GENESIS_DELAY": $node.dag.cfg.GENESIS_DELAY,
|
2020-11-24 18:16:29 +00:00
|
|
|
"SECONDS_PER_SLOT": $SECONDS_PER_SLOT,
|
|
|
|
"MIN_ATTESTATION_INCLUSION_DELAY": $MIN_ATTESTATION_INCLUSION_DELAY,
|
|
|
|
"SLOTS_PER_EPOCH": $SLOTS_PER_EPOCH,
|
|
|
|
"MIN_SEED_LOOKAHEAD": $MIN_SEED_LOOKAHEAD,
|
|
|
|
"MAX_SEED_LOOKAHEAD": $MAX_SEED_LOOKAHEAD,
|
|
|
|
"EPOCHS_PER_ETH1_VOTING_PERIOD": $EPOCHS_PER_ETH1_VOTING_PERIOD,
|
|
|
|
"SLOTS_PER_HISTORICAL_ROOT": $SLOTS_PER_HISTORICAL_ROOT,
|
|
|
|
"MIN_VALIDATOR_WITHDRAWABILITY_DELAY":
|
2021-07-13 14:27:10 +00:00
|
|
|
$node.dag.cfg.MIN_VALIDATOR_WITHDRAWABILITY_DELAY,
|
|
|
|
"SHARD_COMMITTEE_PERIOD": $node.dag.cfg.SHARD_COMMITTEE_PERIOD,
|
2020-11-24 18:16:29 +00:00
|
|
|
"MIN_EPOCHS_TO_INACTIVITY_PENALTY": $MIN_EPOCHS_TO_INACTIVITY_PENALTY,
|
|
|
|
"EPOCHS_PER_HISTORICAL_VECTOR": $EPOCHS_PER_HISTORICAL_VECTOR,
|
|
|
|
"EPOCHS_PER_SLASHINGS_VECTOR": $EPOCHS_PER_SLASHINGS_VECTOR,
|
|
|
|
"HISTORICAL_ROOTS_LIMIT": $HISTORICAL_ROOTS_LIMIT,
|
|
|
|
"VALIDATOR_REGISTRY_LIMIT": $VALIDATOR_REGISTRY_LIMIT,
|
|
|
|
"BASE_REWARD_FACTOR": $BASE_REWARD_FACTOR,
|
|
|
|
"WHISTLEBLOWER_REWARD_QUOTIENT": $WHISTLEBLOWER_REWARD_QUOTIENT,
|
|
|
|
"PROPOSER_REWARD_QUOTIENT": $PROPOSER_REWARD_QUOTIENT,
|
|
|
|
"INACTIVITY_PENALTY_QUOTIENT": $INACTIVITY_PENALTY_QUOTIENT,
|
|
|
|
"MIN_SLASHING_PENALTY_QUOTIENT": $MIN_SLASHING_PENALTY_QUOTIENT,
|
|
|
|
"PROPORTIONAL_SLASHING_MULTIPLIER": $PROPORTIONAL_SLASHING_MULTIPLIER,
|
|
|
|
"MAX_PROPOSER_SLASHINGS": $MAX_PROPOSER_SLASHINGS,
|
|
|
|
"MAX_ATTESTER_SLASHINGS": $MAX_ATTESTER_SLASHINGS,
|
|
|
|
"MAX_ATTESTATIONS": $MAX_ATTESTATIONS,
|
|
|
|
"MAX_DEPOSITS": $MAX_DEPOSITS,
|
|
|
|
"MAX_VOLUNTARY_EXITS": $MAX_VOLUNTARY_EXITS,
|
|
|
|
"DOMAIN_BEACON_PROPOSER":
|
2022-01-08 20:06:34 +00:00
|
|
|
to0xHex(DOMAIN_BEACON_PROPOSER.data),
|
2020-11-24 18:16:29 +00:00
|
|
|
"DOMAIN_BEACON_ATTESTER":
|
2022-01-08 20:06:34 +00:00
|
|
|
to0xHex(DOMAIN_BEACON_ATTESTER.data),
|
2020-11-24 18:16:29 +00:00
|
|
|
"DOMAIN_RANDAO":
|
2022-01-08 20:06:34 +00:00
|
|
|
to0xHex(DOMAIN_RANDAO.data),
|
2020-11-24 18:16:29 +00:00
|
|
|
"DOMAIN_DEPOSIT":
|
2022-01-08 20:06:34 +00:00
|
|
|
to0xHex(DOMAIN_DEPOSIT.data),
|
2020-11-24 18:16:29 +00:00
|
|
|
"DOMAIN_VOLUNTARY_EXIT":
|
2022-01-08 20:06:34 +00:00
|
|
|
to0xHex(DOMAIN_VOLUNTARY_EXIT.data),
|
2020-11-24 18:16:29 +00:00
|
|
|
"DOMAIN_SELECTION_PROOF":
|
2022-01-08 20:06:34 +00:00
|
|
|
to0xHex(DOMAIN_SELECTION_PROOF.data),
|
2020-11-24 18:16:29 +00:00
|
|
|
"DOMAIN_AGGREGATE_AND_PROOF":
|
2022-01-08 20:06:34 +00:00
|
|
|
to0xHex(DOMAIN_AGGREGATE_AND_PROOF.data)
|
2020-11-24 18:16:29 +00:00
|
|
|
}
|
2020-10-27 09:00:57 +00:00
|
|
|
|
|
|
|
rpcServer.rpc("get_v1_config_deposit_contract") do () -> JsonNode:
|
2020-11-24 19:50:42 +00:00
|
|
|
return %*{
|
2021-07-13 14:27:10 +00:00
|
|
|
"chain_id": $node.dag.cfg.DEPOSIT_CHAIN_ID,
|
|
|
|
"address": node.dag.cfg.DEPOSIT_CONTRACT_ADDRESS
|
2020-11-24 19:14:49 +00:00
|
|
|
}
|