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
51 changes: 46 additions & 5 deletions crates/validator/src/distributed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -491,15 +512,12 @@ impl<B: BeaconNodeApi + 'static> Distributed<B> {
let reused: Vec<Option<BlsSignature>> = {
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()
};
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 11 additions & 5 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading