Skip to content

Commit b86434a

Browse files
authored
Merge branch 'unstable' into keep-execution-payload
2 parents c958809 + c9747fb commit b86434a

File tree

190 files changed

+3278
-1240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+3278
-1240
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[env]
22
# Set the number of arenas to 16 when using jemalloc.
33
JEMALLOC_SYS_WITH_MALLOC_CONF = "abort_conf:true,narenas:16"
4+

.github/workflows/test-suite.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ jobs:
392392
cache: false
393393
env:
394394
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
395+
- name: Fetch libssl1.1
396+
run: wget https://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
397+
- name: Install libssl1.1
398+
run: sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
395399
- name: Create Cargo config dir
396400
run: mkdir -p .cargo
397401
- name: Install custom Cargo config

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ members = [
99
"beacon_node/client",
1010
"beacon_node/eth1",
1111
"beacon_node/execution_layer",
12+
"beacon_node/genesis",
1213
"beacon_node/http_api",
1314
"beacon_node/http_metrics",
1415
"beacon_node/lighthouse_network",
1516
"beacon_node/lighthouse_network/gossipsub",
1617
"beacon_node/network",
18+
"beacon_node/operation_pool",
1719
"beacon_node/store",
1820
"beacon_node/timer",
1921

@@ -30,6 +32,7 @@ members = [
3032
"common/eth2_interop_keypairs",
3133
"common/eth2_network_config",
3234
"common/eth2_wallet_manager",
35+
"common/filesystem",
3336
"common/lighthouse_version",
3437
"common/lockfile",
3538
"common/logging",
@@ -48,14 +51,16 @@ members = [
4851
"common/unused_port",
4952
"common/validator_dir",
5053
"common/warp_utils",
54+
5155
"consensus/fixed_bytes",
5256
"consensus/fork_choice",
53-
5457
"consensus/int_to_bytes",
58+
"consensus/merkle_proof",
5559
"consensus/proto_array",
5660
"consensus/safe_arith",
5761
"consensus/state_processing",
5862
"consensus/swap_or_not_shuffle",
63+
"consensus/types",
5964

6065
"crypto/bls",
6166
"crypto/eth2_key_derivation",

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PROFILE ?= release
3030

3131
# List of all hard forks. This list is used to set env variables for several tests so that
3232
# they run for different forks.
33-
FORKS=phase0 altair bellatrix capella deneb electra
33+
FORKS=phase0 altair bellatrix capella deneb electra fulu
3434

3535
# Extra flags for Cargo
3636
CARGO_INSTALL_EXTRA_FLAGS?=

beacon_node/beacon_chain/src/attestation_rewards.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5151
.get_state(&state_root, Some(state_slot))?
5252
.ok_or(BeaconChainError::MissingBeaconState(state_root))?;
5353

54-
match state {
55-
BeaconState::Base(_) => self.compute_attestation_rewards_base(state, validators),
56-
BeaconState::Altair(_)
57-
| BeaconState::Bellatrix(_)
58-
| BeaconState::Capella(_)
59-
| BeaconState::Deneb(_)
60-
| BeaconState::Electra(_) => self.compute_attestation_rewards_altair(state, validators),
54+
if state.fork_name_unchecked().altair_enabled() {
55+
self.compute_attestation_rewards_altair(state, validators)
56+
} else {
57+
self.compute_attestation_rewards_base(state, validators)
6158
}
6259
}
6360

beacon_node/beacon_chain/src/beacon_block_streamer.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use types::{
1515
};
1616
use types::{
1717
ExecutionPayload, ExecutionPayloadBellatrix, ExecutionPayloadCapella, ExecutionPayloadElectra,
18-
ExecutionPayloadHeader,
18+
ExecutionPayloadFulu, ExecutionPayloadHeader,
1919
};
2020

2121
#[derive(PartialEq)]
@@ -99,6 +99,7 @@ fn reconstruct_default_header_block<E: EthSpec>(
9999
ForkName::Capella => ExecutionPayloadCapella::default().into(),
100100
ForkName::Deneb => ExecutionPayloadDeneb::default().into(),
101101
ForkName::Electra => ExecutionPayloadElectra::default().into(),
102+
ForkName::Fulu => ExecutionPayloadFulu::default().into(),
102103
ForkName::Base | ForkName::Altair => {
103104
return Err(Error::PayloadReconstruction(format!(
104105
"Block with fork variant {} has execution payload",
@@ -742,13 +743,14 @@ mod tests {
742743
}
743744

744745
#[tokio::test]
745-
async fn check_all_blocks_from_altair_to_electra() {
746+
async fn check_all_blocks_from_altair_to_fulu() {
746747
let slots_per_epoch = MinimalEthSpec::slots_per_epoch() as usize;
747-
let num_epochs = 10;
748+
let num_epochs = 12;
748749
let bellatrix_fork_epoch = 2usize;
749750
let capella_fork_epoch = 4usize;
750751
let deneb_fork_epoch = 6usize;
751752
let electra_fork_epoch = 8usize;
753+
let fulu_fork_epoch = 10usize;
752754
let num_blocks_produced = num_epochs * slots_per_epoch;
753755

754756
let mut spec = test_spec::<MinimalEthSpec>();
@@ -757,6 +759,7 @@ mod tests {
757759
spec.capella_fork_epoch = Some(Epoch::new(capella_fork_epoch as u64));
758760
spec.deneb_fork_epoch = Some(Epoch::new(deneb_fork_epoch as u64));
759761
spec.electra_fork_epoch = Some(Epoch::new(electra_fork_epoch as u64));
762+
spec.fulu_fork_epoch = Some(Epoch::new(fulu_fork_epoch as u64));
760763
let spec = Arc::new(spec);
761764

762765
let harness = get_harness(VALIDATOR_COUNT, spec.clone());

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 69 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ use std::sync::Arc;
117117
use std::time::Duration;
118118
use store::iter::{BlockRootsIterator, ParentRootBlockIterator, StateRootsIterator};
119119
use store::{
120-
DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore, KeyValueStoreOp, StoreItem, StoreOp,
120+
BlobSidecarListFromRoot, DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore,
121+
KeyValueStoreOp, StoreItem, StoreOp,
121122
};
122123
use task_executor::{ShutdownReason, TaskExecutor};
123124
use tokio::sync::mpsc::Receiver;
@@ -573,7 +574,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
573574
.start_slot(T::EthSpec::slots_per_epoch());
574575
let is_canonical = self
575576
.block_root_at_slot(block_slot, WhenSlotSkipped::None)?
576-
.map_or(false, |canonical_root| block_root == &canonical_root);
577+
.is_some_and(|canonical_root| block_root == &canonical_root);
577578
Ok(block_slot <= finalized_slot && is_canonical)
578579
}
579580

@@ -604,7 +605,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
604605
let slot_is_finalized = state_slot <= finalized_slot;
605606
let canonical = self
606607
.state_root_at_slot(state_slot)?
607-
.map_or(false, |canonical_root| state_root == &canonical_root);
608+
.is_some_and(|canonical_root| state_root == &canonical_root);
608609
Ok(FinalizationAndCanonicity {
609610
slot_is_finalized,
610611
canonical,
@@ -1147,9 +1148,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
11471148
pub fn get_blobs_checking_early_attester_cache(
11481149
&self,
11491150
block_root: &Hash256,
1150-
) -> Result<BlobSidecarList<T::EthSpec>, Error> {
1151+
) -> Result<BlobSidecarListFromRoot<T::EthSpec>, Error> {
11511152
self.early_attester_cache
11521153
.get_blobs(*block_root)
1154+
.map(Into::into)
11531155
.map_or_else(|| self.get_blobs(block_root), Ok)
11541156
}
11551157

@@ -1240,11 +1242,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
12401242
///
12411243
/// ## Errors
12421244
/// May return a database error.
1243-
pub fn get_blobs(&self, block_root: &Hash256) -> Result<BlobSidecarList<T::EthSpec>, Error> {
1244-
match self.store.get_blobs(block_root)? {
1245-
Some(blobs) => Ok(blobs),
1246-
None => Ok(BlobSidecarList::default()),
1247-
}
1245+
pub fn get_blobs(
1246+
&self,
1247+
block_root: &Hash256,
1248+
) -> Result<BlobSidecarListFromRoot<T::EthSpec>, Error> {
1249+
self.store.get_blobs(block_root).map_err(Error::from)
12481250
}
12491251

12501252
/// Returns the data columns at the given root, if any.
@@ -5118,9 +5120,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51185120
.start_of(slot)
51195121
.unwrap_or_else(|| Duration::from_secs(0)),
51205122
);
5121-
block_delays.observed.map_or(false, |delay| {
5122-
delay >= self.slot_clock.unagg_attestation_production_delay()
5123-
})
5123+
block_delays
5124+
.observed
5125+
.is_some_and(|delay| delay >= self.slot_clock.unagg_attestation_production_delay())
51245126
}
51255127

51265128
/// Produce a block for some `slot` upon the given `state`.
@@ -5317,23 +5319,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
53175319

53185320
// If required, start the process of loading an execution payload from the EL early. This
53195321
// allows it to run concurrently with things like attestation packing.
5320-
let prepare_payload_handle = match &state {
5321-
BeaconState::Base(_) | BeaconState::Altair(_) => None,
5322-
BeaconState::Bellatrix(_)
5323-
| BeaconState::Capella(_)
5324-
| BeaconState::Deneb(_)
5325-
| BeaconState::Electra(_) => {
5326-
let prepare_payload_handle = get_execution_payload(
5327-
self.clone(),
5328-
&state,
5329-
parent_root,
5330-
proposer_index,
5331-
builder_params,
5332-
builder_boost_factor,
5333-
block_production_version,
5334-
)?;
5335-
Some(prepare_payload_handle)
5336-
}
5322+
let prepare_payload_handle = if state.fork_name_unchecked().bellatrix_enabled() {
5323+
let prepare_payload_handle = get_execution_payload(
5324+
self.clone(),
5325+
&state,
5326+
parent_root,
5327+
proposer_index,
5328+
builder_params,
5329+
builder_boost_factor,
5330+
block_production_version,
5331+
)?;
5332+
Some(prepare_payload_handle)
5333+
} else {
5334+
None
53375335
};
53385336

53395337
let (mut proposer_slashings, mut attester_slashings, mut voluntary_exits) =
@@ -5751,6 +5749,48 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
57515749
execution_payload_value,
57525750
)
57535751
}
5752+
BeaconState::Fulu(_) => {
5753+
let (
5754+
payload,
5755+
kzg_commitments,
5756+
maybe_blobs_and_proofs,
5757+
maybe_requests,
5758+
execution_payload_value,
5759+
) = block_contents
5760+
.ok_or(BlockProductionError::MissingExecutionPayload)?
5761+
.deconstruct();
5762+
5763+
(
5764+
BeaconBlock::Fulu(BeaconBlockFulu {
5765+
slot,
5766+
proposer_index,
5767+
parent_root,
5768+
state_root: Hash256::zero(),
5769+
body: BeaconBlockBodyFulu {
5770+
randao_reveal,
5771+
eth1_data,
5772+
graffiti,
5773+
proposer_slashings: proposer_slashings.into(),
5774+
attester_slashings: attester_slashings_electra.into(),
5775+
attestations: attestations_electra.into(),
5776+
deposits: deposits.into(),
5777+
voluntary_exits: voluntary_exits.into(),
5778+
sync_aggregate: sync_aggregate
5779+
.ok_or(BlockProductionError::MissingSyncAggregate)?,
5780+
execution_payload: payload
5781+
.try_into()
5782+
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
5783+
bls_to_execution_changes: bls_to_execution_changes.into(),
5784+
blob_kzg_commitments: kzg_commitments
5785+
.ok_or(BlockProductionError::InvalidPayloadFork)?,
5786+
execution_requests: maybe_requests
5787+
.ok_or(BlockProductionError::MissingExecutionRequests)?,
5788+
},
5789+
}),
5790+
maybe_blobs_and_proofs,
5791+
execution_payload_value,
5792+
)
5793+
}
57545794
};
57555795

57565796
let block = SignedBeaconBlock::from_block(

beacon_node/beacon_chain/src/blob_verification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub fn validate_blob_sidecar_for_gossip<T: BeaconChainTypes, O: ObservationStrat
400400
// since we only subscribe to `MaxBlobsPerBlock` subnets over gossip network.
401401
// We include this check only for completeness.
402402
// Getting this error would imply something very wrong with our networking decoding logic.
403-
if blob_index >= T::EthSpec::max_blobs_per_block() as u64 {
403+
if blob_index >= chain.spec.max_blobs_per_block(blob_epoch) {
404404
return Err(GossipBlobError::InvalidSubnet {
405405
expected: subnet,
406406
received: blob_index,

beacon_node/beacon_chain/src/block_verification_types.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ use crate::data_column_verification::{CustodyDataColumn, CustodyDataColumnList};
44
use crate::eth1_finalization_cache::Eth1FinalizationData;
55
use crate::{get_block_root, PayloadVerificationOutcome};
66
use derivative::Derivative;
7-
use ssz_types::VariableList;
87
use state_processing::ConsensusContext;
98
use std::fmt::{Debug, Formatter};
109
use std::sync::Arc;
11-
use types::blob_sidecar::{BlobIdentifier, FixedBlobSidecarList};
10+
use types::blob_sidecar::BlobIdentifier;
1211
use types::{
1312
BeaconBlockRef, BeaconState, BlindedPayload, BlobSidecarList, ChainSpec, Epoch, EthSpec,
1413
Hash256, RuntimeVariableList, SignedBeaconBlock, SignedBeaconBlockHeader, Slot,
@@ -176,23 +175,6 @@ impl<E: EthSpec> RpcBlock<E> {
176175
})
177176
}
178177

179-
pub fn new_from_fixed(
180-
block_root: Hash256,
181-
block: Arc<SignedBeaconBlock<E>>,
182-
blobs: FixedBlobSidecarList<E>,
183-
) -> Result<Self, AvailabilityCheckError> {
184-
let filtered = blobs
185-
.into_iter()
186-
.filter_map(|b| b.clone())
187-
.collect::<Vec<_>>();
188-
let blobs = if filtered.is_empty() {
189-
None
190-
} else {
191-
Some(VariableList::from(filtered))
192-
};
193-
Self::new(Some(block_root), block, blobs)
194-
}
195-
196178
#[allow(clippy::type_complexity)]
197179
pub fn deconstruct(
198180
self,

beacon_node/beacon_chain/src/canonical_head.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,11 +1254,7 @@ pub fn find_reorg_slot<E: EthSpec>(
12541254
($state: ident, $block_root: ident) => {
12551255
std::iter::once(Ok(($state.slot(), $block_root)))
12561256
.chain($state.rev_iter_block_roots(spec))
1257-
.skip_while(|result| {
1258-
result
1259-
.as_ref()
1260-
.map_or(false, |(slot, _)| *slot > lowest_slot)
1261-
})
1257+
.skip_while(|result| result.as_ref().is_ok_and(|(slot, _)| *slot > lowest_slot))
12621258
};
12631259
}
12641260

0 commit comments

Comments
 (0)