Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
54be2b2
perf(crypto): sum validated public keys through blst's batched affine…
MegaRedHand Oct 29, 2026
bece6dd
perf(beacon): verify a block's signatures in one random-weight batch
MegaRedHand Oct 30, 2026
7736808
Merge part a into part b
MegaRedHand Oct 30, 2026
bac0aa3
test(crypto): cover keys that cancel in the batched sum
MegaRedHand Oct 30, 2026
8110d6b
Merge branch 'perf/bls-batched-key-sums' into perf/block-signature-batch
MegaRedHand Oct 30, 2026
e6eeb5b
fix(beacon): check the proposer's signature first and never drop a ba…
MegaRedHand Oct 30, 2026
b650c74
Merge main into perf/bls-batched-key-sums
MegaRedHand Nov 4, 2026
4b648c7
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 4, 2026
9984540
Merge main into perf/bls-batched-key-sums
MegaRedHand Nov 11, 2026
9493f48
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 11, 2026
f46b185
docs(crypto): say where fast_aggregate_verify's non-empty key list co…
MegaRedHand Nov 17, 2026
f42da82
test(crypto): fast_aggregate_verify rejects an empty key list
MegaRedHand Nov 17, 2026
d5eadc3
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 17, 2026
d9f9381
docs(crypto): spell out the compressed-point flag bits behind INFINIT…
MegaRedHand Nov 17, 2026
5c2d988
docs(beacon): say what a failing signature batch costs and why it sta…
MegaRedHand Nov 17, 2026
1bd8f80
docs(beacon): point process_block_with_signatures at the partial-stat…
MegaRedHand Nov 17, 2026
9344f78
test(beacon): explain how the operations wrapper keeps an unhandled c…
MegaRedHand Nov 17, 2026
93e146d
Merge main into perf/bls-batched-key-sums
MegaRedHand Nov 17, 2026
8a0a730
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 17, 2026
8637e3a
Merge main into perf/bls-batched-key-sums
MegaRedHand Nov 18, 2026
b7a8edb
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 18, 2026
461cdde
Merge main into perf/bls-batched-key-sums
MegaRedHand Nov 18, 2026
0bd7072
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 18, 2026
79a4c89
perf(crypto): take a single validated key as its own sum
MegaRedHand Nov 18, 2026
aa65405
fix(beacon): give SignatureBatch no public Default
MegaRedHand Nov 18, 2026
62c4cbc
docs(beacon): say at the check why payload attestation indices may re…
MegaRedHand Nov 18, 2026
b41192b
test(crypto): an invalid aggregate inside a batch fails it
MegaRedHand Nov 18, 2026
1057e4c
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 18, 2026
f8b9cd3
perf(crypto): sum validated public keys through blst's batched affine…
MegaRedHand Oct 29, 2026
b19da8f
test(crypto): cover keys that cancel in the batched sum
MegaRedHand Oct 30, 2026
5bb3dda
docs(crypto): say where fast_aggregate_verify's non-empty key list co…
MegaRedHand Nov 17, 2026
be26d6b
test(crypto): fast_aggregate_verify rejects an empty key list
MegaRedHand Nov 17, 2026
8bf0171
perf(crypto): take a single validated key as its own sum
MegaRedHand Nov 18, 2026
170aee8
fix(beacon): keep the unverified signature batch test-only and make a…
MegaRedHand Nov 18, 2026
f7805d2
perf(crypto): tell an identity key from its affine point, and stop co…
MegaRedHand Nov 18, 2026
bb658bc
docs(beacon): cite the spec's sorted-only check for payload attestati…
MegaRedHand Nov 18, 2026
1f55542
test(beacon): import checked everywhere, and drop the operations harn…
MegaRedHand Nov 18, 2026
45da672
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 18, 2026
4426ef0
Merge main into perf/bls-batched-key-sums
MegaRedHand Nov 19, 2026
093bf34
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 19, 2026
7ecb365
perf(crypto): sum validated public keys through blst's batched affine…
MegaRedHand Oct 29, 2026
ed8f09c
test(crypto): cover keys that cancel in the batched sum
MegaRedHand Oct 30, 2026
1eaf194
docs(crypto): say where fast_aggregate_verify's non-empty key list co…
MegaRedHand Nov 17, 2026
4e4fe13
test(crypto): fast_aggregate_verify rejects an empty key list
MegaRedHand Nov 17, 2026
be952d1
perf(crypto): take a single validated key as its own sum
MegaRedHand Nov 18, 2026
73953da
Merge perf/bls-batched-key-sums into perf/block-signature-batch
MegaRedHand Nov 19, 2026
63ba4aa
Merge main into perf/block-signature-batch
MegaRedHand Nov 19, 2026
477ca69
fix(beacon): check pending signatures before a validator record or th…
MegaRedHand Nov 19, 2026
93b4566
refactor(beacon): return no state from a failed transition_block
MegaRedHand Nov 19, 2026
fa8c70f
refactor(beacon): drop block_signature_set
MegaRedHand Nov 19, 2026
b22918d
refactor(beacon): one definition of is_valid_indexed_attestation's ch…
MegaRedHand Nov 19, 2026
619e202
refactor(crypto): drop the batch's redundant identity-key check
MegaRedHand Nov 19, 2026
01e0024
refactor(crypto): build the bls predicates on SignatureSet
MegaRedHand Nov 19, 2026
0521d9d
refactor(state-transition): register the batch disagreement counter a…
MegaRedHand Nov 19, 2026
147d418
test(beacon): a credential change checks pending signatures before it…
MegaRedHand Nov 19, 2026
02dd69f
docs(beacon): say in apply_block which body signatures are checked be…
MegaRedHand Nov 19, 2026
af1671d
docs(beacon): name the gloas bid among the writes before a signature …
MegaRedHand Nov 19, 2026
c5e2784
Merge main into perf/block-signature-batch
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 25 additions & 8 deletions crates/blockchain/state_transition/src/beacon/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ use super::helpers::fulu::fulu_state;
use super::helpers::misc::compute_signing_root;
use super::helpers::predicates::is_slashable_validator;
use super::lean_boundary::lean_state_unreachable;
use super::stf::signatures::SignatureBatch;
use super::stf::{self, BlockCaches, ExecutionEngine, OwnedBlockCaches};
use ethlambda_storage::pools::single_committee;

Expand Down Expand Up @@ -390,8 +391,14 @@ pub fn pack_operations(state: &BeaconState, candidates: Operations, config: &Con
candidates.proposer_slashings,
preset::MAX_PROPOSER_SLASHINGS,
config,
|state, slashing, config| {
stf::operations::process_proposer_slashing(state, slashing, config, &active_balances)
|state, slashing, config, signatures| {
stf::operations::process_proposer_slashing(
state,
slashing,
config,
&active_balances,
signatures,
)
},
);

Expand All @@ -409,8 +416,14 @@ pub fn pack_operations(state: &BeaconState, candidates: Operations, config: &Con
ranked.into_iter().map(|(_, slashing)| slashing).collect(),
preset::MAX_ATTESTER_SLASHINGS_ELECTRA,
config,
|state, slashing, config| {
stf::electra::process_attester_slashing(state, slashing, config, &active_balances)
|state, slashing, config, signatures| {
stf::electra::process_attester_slashing(
state,
slashing,
config,
&active_balances,
signatures,
)
},
);

Expand All @@ -419,8 +432,8 @@ pub fn pack_operations(state: &BeaconState, candidates: Operations, config: &Con
candidates.voluntary_exits,
preset::MAX_VOLUNTARY_EXITS,
config,
|state, exit, config| {
stf::electra::process_voluntary_exit(state, exit, config, &active_balances)
|state, exit, config, signatures| {
stf::electra::process_voluntary_exit(state, exit, config, &active_balances, signatures)
},
);
let bls_to_execution_changes = pack_each(
Expand Down Expand Up @@ -456,15 +469,19 @@ fn pack_each<T>(
candidates: Vec<T>,
max: usize,
config: &Config,
apply: impl Fn(&mut BeaconState, &T, &Config) -> Result<()>,
apply: impl Fn(&mut BeaconState, &T, &Config, &mut SignatureBatch) -> Result<()>,
) -> Vec<T> {
let mut packed = Vec::new();
// Bounds the work if the pool is full of stale entries.
for candidate in candidates.into_iter().take(4 * max) {
if packed.len() == max {
break;
}
if apply(scratch, &candidate, config).is_ok() {
// An immediate batch, so a bad signature rejects the candidate before
// it writes, which is what lets a rejected candidate leave `scratch`
// untouched (see above); a deferred batch would only fail at the end.
let mut signatures = SignatureBatch::immediate();
if apply(scratch, &candidate, config, &mut signatures).is_ok() {
packed.push(candidate);
}
}
Expand Down
129 changes: 63 additions & 66 deletions crates/blockchain/state_transition/src/beacon/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,11 +1054,14 @@ pub fn advance_to_epoch_start(
/// the precomputed epoch-boundary state when the block crosses into an epoch
/// and one is cached.
///
/// Returns the copy with the transition's outcome, since a failed transition
/// still leaves the caller a state to inspect. Both starting points reach the
/// same post-state: the precomputed one is what `process_slots` would produce
/// from the parent. Either way the copy is independent, so a failing block
/// cannot corrupt a cached entry.
/// Returns the post-state, or the error and no state: a failed transition
/// leaves its copy partly applied (the operations before the failing check,
/// and the attestations and sync aggregate whose signatures were deferred to
/// the end of the block; see `stf::signatures`), and dropping it here is what
/// keeps any caller from reading one. Both starting points reach the same
/// post-state: the precomputed one is what `process_slots` would produce from
/// the parent. Either way the copy is independent, so a failing block cannot
/// corrupt a cached entry.
///
/// This is also where the epoch-boundary balances of a crossing block are
/// built (see [`cache_boundary_balances`]): a block with empty slots between
Expand All @@ -1080,7 +1083,7 @@ fn transition_block(
config: &Config,
engine: &stf::ExecutionEngine,
caches: stf::BlockCaches<'_>,
) -> (BeaconState, Result<()>) {
) -> Result<BeaconState> {
let block_slot = signed_block.slot();
let epoch = compute_epoch_at_slot(block_slot);
let epoch_start = compute_start_slot_at_epoch(epoch);
Expand All @@ -1098,32 +1101,30 @@ fn transition_block(
else {
let mut state = parent_state.clone();
if !crosses_with_empty_slots {
let outcome = stf::state_transition(
stf::state_transition(
&mut state,
signed_block,
validate_result,
config,
engine,
caches,
);
return (state, outcome);
)?;
return Ok(state);
}
// The same `process_slots` steps `state_transition` would run, split
// at the epoch start so the boundary state can be read in between.
let outcome = stf::process_slots(&mut state, epoch_start, config)
.inspect(|()| cache_boundary_balances(store, boundary, &state))
.and_then(|()| stf::process_slots(&mut state, block_slot, config))
.and_then(|()| {
stf::apply_block(
&mut state,
signed_block,
validate_result,
config,
engine,
caches,
)
});
return (state, outcome);
stf::process_slots(&mut state, epoch_start, config)?;
cache_boundary_balances(store, boundary, &state);
stf::process_slots(&mut state, block_slot, config)?;
stf::apply_block(
&mut state,
signed_block,
validate_result,
config,
engine,
caches,
)?;
return Ok(state);
};

if crosses_with_empty_slots {
Expand All @@ -1132,22 +1133,18 @@ fn transition_block(
let mut state = (*precomputed).clone();
// Only the slots skipped past the boundary are left to advance; none when
// the block sits on the boundary itself.
let outcome = if state.slot() < block_slot {
stf::process_slots(&mut state, block_slot, config)
} else {
Ok(())
if state.slot() < block_slot {
stf::process_slots(&mut state, block_slot, config)?;
}
.and_then(|()| {
stf::apply_block(
&mut state,
signed_block,
validate_result,
config,
engine,
caches,
)
});
(state, outcome)
stf::apply_block(
&mut state,
signed_block,
validate_result,
config,
engine,
caches,
)?;
Ok(state)
}

/// The precomputed epoch-boundary state an import can resume from, if any.
Expand Down Expand Up @@ -5094,8 +5091,8 @@ pub struct SpeculativeTransition {
/// [`Self::stands_in_for`] compares it with the one `on_block` would pick
/// rather than restating which verdicts that is.
engine: stf::ExecutionEngine,
state: BeaconState,
outcome: Result<()>,
/// What [`transition_block`] returned: the post-state, or the error alone.
transition: Result<BeaconState>,
}

impl SpeculativeTransition {
Expand Down Expand Up @@ -5128,20 +5125,20 @@ impl SpeculativeTransition {
///
/// Outcomes are compared through their `Debug` rendering, since the error
/// type carries no `PartialEq`, and roots only on success, since a failed
/// transition's partial state is never used. Debug builds only: it doubles
/// the transition, which is the cost the speculation exists to hide.
/// transition has no state. Debug builds only: it doubles the transition,
/// which is the cost the speculation exists to hide.
#[cfg(debug_assertions)]
fn assert_agrees_with(&self, fresh: &(BeaconState, Result<()>)) {
let (fresh_state, fresh_outcome) = fresh;
fn assert_agrees_with(&self, fresh: &Result<BeaconState>) {
let outcome = |transition: &Result<BeaconState>| format!("{:?}", transition.as_ref().err());
assert_eq!(
format!("{:?}", self.outcome),
format!("{fresh_outcome:?}"),
outcome(&self.transition),
outcome(fresh),
"the speculative transition disagrees with on_block's own on the outcome"
);
if self.outcome.is_ok() {
if let (Ok(speculated), Ok(fresh)) = (&self.transition, fresh) {
assert_eq!(
self.state.hash_tree_root(),
fresh_state.hash_tree_root(),
speculated.hash_tree_root(),
fresh.hash_tree_root(),
"the speculative transition disagrees with on_block's own on the post-state root"
);
}
Expand Down Expand Up @@ -5253,7 +5250,7 @@ pub fn speculate_transition(
pubkey_indices: &pubkey_indices,
};
let engine = stf::ExecutionEngine::valid();
let (state, outcome) = transition_block(
let transition = transition_block(
store,
&parent_state,
parent_root,
Expand All @@ -5267,8 +5264,7 @@ pub fn speculate_transition(
block_root,
parent_root,
engine,
state,
outcome,
transition,
})
}

Expand Down Expand Up @@ -5460,11 +5456,11 @@ pub fn on_block_speculative(
caches,
)
};
let (mut state, transition) = match usable {
let transition = match usable {
Some(speculation) => {
#[cfg(debug_assertions)]
speculation.assert_agrees_with(&fresh_transition());
(speculation.state, speculation.outcome)
speculation.transition
}
None => fresh_transition(),
};
Expand Down Expand Up @@ -5509,7 +5505,7 @@ pub fn on_block_speculative(
)));
}

transition?;
let mut state = transition?;

// A block at its epoch's first slot is its own epoch-boundary block: its
// post-state is the checkpoint state. Cached at import so the tick that
Expand Down Expand Up @@ -6806,7 +6802,7 @@ mod tests {
let (signed, _) = block_on(&parent, first_slot);

let mut store = empty_store();
let (mut post, outcome) = transition_block(
let mut post = transition_block(
&store,
&parent,
parent_root,
Expand All @@ -6815,8 +6811,8 @@ mod tests {
&config,
&stf::ExecutionEngine::valid(),
stf::OwnedBlockCaches::default().caches(),
);
outcome.expect("applies");
)
.expect("applies");
post.apply_pending_mutations();
assert!(
store
Expand Down Expand Up @@ -7870,7 +7866,7 @@ mod tests {
config: &Config,
) -> Option<SpeculativeTransition> {
let mut speculation = honest_speculation(store, block, config)?;
speculation.outcome = Err(Error::SpecAssert(POISON));
speculation.transition = Err(Error::SpecAssert(POISON));
Some(speculation)
}

Expand Down Expand Up @@ -7917,10 +7913,11 @@ mod tests {
import_valid_child(&PayloadValidity::Validated, |store, block, config| {
let mut speculation = honest_speculation(store, block, config)?;
speculation
.outcome
.as_ref()
.expect("the transition succeeds");
speculation.state.latest_block_header_mut().body_root = Root::repeat_byte(0xab);
.transition
.as_mut()
.expect("the transition succeeds")
.latest_block_header_mut()
.body_root = Root::repeat_byte(0xab);
Some(speculation)
});
result.expect("the import takes the speculation's outcome");
Expand Down Expand Up @@ -11666,7 +11663,7 @@ mod tests {
parent_root: Root,
block: &SignedBeaconBlock,
) -> Root {
let (mut state, outcome) = transition_block(
let mut state = transition_block(
store,
parent,
parent_root,
Expand All @@ -11675,8 +11672,8 @@ mod tests {
&Config::mainnet(),
&stf::ExecutionEngine::valid(),
stf::OwnedBlockCaches::default().caches(),
);
outcome.expect("the block applies");
)
.expect("the block applies");
state.apply_pending_mutations();
state.hash_tree_root()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ pub fn assemble_gloas_block_on_bid(
pubkey_indices,
..scratch.caches()
};
stf::gloas::process_block(&mut post, &block, config, caches, options)?;
stf::gloas::process_block_and_verify(&mut post, &block, config, caches, options)?;
block.state_root = post.hash_tree_root();
Ok(block)
}
Expand Down Expand Up @@ -553,7 +553,7 @@ pub fn assemble_gloas_block(
pubkey_indices,
..scratch.caches()
};
stf::gloas::process_block(&mut post, &block, config, caches, options)?;
stf::gloas::process_block_and_verify(&mut post, &block, config, caches, options)?;
block.state_root = post.hash_tree_root();

let envelope = ExecutionPayloadEnvelope {
Expand Down Expand Up @@ -769,7 +769,7 @@ pub mod test_support {
/// The state after `block` is applied to `state`, as the chain stores it.
pub fn post_state(state: &BeaconState, block: &BeaconBlock) -> BeaconState {
let mut post = state.clone();
stf::gloas::process_block(
stf::gloas::process_block_and_verify(
&mut post,
block,
&config(),
Expand Down Expand Up @@ -1094,7 +1094,7 @@ mod gloas_block_production_tests {

// Importing it with the same option lands on the state root it names.
let mut post = state.clone();
stf::gloas::process_block(
stf::gloas::process_block_and_verify(
&mut post,
&produced.block,
&config(),
Expand Down
Loading
Loading