Skip to content

Commit 0cb8fdf

Browse files
michaelsprouljclapisdutterbutter
authored
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 <[email protected]> Co-authored-by: Dustin Brickwood <[email protected]>
1 parent 72d8c38 commit 0cb8fdf

File tree

9 files changed

+38
-21
lines changed

9 files changed

+38
-21
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ jobs:
282282
| <img src="https://simpleicons.org/icons/docker.svg" style="width: 32px;"/> | Docker | [${{ env.VERSION }}](https://hub.docker.com/r/${{ env.IMAGE_NAME }}/tags?page=1&ordering=last_updated&name=${{ env.VERSION }}) | [${{ env.IMAGE_NAME }}](https://hub.docker.com/r/${{ env.IMAGE_NAME }}) |
283283
ENDBODY
284284
)
285-
assets=()
286-
for asset in ./lighthouse-*.tar.gz*; do
287-
assets+=("-a" "$asset/$asset")
288-
done
285+
assets=(./lighthouse-*.tar.gz*)
289286
tag_name="${{ env.VERSION }}"
290-
echo "$body" | hub release create --draft "${assets[@]}" -F "-" "$tag_name"
287+
echo "$body" | gh release create --draft -F "-" "$tag_name" "${assets[@]}"

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-de
33
COPY . lighthouse
44
ARG FEATURES
55
ARG PROFILE=release
6+
ARG CARGO_USE_GIT_CLI=false
67
ENV FEATURES $FEATURES
78
ENV PROFILE $PROFILE
9+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_USE_GIT_CLI
810
RUN cd lighthouse && make
911

1012
FROM ubuntu:22.04

beacon_node/beacon_chain/src/historical_blocks.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
140140
prev_block_slot = block.slot();
141141
expected_block_root = block.message().parent_root();
142142

143-
// If we've reached genesis, add the genesis block root to the batch and set the
144-
// anchor slot to 0 to indicate completion.
143+
// If we've reached genesis, add the genesis block root to the batch for all slots
144+
// between 0 and the first block slot, and set the anchor slot to 0 to indicate
145+
// completion.
145146
if expected_block_root == self.genesis_block_root {
146147
let genesis_slot = self.spec.genesis_slot;
147-
cold_batch.push(KeyValueStoreOp::PutKeyValue(
148-
get_key_for_col(
149-
DBColumn::BeaconBlockRoots.into(),
150-
&genesis_slot.as_u64().to_be_bytes(),
151-
),
152-
self.genesis_block_root.as_bytes().to_vec(),
153-
));
148+
for slot in genesis_slot.as_u64()..block.slot().as_u64() {
149+
cold_batch.push(KeyValueStoreOp::PutKeyValue(
150+
get_key_for_col(DBColumn::BeaconBlockRoots.into(), &slot.to_be_bytes()),
151+
self.genesis_block_root.as_bytes().to_vec(),
152+
));
153+
}
154154
prev_block_slot = genesis_slot;
155155
expected_block_root = Hash256::zero();
156156
break;

beacon_node/beacon_chain/tests/store_tests.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,18 @@ async fn weak_subjectivity_sync_unaligned_unadvanced_checkpoint() {
21032103
weak_subjectivity_sync_test(slots, checkpoint_slot).await
21042104
}
21052105

2106+
// Regression test for https://github.com/sigp/lighthouse/issues/4817
2107+
// Skip 3 slots immediately after genesis, creating a gap between the genesis block and the first
2108+
// real block.
2109+
#[tokio::test]
2110+
async fn weak_subjectivity_sync_skips_at_genesis() {
2111+
let start_slot = 4;
2112+
let end_slot = E::slots_per_epoch() * 4;
2113+
let slots = (start_slot..end_slot).map(Slot::new).collect();
2114+
let checkpoint_slot = Slot::new(E::slots_per_epoch() * 2);
2115+
weak_subjectivity_sync_test(slots, checkpoint_slot).await
2116+
}
2117+
21062118
async fn weak_subjectivity_sync_test(slots: Vec<Slot>, checkpoint_slot: Slot) {
21072119
// Build an initial chain on one harness, representing a synced node with full history.
21082120
let num_final_blocks = E::slots_per_epoch() * 2;

beacon_node/store/src/forwards_iter.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,15 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
7272
let anchor_info = self.get_anchor_info();
7373
// There are no historic states stored if the state upper limit lies in the hot
7474
// database. It hasn't been reached yet, and may never be.
75-
if anchor_info.map_or(false, |a| a.state_upper_limit >= split_slot) {
75+
if anchor_info.as_ref().map_or(false, |a| {
76+
a.state_upper_limit >= split_slot && a.state_lower_limit == 0
77+
}) {
7678
None
79+
} else if let Some(lower_limit) = anchor_info
80+
.map(|a| a.state_lower_limit)
81+
.filter(|limit| *limit > 0)
82+
{
83+
Some(lower_limit)
7784
} else {
7885
// Otherwise if the state upper limit lies in the freezer or all states are
7986
// reconstructed then state roots are available up to the split slot.

beacon_node/store/src/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ssz::{Decode, Encode};
44
use ssz_derive::{Decode, Encode};
55
use types::{Checkpoint, Hash256, Slot};
66

7-
pub const CURRENT_SCHEMA_VERSION: SchemaVersion = SchemaVersion(25);
7+
pub const CURRENT_SCHEMA_VERSION: SchemaVersion = SchemaVersion(24);
88

99
// All the keys that get stored under the `BeaconMeta` column.
1010
//

book/src/api-lighthouse.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ reconstruction has yet to be completed. For more information
547547
on the specific meanings of these fields see the docs on [Checkpoint
548548
Sync](./checkpoint-sync.md#reconstructing-states).
549549

550-
551550
### `/lighthouse/merge_readiness`
552551
Returns the current difficulty and terminal total difficulty of the network. Before [The Merge](https://ethereum.org/en/roadmap/merge/) on 15<sup>th</sup> September 2022, you will see that the current difficulty is less than the terminal total difficulty, An example is shown below:
553552
```bash

database_manager/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,6 @@ pub fn inspect_db<E: EthSpec>(
365365
} else {
366366
println!("Successfully saved values to file: {:?}", file_path);
367367
}
368-
369-
total += value.len();
370368
}
371369
}
372370
total += value.len();

lcli/src/skip_slots.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ pub fn run<T: EthSpec>(
110110
}
111111
_ => return Err("must supply either --state-path or --beacon-url".into()),
112112
};
113+
let mut post_state = None;
113114

114115
let initial_slot = state.slot();
115116
let target_slot = initial_slot + slots;
@@ -141,14 +142,15 @@ pub fn run<T: EthSpec>(
141142

142143
let duration = Instant::now().duration_since(start);
143144
info!("Run {}: {:?}", i, duration);
145+
post_state = Some(state);
144146
}
145147

146-
if let Some(output_path) = output_path {
148+
if let (Some(post_state), Some(output_path)) = (post_state, output_path) {
147149
let mut output_file = File::create(output_path)
148150
.map_err(|e| format!("Unable to create output file: {:?}", e))?;
149151

150152
output_file
151-
.write_all(&state.as_ssz_bytes())
153+
.write_all(&post_state.as_ssz_bytes())
152154
.map_err(|e| format!("Unable to write to output file: {:?}", e))?;
153155
}
154156

0 commit comments

Comments
 (0)