Skip to content

Commit f8acdac

Browse files
committed
Merge remote-tracking branch 'origin/unstable' into das-sampling-sync
2 parents 2367153 + c5bab04 commit f8acdac

File tree

36 files changed

+762
-342
lines changed

36 files changed

+762
-342
lines changed

.github/workflows/test-suite.yml

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,13 @@ jobs:
221221
name: dockerfile-ubuntu
222222
runs-on: ubuntu-latest
223223
steps:
224-
<<<<<<< HEAD
225224
- uses: actions/checkout@v4
226225
- name: Build the root Dockerfile
227226
run: docker build --build-arg FEATURES=portable -t lighthouse:local .
228227
- name: Test the built image
229228
run: docker run -t lighthouse:local lighthouse --version
230-
eth1-simulator-ubuntu:
231-
name: eth1-simulator-ubuntu
232-
=======
233-
- uses: actions/checkout@v4
234-
- name: Build the root Dockerfile
235-
run: docker build --build-arg FEATURES=portable -t lighthouse:local .
236-
- name: Test the built image
237-
run: docker run -t lighthouse:local lighthouse --version
238229
basic-simulator-ubuntu:
239230
name: basic-simulator-ubuntu
240-
>>>>>>> sigp/unstable
241231
runs-on: ubuntu-latest
242232
steps:
243233
- uses: actions/checkout@v4
@@ -246,50 +236,10 @@ jobs:
246236
with:
247237
channel: stable
248238
cache-target: release
249-
<<<<<<< HEAD
250-
- name: Install Foundry (anvil)
251-
uses: foundry-rs/foundry-toolchain@v1
252-
with:
253-
version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
254-
- name: Run the beacon chain sim that starts from an eth1 contract
255-
run: cargo run --release --bin simulator eth1-sim
256-
merge-transition-ubuntu:
257-
name: merge-transition-ubuntu
258-
=======
259-
- name: Run a basic beacon chain sim that starts from Bellatrix
260-
run: cargo run --release --bin simulator basic-sim
239+
- name: Run a basic beacon chain sim that starts from Bellatrix
240+
run: cargo run --release --bin simulator basic-sim
261241
fallback-simulator-ubuntu:
262242
name: fallback-simulator-ubuntu
263-
>>>>>>> sigp/unstable
264-
runs-on: ubuntu-latest
265-
steps:
266-
- uses: actions/checkout@v4
267-
- name: Get latest version of stable Rust
268-
uses: moonrepo/setup-rust@v1
269-
with:
270-
channel: stable
271-
cache-target: release
272-
<<<<<<< HEAD
273-
- name: Install Foundry (anvil)
274-
uses: foundry-rs/foundry-toolchain@v1
275-
with:
276-
version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
277-
- name: Run the beacon chain sim and go through the merge transition
278-
run: cargo run --release --bin simulator eth1-sim --post-merge
279-
no-eth1-simulator-ubuntu:
280-
name: no-eth1-simulator-ubuntu
281-
runs-on: ubuntu-latest
282-
steps:
283-
- uses: actions/checkout@v4
284-
- name: Get latest version of stable Rust
285-
uses: moonrepo/setup-rust@v1
286-
with:
287-
channel: stable
288-
cache-target: release
289-
- name: Run the beacon chain sim without an eth1 connection
290-
run: cargo run --release --bin simulator no-eth1-sim
291-
syncing-simulator-ubuntu:
292-
name: syncing-simulator-ubuntu
293243
runs-on: ubuntu-latest
294244
steps:
295245
- uses: actions/checkout@v4
@@ -298,16 +248,8 @@ jobs:
298248
with:
299249
channel: stable
300250
cache-target: release
301-
- name: Install Foundry (anvil)
302-
uses: foundry-rs/foundry-toolchain@v1
303-
with:
304-
version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
305-
- name: Run the syncing simulator
306-
run: cargo run --release --bin simulator syncing-sim
307-
=======
308-
- name: Run a beacon chain sim which tests VC fallback behaviour
309-
run: cargo run --release --bin simulator fallback-sim
310-
>>>>>>> sigp/unstable
251+
- name: Run a beacon chain sim which tests VC fallback behaviour
252+
run: cargo run --release --bin simulator fallback-sim
311253
doppelganger-protection-test:
312254
name: doppelganger-protection-test
313255
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "small"]') || 'ubuntu-latest' }}

Cargo.lock

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ libsecp256k1 = "0.7"
119119
log = "0.4"
120120
lru = "0.12"
121121
maplit = "1"
122+
mockall = "0.12"
123+
mockall_double = "0.3"
122124
num_cpus = "1"
123125
parking_lot = "0.12"
124126
paste = "1"

beacon_node/beacon_chain/src/block_verification.rs

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
// returned alongside.
4949
#![allow(clippy::result_large_err)]
5050

51-
use crate::blob_verification::{GossipBlobError, GossipVerifiedBlob};
51+
use crate::blob_verification::{GossipBlobError, GossipVerifiedBlob, GossipVerifiedBlobList};
5252
use crate::block_verification_types::{
5353
AsBlock, BlockContentsError, BlockImportData, GossipVerifiedBlockContents, RpcBlock,
5454
};
@@ -104,8 +104,8 @@ use tree_hash::TreeHash;
104104
use types::data_column_sidecar::DataColumnSidecarError;
105105
use types::{
106106
BeaconBlockRef, BeaconState, BeaconStateError, BlobSidecarList, ChainSpec, CloneConfig,
107-
DataColumnSidecar, DataColumnSubnetId, Epoch, EthSpec, ExecutionBlockHash, Hash256,
108-
InconsistentFork, PublicKey, PublicKeyBytes, RelativeEpoch, SignedBeaconBlock,
107+
DataColumnSidecar, DataColumnSubnetId, Epoch, EthSpec, ExecutionBlockHash, FullPayload,
108+
Hash256, InconsistentFork, PublicKey, PublicKeyBytes, RelativeEpoch, SignedBeaconBlock,
109109
SignedBeaconBlockHeader, Slot,
110110
};
111111
use types::{BlobSidecar, ExecPayload};
@@ -741,43 +741,16 @@ impl<T: BeaconChainTypes> IntoGossipVerifiedBlockContents<T> for PublishBlockReq
741741
})
742742
.transpose()?;
743743

744-
let gossip_verified_data_columns = gossip_verified_blobs
745-
.as_ref()
746-
.map(|blobs| {
747-
// NOTE: we expect KZG to be initialized if the blobs are present
748-
let kzg = chain
749-
.kzg
750-
.as_ref()
751-
.ok_or(BlockContentsError::DataColumnError(
752-
GossipDataColumnError::<T::EthSpec>::KzgNotInitialized,
753-
))?;
754-
755-
let blob_sidecar_list: Vec<_> =
756-
blobs.iter().map(|blob| blob.clone_blob()).collect();
757-
let blob_sidecar_list = BlobSidecarList::new(blob_sidecar_list)
758-
.map_err(DataColumnSidecarError::SszError)?;
759-
let timer = metrics::start_timer(&metrics::DATA_COLUMN_SIDECAR_COMPUTATION);
760-
let sidecars = DataColumnSidecar::build_sidecars(&blob_sidecar_list, &block, kzg)?;
761-
drop(timer);
762-
let mut gossip_verified_data_columns = vec![];
763-
for sidecar in sidecars {
764-
let subnet = DataColumnSubnetId::try_from_column_index::<T::EthSpec>(
765-
sidecar.index as usize,
766-
)
767-
.map_err(|_| {
768-
BlockContentsError::<T::EthSpec>::DataColumnSidecarError(
769-
DataColumnSidecarError::DataColumnIndexOutOfBounds,
770-
)
771-
})?;
772-
let column = GossipVerifiedDataColumn::new(sidecar, subnet.into(), chain)?;
773-
gossip_verified_data_columns.push(column);
774-
}
775-
let gossip_verified_data_columns =
776-
GossipVerifiedDataColumnList::new(gossip_verified_data_columns)
777-
.map_err(DataColumnSidecarError::SszError)?;
778-
Ok::<_, BlockContentsError<T::EthSpec>>(gossip_verified_data_columns)
779-
})
780-
.transpose()?;
744+
let peer_das_enabled = chain
745+
.spec
746+
.peer_das_epoch
747+
.map_or(false, |peer_das_epoch| block.epoch() >= peer_das_epoch);
748+
749+
let gossip_verified_data_columns = if peer_das_enabled {
750+
build_gossip_verified_data_columns(chain, &block, gossip_verified_blobs.as_ref())?
751+
} else {
752+
None
753+
};
781754

782755
let gossip_verified_block = GossipVerifiedBlock::new(block, chain)?;
783756

@@ -793,6 +766,49 @@ impl<T: BeaconChainTypes> IntoGossipVerifiedBlockContents<T> for PublishBlockReq
793766
}
794767
}
795768

769+
fn build_gossip_verified_data_columns<T: BeaconChainTypes>(
770+
chain: &BeaconChain<T>,
771+
block: &SignedBeaconBlock<T::EthSpec, FullPayload<T::EthSpec>>,
772+
gossip_verified_blobs: Option<&GossipVerifiedBlobList<T>>,
773+
) -> Result<Option<GossipVerifiedDataColumnList<T>>, BlockContentsError<T::EthSpec>> {
774+
gossip_verified_blobs
775+
// Only attempt to build data columns if blobs is non empty to avoid skewing the metrics.
776+
.filter(|b| !b.is_empty())
777+
.map(|blobs| {
778+
// NOTE: we expect KZG to be initialized if the blobs are present
779+
let kzg = chain
780+
.kzg
781+
.as_ref()
782+
.ok_or(BlockContentsError::DataColumnError(
783+
GossipDataColumnError::<T::EthSpec>::KzgNotInitialized,
784+
))?;
785+
786+
let blob_sidecar_list: Vec<_> = blobs.iter().map(|blob| blob.clone_blob()).collect();
787+
let blob_sidecar_list = BlobSidecarList::new(blob_sidecar_list)
788+
.map_err(DataColumnSidecarError::SszError)?;
789+
let timer = metrics::start_timer(&metrics::DATA_COLUMN_SIDECAR_COMPUTATION);
790+
let sidecars = DataColumnSidecar::build_sidecars(&blob_sidecar_list, block, kzg)?;
791+
drop(timer);
792+
let mut gossip_verified_data_columns = vec![];
793+
for sidecar in sidecars {
794+
let subnet =
795+
DataColumnSubnetId::try_from_column_index::<T::EthSpec>(sidecar.index as usize)
796+
.map_err(|_| {
797+
BlockContentsError::<T::EthSpec>::DataColumnSidecarError(
798+
DataColumnSidecarError::DataColumnIndexOutOfBounds,
799+
)
800+
})?;
801+
let column = GossipVerifiedDataColumn::new(sidecar, subnet.into(), chain)?;
802+
gossip_verified_data_columns.push(column);
803+
}
804+
let gossip_verified_data_columns =
805+
GossipVerifiedDataColumnList::new(gossip_verified_data_columns)
806+
.map_err(DataColumnSidecarError::SszError)?;
807+
Ok::<_, BlockContentsError<T::EthSpec>>(gossip_verified_data_columns)
808+
})
809+
.transpose()
810+
}
811+
796812
/// Implemented on types that can be converted into a `ExecutionPendingBlock`.
797813
///
798814
/// Used to allow functions to accept blocks at various stages of verification.

beacon_node/beacon_chain/src/block_verification_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ enum RpcBlockInner<E: EthSpec> {
8484
/// This variant is used with parent lookups and by-range responses. It should have all blobs
8585
/// ordered, all block roots matching, and the correct number of blobs for this block.
8686
BlockAndBlobs(Arc<SignedBeaconBlock<E>>, BlobSidecarList<E>),
87-
/// This variant is used with parent lookups and by-range responses. It should have all data columns
88-
/// ordered, all block roots matching, and the correct number of data columns for this block.
87+
/// This variant is used with parent lookups and by-range responses. It should have all
88+
/// requested data columns, all block roots matching for this block.
8989
BlockAndDataColumns(Arc<SignedBeaconBlock<E>>, DataColumnSidecarList<E>),
9090
}
9191

0 commit comments

Comments
 (0)