Add even more

This commit is contained in:
Mac L
2024-05-02 18:07:56 +10:00
parent d9a0c3d6c2
commit 5a4be377d4
18 changed files with 251 additions and 334 deletions

View File

@@ -262,29 +262,22 @@ pub fn process_attestations<E: EthSpec, Payload: AbstractExecPayload<E>>(
ctxt: &mut ConsensusContext<E>,
spec: &ChainSpec,
) -> Result<(), BlockProcessingError> {
match block_body {
BeaconBlockBodyRef::Base(_) => {
base::process_attestations(
state,
block_body.attestations(),
verify_signatures,
ctxt,
spec,
)?;
}
BeaconBlockBodyRef::Altair(_)
| BeaconBlockBodyRef::Bellatrix(_)
| BeaconBlockBodyRef::Capella(_)
| BeaconBlockBodyRef::Deneb(_)
| BeaconBlockBodyRef::Electra(_) => {
altair_deneb::process_attestations(
state,
block_body.attestations(),
verify_signatures,
ctxt,
spec,
)?;
}
if block_body.has_feature(FeatureName::Altair) {
altair_deneb::process_attestations(
state,
block_body.attestations(),
verify_signatures,
ctxt,
spec,
)?;
} else {
base::process_attestations(
state,
block_body.attestations(),
verify_signatures,
ctxt,
spec,
)?;
}
Ok(())
}

View File

@@ -8,7 +8,7 @@ use std::borrow::Cow;
use tree_hash::TreeHash;
use types::{
AbstractExecPayload, AggregateSignature, AttesterSlashing, BeaconBlockRef, BeaconState,
BeaconStateError, ChainSpec, DepositData, Domain, Epoch, EthSpec, Fork, Hash256,
BeaconStateError, ChainSpec, DepositData, Domain, Epoch, EthSpec, FeatureName, Fork, Hash256,
InconsistentFork, IndexedAttestation, ProposerSlashing, PublicKey, PublicKeyBytes, Signature,
SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockHeader,
SignedBlsToExecutionChange, SignedContributionAndProof, SignedRoot, SignedVoluntaryExit,
@@ -387,22 +387,20 @@ where
let exit = &signed_exit.message;
let proposer_index = exit.validator_index as usize;
let domain = match state {
BeaconState::Base(_)
| BeaconState::Altair(_)
| BeaconState::Bellatrix(_)
| BeaconState::Capella(_) => spec.get_domain(
let domain = if state.has_feature(FeatureName::Deneb) {
// EIP-7044
spec.compute_domain(
Domain::VoluntaryExit,
spec.capella_fork_version,
state.genesis_validators_root(),
)
} else {
spec.get_domain(
exit.epoch,
Domain::VoluntaryExit,
&state.fork(),
state.genesis_validators_root(),
),
// EIP-7044
BeaconState::Deneb(_) | BeaconState::Electra(_) => spec.compute_domain(
Domain::VoluntaryExit,
spec.capella_fork_version,
state.genesis_validators_root(),
),
)
};
let message = exit.signing_root(domain);

View File

@@ -32,21 +32,17 @@ pub fn verify_attestation_for_block_inclusion<'ctxt, E: EthSpec>(
attestation: data.slot,
}
);
match state {
BeaconState::Base(_)
| BeaconState::Altair(_)
| BeaconState::Bellatrix(_)
| BeaconState::Capella(_) => {
verify!(
state.slot() <= data.slot.safe_add(E::slots_per_epoch())?,
Invalid::IncludedTooLate {
state: state.slot(),
attestation: data.slot,
}
);
}
if state.has_feature(FeatureName::Deneb) {
// [Modified in Deneb:EIP7045]
BeaconState::Deneb(_) | BeaconState::Electra(_) => {}
{}
} else {
verify!(
state.slot() <= data.slot.safe_add(E::slots_per_epoch())?,
Invalid::IncludedTooLate {
state: state.slot(),
attestation: data.slot,
}
);
}
verify_attestation_for_state(state, attestation, ctxt, verify_signatures, spec)