Various small tree-states fixes (#4861)

* Fix block backfill with genesis skip slots

* Fix freezer upper limit

* Fix: write post state in lcli skip-slots (#4843)

* Added CARGO_USE_GIT_CLI to the Dockerfile (#4828)

* chore: replace deprecated hub with gh for releases (#4839)

* Put schema version back to 24 (ignore Deneb)

* Minimise diff

---------

Co-authored-by: Joe Clapis <jclapis@outlook.com>
Co-authored-by: Dustin Brickwood <dustinbrickwood204@gmail.com>
This commit is contained in:
Michael Sproul
2023-10-19 14:59:29 +11:00
committed by GitHub
parent 72d8c3852c
commit 0cb8fdf370
9 changed files with 38 additions and 21 deletions

View File

@@ -140,17 +140,17 @@ 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;
cold_batch.push(KeyValueStoreOp::PutKeyValue(
get_key_for_col(
DBColumn::BeaconBlockRoots.into(),
&genesis_slot.as_u64().to_be_bytes(),
),
self.genesis_block_root.as_bytes().to_vec(),
));
for slot in genesis_slot.as_u64()..block.slot().as_u64() {
cold_batch.push(KeyValueStoreOp::PutKeyValue(
get_key_for_col(DBColumn::BeaconBlockRoots.into(), &slot.to_be_bytes()),
self.genesis_block_root.as_bytes().to_vec(),
));
}
prev_block_slot = genesis_slot;
expected_block_root = Hash256::zero();
break;

View File

@@ -2103,6 +2103,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;

View File

@@ -72,8 +72,15 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
let anchor_info = self.get_anchor_info();
// There are no historic states stored if the state upper limit lies in the hot
// database. It hasn't been reached yet, and may never be.
if anchor_info.map_or(false, |a| a.state_upper_limit >= split_slot) {
if anchor_info.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_info
.map(|a| a.state_lower_limit)
.filter(|limit| *limit > 0)
{
Some(lower_limit)
} else {
// Otherwise if the state upper limit lies in the freezer or all states are
// reconstructed then state roots are available up to the split slot.

View File

@@ -4,7 +4,7 @@ use ssz::{Decode, Encode};
use ssz_derive::{Decode, Encode};
use types::{Checkpoint, Hash256, Slot};
pub const CURRENT_SCHEMA_VERSION: SchemaVersion = SchemaVersion(25);
pub const CURRENT_SCHEMA_VERSION: SchemaVersion = SchemaVersion(24);
// All the keys that get stored under the `BeaconMeta` column.
//