Merge remote-tracking branch 'origin/deneb-free-blobs' into tree-states

This commit is contained in:
Michael Sproul
2023-09-29 16:34:29 +10:00
253 changed files with 21791 additions and 3122 deletions

View File

@@ -0,0 +1,9 @@
use ethereum_hashing::hash_fixed;
use types::consts::deneb::VERSIONED_HASH_VERSION_KZG;
use types::{KzgCommitment, VersionedHash};
pub fn kzg_commitment_to_versioned_hash(kzg_commitment: &KzgCommitment) -> VersionedHash {
let mut hashed_commitment = hash_fixed(&kzg_commitment.0);
hashed_commitment[0] = VERSIONED_HASH_VERSION_KZG;
VersionedHash::from(hashed_commitment)
}

View File

@@ -78,6 +78,10 @@ pub enum BlockProcessingError {
expected: u64,
found: u64,
},
ExecutionInvalidBlobsLen {
max: usize,
actual: usize,
},
ExecutionInvalid,
ConsensusContext(ContextError),
MilhouseError(milhouse::Error),

View File

@@ -95,7 +95,7 @@ pub mod base {
}
}
pub mod altair {
pub mod altair_deneb {
use super::*;
use crate::common::update_progressive_balances_cache::update_progressive_balances_on_attestation;
@@ -276,8 +276,9 @@ pub fn process_attestations<T: EthSpec, Payload: AbstractExecPayload<T>>(
}
BeaconBlockBodyRef::Altair(_)
| BeaconBlockBodyRef::Merge(_)
| BeaconBlockBodyRef::Capella(_) => {
altair::process_attestations(
| BeaconBlockBodyRef::Capella(_)
| BeaconBlockBodyRef::Deneb(_) => {
altair_deneb::process_attestations(
state,
block_body.attestations(),
verify_signatures,

View File

@@ -387,12 +387,23 @@ where
let exit = &signed_exit.message;
let proposer_index = exit.validator_index as usize;
let domain = spec.get_domain(
exit.epoch,
Domain::VoluntaryExit,
&state.fork(),
state.genesis_validators_root(),
);
let domain = match state {
BeaconState::Base(_)
| BeaconState::Altair(_)
| BeaconState::Merge(_)
| BeaconState::Capella(_) => spec.get_domain(
exit.epoch,
Domain::VoluntaryExit,
&state.fork(),
state.genesis_validators_root(),
),
// EIP-7044
BeaconState::Deneb(_) => spec.compute_domain(
Domain::VoluntaryExit,
spec.capella_fork_version,
state.genesis_validators_root(),
),
};
let message = exit.signing_root(domain);

View File

@@ -34,7 +34,7 @@ async fn get_harness<E: EthSpec>(
// Set the state and block to be in the last slot of the `epoch_offset`th epoch.
let last_slot_of_epoch =
(MainnetEthSpec::genesis_epoch() + epoch_offset).end_slot(E::slots_per_epoch());
let harness = BeaconChainHarness::builder(E::default())
let harness = BeaconChainHarness::<EphemeralHarnessType<E>>::builder(E::default())
.default_spec()
.keypairs(KEYPAIRS[0..num_validators].to_vec())
.fresh_ephemeral_store()
@@ -63,7 +63,7 @@ async fn valid_block_ok() {
let state = harness.get_current_state();
let slot = state.slot();
let (block, mut state) = harness
let ((block, _), mut state) = harness
.make_block_return_pre_state(state, slot + Slot::new(1))
.await;
@@ -89,7 +89,7 @@ async fn invalid_block_header_state_slot() {
let state = harness.get_current_state();
let slot = state.slot() + Slot::new(1);
let (signed_block, mut state) = harness.make_block_return_pre_state(state, slot).await;
let ((signed_block, _), mut state) = harness.make_block_return_pre_state(state, slot).await;
let (mut block, signature) = signed_block.deconstruct();
*block.slot_mut() = slot + Slot::new(1);
@@ -120,7 +120,7 @@ async fn invalid_parent_block_root() {
let state = harness.get_current_state();
let slot = state.slot();
let (signed_block, mut state) = harness
let ((signed_block, _), mut state) = harness
.make_block_return_pre_state(state, slot + Slot::new(1))
.await;
let (mut block, signature) = signed_block.deconstruct();
@@ -155,7 +155,7 @@ async fn invalid_block_signature() {
let state = harness.get_current_state();
let slot = state.slot();
let (signed_block, mut state) = harness
let ((signed_block, _), mut state) = harness
.make_block_return_pre_state(state, slot + Slot::new(1))
.await;
let (block, _) = signed_block.deconstruct();
@@ -188,7 +188,7 @@ async fn invalid_randao_reveal_signature() {
let state = harness.get_current_state();
let slot = state.slot();
let (signed_block, mut state) = harness
let ((signed_block, _), mut state) = harness
.make_block_with_modifier(state, slot + 1, |block| {
*block.body_mut().randao_reveal_mut() = Signature::empty();
})

View File

@@ -32,13 +32,22 @@ pub fn verify_attestation_for_block_inclusion<'ctxt, T: EthSpec>(
attestation: data.slot,
}
);
verify!(
state.slot() <= data.slot.safe_add(T::slots_per_epoch())?,
Invalid::IncludedTooLate {
state: state.slot(),
attestation: data.slot,
match state {
BeaconState::Base(_)
| BeaconState::Altair(_)
| BeaconState::Merge(_)
| BeaconState::Capella(_) => {
verify!(
state.slot() <= data.slot.safe_add(T::slots_per_epoch())?,
Invalid::IncludedTooLate {
state: state.slot(),
attestation: data.slot,
}
);
}
);
// [Modified in Deneb:EIP7045]
BeaconState::Deneb(_) => {}
}
verify_attestation_for_state(state, attestation, ctxt, verify_signatures, spec)
}