Skip to content

Commit

Permalink
Fix VoluntaryExit validation in Electra
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumas committed Jan 20, 2025
1 parent 1944401 commit 6ae99f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
19 changes: 14 additions & 5 deletions block_producer/src/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,20 @@ impl<P: Preset, W: Wait> BlockProducer<P, W> {
.controller
.preprocessed_state_at_current_slot()?;

let outcome = match unphased::validate_voluntary_exit(
&self.producer_context.chain_config,
&state,
exit,
) {
let result = match state.as_ref() {
BeaconState::Phase0(_)
| BeaconState::Altair(_)
| BeaconState::Bellatrix(_)
| BeaconState::Capella(_)
| BeaconState::Deneb(_) => {
unphased::validate_voluntary_exit(&self.producer_context.chain_config, &state, exit)
}
BeaconState::Electra(state) => {
electra::validate_voluntary_exit(&self.producer_context.chain_config, state, exit)
}
};

let outcome = match result {
Ok(()) => {
voluntary_exits.push(exit);
PoolAdditionOutcome::Accept
Expand Down
8 changes: 8 additions & 0 deletions transition_functions/src/electra/block_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,14 @@ pub fn process_voluntary_exit<P: Preset>(
initiate_validator_exit(config, state, signed_voluntary_exit.message.validator_index)
}

pub fn validate_voluntary_exit<P: Preset>(
config: &Config,
state: &impl PostElectraBeaconState<P>,
signed_voluntary_exit: SignedVoluntaryExit,
) -> Result<()> {
validate_voluntary_exit_with_verifier(config, state, signed_voluntary_exit, SingleVerifier)
}

fn validate_voluntary_exit_with_verifier<P: Preset>(
config: &Config,
state: &impl PostElectraBeaconState<P>,
Expand Down
2 changes: 1 addition & 1 deletion transition_functions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub mod deneb {

pub mod electra {
pub(crate) use blinded_block_processing::custom_process_blinded_block;
pub use block_processing::get_expected_withdrawals;
pub use block_processing::{get_expected_withdrawals, validate_voluntary_exit};
pub(crate) use block_processing::{
process_block, process_block_for_gossip, process_deposit_data,
};
Expand Down

0 comments on commit 6ae99f4

Please sign in to comment.