Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f552013
perf(crypto): resolve registry public keys through a validator-index …
MegaRedHand Oct 30, 2026
7d21594
perf(crypto): copy byte-path keys into the index table on first index…
MegaRedHand Oct 30, 2026
a2156d3
Merge branch 'perf/committee-key-sums' into perf/index-keyed-pubkey-c…
MegaRedHand Oct 30, 2026
4eeba56
perf(beacon): look up registry keys by index on the gossip and API paths
MegaRedHand Oct 30, 2026
f733e97
Merge branch 'perf/committee-key-sums' into perf/index-keyed-pubkey-c…
MegaRedHand Oct 30, 2026
b39cafa
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 4, 2026
035c54a
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 11, 2026
6df4444
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 11, 2026
0bb1a81
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 17, 2026
810ba1d
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 18, 2026
40b9243
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 18, 2026
f5a2461
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 18, 2026
0c67a1f
perf(crypto): leave an occupied index slot alone when promoting a byt…
MegaRedHand Nov 19, 2026
236d69d
docs(metrics): say the pubkey cache gauge needs a sum since it gained…
MegaRedHand Nov 19, 2026
96431eb
refactor(beacon): name the indexed keys for what they are
MegaRedHand Nov 19, 2026
3f71c95
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 19, 2026
76fc1e2
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 19, 2026
9a313ec
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 19, 2026
64aaac6
Merge perf/committee-key-sums into perf/index-keyed-pubkey-cache
MegaRedHand Nov 20, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,16 @@ pub fn stateful_checks(
let Ok(aggregator) = state.validator(aggregator_index) else {
return Err(Outcome::Reject(RejectReason::UnknownValidator));
};
let aggregator_pubkey = bls::IndexedPubkey {
index: aggregator_index,
pubkey: aggregator.pubkey,
};
// [REJECT] The selection proof selects the validator as an aggregator.
let selection_proof = aggregate.selection_proof();
let selection_domain =
get_domain_from_schedule(&config, &state, DOMAIN_SELECTION_PROOF, target_epoch);
let selection_signing_root = compute_signing_root(data.slot.hash_tree_root(), selection_domain);
if !bls::verify(&aggregator.pubkey, selection_signing_root, &selection_proof) {
if !bls::verify(&aggregator_pubkey, selection_signing_root, &selection_proof) {
return Err(Outcome::Reject(RejectReason::SelectionProof));
}
// [REJECT] The aggregator's own signature, over the whole envelope.
Expand All @@ -401,7 +405,7 @@ pub fn stateful_checks(
let aggregator_signing_root =
compute_signing_root(aggregate_and_proof_root(aggregate), aggregator_domain);
if !bls::verify(
&aggregator.pubkey,
&aggregator_pubkey,
aggregator_signing_root,
&aggregate.signature(),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ pub fn stateful_checks(store: &Store, attestation: &SingleAttestation, subnet_id
};
let domain = get_domain_from_schedule(&config, &state, DOMAIN_BEACON_ATTESTER, target_epoch);
let signing_root = compute_signing_root(data.hash_tree_root(), domain);
if !bls::verify(&attester.pubkey, signing_root, &attestation.signature) {
let attester_key = bls::IndexedPubkey {
index: attestation.attester_index,
pubkey: attester.pubkey,
};
if !bls::verify(&attester_key, signing_root, &attestation.signature) {
return Outcome::Reject(RejectReason::BadSignature);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,11 @@ fn header_signature_is_valid(
state.genesis_validators_root(),
);
let signing_root = compute_signing_root(header.hash_tree_root(), domain);
if !bls::verify(&proposer.pubkey, signing_root, &signed_header.signature) {
let proposer = bls::IndexedPubkey {
index: header.proposer_index,
pubkey: proposer.pubkey,
};
if !bls::verify(&proposer, signing_root, &signed_header.signature) {
return Err(Outcome::Reject(RejectReason::BadSignature));
}
Ok(())
Expand Down
12 changes: 10 additions & 2 deletions crates/blockchain/state_transition/src/beacon/gossip/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ fn voluntary_exit(state: &BeaconState, signed: &SignedVoluntaryExit, config: &Co
state.genesis_validators_root(),
);
let signing_root = compute_signing_root(exit.hash_tree_root(), domain);
if !bls::verify(&validator.pubkey, signing_root, &signed.signature) {
let validator = bls::IndexedPubkey {
index: exit.validator_index,
pubkey: validator.pubkey,
};
if !bls::verify(&validator, signing_root, &signed.signature) {
return Err(Outcome::Reject(RejectReason::BadSignature));
}
Ok(())
Expand All @@ -264,6 +268,10 @@ fn proposer_slashing(state: &BeaconState, slashing: &ProposerSlashing) -> Verdic
if !is_slashable_validator(proposer, get_current_epoch(state)) {
return Err(Outcome::Reject(RejectReason::InvalidOperation));
}
let proposer = bls::IndexedPubkey {
index: proposer_index,
pubkey: proposer.pubkey,
};
// [REJECT] Both signatures are valid.
for signed_header in [&slashing.signed_header_1, &slashing.signed_header_2] {
let header = &signed_header.message;
Expand All @@ -273,7 +281,7 @@ fn proposer_slashing(state: &BeaconState, slashing: &ProposerSlashing) -> Verdic
Some(compute_epoch_at_slot(header.slot)),
);
let signing_root = compute_signing_root(header.hash_tree_root(), domain);
if !bls::verify(&proposer.pubkey, signing_root, &signed_header.signature) {
if !bls::verify(&proposer, signing_root, &signed_header.signature) {
return Err(Outcome::Reject(RejectReason::BadSignature));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ pub fn stateful_checks(store: &Store, message: &gloas::PayloadAttestationMessage
Some(compute_epoch_at_slot(data.slot)),
);
let signing_root = compute_signing_root(data.hash_tree_root(), domain);
if !bls::verify(&validator.pubkey, signing_root, &message.signature) {
let validator = bls::IndexedPubkey {
index: validator_index,
pubkey: validator.pubkey,
};
if !bls::verify(&validator, signing_root, &message.signature) {
return Outcome::Reject(RejectReason::BadSignature);
}
Outcome::Accept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,13 @@ fn stateful_rules(store: &Store, signed: &gloas::SignedProposerPreferences) -> R
return Err(Outcome::Reject(RejectReason::WrongProposer));
}
// [REJECT] The signature is valid, under any candidate domain.
let pubkey = state
.validator(preferences.validator_index)
.map_err(|_| Outcome::Reject(RejectReason::WrongProposer))?
.pubkey;
let pubkey = bls::IndexedPubkey {
index: preferences.validator_index,
pubkey: state
.validator(preferences.validator_index)
.map_err(|_| Outcome::Reject(RejectReason::WrongProposer))?
.pubkey,
};
let message_root = preferences.hash_tree_root();
let valid = proposer_preferences_domains(&state, &config, proposal_epoch)
.into_iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ pub fn check_message(
message.slot,
message.beacon_block_root,
);
if !bls::verify(&validator.pubkey, signing_root, &message.signature) {
let validator = bls::IndexedPubkey {
index: message.validator_index,
pubkey: validator.pubkey,
};
if !bls::verify(&validator, signing_root, &message.signature) {
return Err(Outcome::Reject(RejectReason::BadSignature));
}
Ok(seats)
Expand Down Expand Up @@ -353,12 +357,16 @@ pub fn check_contribution(
contribution.slot,
contribution.subcommittee_index,
);
if !bls::verify(&aggregator.pubkey, selection_root, &message.selection_proof) {
let aggregator_pubkey = bls::IndexedPubkey {
index: message.aggregator_index,
pubkey: aggregator.pubkey,
};
if !bls::verify(&aggregator_pubkey, selection_root, &message.selection_proof) {
return Outcome::Reject(RejectReason::SelectionProof);
}
// [REJECT] The aggregator's signature over the envelope is valid.
let envelope_root = contribution_and_proof_signing_root(config, gvr, message);
if !bls::verify(&aggregator.pubkey, envelope_root, &signed.signature) {
if !bls::verify(&aggregator_pubkey, envelope_root, &signed.signature) {
return Outcome::Reject(RejectReason::AggregatorSignature);
}
// [REJECT] The aggregate signature is valid over the participants.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use ethlambda_storage::{
ActiveBalanceCache, ActiveBalanceKey, CommitteeCache, Lookup, PubkeyIndexCache, ShufflingKey,
};

use crate::beacon::bls::{AggregatePubkey, CommitteeKeySums};
use crate::beacon::bls::{AggregatePubkey, CommitteeKeySums, IndexedPubkey};
use crate::beacon::config::Config;
use crate::beacon::constants;
use crate::beacon::containers::BeaconState;
Expand Down Expand Up @@ -428,9 +428,14 @@ fn build_committee_key_sums(
let sums = members
.par_iter()
.map(|committee| {
let keys: Option<Vec<BlsPubkey>> = committee
// The index is attached per committee rather than stored in the
// flat list, which spans the whole registry.
let keys: Option<Vec<IndexedPubkey>> = committee
.iter()
.map(|index| pubkeys.get(*index as usize).copied())
.map(|&index| {
let pubkey = *pubkeys.get(index as usize)?;
Some(IndexedPubkey { index, pubkey })
})
.collect();
AggregatePubkey::sum(&keys?)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! the aggregation bits from one committee to a whole slot's worth and adding a
//! committee bitfield, so it gets its own versions rather than reusing these.

use crate::beacon::bls::SignatureSet;
use crate::beacon::bls::{IndexedPubkey, SignatureSet};
use crate::beacon::constants;
use crate::beacon::containers::BeaconState;
use crate::beacon::containers::phase0::{Attestation, AttestingIndices, IndexedAttestation};
Expand Down Expand Up @@ -135,7 +135,10 @@ pub(crate) fn attesters_signature_set(
let mut pubkeys = Vec::with_capacity(attesting_indices.len());
for index in attesting_indices {
match state.validator(*index) {
Ok(validator) => pubkeys.push(validator.pubkey),
Ok(validator) => pubkeys.push(IndexedPubkey {
index: *index,
pubkey: validator.pubkey,
}),
Err(_) => return None,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
//! single easiest mistake to make copying that shape without also copying
//! the reasoning behind it.

use crate::beacon::bls::{AggregatePubkey, SignatureSet};
use crate::beacon::bls::{AggregatePubkey, IndexedPubkey, SignatureSet};
use crate::beacon::config::Config;
use crate::beacon::constants::{self, FAR_FUTURE_EPOCH};
use crate::beacon::containers::shared::{AttestationData, Validator};
Expand Down Expand Up @@ -545,7 +545,12 @@ pub(crate) fn attesters_aggregate_pubkey(
let key_sums = committees.key_sums(state, epoch);
let committees_per_slot = epoch_committees.committees_per_slot();

let pubkey_of = |index: ValidatorIndex| state.validator(index).ok().map(|v| v.pubkey);
let pubkey_of = |index: ValidatorIndex| {
state.validator(index).ok().map(|v| IndexedPubkey {
index,
pubkey: v.pubkey,
})
};

// Committees derived from their sums, added as they come, and the keys of
// every committee summed directly, summed once at the end.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
//! doc), read through [`super::fulu::get_beacon_proposer_index`] rather
//! than a copy of it here.

use crate::beacon::bls::SignatureSet;
use crate::beacon::bls::{IndexedPubkey, SignatureSet};
use crate::beacon::config::Config;
use crate::beacon::constants;
use crate::beacon::containers::shared::AttestationData;
Expand Down Expand Up @@ -311,7 +311,10 @@ pub fn indexed_payload_attestation_signature_set(
let mut pubkeys = Vec::with_capacity(indices.len());
for index in indices {
match state.validator(*index) {
Ok(validator) => pubkeys.push(validator.pubkey),
Ok(validator) => pubkeys.push(IndexedPubkey {
index: *index,
pubkey: validator.pubkey,
}),
Err(_) => return None,
}
}
Expand Down
9 changes: 6 additions & 3 deletions crates/blockchain/state_transition/src/beacon/precheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ pub fn precheck_block(
Reference::Recent(state) => state,
};

let pubkey = match (state.validator(proposer), reference) {
(Ok(validator), _) => &validator.pubkey,
let proposer_key = match (state.validator(proposer), reference) {
(Ok(validator), _) => bls::IndexedPubkey {
index: proposer,
pubkey: validator.pubkey,
},
(Err(_), Reference::Parent(_)) => {
return Err(PrecheckError::UnknownProposer { proposer });
}
Expand All @@ -125,7 +128,7 @@ pub fn precheck_block(
state.genesis_validators_root(),
);
let signing_root = compute_signing_root(block_root, domain);
if !bls::verify(pubkey, signing_root, &signed_block.signature()) {
if !bls::verify(&proposer_key, signing_root, &signed_block.signature()) {
return Err(PrecheckError::BadSignature);
}
Ok(())
Expand Down
11 changes: 9 additions & 2 deletions crates/blockchain/state_transition/src/beacon/stf/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! every driver, present and future, call the identical function regardless of
//! what else that fork's body carries.

use crate::beacon::bls::SignatureSet;
use crate::beacon::bls::{IndexedPubkey, SignatureSet};
use crate::beacon::config::Config;
use crate::beacon::constants;
use crate::beacon::containers::{self, BeaconBlockHeader, BeaconState, Eth1Data, altair, phase0};
Expand Down Expand Up @@ -335,7 +335,14 @@ pub fn process_randao(
let proposer = state.validator(proposer_index)?;
if verification == RandaoVerification::Verify {
signatures.push(
SignatureSet::single(&proposer.pubkey, signing_root, randao_reveal),
SignatureSet::single(
&IndexedPubkey {
index: proposer_index,
pubkey: proposer.pubkey,
},
signing_root,
randao_reveal,
),
"RANDAO reveal signature",
)?;
signatures.verify_pending()?;
Expand Down
7 changes: 5 additions & 2 deletions crates/blockchain/state_transition/src/beacon/stf/deneb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//! caches two new blob-gas fields for EIP-4844, and [`process_voluntary_exit`]
//! signs under a fixed fork version for EIP-7044.

use crate::beacon::bls::SignatureSet;
use crate::beacon::bls::{IndexedPubkey, SignatureSet};
use crate::beacon::config::Config;
use crate::beacon::constants::{self, FAR_FUTURE_EPOCH};
use crate::beacon::containers::capella::SignedBLSToExecutionChange;
Expand Down Expand Up @@ -740,7 +740,10 @@ pub fn process_voluntary_exit(
let signing_root = compute_signing_root(voluntary_exit.hash_tree_root(), domain);
signatures.push(
SignatureSet::single(
&validator.pubkey,
&IndexedPubkey {
index: voluntary_exit.validator_index,
pubkey: validator.pubkey,
},
signing_root,
&signed_voluntary_exit.signature,
),
Expand Down
7 changes: 5 additions & 2 deletions crates/blockchain/state_transition/src/beacon/stf/electra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

use libssz::SszEncode as _;

use crate::beacon::bls::{self, SignatureSet};
use crate::beacon::bls::{self, IndexedPubkey, SignatureSet};
use crate::beacon::config::Config;
use crate::beacon::constants::{self, FAR_FUTURE_EPOCH};
use crate::beacon::containers::shared::{
Expand Down Expand Up @@ -533,7 +533,10 @@ pub fn process_voluntary_exit(
let signing_root = compute_signing_root(voluntary_exit.hash_tree_root(), domain);
signatures.push(
SignatureSet::single(
&validator.pubkey,
&IndexedPubkey {
index: voluntary_exit.validator_index,
pubkey: validator.pubkey,
},
signing_root,
&signed_voluntary_exit.signature,
),
Expand Down
6 changes: 5 additions & 1 deletion crates/blockchain/state_transition/src/beacon/stf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ fn proposer_signature_set(
let proposer = state.validator(proposer_index).ok()?;
let domain = get_domain(state, constants::DOMAIN_BEACON_PROPOSER, None);
let signing_root = compute_signing_root(block_root, domain);
bls::SignatureSet::single(&proposer.pubkey, signing_root, signature)
let proposer = bls::IndexedPubkey {
index: proposer_index,
pubkey: proposer.pubkey,
};
bls::SignatureSet::single(&proposer, signing_root, signature)
}

/// Advances the state to `slot`, running epoch processing at each boundary and
Expand Down
12 changes: 9 additions & 3 deletions crates/blockchain/state_transition/src/beacon/stf/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use std::collections::HashSet;

use crate::beacon::bls::{self, SignatureSet};
use crate::beacon::bls::{self, IndexedPubkey, SignatureSet};
use crate::beacon::config::Config;
use crate::beacon::constants::{self, FAR_FUTURE_EPOCH};
use crate::beacon::containers::BeaconState;
Expand Down Expand Up @@ -249,7 +249,10 @@ pub(crate) fn verify_proposer_slashing(
// Copied out rather than re-borrowed per iteration below: both signatures
// are checked against the same proposer, and holding the borrow across
// the loop would conflict with `get_domain`'s borrow of `state`.
let pubkey = proposer.pubkey;
let pubkey = IndexedPubkey {
index: proposer_index,
pubkey: proposer.pubkey,
};

for signed_header in [
&proposer_slashing.signed_header_1,
Expand Down Expand Up @@ -727,7 +730,10 @@ pub fn process_voluntary_exit(
let signing_root = compute_signing_root(voluntary_exit.hash_tree_root(), domain);
signatures.push(
SignatureSet::single(
&validator.pubkey,
&IndexedPubkey {
index: voluntary_exit.validator_index,
pubkey: validator.pubkey,
},
signing_root,
&signed_voluntary_exit.signature,
),
Expand Down
Loading
Loading