Skip to content

Commit

Permalink
Merge branch 'unstable' into prune-states
Browse files Browse the repository at this point in the history
# Conflicts:
#	beacon_node/store/src/lib.rs
#	beacon_node/store/src/memory_store.rs
#	database_manager/src/lib.rs
  • Loading branch information
jimmygchen committed Oct 30, 2023
2 parents 7f2de7d + a9f9dc2 commit ddfe53e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 20 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,8 @@ jobs:
run: make arbitrary-fuzz
- name: Run cargo audit
run: make audit-CI
# TODO(sean): re-enable this when we can figure it out with c-kzg
# Issue: https://github.com/sigp/lighthouse/issues/4440
# - name: Run cargo vendor to make sure dependencies can be vendored for packaging, reproducibility and archival purpose
# run: CARGO_HOME=$(readlink -f $HOME) make vendor
- name: Run cargo vendor to make sure dependencies can be vendored for packaging, reproducibility and archival purpose
run: CARGO_HOME=$(readlink -f $HOME) make vendor
check-msrv:
name: check-msrv
runs-on: ubuntu-latest
Expand Down
13 changes: 6 additions & 7 deletions beacon_node/beacon_chain/src/historical_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
prev_block_slot = block.slot();
expected_block_root = block.message().parent_root();

// If we've reached genesis, add the genesis block root to the batch and set the
// anchor slot to 0 to indicate completion.
// If we've reached genesis, add the genesis block root to the batch for all slots
// between 0 and the first block slot, and set the anchor slot to 0 to indicate
// completion.
if expected_block_root == self.genesis_block_root {
let genesis_slot = self.spec.genesis_slot;
chunk_writer.set(
genesis_slot.as_usize(),
self.genesis_block_root,
&mut cold_batch,
)?;
for slot in genesis_slot.as_usize()..block.slot().as_usize() {
chunk_writer.set(slot, self.genesis_block_root, &mut cold_batch)?;
}
prev_block_slot = genesis_slot;
expected_block_root = Hash256::zero();
break;
Expand Down
12 changes: 12 additions & 0 deletions beacon_node/beacon_chain/tests/store_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2273,6 +2273,18 @@ async fn weak_subjectivity_sync_unaligned_unadvanced_checkpoint() {
weak_subjectivity_sync_test(slots, checkpoint_slot).await
}

// Regression test for https://github.com/sigp/lighthouse/issues/4817
// Skip 3 slots immediately after genesis, creating a gap between the genesis block and the first
// real block.
#[tokio::test]
async fn weak_subjectivity_sync_skips_at_genesis() {
let start_slot = 4;
let end_slot = E::slots_per_epoch() * 4;
let slots = (start_slot..end_slot).map(Slot::new).collect();
let checkpoint_slot = Slot::new(E::slots_per_epoch() * 2);
weak_subjectivity_sync_test(slots, checkpoint_slot).await
}

async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
// Build an initial chain on one harness, representing a synced node with full history.
let num_final_blocks = E::slots_per_epoch() * 2;
Expand Down
3 changes: 2 additions & 1 deletion beacon_node/store/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ pub enum Error {
BlockReplayError(BlockReplayError),
AddPayloadLogicError,
SlotClockUnavailableForMigration,
InvalidKey,
InvalidBytes,
UnableToDowngrade,
InconsistentFork(InconsistentFork),
InvalidKey,
}

pub trait HandleUnavailable<T> {
Expand Down
13 changes: 10 additions & 3 deletions beacon_node/store/src/hot_cold_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,10 +1490,17 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
let split_slot = self.get_split_slot();
let anchor = self.get_anchor_info();

// There are no restore points stored if the state upper limit lies in the hot database.
// It hasn't been reached yet, and may never be.
if anchor.map_or(false, |a| a.state_upper_limit >= split_slot) {
// There are no restore points stored if the state upper limit lies in the hot database,
// and the lower limit is zero. It hasn't been reached yet, and may never be.
if anchor.as_ref().map_or(false, |a| {
a.state_upper_limit >= split_slot && a.state_lower_limit == 0
}) {
None
} else if let Some(lower_limit) = anchor
.map(|a| a.state_lower_limit)
.filter(|limit| *limit > 0)
{
Some(lower_limit)
} else {
Some(
(split_slot - 1) / self.config.slots_per_restore_point
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,11 @@ impl DBColumn {
/// This function returns the number of bytes used by keys in a given column.
pub fn key_size(self) -> usize {
match self {
Self::OverflowLRUCache => 40,
Self::BeaconMeta
| Self::BeaconBlock
| Self::BeaconState
| Self::BeaconBlob
| Self::BeaconStateSummary
| Self::BeaconStateTemporary
| Self::ExecPayload
Expand All @@ -288,8 +290,6 @@ impl DBColumn {
| Self::PubkeyCache
| Self::BeaconRestorePoint
| Self::DhtEnrs
| Self::BeaconBlob
| Self::OverflowLRUCache
| Self::OptimisticTransitionBlock => 32,
Self::BeaconBlockRoots
| Self::BeaconStateRoots
Expand Down
2 changes: 1 addition & 1 deletion database_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ beacon_node = { workspace = true }
clap = { workspace = true }
clap_utils = { workspace = true }
environment = { workspace = true }
hex = { workspace = true }
logging = { workspace = true }
sloggers = { workspace = true }
store = { workspace = true }
tempfile = { workspace = true }
types = { workspace = true }
slog = { workspace = true }
strum = { workspace = true }
hex = { workspace = true }
2 changes: 0 additions & 2 deletions database_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,6 @@ pub fn inspect_db<E: EthSpec>(
} else {
println!("Successfully saved values to file: {:?}", file_path);
}

total += value.len();
}
}
total += value.len();
Expand Down

0 comments on commit ddfe53e

Please sign in to comment.