Skip to content

chore: account for state availability when fetching sync committees #7435 #7436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions beacon_node/http_api/src/sync_committees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use eth2::types::{self as api_types};
use lighthouse_network::PubsubMessage;
use network::NetworkMessage;
use slot_clock::SlotClock;
use std::cmp::max;
use std::collections::HashMap;
use store::metadata::STATE_UPPER_LIMIT_NO_RETAIN;
use tokio::sync::mpsc::UnboundedSender;
use tracing::{debug, error, warn};
use types::{
Expand Down Expand Up @@ -108,11 +108,21 @@ fn duties_from_state_load<T: BeaconChainTypes>(
// have to transition the head to start of the current period).
//
// We also need to ensure that the load slot is after the Altair fork.
let load_slot = max(
let anchor_info = chain.store.get_anchor_info();
let state_upper_limit = anchor_info.state_upper_limit;
// Compute the lower bound in epoch units.
let computed_epoch = std::cmp::max(
chain.spec.epochs_per_sync_committee_period * sync_committee_period.saturating_sub(1),
altair_fork_epoch,
)
.start_slot(T::EthSpec::slots_per_epoch());
);
let computed_slot = computed_epoch.start_slot(T::EthSpec::slots_per_epoch());
let effective_state_upper_limit = if state_upper_limit == STATE_UPPER_LIMIT_NO_RETAIN {
computed_slot
} else {
state_upper_limit
};

let load_slot = std::cmp::max(computed_slot, effective_state_upper_limit);

let state = chain.state_at_slot(load_slot, StateSkipConfig::WithoutStateRoots)?;

Expand Down
Loading