Skip to content

Commit d6596db

Browse files
authored
Keep execution payload during historical backfill when prune-payloads set to false (#6766)
- #6510 - Keep execution payload during historical backfill when `--prune-payloads false` is set - Add a field in the historical backfill debug log to indicate if execution payload is kept - Add a test to check historical blocks has execution payload when `--prune-payloads false is set - Very minor typo correction that I notice when working on this
1 parent 921d952 commit d6596db

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

beacon_node/beacon_chain/src/historical_blocks.rs

Lines changed: 14 additions & 4 deletions
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/tests/store_tests.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ type E = MinimalEthSpec;
4747
type TestHarness = BeaconChainHarness<DiskHarnessType<E>>;
4848

4949
fn get_store(db_path: &TempDir) -> Arc<HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>> {
50-
get_store_generic(db_path, StoreConfig::default(), test_spec::<E>())
50+
let store_config = StoreConfig {
51+
prune_payloads: false,
52+
..StoreConfig::default()
53+
};
54+
get_store_generic(db_path, store_config, test_spec::<E>())
5155
}
5256

5357
fn get_store_generic(
@@ -2571,6 +2575,15 @@ async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
25712575
if block_root != prev_block_root {
25722576
assert_eq!(block.slot(), slot);
25732577
}
2578+
2579+
// Prune_payloads is set to false in the default config, so the payload should exist
2580+
if block.message().execution_payload().is_ok() {
2581+
assert!(beacon_chain
2582+
.store
2583+
.execution_payload_exists(&block_root)
2584+
.unwrap(),);
2585+
}
2586+
25742587
prev_block_root = block_root;
25752588
}
25762589

@@ -3558,7 +3571,6 @@ fn check_split_slot(
35583571
/// Check that all the states in a chain dump have the correct tree hash.
35593572
fn check_chain_dump(harness: &TestHarness, expected_len: u64) {
35603573
let mut chain_dump = harness.chain.chain_dump().unwrap();
3561-
let split_slot = harness.chain.store.get_split_slot();
35623574

35633575
assert_eq!(chain_dump.len() as u64, expected_len);
35643576

@@ -3585,13 +3597,12 @@ fn check_chain_dump(harness: &TestHarness, expected_len: u64) {
35853597

35863598
// Check presence of execution payload on disk.
35873599
if harness.chain.spec.bellatrix_fork_epoch.is_some() {
3588-
assert_eq!(
3600+
assert!(
35893601
harness
35903602
.chain
35913603
.store
35923604
.execution_payload_exists(&checkpoint.beacon_block_root)
35933605
.unwrap(),
3594-
checkpoint.beacon_block.slot() >= split_slot,
35953606
"incorrect payload storage for block at slot {}: {:?}",
35963607
checkpoint.beacon_block.slot(),
35973608
checkpoint.beacon_block_root,

beacon_node/network/src/network_beacon_processor/sync_methods.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
483483
debug!(self.log, "Backfill batch processed";
484484
"batch_epoch" => epoch,
485485
"first_block_slot" => start_slot,
486+
"keep_execution_payload" => !self.chain.store.get_config().prune_payloads,
486487
"last_block_slot" => end_slot,
487488
"processed_blocks" => sent_blocks,
488489
"processed_blobs" => n_blobs,

beacon_node/store/src/hot_cold_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
516516
.ok_or(Error::AddPayloadLogicError)
517517
}
518518

519-
/// Prepare a signed beacon block for storage in the datbase *without* its payload.
519+
/// Prepare a signed beacon block for storage in the database *without* its payload.
520520
pub fn blinded_block_as_kv_store_ops(
521521
&self,
522522
key: &Hash256,

0 commit comments

Comments
 (0)