validator: detect a slashed validator, warn loudly, and optionally stop
维护者通常 6 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 活跃
- 技术栈
- rust
调研方向
Start with crates/validator/src/lib.rs around refresh_epoch and trace how resolved validator entries feed duties and fee-recipient preparations; read the DTO and beacon node references named in the issue. The proposal leaves key behavior undecided, including whether to stop the process, how to handle sync committee duties, and how to verify a slashing report. Done would require settling those decisions and covering the proposed DTO, mock beacon node, and stop-flag behavior with tests.
由索引模型根据 Issue 内容生成。
描述
The validator client never notices that one of its keys has been slashed. It keeps signing for that key, says nothing, and keeps running every other key under the same setup that got the first one slashed. The data that would tell it is already fetched every epoch.
Code references are at bf66e86c.
What happens today
refresh_epochresolves every loaded key once an epoch throughPOST /eth/v1/beacon/states/head/validators(crates/validator/src/lib.rs:986,crates/validator/src/beacon_node/http.rs:670-698). The response carries each validator'sstatusandvalidator.slashed, as the DTO test body shows (crates/validator/src/beacon_node/dto.rs:936-950).ValidatorEntryDtokeepsindex,statusandvalidator.pubkey(dto.rs:282-293), soslashedis dropped on decode.statusreachesValidatorEntry(crates/validator/src/beacon_node/mod.rs:346-351) and is read only byis_registrable, which picks the keys that get builder registrations (lib.rs:1044,:1061-1063). Itsstarts_with("active")letsactive_slashedthrough, so a slashed key is still registered.- On current
main(#804) the duty loop keeps the epoch's resolved entries for the per-slot fee-recipient re-send (resolvedinrunat5d8628e9), so the statuses are in memory for the whole epoch. - Nothing logs a validator's status, a change of status, or a slashing. No metric carries a per-validator label (
crates/validator/src/metrics.rs). - The client subscribes to no beacon node events. An ethlambda beacon node would not send
proposer_slashingorattester_slashingevents anyway: it accepts the topics and never emits them (docs/rpc.md:999-1003). - Duties go on for the slashed key. Its proposals are invalid, since
process_block_headerrefuses a slashed proposer (crates/blockchain/state_transition/src/beacon/stf/block.rs:254-257). Its attestations earn nothing, since attestation rewards count only unslashed participants (get_unslashed_participating_indices,crates/blockchain/state_transition/src/beacon/helpers/altair.rs:242).
Why it matters
The slashed key itself has little left to lose. It cannot be slashed a second time (is_slashable_validator requires !slashed, crates/blockchain/state_transition/src/beacon/helpers/predicates.rs:35-39), and its duties earn nothing.
The other keys are what is at risk. A slashing means the setup is broken: the keys are running in a second place, slashing protection was bypassed (a key started with --init-slashing-protection that had history elsewhere, or a record restored from an old backup), or a key leaked. Whatever caused it usually applies to every key that shares the validators directory or the copied setup, and those keys are next. Each slashed validator's epoch-processing penalty grows with the total slashed in the surrounding window (process_slashings, crates/blockchain/state_transition/src/beacon/stf/epoch/electra.rs:279), so every further key slashed raises the cost for all of them. Stopping when the first is detected bounds that. Today the operator finds out from a block explorer or a falling balance.
What other clients do
| Client | Behavior | Read at |
|---|---|---|
| Teku | --shut-down-when-validator-slashed-enabled, off by default ("If enabled and an owned validator key is detected as slashed, the node will terminate. In this case, the service should not be restarted.") (teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorOptions.java:195-203, default in validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorConfig.java:54). When on, an owned key in a proposer or attester slashing event from the beacon node, or with status active_slashed or exited_slashed in a status update, logs a fatal line and exits with the fatal exit code (validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorTimingActions.java:128-176, slashingriskactions/SlashedValidatorShutDown.java:34-39, slashingriskactions/SlashingRiskAction.java:30) |
master @ 62a54b96 |
| Lighthouse | The validator client has no slashed handling (no slashed check anywhere under validator_client/). The beacon node's validator monitor exports validator_monitor_slashed per monitored validator (beacon_node/beacon_chain/src/metrics.rs:972-977) and logs a proposer or attester slashing that names one at crit (beacon_node/beacon_chain/src/validator_monitor.rs:1810-1817, :1864-1869) |
unstable @ 11813cfb |
| Nimbus | The beacon node's validator monitor exports validator_monitor_slashed (beacon_chain/validators/validator_monitor.nim:63) |
unstable @ 9bed158a |
| Prysm | The validator client exports a per-key validator_statuses gauge in which 5 is SLASHING (validator/client/metrics.go:22-31) |
develop @ 0c1e3d24 |
| Lodestar | The validator client folds active_slashed into "active" in its status summary (packages/validator/src/services/indices.ts:20-27) |
unstable @ 77088eb7 |
Teku is the only client read here that stops on a slashed key, and only when asked. Lighthouse and Nimbus surface it on the beacon node.
Proposal
- Read it. Declare
validator.slashedinValidatorEntryDtoand carry it inValidatorEntry.statusalone loses it once a validator reacheswithdrawal_possibleorwithdrawal_done. - Say it. In
refresh_epoch, log every slashed loaded key aterror!(pubkey, index, status) the first time it is seen, and keep a gauge of slashed loaded keys (ethlambda_validator_validators_slashed). - Stop signing for that key. Drop its proposer, attester and aggregation duties: a block from it is invalid and its attestations earn nothing. Leave it out of builder registrations (
is_registrable) and fee-recipient preparations. - Optionally stop the process. A flag (Teku's is
--shut-down-when-validator-slashed-enabled) that exits with a distinct, documented exit code and a message saying not to restart until the cause is found. - Events later. Polling once an epoch works against any beacon node, and a slashing shows in the head state as soon as a block includes it, so detection takes at most an epoch. Subscribing to
proposer_slashingandattester_slashingevents would cut that to seconds, against a node that emits them.
To decide
- The default. Warn, count and drop the slashed key's duties by default, with stopping opt-in as in Teku? Or stop by default, given that the other keys are the ones at risk?
- Restart loops. A supervisor with
Restart=alwayswould restart the client, which would detect the same key and exit again. DocumentRestartPreventExitStatus=with the exit code, or stay up with every key paused instead of exiting. - Trusting one node. With several
--beacon-nodesthe lookup takes the first node that answers (try_each,crates/validator/src/beacon_node/fallback.rs:325-328), so one faulty node reportingslashedwould stop the client. Confirm against a second node, or against the finalized state, before exiting? - The slashed key's sync committee duty. Sync committee rewards have no slashed check (
process_sync_aggregate,crates/blockchain/state_transition/src/beacon/stf/altair.rs:303), so a slashed member still earns them. Keep that duty, or drop every duty for simplicity?
Tests
- A DTO test decoding
"slashed": true. MockBeaconNoderesolving two keys, one slashed: the refresh logs it once, sets the gauge to 1, serves no duties for it and serves the other key's.- With the stop flag:
runreturns the dedicated error, and the binary maps it to its exit code.
- 主要语言
- Rust
- 星标
- 86
- 派生
- 34
- 平均合并
- 9 天 20 小时
- 30 天内合并 PR
- 77
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
lambdaclass/ethlambda 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
lambdaclass/ethlambda#850 ·
维护者通常 6 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
lambdaclass/ethlambda#777 · 1 个 reaction ·
维护者通常 6 天内回复
-
Run all gossip validation tests可能重新可做 @dicethedev 于 9 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
lambdaclass/ethlambda#725 · 2 条评论 ·
维护者通常 6 天内回复
-
Handle malformed DB data可能重新可做 @dicethedev 于 115 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
lambdaclass/ethlambda#529 · 4 条评论 ·
维护者通常 6 天内回复
-
Document architectural choices可能重新可做 @dicethedev 于 115 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
lambdaclass/ethlambda#521 · 2 条评论 ·
维护者通常 6 天内回复
查看 lambdaclass/ethlambda 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
antithesishq/bombadil#473 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
libracoder/kiri#669 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 5 天内回复
-
autofixer: follow-up
难度 2/5 1-3 小时 新手友好度 75/100
tursodatabase/turso#12217 ·
维护者通常 1 天内回复
-
Declare the CMS schema library in the optional recipients extra可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area:python in-progress
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复