diff --git a/beacon_chain/deposits.nim b/beacon_chain/deposits.nim index 703888c63..63d194894 100644 --- a/beacon_chain/deposits.nim +++ b/beacon_chain/deposits.nim @@ -8,7 +8,7 @@ import std/[os, sequtils, times], - stew/byteutils, + stew/[byteutils, base10], chronicles, ./spec/eth2_apis/rest_beacon_client, ./spec/signatures, @@ -220,15 +220,29 @@ proc restValidatorExit(config: BeaconNodeConf) {.async.} = quit 1 let signingFork = try: - let response = await client.getSpec() + let response = await client.getSpecVC() if response.status == 200: - let spec = response.data + let + spec = response.data.data + denebForkEpoch = + block: + let s = spec.getOrDefault("DENEB_FORK_EPOCH", $FAR_FUTURE_EPOCH) + Epoch(Base10.decode(uint64, s).get(uint64(FAR_FUTURE_EPOCH))) # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#voluntary-exits # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#modified-process_voluntary_exit - if currentEpoch >= Epoch(spec.data.DENEB_FORK_EPOCH): + if currentEpoch >= denebForkEpoch: + let capellaForkVersion = + block: + var res: Version + # CAPELLA_FOR_VERSION has specific format - "0x01000000", so + # default empty string is invalid, so `hexToByteArrayStrict` + # will raise exception on empty string. + let s = spec.getOrDefault("CAPELLA_FORK_VERSION", "") + hexToByteArrayStrict(s, distinctBase(res)) + res Fork( - current_version: spec.data.CAPELLA_FORK_VERSION, - previous_version: spec.data.CAPELLA_FORK_VERSION, + current_version: capellaForkVersion, + previous_version: capellaForkVersion, epoch: GENESIS_EPOCH) # irrelevant when current/previous identical else: fork @@ -239,6 +253,8 @@ proc restValidatorExit(config: BeaconNodeConf) {.async.} = reason = exc.msg quit 1 + debug "Signing fork obtained", fork = fork + if not config.printData: case askForExitConfirmation() of ClientExitAction.abort: @@ -249,7 +265,8 @@ proc restValidatorExit(config: BeaconNodeConf) {.async.} = var hadErrors = false for validator in validators: let restValidator = try: - let response = await client.getStateValidatorPlain(stateIdHead, validator.getIdent) + let response = await client.getStateValidatorPlain( + stateIdHead, validator.getIdent) if response.status == 200: let validatorInfo = decodeBytes(GetStateValidatorResponse, response.data, response.contentType) diff --git a/beacon_chain/spec/eth2_apis/rest_config_calls.nim b/beacon_chain/spec/eth2_apis/rest_config_calls.nim index 2368e5d24..4987ba004 100644 --- a/beacon_chain/spec/eth2_apis/rest_config_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_config_calls.nim @@ -20,10 +20,6 @@ proc getForkSchedulePlain*(): RestPlainResponse {. rest, endpoint: "/eth/v1/config/fork_schedule", meth: MethodGet.} ## https://ethereum.github.io/beacon-APIs/#/Config/getForkSchedule -proc getSpec*(): RestResponse[GetSpecResponse] {. - rest, endpoint: "/eth/v1/config/spec", meth: MethodGet.} - ## https://ethereum.github.io/beacon-APIs/#/Config/getSpec - proc getSpecVC*(): RestResponse[GetSpecVCResponse] {. rest, endpoint: "/eth/v1/config/spec", meth: MethodGet.} ## https://ethereum.github.io/beacon-APIs/#/Config/getSpec diff --git a/beacon_chain/spec/eth2_apis/rest_types.nim b/beacon_chain/spec/eth2_apis/rest_types.nim index df75b0527..f5888330a 100644 --- a/beacon_chain/spec/eth2_apis/rest_types.nim +++ b/beacon_chain/spec/eth2_apis/rest_types.nim @@ -344,143 +344,6 @@ type of ConsensusFork.Capella: capellaData*: capella.BeaconBlock of ConsensusFork.Deneb: denebData*: DenebBlockContents - RestSpec* = object - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.1/presets/mainnet/phase0.yaml - MAX_COMMITTEES_PER_SLOT*: uint64 - TARGET_COMMITTEE_SIZE*: uint64 - MAX_VALIDATORS_PER_COMMITTEE*: uint64 - SHUFFLE_ROUND_COUNT*: uint64 - HYSTERESIS_QUOTIENT*: uint64 - HYSTERESIS_DOWNWARD_MULTIPLIER*: uint64 - HYSTERESIS_UPWARD_MULTIPLIER*: uint64 - MIN_DEPOSIT_AMOUNT*: uint64 - MAX_EFFECTIVE_BALANCE*: uint64 - EFFECTIVE_BALANCE_INCREMENT*: uint64 - MIN_ATTESTATION_INCLUSION_DELAY*: uint64 - SLOTS_PER_EPOCH*: uint64 - MIN_SEED_LOOKAHEAD*: uint64 - MAX_SEED_LOOKAHEAD*: uint64 - EPOCHS_PER_ETH1_VOTING_PERIOD*: uint64 - SLOTS_PER_HISTORICAL_ROOT*: uint64 - MIN_EPOCHS_TO_INACTIVITY_PENALTY*: uint64 - EPOCHS_PER_HISTORICAL_VECTOR*: uint64 - EPOCHS_PER_SLASHINGS_VECTOR*: uint64 - HISTORICAL_ROOTS_LIMIT*: uint64 - VALIDATOR_REGISTRY_LIMIT*: uint64 - BASE_REWARD_FACTOR*: uint64 - WHISTLEBLOWER_REWARD_QUOTIENT*: uint64 - PROPOSER_REWARD_QUOTIENT*: uint64 - INACTIVITY_PENALTY_QUOTIENT*: uint64 - MIN_SLASHING_PENALTY_QUOTIENT*: uint64 - PROPORTIONAL_SLASHING_MULTIPLIER*: uint64 - MAX_PROPOSER_SLASHINGS*: uint64 - MAX_ATTESTER_SLASHINGS*: uint64 - MAX_ATTESTATIONS*: uint64 - MAX_DEPOSITS*: uint64 - MAX_VOLUNTARY_EXITS*: uint64 - - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/altair.yaml - INACTIVITY_PENALTY_QUOTIENT_ALTAIR*: uint64 - MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR*: uint64 - PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR*: uint64 - SYNC_COMMITTEE_SIZE*: uint64 - EPOCHS_PER_SYNC_COMMITTEE_PERIOD*: uint64 - MIN_SYNC_COMMITTEE_PARTICIPANTS*: uint64 - UPDATE_TIMEOUT*: uint64 - - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/bellatrix.yaml - INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64 - MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64 - PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64 - MAX_BYTES_PER_TRANSACTION*: uint64 - MAX_TRANSACTIONS_PER_PAYLOAD*: uint64 - BYTES_PER_LOGS_BLOOM*: uint64 - MAX_EXTRA_DATA_BYTES*: uint64 - - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/capella.yaml - MAX_BLS_TO_EXECUTION_CHANGES*: uint64 - MAX_WITHDRAWALS_PER_PAYLOAD*: uint64 - MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP*: uint64 - - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/configs/mainnet.yaml - PRESET_BASE*: string - CONFIG_NAME*: string - TERMINAL_TOTAL_DIFFICULTY*: UInt256 - TERMINAL_BLOCK_HASH*: BlockHash - TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH*: uint64 - MIN_GENESIS_ACTIVE_VALIDATOR_COUNT*: uint64 - MIN_GENESIS_TIME*: uint64 - GENESIS_FORK_VERSION*: Version - GENESIS_DELAY*: uint64 - ALTAIR_FORK_VERSION*: Version - ALTAIR_FORK_EPOCH*: uint64 - BELLATRIX_FORK_VERSION*: Version - BELLATRIX_FORK_EPOCH*: uint64 - CAPELLA_FORK_VERSION*: Version - CAPELLA_FORK_EPOCH*: uint64 - DENEB_FORK_VERSION*: Version - DENEB_FORK_EPOCH*: uint64 - SECONDS_PER_SLOT*: uint64 - SECONDS_PER_ETH1_BLOCK*: uint64 - MIN_VALIDATOR_WITHDRAWABILITY_DELAY*: uint64 - SHARD_COMMITTEE_PERIOD*: uint64 - ETH1_FOLLOW_DISTANCE*: uint64 - INACTIVITY_SCORE_BIAS*: uint64 - INACTIVITY_SCORE_RECOVERY_RATE*: uint64 - EJECTION_BALANCE*: uint64 - MIN_PER_EPOCH_CHURN_LIMIT*: uint64 - CHURN_LIMIT_QUOTIENT*: uint64 - PROPOSER_SCORE_BOOST*: uint64 - DEPOSIT_CHAIN_ID*: uint64 - DEPOSIT_NETWORK_ID*: uint64 - DEPOSIT_CONTRACT_ADDRESS*: Eth1Address - - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#constants - # GENESIS_SLOT - # GENESIS_EPOCH - # FAR_FUTURE_EPOCH - # BASE_REWARDS_PER_EPOCH - # DEPOSIT_CONTRACT_TREE_DEPTH - # JUSTIFICATION_BITS_LENGTH - # ENDIANNESS - BLS_WITHDRAWAL_PREFIX*: RestWithdrawalPrefix - ETH1_ADDRESS_WITHDRAWAL_PREFIX*: RestWithdrawalPrefix - DOMAIN_BEACON_PROPOSER*: DomainType - DOMAIN_BEACON_ATTESTER*: DomainType - DOMAIN_RANDAO*: DomainType - DOMAIN_DEPOSIT*: DomainType - DOMAIN_VOLUNTARY_EXIT*: DomainType - DOMAIN_SELECTION_PROOF*: DomainType - DOMAIN_AGGREGATE_AND_PROOF*: DomainType - - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#constants - TIMELY_SOURCE_FLAG_INDEX*: byte - TIMELY_TARGET_FLAG_INDEX*: byte - TIMELY_HEAD_FLAG_INDEX*: byte - TIMELY_SOURCE_WEIGHT*: uint64 - TIMELY_TARGET_WEIGHT*: uint64 - TIMELY_HEAD_WEIGHT*: uint64 - SYNC_REWARD_WEIGHT*: uint64 - PROPOSER_WEIGHT*: uint64 - WEIGHT_DENOMINATOR*: uint64 - DOMAIN_SYNC_COMMITTEE*: DomainType - DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF*: DomainType - DOMAIN_CONTRIBUTION_AND_PROOF*: DomainType - # PARTICIPATION_FLAG_WEIGHTS - - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#domain-types - DOMAIN_BLS_TO_EXECUTION_CHANGE*: DomainType - - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#constants - TARGET_AGGREGATORS_PER_COMMITTEE*: uint64 - RANDOM_SUBNETS_PER_VALIDATOR*: uint64 - EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION*: uint64 - ATTESTATION_SUBNET_COUNT*: uint64 - - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/validator.md#constants - TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE*: uint64 - SYNC_COMMITTEE_SUBNET_COUNT*: uint64 - VCRuntimeConfig* = Table[string, string] RestDepositContract* = object @@ -665,7 +528,6 @@ type GetPoolProposerSlashingsResponse* = DataEnclosedObject[seq[ProposerSlashing]] GetPoolVoluntaryExitsResponse* = DataEnclosedObject[seq[SignedVoluntaryExit]] GetProposerDutiesResponse* = DataRootEnclosedObject[seq[RestProposerDuty]] - GetSpecResponse* = DataEnclosedObject[RestSpec] GetSpecVCResponse* = DataEnclosedObject[VCRuntimeConfig] GetStateFinalityCheckpointsResponse* = DataEnclosedObject[RestBeaconStatesFinalityCheckpoints] GetStateForkResponse* = DataEnclosedObject[Fork]