Skip to content

Commit 5aed118

Browse files
authored
Merge of #7751
2 parents 57a301d + 55dd21a commit 5aed118

File tree

6 files changed

+76
-5
lines changed

6 files changed

+76
-5
lines changed

beacon_node/beacon_chain/src/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@ where
899899
let genesis_time = head_snapshot.beacon_state.genesis_time();
900900
let canonical_head = CanonicalHead::new(fork_choice, Arc::new(head_snapshot));
901901
let shuffling_cache_size = self.chain_config.shuffling_cache_size;
902+
let complete_blob_backfill = self.chain_config.complete_blob_backfill;
902903

903904
// Calculate the weak subjectivity point in which to backfill blocks to.
904905
let genesis_backfill_slot = if self.chain_config.genesis_backfill {
@@ -1013,6 +1014,7 @@ where
10131014
genesis_backfill_slot,
10141015
data_availability_checker: Arc::new(
10151016
DataAvailabilityChecker::new(
1017+
complete_blob_backfill,
10161018
slot_clock,
10171019
self.kzg.clone(),
10181020
store,

beacon_node/beacon_chain/src/chain_config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub struct ChainConfig {
8686
/// If using a weak-subjectivity sync, whether we should download blocks all the way back to
8787
/// genesis.
8888
pub genesis_backfill: bool,
89+
/// EXPERIMENTAL: backfill blobs and data columns beyond the data availability window.
90+
pub complete_blob_backfill: bool,
8991
/// Whether to send payload attributes every slot, regardless of connected proposers.
9092
///
9193
/// This is useful for block builders and testing.
@@ -144,6 +146,7 @@ impl Default for ChainConfig {
144146
optimistic_finalized_sync: true,
145147
shuffling_cache_size: crate::shuffling_cache::DEFAULT_CACHE_SIZE,
146148
genesis_backfill: false,
149+
complete_blob_backfill: false,
147150
always_prepare_payload: false,
148151
epochs_per_migration: crate::migrate::DEFAULT_EPOCHS_PER_MIGRATION,
149152
enable_light_client_server: true,

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub const STATE_LRU_CAPACITY: usize = STATE_LRU_CAPACITY_NON_ZERO.get();
7878
/// proposer. Having a capacity > 1 is an optimization to prevent sync lookup from having re-fetch
7979
/// data during moments of unstable network conditions.
8080
pub struct DataAvailabilityChecker<T: BeaconChainTypes> {
81+
complete_blob_backfill: bool,
8182
availability_cache: Arc<DataAvailabilityCheckerInner<T>>,
8283
slot_clock: T::SlotClock,
8384
kzg: Arc<Kzg>,
@@ -116,6 +117,7 @@ impl<E: EthSpec> Debug for Availability<E> {
116117

117118
impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
118119
pub fn new(
120+
complete_blob_backfill: bool,
119121
slot_clock: T::SlotClock,
120122
kzg: Arc<Kzg>,
121123
store: BeaconStore<T>,
@@ -129,6 +131,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
129131
spec.clone(),
130132
)?;
131133
Ok(Self {
134+
complete_blob_backfill,
132135
availability_cache: Arc::new(inner),
133136
slot_clock,
134137
kzg,
@@ -518,9 +521,15 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
518521
/// The epoch at which we require a data availability check in block processing.
519522
/// `None` if the `Deneb` fork is disabled.
520523
pub fn data_availability_boundary(&self) -> Option<Epoch> {
521-
let current_epoch = self.slot_clock.now()?.epoch(T::EthSpec::slots_per_epoch());
522-
self.spec
523-
.min_epoch_data_availability_boundary(current_epoch)
524+
let fork_epoch = self.spec.deneb_fork_epoch?;
525+
526+
if self.complete_blob_backfill {
527+
Some(fork_epoch)
528+
} else {
529+
let current_epoch = self.slot_clock.now()?.epoch(T::EthSpec::slots_per_epoch());
530+
self.spec
531+
.min_epoch_data_availability_boundary(current_epoch)
532+
}
524533
}
525534

526535
/// Returns true if the given epoch lies within the da boundary and false otherwise.
@@ -1076,7 +1085,15 @@ mod test {
10761085
let kzg = get_kzg(&spec);
10771086
let store = Arc::new(HotColdDB::open_ephemeral(<_>::default(), spec.clone()).unwrap());
10781087
let custody_context = Arc::new(CustodyContext::new(false));
1079-
DataAvailabilityChecker::new(slot_clock, kzg, store, custody_context, spec)
1080-
.expect("should initialise data availability checker")
1088+
let complete_blob_backfill = false;
1089+
DataAvailabilityChecker::new(
1090+
complete_blob_backfill,
1091+
slot_clock,
1092+
kzg,
1093+
store,
1094+
custody_context,
1095+
spec,
1096+
)
1097+
.expect("should initialise data availability checker")
10811098
}
10821099
}

beacon_node/src/cli.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,16 @@ pub fn cli_app() -> Command {
401401
.help_heading(FLAG_HEADER)
402402
.display_order(0)
403403
)
404+
.arg(
405+
Arg::new("complete-blob-backfill")
406+
.long("complete-blob-backfill")
407+
.help("Download all blobs back to the Deneb fork epoch. This will likely result in \
408+
the node banning most of its peers.")
409+
.action(ArgAction::SetTrue)
410+
.help_heading(FLAG_HEADER)
411+
.display_order(0)
412+
.hide(true)
413+
)
404414
.arg(
405415
Arg::new("enable-private-discovery")
406416
.long("enable-private-discovery")

beacon_node/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,14 @@ pub fn get_config<E: EthSpec>(
825825
client_config.chain.genesis_backfill = true;
826826
}
827827

828+
client_config.chain.complete_blob_backfill = cli_args.get_flag("complete-blob-backfill");
829+
830+
// Ensure `prune_blobs` is false whenever complete-blob-backfill is set. This overrides any
831+
// setting of `--prune-blobs true` applied earlier in flag parsing.
832+
if client_config.chain.complete_blob_backfill {
833+
client_config.store.prune_blobs = false;
834+
}
835+
828836
// Backfill sync rate-limiting
829837
client_config.beacon_processor.enable_backfill_rate_limiting =
830838
!cli_args.get_flag("disable-backfill-rate-limiting");

lighthouse/tests/beacon_node.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,37 @@ fn genesis_backfill_with_historic_flag() {
392392
.with_config(|config| assert!(config.chain.genesis_backfill));
393393
}
394394

395+
#[test]
396+
fn complete_blob_backfill_default() {
397+
CommandLineTest::new()
398+
.run_with_zero_port()
399+
.with_config(|config| assert!(!config.chain.complete_blob_backfill));
400+
}
401+
402+
#[test]
403+
fn complete_blob_backfill_flag() {
404+
CommandLineTest::new()
405+
.flag("complete-blob-backfill", None)
406+
.run_with_zero_port()
407+
.with_config(|config| {
408+
assert!(config.chain.complete_blob_backfill);
409+
assert!(!config.store.prune_blobs);
410+
});
411+
}
412+
413+
// Even if `--prune-blobs true` is provided, `--complete-blob-backfill` should override it to false.
414+
#[test]
415+
fn complete_blob_backfill_and_prune_blobs_true() {
416+
CommandLineTest::new()
417+
.flag("complete-blob-backfill", None)
418+
.flag("prune-blobs", Some("true"))
419+
.run_with_zero_port()
420+
.with_config(|config| {
421+
assert!(config.chain.complete_blob_backfill);
422+
assert!(!config.store.prune_blobs);
423+
});
424+
}
425+
395426
// Tests for Eth1 flags.
396427
// DEPRECATED but should not crash
397428
#[test]

0 commit comments

Comments
 (0)