update some beacon API spec URLs; fix some Name and DuplicateModuleImport hints (#4929)

This commit is contained in:
tersec 2023-05-10 10:20:55 +00:00 committed by GitHub
parent 4873f8bdc4
commit d3929cbb45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 25 additions and 40 deletions

View File

@ -112,10 +112,6 @@ proc expectBlock*(self: var ConsensusManager, expectedSlot: Slot): Future[bool]
return fut
from web3/engine_api_types import
ForkchoiceUpdatedResponse, PayloadExecutionStatus, PayloadStatusV1,
PayloadAttributesV1
func `$`(h: BlockHash): string = $h.asEth2Digest
func shouldSyncOptimistically*(

View File

@ -422,7 +422,7 @@ func asConsensusWithdrawal(w: WithdrawalV1): capella.Withdrawal =
index: w.index.uint64,
validator_index: w.validatorIndex.uint64,
address: ExecutionAddress(data: w.address.distinctBase),
amount: GWei w.amount)
amount: Gwei w.amount)
func asEngineWithdrawal(w: capella.Withdrawal): WithdrawalV1 =
WithdrawalV1(

View File

@ -19,7 +19,8 @@ from ../consensus_object_pools/consensus_manager import
runProposalForkchoiceUpdated, shouldSyncOptimistically, updateHead,
updateHeadWithExecution
from ../consensus_object_pools/blockchain_dag import
getBlockRef, getProposer, forkAtEpoch, validatorKey
getBlockRef, getProposer, forkAtEpoch, is_optimistic, loadExecutionBlockHash,
markBlockVerified, validatorKey
from ../beacon_clock import GetBeaconTimeFn, toFloatSeconds
from ../consensus_object_pools/block_dag import BlockRef, root, shortLog, slot
from ../consensus_object_pools/block_pools_types import
@ -230,7 +231,7 @@ from web3/engine_api_types import
PayloadStatusV1
from ../eth1/eth1_monitor import
ELManager, asEngineExecutionPayload, forkchoiceUpdated, hasConnection,
sendNewPayload
hasProperlyConfiguredConnection, sendNewPayload
proc expectValidForkchoiceUpdated(
elManager: ELManager, headBlockPayloadAttributesType: typedesc,
@ -273,8 +274,6 @@ proc expectValidForkchoiceUpdated(
from ../consensus_object_pools/attestation_pool import
addForkChoice, selectOptimisticHead, BeaconHead
from ../consensus_object_pools/blockchain_dag import
is_optimistic, loadExecutionBlockHash, markBlockVerified
from ../consensus_object_pools/spec_cache import get_attesting_indices
from ../spec/datatypes/phase0 import TrustedSignedBeaconBlock
from ../spec/datatypes/altair import SignedBeaconBlock
@ -287,7 +286,6 @@ from ../spec/datatypes/capella import
# directly address deneb.ExecutionPayload when complaint was that it didn't
# know about "deneb"
from ../spec/datatypes/deneb import SignedBeaconBlock, asTrusted, shortLog
from ../eth1/eth1_monitor import hasProperlyConfiguredConnection
proc newExecutionPayload*(
elManager: ELManager,

View File

@ -2289,7 +2289,7 @@ proc createEth2Node*(rng: ref HmacDrbgContext,
func msgIdProvider(m: messages.Message): Result[seq[byte], ValidationResult] =
template topic: untyped =
if m.topicIDs.len > 0: m.topicIDs[0] else: ""
if m.topicIds.len > 0: m.topicIds[0] else: ""
try:
# This doesn't have to be a tight bound, just enough to avoid denial of
@ -2631,8 +2631,6 @@ proc broadcastBeaconBlock*(
let topic = getBeaconBlocksTopic(node.forkDigests.deneb)
node.broadcast(topic, blck)
from ../spec/datatypes/deneb import SignedBeaconBlock
proc broadcastSyncCommitteeMessage*(
node: Eth2Node, msg: SyncCommitteeMessage,
subcommitteeIdx: SyncSubcommitteeIndex): Future[SendResult] =

View File

@ -238,7 +238,7 @@ elif const_preset == "mainnet":
for network in [mainnetMetadata, praterMetadata, sepoliaMetadata]:
checkForkConsistency(network.cfg)
for network in [mainnetMetadata, praterMetadata, sepoliaMetaData]:
for network in [mainnetMetadata, praterMetadata, sepoliaMetadata]:
doAssert network.cfg.ALTAIR_FORK_EPOCH < FAR_FUTURE_EPOCH
doAssert network.cfg.BELLATRIX_FORK_EPOCH < FAR_FUTURE_EPOCH
doAssert network.cfg.CAPELLA_FORK_EPOCH < FAR_FUTURE_EPOCH

View File

@ -411,7 +411,7 @@ proc asyncInit(sn: SigningNodeRef) {.async.} =
proc asyncRun*(sn: SigningNodeRef) {.async.} =
sn.runKeystoreCachePruningLoopFut =
runKeystorecachePruningLoop(sn.keystoreCache)
runKeystoreCachePruningLoop(sn.keystoreCache)
sn.installApiHandlers()
sn.start()

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2023 Status Research & Development GmbH
# 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).
@ -419,7 +419,7 @@ proc asyncRun*(vc: ValidatorClientRef) {.async.} =
# Main processing loop.
vc.runSlotLoopFut = vc.runVCSlotLoop()
vc.runKeystoreCachePruningLoopFut =
runKeystorecachePruningLoop(vc.keystoreCache)
runKeystoreCachePruningLoop(vc.keystoreCache)
discard await race(vc.runSlotLoopFut, doppelEventFut)
if not(vc.runSlotLoopFut.finished()):
notice "Received shutdown event, exiting"

View File

@ -862,7 +862,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
return RestApiResponse.jsonMsgResponse(BlockValidationSuccess)
# https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
# https://github.com/ethereum/beacon-APIs/blob/v2.3.0/apis/beacon/blocks/blinded_blocks.yaml
# https://github.com/ethereum/beacon-APIs/blob/v2.4.0/apis/beacon/blocks/blinded_blocks.yaml
router.api(MethodPost, "/eth/v1/beacon/blinded_blocks") do (
contentBody: Option[ContentBody]) -> RestApiResponse:
## Instructs the beacon node to use the components of the

View File

@ -404,7 +404,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
return RestApiResponse.jsonResponsePlain(message)
# https://ethereum.github.io/beacon-APIs/#/Validator/produceBlindedBlock
# https://github.com/ethereum/beacon-APIs/blob/v2.3.0/apis/validator/blinded_block.yaml
# https://github.com/ethereum/beacon-APIs/blob/v2.4.0/apis/validator/blinded_block.yaml
router.api(MethodGet, "/eth/v1/validator/blinded_blocks/{slot}") do (
slot: Slot, randao_reveal: Option[ValidatorSig],
graffiti: Option[GraffitiBytes],

View File

@ -191,13 +191,13 @@ type
validators*: seq[ValidatorIndex]
RestErrorMessage* = object
## https://github.com/ethereum/beacon-APIs/blob/v2.3.0/types/http.yaml#L86
## https://github.com/ethereum/beacon-APIs/blob/v2.4.0/types/http.yaml#L130
code*: int
message*: string
stacktraces*: Option[seq[string]]
RestIndexedErrorMessage* = object
## https://github.com/ethereum/beacon-APIs/blob/v2.3.0/types/http.yaml#L101
## https://github.com/ethereum/beacon-APIs/blob/v2.4.0/types/http.yaml#L145
code*: int
message*: string
failures*: seq[RestIndexedErrorMessageItem]

View File

@ -273,9 +273,6 @@ func findValidatorIndex*(state: ForkyBeaconState, pubkey: ValidatorPubKey):
if state.validators.asSeq[vidx].pubkey == pubkey:
return Opt[ValidatorIndex].ok(vidx)
from ./datatypes/deneb import
BLOB_TX_TYPE, BeaconState, KzgCommitment, VersionedHash
proc process_deposit*(cfg: RuntimeConfig,
state: var ForkyBeaconState,
deposit: Deposit,

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2021-2022 Status Research & Development GmbH
# Copyright (c) 2021-2023 Status Research & Development GmbH
# 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).
@ -425,10 +425,10 @@ proc pollForSyncCommitteeDuties*(service: DutiesServiceRef) {.async.} =
(epoch: currentSlot.epoch(),
period: currentPeriod)
)
if lookAheadPeriod > currentPeriod:
if lookaheadPeriod > currentPeriod:
res.add(
(epoch: lookaheadPeriod.start_epoch(),
period: lookAheadPeriod)
period: lookaheadPeriod)
)
res

View File

@ -1220,7 +1220,7 @@ proc handleSyncCommitteeContributions(
genesis_validators_root = node.dag.genesis_validators_root
syncCommittee = node.dag.syncCommitteeParticipants(slot + 1)
for subcommitteeIdx in SyncSubCommitteeIndex:
for subcommitteeIdx in SyncSubcommitteeIndex:
for valIdx in syncSubcommittee(syncCommittee, subcommitteeIdx):
let validator = node.getValidatorForDuties(
valIdx, slot, slashingSafe = true).valueOr:
@ -1389,8 +1389,6 @@ proc getValidatorRegistration(
return ok validatorRegistration
from std/sequtils import toSeq
proc registerValidators*(node: BeaconNode, epoch: Epoch) {.async.} =
try:
if (not node.config.payloadBuilderEnable) or
@ -1440,12 +1438,11 @@ proc registerValidators*(node: BeaconNode, epoch: Epoch) {.async.} =
withState(node.dag.headState):
let currentEpoch = node.currentSlot().epoch
for i in 0 ..< forkyState.data.validators.len:
# https://github.com/ethereum/beacon-APIs/blob/v2.3.0/apis/validator/register_validator.yaml
# "requests containing currently inactive or unknown validator
# pubkeys will be accepted, as they may become active at a later
# epoch" which means filtering is needed here, because including
# any validators not pending or active may cause the request, as
# a whole, to fail.
# https://github.com/ethereum/beacon-APIs/blob/v2.4.0/apis/validator/register_validator.yaml
# "Note that only registrations for active or pending validators must
# be sent to the builder network. Registrations for unknown or exited
# validators must be filtered out and not sent to the builder
# network."
let pubkey = forkyState.data.validators.item(i).pubkey
if pubkey in node.externalBuilderRegistrations and
forkyState.data.validators.item(i).exit_epoch > currentEpoch:

View File

@ -17,9 +17,7 @@ import
# TODO remove this dependency
from std/random import rand
from eth/common/eth_types import EMPTY_ROOT_HASH
from eth/common/eth_types_rlp import rlpHash
from eth/eip1559 import EIP1559_INITIAL_BASE_FEE
type
MockPrivKeysT = object
@ -87,6 +85,9 @@ func signBlock(
ValidatorSig()
ForkedSignedBeaconBlock.init(forked, root, signature)
from eth/eip1559 import EIP1559_INITIAL_BASE_FEE, calcEip1599BaseFee
from eth/common/eth_types import EMPTY_ROOT_HASH, GasInt
proc build_empty_merge_execution_payload(state: bellatrix.BeaconState):
bellatrix.ExecutionPayloadForSigning =
## Assuming a pre-state of the same slot, build a valid ExecutionPayload
@ -115,8 +116,6 @@ proc build_empty_merge_execution_payload(state: bellatrix.BeaconState):
bellatrix.ExecutionPayloadForSigning(executionPayload: payload,
blockValue: Wei.zero)
from eth/common/eth_types import GasInt
from eth/eip1559 import calcEip1599BaseFee
from stew/saturating_arith import saturate
proc build_empty_execution_payload(