Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,6 @@ AllTests-mainnet
```
## Nimbus remote signer/signing test (verifying-web3signer)
```diff
+ Signing BeaconBlock (getBlockSignature(capella)) OK
+ Signing BeaconBlock (getBlockSignature(deneb)) OK
+ Waiting for signing node (/upcheck) test OK
```
Expand All @@ -749,7 +748,6 @@ AllTests-mainnet
+ Connection timeout test OK
+ Public keys enumeration (/api/v1/eth2/publicKeys) test OK
+ Public keys reload (/reload) test OK
+ Signing BeaconBlock (getBlockSignature(capella)) OK
+ Signing BeaconBlock (getBlockSignature(deneb)) OK
+ Signing SC contribution and proof (getContributionAndProofSignature()) OK
+ Signing SC message (getSyncCommitteeMessage()) OK
Expand Down
5 changes: 3 additions & 2 deletions beacon_chain/beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ type
EventBus* = object
headQueue*: AsyncEventQueue[HeadChangeInfoObject]
blocksQueue*: AsyncEventQueue[EventBeaconBlockObject]
attestQueue*: AsyncEventQueue[phase0.Attestation]
phase0AttestQueue*: AsyncEventQueue[phase0.Attestation]
singleAttestQueue*: AsyncEventQueue[SingleAttestation]
exitQueue*: AsyncEventQueue[SignedVoluntaryExit]
blsToExecQueue*: AsyncEventQueue[SignedBLSToExecutionChange]
propSlashQueue*: AsyncEventQueue[ProposerSlashing]
attSlashQueue*: AsyncEventQueue[phase0.AttesterSlashing]
phase0AttSlashQueue*: AsyncEventQueue[phase0.AttesterSlashing]
electraAttSlashQueue*: AsyncEventQueue[electra.AttesterSlashing]
blobSidecarQueue*: AsyncEventQueue[BlobSidecarInfoObject]
finalQueue*: AsyncEventQueue[FinalizationInfoObject]
reorgQueue*: AsyncEventQueue[ReorgInfoObject]
Expand Down
11 changes: 6 additions & 5 deletions beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ proc initFullNode(
template config(): auto = node.config

proc onPhase0AttestationReceived(data: phase0.Attestation) =
node.eventBus.attestQueue.emit(data)
node.eventBus.phase0AttestQueue.emit(data)
proc onSingleAttestationReceived(data: SingleAttestation) =
node.eventBus.singleAttestQueue.emit(data)
proc onSyncContribution(data: SignedContributionAndProof) =
Expand All @@ -312,9 +312,9 @@ proc initFullNode(
proc onProposerSlashingAdded(data: ProposerSlashing) =
node.eventBus.propSlashQueue.emit(data)
proc onPhase0AttesterSlashingAdded(data: phase0.AttesterSlashing) =
node.eventBus.attSlashQueue.emit(data)
node.eventBus.phase0AttSlashQueue.emit(data)
proc onElectraAttesterSlashingAdded(data: electra.AttesterSlashing) =
debugComment "electra att slasher queue"
node.eventBus.electraAttSlashQueue.emit(data)
proc onBlobSidecarAdded(data: BlobSidecarInfoObject) =
node.eventBus.blobSidecarQueue.emit(data)
proc onBlockAdded(data: ForkedTrustedSignedBeaconBlock) =
Expand Down Expand Up @@ -744,12 +744,13 @@ proc init*(T: type BeaconNode,
eventBus = EventBus(
headQueue: newAsyncEventQueue[HeadChangeInfoObject](),
blocksQueue: newAsyncEventQueue[EventBeaconBlockObject](),
attestQueue: newAsyncEventQueue[phase0.Attestation](),
phase0AttestQueue: newAsyncEventQueue[phase0.Attestation](),
singleAttestQueue: newAsyncEventQueue[SingleAttestation](),
exitQueue: newAsyncEventQueue[SignedVoluntaryExit](),
blsToExecQueue: newAsyncEventQueue[SignedBLSToExecutionChange](),
propSlashQueue: newAsyncEventQueue[ProposerSlashing](),
attSlashQueue: newAsyncEventQueue[phase0.AttesterSlashing](),
phase0AttSlashQueue: newAsyncEventQueue[phase0.AttesterSlashing](),
electraAttSlashQueue: newAsyncEventQueue[electra.AttesterSlashing](),
blobSidecarQueue: newAsyncEventQueue[BlobSidecarInfoObject](),
finalQueue: newAsyncEventQueue[FinalizationInfoObject](),
reorgQueue: newAsyncEventQueue[ReorgInfoObject](),
Expand Down
21 changes: 15 additions & 6 deletions beacon_chain/rpc/rest_event_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) =
# so there no need to respond with HTTP error response.
return

debugComment "add single_attestation handler"
let handlers =
block:
var res: seq[Future[void]]
Expand All @@ -127,9 +126,13 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) =
"block")
res.add(handler)
if EventTopic.Attestation in eventTopics:
let handler = response.eventHandler(node.eventBus.attestQueue,
let handler = response.eventHandler(node.eventBus.phase0AttestQueue,
"attestation")
res.add(handler)
if EventTopic.Attestation in eventTopics:
let handler = response.eventHandler(node.eventBus.singleAttestQueue,
"single_attestation")
res.add(handler)
if EventTopic.VoluntaryExit in eventTopics:
let handler = response.eventHandler(node.eventBus.exitQueue,
"voluntary_exit")
Expand All @@ -143,9 +146,15 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) =
"proposer_slashing")
res.add(handler)
if EventTopic.AttesterSlashing in eventTopics:
let handler = response.eventHandler(node.eventBus.attSlashQueue,
"attester_slashing")
res.add(handler)
block:
let handler = response.eventHandler(node.eventBus.phase0AttSlashQueue,
"attester_slashing")
res.add(handler)

block:
let handler = response.eventHandler(node.eventBus.electraAttSlashQueue,
"attester_slashing")
res.add(handler)
if EventTopic.BlobSidecar in eventTopics:
let handler = response.eventHandler(node.eventBus.blobSidecarQueue,
"blob_sidecar")
Expand Down Expand Up @@ -179,7 +188,7 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) =
except ValueError:
raiseAssert "There should be more than one event handler at this point!"
# One of the handlers finished, it means that connection has been dropped, so
# we cancelling all other handlers.
# we are cancelling all other handlers.
let pending =
handlers.filterIt(not(it.finished())).mapIt(it.cancelAndWait())
await noCancel allFutures(pending)
Expand Down
5 changes: 2 additions & 3 deletions beacon_chain/spec/datatypes/electra.nim
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,10 @@ template asTrusted*(
MsgTrustedSignedBeaconBlock): TrustedSignedBeaconBlock =
isomorphicCast[TrustedSignedBeaconBlock](x)

debugComment "this whole section with getValidatorIndices/shortLog needs refactoring and probably can be combined with identical implementations elsewhere"

from std/sets import toHashSet

iterator getValidatorIndices*(attester_slashing: AttesterSlashing | TrustedAttesterSlashing): uint64 =
iterator getValidatorIndices*(
attester_slashing: AttesterSlashing | TrustedAttesterSlashing): uint64 =
template attestation_1(): auto = attester_slashing.attestation_1
template attestation_2(): auto = attester_slashing.attestation_2

Expand Down
4 changes: 4 additions & 0 deletions beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3638,6 +3638,8 @@ func decodeString*(t: typedesc[EventTopic],
ok(EventTopic.Block)
of "attestation":
ok(EventTopic.Attestation)
of "single_attestation":
ok(EventTopic.SingleAttestation)
of "voluntary_exit":
ok(EventTopic.VoluntaryExit)
of "bls_to_execution_change":
Expand Down Expand Up @@ -3669,6 +3671,8 @@ func encodeString*(value: set[EventTopic]): Result[string, cstring] =
res.add("block,")
if EventTopic.Attestation in value:
res.add("attestation,")
if EventTopic.SingleAttestation in value:
res.add("single_attestation,")
if EventTopic.VoluntaryExit in value:
res.add("voluntary_exit,")
if EventTopic.BLSToExecutionChange in value:
Expand Down
8 changes: 4 additions & 4 deletions beacon_chain/spec/eth2_apis/rest_types.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 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).
Expand Down Expand Up @@ -57,9 +57,9 @@ type
# https://github.com/ethereum/beacon-APIs/blob/v2.4.2/apis/eventstream/index.yaml
EventTopic* {.pure.} = enum
Head, Block, Attestation, VoluntaryExit, BLSToExecutionChange,
ProposerSlashing, AttesterSlashing, BlobSidecar, FinalizedCheckpoint,
ChainReorg, ContributionAndProof, LightClientFinalityUpdate,
LightClientOptimisticUpdate
ProposerSlashing, AttesterSlashing, BlobSidecar, SingleAttestation,
FinalizedCheckpoint, ChainReorg, ContributionAndProof,
LightClientFinalityUpdate, LightClientOptimisticUpdate

EventTopics* = set[EventTopic]

Expand Down
4 changes: 3 additions & 1 deletion beacon_chain/spec/state_transition_block.nim
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ proc check_voluntary_exit*(
return err("Exit: not in validator set long enough")

when typeof(state).kind >= ConsensusFork.Electra:
if voluntary_exit.validator_index >= state.validators.lenu64:
return err("Exit: validator index out of range")

# Only exit validator if it has no pending withdrawals in the queue
debugComment "truncating"
if not (get_pending_balance_to_withdraw(
state, voluntary_exit.validator_index.ValidatorIndex) == 0.Gwei):
return err("Exit: still has pending withdrawals")
Expand Down
3 changes: 1 addition & 2 deletions beacon_chain/validators/beacon_validators.nim
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ proc isSynced*(node: BeaconNode, head: BlockRef): bool =
## determine if we're in sync and should be producing blocks and
## attestations. Generally, the problem is that slot time keeps advancing
## even when there are no blocks being produced, so there's no way to
## distinguish validators geniunely going missing from the node not being
## distinguish validators genuinely going missing from the node not being
## well connected (during a network split or an internet outage for
## example). It would generally be correct to simply keep running as if
## we were the only legit node left alive, but then we run into issues:
Expand Down Expand Up @@ -958,7 +958,6 @@ proc getBlindedBlockParts[
else:
static: doAssert false

debugComment "the electra builder API bids have these requests"
let newBlock = await makeBeaconBlockForHeadAndSlot(
PayloadType, node, randao, validator_index, graffiti, head, slot,
execution_payload = Opt.some shimExecutionPayload,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_keymanager_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import
../beacon_chain/networking/network_metadata,
../beacon_chain/rpc/rest_key_management_api,
../beacon_chain/[conf, filepath, beacon_node,
nimbus_beacon_node, beacon_node_status,
nimbus_validator_client],
nimbus_beacon_node, beacon_node_status],
../beacon_chain/validator_client/common,
../ncli/ncli_testnet,
./testutil
Expand Down
Loading