Skip to content

Commit 82a2864

Browse files
committed
Keep execution payload during historical backfill when prune-payloads set to false (#6766)
Squashed commit of the following: commit 5db1b78 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Fri Feb 7 07:54:00 2025 +0800 assert commit 617abb0 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Feb 6 23:31:13 2025 +0800 remove split_slot commit f97f50b Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Feb 6 23:30:32 2025 +0800 Update test commit f791df1 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Feb 6 22:25:05 2025 +0800 test commit b2abae9 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Feb 6 15:11:33 2025 +0800 Test commit 42fb4d5 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Feb 6 12:29:14 2025 +0800 Fix test commit 424d4c1 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Feb 6 09:37:45 2025 +0800 test commit 833d4e2 Merge: e1f81ce 2193f6a Author: chonghe <44791194+chong-he@users.noreply.github.com> Date: Thu Feb 6 09:31:11 2025 +0800 Merge branch 'unstable' into keep-execution-payload commit e1f81ce Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Feb 6 09:18:02 2025 +0800 test commit beefb92 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Fri Jan 17 09:19:31 2025 +0800 Add test commit 2e2efa6 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Wed Jan 15 09:35:48 2025 +0800 remove info commit 7b5d5de Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Wed Jan 15 09:27:27 2025 +0800 Even more simplified logging commit 9492cab Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Mon Jan 13 11:30:26 2025 +0800 Simplify logging commit 0a61483 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Mon Jan 13 10:19:48 2025 +0800 get to prune_paylods correctly commit b86434a Merge: c958809 c9747fb Author: chonghe <44791194+chong-he@users.noreply.github.com> Date: Mon Jan 13 09:51:11 2025 +0800 Merge branch 'unstable' into keep-execution-payload commit c958809 Merge: 412e8e9 7c414cc Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Thu Jan 9 11:05:42 2025 +0800 Merge remote-tracking branch 'lion/anchor_slot_pruning' into keep-execution-payload commit 7c414cc Author: Lion - dapplion <35266934+dapplion@users.noreply.github.com> Date: Thu Jan 9 09:06:45 2025 +0800 Update beacon_node/store/src/hot_cold_store.rs Co-authored-by: Michael Sproul <micsproul@gmail.com> commit 412e8e9 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Wed Jan 8 14:52:46 2025 +0800 Add prune_payload in config.rs commit a9c2f78 Merge: 9d85619 87b72de Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Wed Jan 8 11:40:16 2025 +0800 Merge remote-tracking branch 'origin/unstable' into keep-execution-payload commit 9d85619 Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Fri Jan 3 09:41:06 2025 +0800 add log commit 016e58e Author: Tan Chee Keong <tanck@sigmaprime.io> Date: Fri Jan 3 09:04:19 2025 +0800 Add prune_payloads false commit 791395a Author: dapplion <35266934+dapplion@users.noreply.github.com> Date: Sat Dec 28 21:57:40 2024 +0800 Use oldest_block_slot to break of pruning payloads
1 parent 59afe41 commit 82a2864

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)