From 83369e992a20f3b7fc35482d4795d3e013f2459d Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Tue, 1 Dec 2026 16:08:22 +0000 Subject: [PATCH] fix(validator): distributed mode follow-ups after the Charon run (#951) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🗒️ Description / Motivation Two follow-ups to #874, from running `--distributed` behind a real Charon cluster (the results are in a comment on that PR). - The partial selection proofs `Distributed` keeps could follow the schedule generation backwards. An exchange reads the generation, waits for the store, and only then looks at the kept proofs. One that read the generation before a schedule swap could get there after an exchange that read it since, wipe that exchange's proofs and set the generation back. - `docs/cli.md` still said the mode had not run against real middleware. ## What Changed - `crates/validator/src/distributed.rs`: `Partials::reusable_at` replaces the inline "clear when the generation differs". The generation only moves forward, and an exchange that is behind it reuses nothing. - `docs/cli.md`, "Distributed validators": says what the mode was run against (Charon v1.11.4, local fulu devnet, Lighthouse peers and all-ethlambda) and what that run did not cover. ## Correctness / Behavior Guarantees - Nothing wrong was ever sent before this: the next exchange under the current schedule cleared the mislabelled proofs, and the late exchange's answer is dropped because the generation moved. The cost was signatures redone. A schedule swap is itself rare (a fork schedule changing under a running client). - No change to what is sent to the middleware, or when. ## Tests Added / Run - New: `the_kept_partial_proofs_never_follow_the_schedule_back`. - On this branch: `cargo fmt --all -- --check`, `cargo test -p ethlambda-validator --profile release-fast` (1035 passed), `cargo clippy -p ethlambda-validator --all-targets -- -D warnings`. CI ran the workspace-wide lint and test suites on this PR, and every check passes. - A build of `main` with this branch (and the relative `--validators-dir` fix) ran on all four operators of a Charon v1.11.4 cluster (threshold 3, 64 validators) for 29 slots across an epoch boundary: attestations and aggregates in every slot that had attester duties, sync contributions in 28 slots, 12 blocks proposed through the cluster, no errors. In the remaining slot Charon did not answer the contribution requests before the slot ended, and each client abandoned the step with one warning. The proposal check from #875 reported all 9 blocks it had checked canonical, so it holds behind middleware that replaces the share's signature with the combined one. ## Related Issues / PRs - Follows #874. ## ✅ Verification Checklist - [x] Ran `make fmt` — clean - [x] `make lint` (clippy with `-D warnings`) — clean in CI; run locally for `ethlambda-validator` - [x] `make test` — all passing in CI; run locally for `ethlambda-validator` (cherry picked from commit a53f6be14e07571b9d44baffb0005f6dcdb5b1f7) --- crates/validator/src/distributed.rs | 51 ++++++++++++++++++++++++++--- docs/cli.md | 16 ++++++--- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/crates/validator/src/distributed.rs b/crates/validator/src/distributed.rs index 60f659268..7c4574d0c 100644 --- a/crates/validator/src/distributed.rs +++ b/crates/validator/src/distributed.rs @@ -126,6 +126,27 @@ struct Partials { by_duty: HashMap<(BlsPubkey, Slot), BlsSignature>, } +impl Partials { + /// Bring the proofs held to `generation`, the schedule an exchange read, + /// and answer whether that exchange may send them again. + /// + /// They are forgotten when the schedule has moved on since they were + /// signed, and the generation only ever moves forward. An exchange reads + /// the schedule and then waits for the store, so one that read it before + /// a swap can get here after one that read it since. Following it back + /// would wipe the newer exchange's proofs and leave what that exchange + /// then keeps labelled with the old schedule. The late one reuses + /// nothing instead, and its answer is dropped all the same (see + /// [`Distributed::exchange_attester`]). + fn reusable_at(&mut self, generation: u64) -> bool { + if self.generation < generation { + self.by_duty.clear(); + self.generation = generation; + } + self.generation == generation + } +} + /// How one seat of [`Distributed::exchange_sync`] came out. enum Seat { /// Nothing was asked: the duty names a key this client no longer @@ -491,15 +512,12 @@ impl Distributed { let reused: Vec> = { let held = store.read().await; let mut partials = self.partials(); - if partials.generation != generation { - partials.by_duty.clear(); - partials.generation = generation; - } + let reusable = partials.reusable_at(generation); keyed .iter() .map(|(duty, pubkey)| { let partial = partials.by_duty.get(&(*pubkey, duty.slot)).copied()?; - held.contains(pubkey).then_some(partial) + (reusable && held.contains(pubkey)).then_some(partial) }) .collect() }; @@ -1454,6 +1472,29 @@ mod tests { assert_partials_are_the_shares_own(&node, &pubkey, &context); } + /// The kept partial proofs follow the schedule forward only. An exchange + /// that read it before a swap and arrives after one that read it since + /// neither wipes that one's proofs nor sends them as its own. + #[test] + fn the_kept_partial_proofs_never_follow_the_schedule_back() { + let mut partials = Partials::default(); + let duty = (BlsPubkey([1; 48]), EPOCH_START); + assert!(partials.reusable_at(0)); + partials.by_duty.insert(duty, BlsSignature([9; 96])); + assert!(partials.reusable_at(0), "the same schedule keeps them"); + assert_eq!(partials.by_duty.len(), 1); + + // A swap: the exchange that reads the new schedule forgets them. + assert!(partials.reusable_at(1)); + assert!(partials.by_duty.is_empty()); + partials.by_duty.insert(duty, BlsSignature([8; 96])); + + // One that read the schedule before the swap, arriving late. + assert!(!partials.reusable_at(0)); + assert_eq!(partials.generation, 1); + assert_eq!(partials.by_duty.get(&duty), Some(&BlsSignature([8; 96]))); + } + /// A partial proof kept for a key the keymanager has since deleted is /// not sent: reusing it skips the signer, which is where a deleted key /// is otherwise found. diff --git a/docs/cli.md b/docs/cli.md index ea8ad8672..7a8b15de5 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -971,11 +971,17 @@ epoch ahead; those duties are asked for again as the current epoch's, and that request's failure or short answer is logged at debug, not warned about. `--enable-doppelganger-protection` is refused with it: the other operators -keep the validator live, so the check would stop the client. Not yet run -against real middleware. Builder registrations (each signed with its client's -own timestamp), gloas proposer preferences and payload envelopes, and -voluntary exits are signed with the share as usual, and whether a middleware -combines each of them is up to it. +keep the validator live, so the check would stop the client. + +Run behind a Charon v1.11.4 cluster on a local fulu devnet, with Lighthouse +validator clients as the other operators and with ethlambda on every +operator: attestations, proposals, aggregates and sync contributions all went +out under the cluster's combined signatures. Other middleware, and operators +running Teku, Lodestar, Nimbus or Prysm, are untested. So are builder +registrations (each signed with its client's own timestamp), gloas proposer +preferences and payload envelopes, and voluntary exits: they are signed with +the share as usual, and whether a middleware combines each of them is up to +it. ### Slashed validators