Skip to content

Commit b4e79ed

Browse files
committed
Merge remote-tracking branch 'origin/release-v7.0.0' into unstable
2 parents 3bc5f1f + 166f6df commit b4e79ed

File tree

19 files changed

+154
-36
lines changed

19 files changed

+154
-36
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ install-audit:
250250
cargo install --force cargo-audit
251251

252252
audit-CI:
253-
cargo audit
253+
cargo audit --ignore RUSTSEC-2025-0009 --ignore RUSTSEC-2024-0437
254254

255255
# Runs `cargo vendor` to make sure dependencies can be vendored for packaging, reproducibility and archival purpose.
256256
vendor:

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ pub const FORK_CHOICE_DB_KEY: Hash256 = Hash256::ZERO;
144144
/// Defines how old a block can be before it's no longer a candidate for the early attester cache.
145145
const EARLY_ATTESTER_CACHE_HISTORIC_SLOTS: u64 = 4;
146146

147-
/// Defines a distance between the head block slot and the current slot.
148-
///
149-
/// If the head block is older than this value, don't bother preparing beacon proposers.
150-
const PREPARE_PROPOSER_HISTORIC_EPOCHS: u64 = 4;
151-
152147
/// If the head is more than `MAX_PER_SLOT_FORK_CHOICE_DISTANCE` slots behind the wall-clock slot, DO NOT
153148
/// run the per-slot tasks (primarily fork choice).
154149
///
@@ -4848,7 +4843,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
48484843
let proposer_index = if let Some(proposer) = cached_proposer {
48494844
proposer.index as u64
48504845
} else {
4851-
if head_epoch + 2 < proposal_epoch {
4846+
if head_epoch + self.config.sync_tolerance_epochs < proposal_epoch {
48524847
warn!(
48534848
self.log,
48544849
"Skipping proposer preparation";
@@ -6079,19 +6074,18 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
60796074
// Use a blocking task since blocking the core executor on the canonical head read lock can
60806075
// block the core tokio executor.
60816076
let chain = self.clone();
6077+
let tolerance_slots = self.config.sync_tolerance_epochs * T::EthSpec::slots_per_epoch();
60826078
let maybe_prep_data = self
60836079
.spawn_blocking_handle(
60846080
move || {
60856081
let cached_head = chain.canonical_head.cached_head();
60866082

60876083
// Don't bother with proposer prep if the head is more than
6088-
// `PREPARE_PROPOSER_HISTORIC_EPOCHS` prior to the current slot.
6084+
// `sync_tolerance_epochs` prior to the current slot.
60896085
//
60906086
// This prevents the routine from running during sync.
60916087
let head_slot = cached_head.head_slot();
6092-
if head_slot + T::EthSpec::slots_per_epoch() * PREPARE_PROPOSER_HISTORIC_EPOCHS
6093-
< current_slot
6094-
{
6088+
if head_slot + tolerance_slots < current_slot {
60956089
debug!(
60966090
chain.log,
60976091
"Head too old for proposer prep";

beacon_node/beacon_chain/src/bellatrix_readiness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
171171
return BellatrixReadiness::NotSynced;
172172
}
173173
let params = MergeConfig::from_chainspec(&self.spec);
174-
let current_difficulty = el.get_current_difficulty().await.ok();
174+
let current_difficulty = el.get_current_difficulty().await.ok().flatten();
175175
BellatrixReadiness::Ready {
176176
config: params,
177177
current_difficulty,

beacon_node/beacon_chain/src/chain_config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pub const DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR: u32 = 3;
1616
/// Fraction of a slot lookahead for fork choice in the state advance timer (500ms on mainnet).
1717
pub const FORK_CHOICE_LOOKAHEAD_FACTOR: u32 = 24;
1818

19+
/// Default sync tolerance epochs.
20+
pub const DEFAULT_SYNC_TOLERANCE_EPOCHS: u64 = 2;
21+
1922
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
2023
pub struct ChainConfig {
2124
/// Maximum number of slots to skip when importing an attestation.
@@ -94,6 +97,9 @@ pub struct ChainConfig {
9497
/// The delay in milliseconds applied by the node between sending each blob or data column batch.
9598
/// This doesn't apply if the node is the block proposer.
9699
pub blob_publication_batch_interval: Duration,
100+
/// The max distance between the head block and the current slot at which Lighthouse will
101+
/// consider itself synced and still serve validator-related requests.
102+
pub sync_tolerance_epochs: u64,
97103
/// Artificial delay for block publishing. For PeerDAS testing only.
98104
pub block_publishing_delay: Option<Duration>,
99105
/// Artificial delay for data column publishing. For PeerDAS testing only.
@@ -133,6 +139,7 @@ impl Default for ChainConfig {
133139
enable_sampling: false,
134140
blob_publication_batches: 4,
135141
blob_publication_batch_interval: Duration::from_millis(300),
142+
sync_tolerance_epochs: DEFAULT_SYNC_TOLERANCE_EPOCHS,
136143
block_publishing_delay: None,
137144
data_column_publishing_delay: None,
138145
}

beacon_node/execution_layer/src/engine_api.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,18 @@ pub struct ExecutionBlock {
142142
pub block_number: u64,
143143

144144
pub parent_hash: ExecutionBlockHash,
145-
pub total_difficulty: Uint256,
145+
pub total_difficulty: Option<Uint256>,
146146
#[serde(with = "serde_utils::u64_hex_be")]
147147
pub timestamp: u64,
148148
}
149149

150+
impl ExecutionBlock {
151+
pub fn terminal_total_difficulty_reached(&self, terminal_total_difficulty: Uint256) -> bool {
152+
self.total_difficulty
153+
.is_none_or(|td| td >= terminal_total_difficulty)
154+
}
155+
}
156+
150157
#[superstruct(
151158
variants(V1, V2, V3),
152159
variant_attributes(derive(Clone, Debug, Eq, Hash, PartialEq),),

beacon_node/execution_layer/src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ impl<E: EthSpec> ExecutionLayer<E> {
621621
}
622622

623623
/// Get the current difficulty of the PoW chain.
624-
pub async fn get_current_difficulty(&self) -> Result<Uint256, ApiError> {
624+
pub async fn get_current_difficulty(&self) -> Result<Option<Uint256>, ApiError> {
625625
let block = self
626626
.engine()
627627
.api
@@ -1680,7 +1680,8 @@ impl<E: EthSpec> ExecutionLayer<E> {
16801680
self.execution_blocks().await.put(block.block_hash, block);
16811681

16821682
loop {
1683-
let block_reached_ttd = block.total_difficulty >= spec.terminal_total_difficulty;
1683+
let block_reached_ttd =
1684+
block.terminal_total_difficulty_reached(spec.terminal_total_difficulty);
16841685
if block_reached_ttd {
16851686
if block.parent_hash == ExecutionBlockHash::zero() {
16861687
return Ok(Some(block));
@@ -1689,7 +1690,8 @@ impl<E: EthSpec> ExecutionLayer<E> {
16891690
.get_pow_block(engine, block.parent_hash)
16901691
.await?
16911692
.ok_or(ApiError::ExecutionBlockNotFound(block.parent_hash))?;
1692-
let parent_reached_ttd = parent.total_difficulty >= spec.terminal_total_difficulty;
1693+
let parent_reached_ttd =
1694+
parent.terminal_total_difficulty_reached(spec.terminal_total_difficulty);
16931695

16941696
if block_reached_ttd && !parent_reached_ttd {
16951697
return Ok(Some(block));
@@ -1765,9 +1767,11 @@ impl<E: EthSpec> ExecutionLayer<E> {
17651767
parent: ExecutionBlock,
17661768
spec: &ChainSpec,
17671769
) -> bool {
1768-
let is_total_difficulty_reached = block.total_difficulty >= spec.terminal_total_difficulty;
1769-
let is_parent_total_difficulty_valid =
1770-
parent.total_difficulty < spec.terminal_total_difficulty;
1770+
let is_total_difficulty_reached =
1771+
block.terminal_total_difficulty_reached(spec.terminal_total_difficulty);
1772+
let is_parent_total_difficulty_valid = parent
1773+
.total_difficulty
1774+
.is_some_and(|td| td < spec.terminal_total_difficulty);
17711775
is_total_difficulty_reached && is_parent_total_difficulty_valid
17721776
}
17731777

beacon_node/execution_layer/src/test_utils/execution_block_generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ impl<E: EthSpec> Block<E> {
8484
block_hash: block.block_hash,
8585
block_number: block.block_number,
8686
parent_hash: block.parent_hash,
87-
total_difficulty: block.total_difficulty,
87+
total_difficulty: Some(block.total_difficulty),
8888
timestamp: block.timestamp,
8989
},
9090
Block::PoS(payload) => ExecutionBlock {
9191
block_hash: payload.block_hash(),
9292
block_number: payload.block_number(),
9393
parent_hash: payload.parent_hash(),
94-
total_difficulty,
94+
total_difficulty: Some(total_difficulty),
9595
timestamp: payload.timestamp(),
9696
},
9797
}

beacon_node/http_api/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ use warp_utils::{query::multi_key_query, reject::convert_rejection, uor::Unifyin
107107

108108
const API_PREFIX: &str = "eth";
109109

110-
/// If the node is within this many epochs from the head, we declare it to be synced regardless of
111-
/// the network sync state.
112-
///
113-
/// This helps prevent attacks where nodes can convince us that we're syncing some non-existent
114-
/// finalized head.
115-
const DEFAULT_SYNC_TOLERANCE_EPOCHS: u64 = 8;
116-
117110
/// A custom type which allows for both unsecured and TLS-enabled HTTP servers.
118111
type HttpServer = (SocketAddr, Pin<Box<dyn Future<Output = ()> + Send>>);
119112

@@ -461,10 +454,8 @@ pub fn serve<T: BeaconChainTypes>(
461454
)
462455
})?;
463456

464-
let sync_tolerance_epochs = config
465-
.sync_tolerance_epochs
466-
.unwrap_or(DEFAULT_SYNC_TOLERANCE_EPOCHS);
467-
let tolerance = sync_tolerance_epochs * T::EthSpec::slots_per_epoch();
457+
let tolerance =
458+
chain.config.sync_tolerance_epochs * T::EthSpec::slots_per_epoch();
468459

469460
if head_slot + tolerance >= current_slot {
470461
Ok(())

beacon_node/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ pub fn get_config<E: EthSpec>(
191191
client_config.chain.enable_light_client_server = false;
192192
}
193193

194+
if let Some(sync_tolerance_epochs) =
195+
clap_utils::parse_optional(cli_args, "sync-tolerance-epochs")?
196+
{
197+
client_config.chain.sync_tolerance_epochs = sync_tolerance_epochs;
198+
}
199+
194200
if let Some(cache_size) = clap_utils::parse_optional(cli_args, "shuffling-cache-size")? {
195201
client_config.chain.shuffling_cache_size = cache_size;
196202
}

book/src/help_vc.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ Flags:
175175
If this flag is set, Lighthouse will query the Beacon Node for only
176176
block headers during proposals and will sign over headers. Useful for
177177
outsourcing execution payload construction during proposals.
178+
--disable-attesting
179+
Disable the performance of attestation duties (and sync committee
180+
duties). This flag should only be used in emergencies to prioritise
181+
block proposal duties.
178182
--disable-auto-discover
179183
If present, do not attempt to discover new validators in the
180184
validators-dir. Validators will need to be manually added to the
@@ -247,6 +251,13 @@ Flags:
247251
contain sensitive information about your validator and so this flag
248252
should be used with caution. For Windows users, the log file
249253
permissions will be inherited from the parent folder.
254+
--long-timeouts-multiplier <LONG_TIMEOUTS_MULTIPLIER>
255+
If present, the validator client will use a multiplier for the timeout
256+
when making requests to the beacon node. This only takes effect when
257+
the `--use-long-timeouts` flag is present. The timeouts will be the
258+
slot duration multiplied by this value. This flag is generally not
259+
recommended, longer timeouts can cause missed duties when fallbacks
260+
are used. [default: 1]
250261
--metrics
251262
Enable the Prometheus metrics HTTP server. Disabled by default.
252263
--prefer-builder-proposals

0 commit comments

Comments
 (0)