Skip to content

Commit cc6bb00

Browse files
committed
Merge branch 'unstable' into import-blobs-api
2 parents 3c0f7be + 6ab6eae commit cc6bb00

File tree

84 files changed

+2716
-1493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2716
-1493
lines changed

Cargo.lock

+49-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon_node/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "beacon_node"
3-
version = "6.0.1"
3+
version = "7.0.0-beta.0"
44
authors = [
55
"Paul Hauner <[email protected]>",
66
"Age Manning <[email protected]",

beacon_node/beacon_chain/src/attestation_rewards.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
175175
let base_reward_per_increment =
176176
BaseRewardPerIncrement::new(total_active_balance, spec)?;
177177

178-
for effective_balance_eth in 1..=self.max_effective_balance_increment_steps()? {
178+
for effective_balance_eth in
179+
1..=self.max_effective_balance_increment_steps(previous_epoch)?
180+
{
179181
let effective_balance =
180182
effective_balance_eth.safe_mul(spec.effective_balance_increment)?;
181183
let base_reward =
@@ -321,11 +323,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
321323
})
322324
}
323325

324-
fn max_effective_balance_increment_steps(&self) -> Result<u64, BeaconChainError> {
326+
fn max_effective_balance_increment_steps(
327+
&self,
328+
rewards_epoch: Epoch,
329+
) -> Result<u64, BeaconChainError> {
325330
let spec = &self.spec;
326-
let max_steps = spec
327-
.max_effective_balance
328-
.safe_div(spec.effective_balance_increment)?;
331+
let fork_name = spec.fork_name_at_epoch(rewards_epoch);
332+
let max_effective_balance = spec.max_effective_balance_for_fork(fork_name);
333+
let max_steps = max_effective_balance.safe_div(spec.effective_balance_increment)?;
329334
Ok(max_steps)
330335
}
331336

@@ -386,7 +391,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
386391

387392
let mut ideal_attestation_rewards_list = Vec::new();
388393
let sqrt_total_active_balance = SqrtTotalActiveBalance::new(total_balances.current_epoch());
389-
for effective_balance_step in 1..=self.max_effective_balance_increment_steps()? {
394+
for effective_balance_step in
395+
1..=self.max_effective_balance_increment_steps(previous_epoch)?
396+
{
390397
let effective_balance =
391398
effective_balance_step.safe_mul(spec.effective_balance_increment)?;
392399
let base_reward =

beacon_node/beacon_chain/src/attestation_verification.rs

+26-7
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ use std::borrow::Cow;
6060
use strum::AsRefStr;
6161
use tree_hash::TreeHash;
6262
use types::{
63-
Attestation, AttestationRef, BeaconCommittee, BeaconStateError::NoCommitteeFound, ChainSpec,
64-
CommitteeIndex, Epoch, EthSpec, Hash256, IndexedAttestation, SelectionProof,
65-
SignedAggregateAndProof, SingleAttestation, Slot, SubnetId,
63+
Attestation, AttestationData, AttestationRef, BeaconCommittee,
64+
BeaconStateError::NoCommitteeFound, ChainSpec, CommitteeIndex, Epoch, EthSpec, Hash256,
65+
IndexedAttestation, SelectionProof, SignedAggregateAndProof, SingleAttestation, Slot, SubnetId,
6666
};
6767

6868
pub use batch::{batch_verify_aggregated_attestations, batch_verify_unaggregated_attestations};
@@ -115,6 +115,17 @@ pub enum Error {
115115
///
116116
/// The peer has sent an invalid message.
117117
AggregatorNotInCommittee { aggregator_index: u64 },
118+
/// The `attester_index` for a `SingleAttestation` is not a member of the committee defined
119+
/// by its `beacon_block_root`, `committee_index` and `slot`.
120+
///
121+
/// ## Peer scoring
122+
///
123+
/// The peer has sent an invalid message.
124+
AttesterNotInCommittee {
125+
attester_index: u64,
126+
committee_index: u64,
127+
slot: Slot,
128+
},
118129
/// The aggregator index refers to a validator index that we have not seen.
119130
///
120131
/// ## Peer scoring
@@ -485,7 +496,11 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {
485496
// MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance).
486497
//
487498
// We do not queue future attestations for later processing.
488-
verify_propagation_slot_range(&chain.slot_clock, attestation, &chain.spec)?;
499+
verify_propagation_slot_range::<_, T::EthSpec>(
500+
&chain.slot_clock,
501+
attestation.data(),
502+
&chain.spec,
503+
)?;
489504

490505
// Check the attestation's epoch matches its target.
491506
if attestation.data().slot.epoch(T::EthSpec::slots_per_epoch())
@@ -817,7 +832,11 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
817832
// MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance).
818833
//
819834
// We do not queue future attestations for later processing.
820-
verify_propagation_slot_range(&chain.slot_clock, attestation, &chain.spec)?;
835+
verify_propagation_slot_range::<_, T::EthSpec>(
836+
&chain.slot_clock,
837+
attestation.data(),
838+
&chain.spec,
839+
)?;
821840

822841
// Check to ensure that the attestation is "unaggregated". I.e., it has exactly one
823842
// aggregation bit set.
@@ -1133,10 +1152,10 @@ fn verify_head_block_is_known<T: BeaconChainTypes>(
11331152
/// Accounts for `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
11341153
pub fn verify_propagation_slot_range<S: SlotClock, E: EthSpec>(
11351154
slot_clock: &S,
1136-
attestation: AttestationRef<E>,
1155+
attestation: &AttestationData,
11371156
spec: &ChainSpec,
11381157
) -> Result<(), Error> {
1139-
let attestation_slot = attestation.data().slot;
1158+
let attestation_slot = attestation.slot;
11401159
let latest_permissible_slot = slot_clock
11411160
.now_with_future_tolerance(spec.maximum_gossip_clock_disparity())
11421161
.ok_or(BeaconChainError::UnableToReadSlot)?;

beacon_node/beacon_chain/src/beacon_chain.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2974,10 +2974,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
29742974
/// Only completed sampling results are received. Blocks are unavailable by default and should
29752975
/// be pruned on finalization, on a timeout or by a max count.
29762976
pub async fn process_sampling_completed(self: &Arc<Self>, block_root: Hash256) {
2977-
// TODO(das): update fork-choice
2977+
// TODO(das): update fork-choice, act on sampling result, adjust log level
29782978
// NOTE: It is possible that sampling complets before block is imported into fork choice,
29792979
// in that case we may need to update availability cache.
2980-
// TODO(das): These log levels are too high, reduce once DAS matures
29812980
info!(self.log, "Sampling completed"; "block_root" => %block_root);
29822981
}
29832982

beacon_node/beacon_chain/src/chain_config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Default for ChainConfig {
124124
genesis_backfill: false,
125125
always_prepare_payload: false,
126126
epochs_per_migration: crate::migrate::DEFAULT_EPOCHS_PER_MIGRATION,
127-
enable_light_client_server: false,
127+
enable_light_client_server: true,
128128
malicious_withhold_count: 0,
129129
enable_sampling: false,
130130
blob_publication_batches: 4,

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,6 @@ impl<E: EthSpec> PendingComponents<E> {
110110
self.get_cached_blobs().iter().flatten().count()
111111
}
112112

113-
/// Checks if a data column of a given index exists in the cache.
114-
///
115-
/// Returns:
116-
/// - `true` if a data column for the given index exists.
117-
/// - `false` otherwise.
118-
fn data_column_exists(&self, data_column_index: u64) -> bool {
119-
self.get_cached_data_column(data_column_index).is_some()
120-
}
121-
122113
/// Returns the number of data columns that have been received and are stored in the cache.
123114
pub fn num_received_data_columns(&self) -> usize {
124115
self.verified_data_columns.len()
@@ -182,8 +173,7 @@ impl<E: EthSpec> PendingComponents<E> {
182173
kzg_verified_data_columns: I,
183174
) -> Result<(), AvailabilityCheckError> {
184175
for data_column in kzg_verified_data_columns {
185-
// TODO(das): Add equivalent checks for data columns if necessary
186-
if !self.data_column_exists(data_column.index()) {
176+
if self.get_cached_data_column(data_column.index()).is_none() {
187177
self.verified_data_columns.push(data_column);
188178
}
189179
}

beacon_node/beacon_chain/src/fetch_blobs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub async fn fetch_and_process_engine_blobs<T: BeaconChainTypes>(
9191
.await
9292
.map_err(FetchEngineBlobError::RequestFailed)?;
9393

94-
if response.is_empty() {
94+
if response.is_empty() || response.iter().all(|opt| opt.is_none()) {
9595
debug!(
9696
log,
9797
"No blobs fetched from the EL";

beacon_node/beacon_chain/src/historical_blocks.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,20 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
130130
});
131131
}
132132

133-
let blinded_block = block.clone_as_blinded();
134-
// Store block in the hot database without payload.
135-
self.store
136-
.blinded_block_as_kv_store_ops(&block_root, &blinded_block, &mut hot_batch);
133+
if !self.store.get_config().prune_payloads {
134+
// If prune-payloads is set to false, store the block which includes the execution payload
135+
self.store
136+
.block_as_kv_store_ops(&block_root, (*block).clone(), &mut hot_batch)?;
137+
} else {
138+
let blinded_block = block.clone_as_blinded();
139+
// Store block in the hot database without payload.
140+
self.store.blinded_block_as_kv_store_ops(
141+
&block_root,
142+
&blinded_block,
143+
&mut hot_batch,
144+
);
145+
}
146+
137147
// Store the blobs too
138148
if let Some(blobs) = maybe_blobs {
139149
new_oldest_blob_slot = Some(block.slot());

beacon_node/beacon_chain/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ mod pre_finalization_cache;
5454
pub mod proposer_prep_service;
5555
pub mod schema_change;
5656
pub mod shuffling_cache;
57+
pub mod single_attestation;
5758
pub mod state_advance_timer;
5859
pub mod sync_committee_rewards;
5960
pub mod sync_committee_verification;

0 commit comments

Comments
 (0)