Merge branch 'unstable' into into-anchor

This commit is contained in:
Daniel Knopik
2025-02-10 08:41:20 +01:00
207 changed files with 8646 additions and 4714 deletions

View File

@@ -1,4 +1,4 @@
TESTS_TAG := v1.5.0-beta.0
TESTS_TAG := v1.5.0-beta.2
TESTS = general minimal mainnet
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))

View File

@@ -49,11 +49,9 @@ excluded_paths = [
"bls12-381-tests/hash_to_G2",
"tests/.*/eip6110",
"tests/.*/whisk",
"tests/.*/eip7594",
# Fulu tests are not yet being run
# TODO(das): Fulu tests are ignored for now
"tests/.*/fulu",
# TODO(electra): SingleAttestation tests are waiting on Eitan's PR
"tests/.*/electra/ssz_static/SingleAttestation"
"tests/.*/fulu/ssz_static/MatrixEntry",
]

View File

@@ -91,6 +91,9 @@ pub use transition::TransitionTest;
/// to return `true` for the feature in order for the feature test vector to be tested.
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum FeatureName {
// TODO(fulu): to be removed once we start using Fulu types for test vectors.
// Existing SSZ types for PeerDAS (Fulu) are the same as Electra, so the test vectors get
// loaded as Electra types (default serde behaviour for untagged enums).
Fulu,
}

View File

@@ -21,12 +21,8 @@ impl<E: EthSpec> LoadCase for ComputeColumnsForCustodyGroups<E> {
}
impl<E: EthSpec> Case for ComputeColumnsForCustodyGroups<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

View File

@@ -24,12 +24,8 @@ impl<E: EthSpec> LoadCase for GetCustodyGroups<E> {
}
impl<E: EthSpec> Case for GetCustodyGroups<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

View File

@@ -26,12 +26,8 @@ impl<E: EthSpec> LoadCase for KZGComputeCellsAndKZGProofs<E> {
}
impl<E: EthSpec> Case for KZGComputeCellsAndKZGProofs<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

View File

@@ -27,12 +27,8 @@ impl<E: EthSpec> LoadCase for KZGRecoverCellsAndKZGProofs<E> {
}
impl<E: EthSpec> Case for KZGRecoverCellsAndKZGProofs<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

View File

@@ -29,12 +29,8 @@ impl<E: EthSpec> LoadCase for KZGVerifyCellKZGProofBatch<E> {
}
impl<E: EthSpec> Case for KZGVerifyCellKZGProofBatch<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

View File

@@ -25,9 +25,9 @@ use std::fmt::Debug;
use types::{
Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockBodyBellatrix,
BeaconBlockBodyCapella, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconState,
BlindedPayload, ConsolidationRequest, Deposit, DepositRequest, ExecutionPayload, FullPayload,
ProposerSlashing, SignedBlsToExecutionChange, SignedVoluntaryExit, SyncAggregate,
WithdrawalRequest,
BlindedPayload, ConsolidationRequest, Deposit, DepositRequest, ExecutionPayload,
ForkVersionDecode, FullPayload, ProposerSlashing, SignedBlsToExecutionChange,
SignedVoluntaryExit, SyncAggregate, WithdrawalRequest,
};
#[derive(Debug, Clone, Default, Deserialize)]
@@ -398,7 +398,7 @@ impl<E: EthSpec> Operation<E> for WithdrawalsPayload<E> {
fn decode(path: &Path, fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
ssz_decode_file_with(path, |bytes| {
ExecutionPayload::from_ssz_bytes(bytes, fork_name)
ExecutionPayload::from_ssz_bytes_by_fork(bytes, fork_name)
})
.map(|payload| WithdrawalsPayload {
payload: payload.into(),

View File

@@ -355,11 +355,14 @@ where
}
fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
// This ensures we only run the tests **once** for the feature, using the types matching the
// correct fork, e.g. `Fulu` uses SSZ types from `Electra` fork as of spec test version
// `v1.5.0-beta.0`, therefore the `Fulu` tests should get included when testing Electra types.
// TODO(fulu): to be removed once Fulu types start differing from Electra. We currently run Fulu tests as a
// "feature" - this means we use Electra types for Fulu SSZ tests (except for PeerDAS types, e.g. `DataColumnSidecar`).
//
// e.g. Fulu test vectors are executed in the first line below, but excluded in the 2nd
// This ensures we only run the tests **once** for `Fulu`, using the types matching the
// correct fork, e.g. `Fulu` uses SSZ types from `Electra` as of spec test version
// `v1.5.0-beta.0`, therefore the `Fulu` tests should get included when testing Deneb types.
//
// e.g. Fulu test vectors are executed in the 2nd line below, but excluded in the 1st
// line when testing the type `AttestationElectra`:
//
// ```
@@ -677,6 +680,11 @@ impl<E: EthSpec + TypeName> Handler for ForkChoiceHandler<E> {
return false;
}
// Deposit tests exist only after Electra.
if self.handler_name == "deposit_with_reorg" && !fork_name.electra_enabled() {
return false;
}
// These tests check block validity (which may include signatures) and there is no need to
// run them with fake crypto.
cfg!(not(feature = "fake_crypto"))
@@ -890,6 +898,10 @@ impl<E: EthSpec + TypeName> Handler for GetCustodyGroupsHandler<E> {
fn handler_name(&self) -> String {
"get_custody_groups".into()
}
fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}
#[derive(Derivative)]
@@ -910,6 +922,10 @@ impl<E: EthSpec + TypeName> Handler for ComputeColumnsForCustodyGroupHandler<E>
fn handler_name(&self) -> String {
"compute_columns_for_custody_group".into()
}
fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}
#[derive(Derivative)]
@@ -930,6 +946,10 @@ impl<E: EthSpec> Handler for KZGComputeCellsAndKZGProofHandler<E> {
fn handler_name(&self) -> String {
"compute_cells_and_kzg_proofs".into()
}
fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}
#[derive(Derivative)]
@@ -950,6 +970,10 @@ impl<E: EthSpec> Handler for KZGVerifyCellKZGProofBatchHandler<E> {
fn handler_name(&self) -> String {
"verify_cell_kzg_proof_batch".into()
}
fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}
#[derive(Derivative)]
@@ -970,6 +994,10 @@ impl<E: EthSpec> Handler for KZGRecoverCellsAndKZGProofHandler<E> {
fn handler_name(&self) -> String {
"recover_cells_and_kzg_proofs".into()
}
fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}
#[derive(Derivative)]

View File

@@ -54,6 +54,7 @@ type_name_generic!(BeaconBlockBodyBellatrix, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyCapella, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyDeneb, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyElectra, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyFulu, "BeaconBlockBody");
type_name!(BeaconBlockHeader);
type_name_generic!(BeaconState);
type_name!(BlobIdentifier);
@@ -74,12 +75,14 @@ type_name_generic!(ExecutionPayloadBellatrix, "ExecutionPayload");
type_name_generic!(ExecutionPayloadCapella, "ExecutionPayload");
type_name_generic!(ExecutionPayloadDeneb, "ExecutionPayload");
type_name_generic!(ExecutionPayloadElectra, "ExecutionPayload");
type_name_generic!(ExecutionPayloadFulu, "ExecutionPayload");
type_name_generic!(FullPayload, "ExecutionPayload");
type_name_generic!(ExecutionPayloadHeader);
type_name_generic!(ExecutionPayloadHeaderBellatrix, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderCapella, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderDeneb, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderElectra, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderFulu, "ExecutionPayloadHeader");
type_name_generic!(ExecutionRequests);
type_name_generic!(BlindedPayload, "ExecutionPayloadHeader");
type_name!(Fork);
@@ -93,6 +96,7 @@ type_name_generic!(LightClientBootstrapAltair, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapCapella, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapDeneb, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapElectra, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapFulu, "LightClientBootstrap");
type_name_generic!(LightClientFinalityUpdate);
type_name_generic!(LightClientFinalityUpdateAltair, "LightClientFinalityUpdate");
type_name_generic!(
@@ -104,11 +108,13 @@ type_name_generic!(
LightClientFinalityUpdateElectra,
"LightClientFinalityUpdate"
);
type_name_generic!(LightClientFinalityUpdateFulu, "LightClientFinalityUpdate");
type_name_generic!(LightClientHeader);
type_name_generic!(LightClientHeaderAltair, "LightClientHeader");
type_name_generic!(LightClientHeaderCapella, "LightClientHeader");
type_name_generic!(LightClientHeaderDeneb, "LightClientHeader");
type_name_generic!(LightClientHeaderElectra, "LightClientHeader");
type_name_generic!(LightClientHeaderFulu, "LightClientHeader");
type_name_generic!(LightClientOptimisticUpdate);
type_name_generic!(
LightClientOptimisticUpdateAltair,
@@ -126,11 +132,16 @@ type_name_generic!(
LightClientOptimisticUpdateElectra,
"LightClientOptimisticUpdate"
);
type_name_generic!(
LightClientOptimisticUpdateFulu,
"LightClientOptimisticUpdate"
);
type_name_generic!(LightClientUpdate);
type_name_generic!(LightClientUpdateAltair, "LightClientUpdate");
type_name_generic!(LightClientUpdateCapella, "LightClientUpdate");
type_name_generic!(LightClientUpdateDeneb, "LightClientUpdate");
type_name_generic!(LightClientUpdateElectra, "LightClientUpdate");
type_name_generic!(LightClientUpdateFulu, "LightClientUpdate");
type_name_generic!(PendingAttestation);
type_name!(PendingConsolidation);
type_name!(PendingPartialWithdrawal);
@@ -144,6 +155,7 @@ type_name!(SignedBeaconBlockHeader);
type_name_generic!(SignedContributionAndProof);
type_name!(SignedVoluntaryExit);
type_name!(SigningData);
type_name!(SingleAttestation);
type_name_generic!(SyncCommitteeContribution);
type_name!(SyncCommitteeMessage);
type_name!(SyncAggregatorSelectionData);

View File

@@ -276,21 +276,27 @@ mod ssz_static {
fn attestation() {
SszStaticHandler::<AttestationBase<MinimalEthSpec>, MinimalEthSpec>::pre_electra().run();
SszStaticHandler::<AttestationBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra().run();
SszStaticHandler::<AttestationElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only()
SszStaticHandler::<AttestationElectra<MinimalEthSpec>, MinimalEthSpec>::electra_and_later()
.run();
SszStaticHandler::<AttestationElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only()
SszStaticHandler::<AttestationElectra<MainnetEthSpec>, MainnetEthSpec>::electra_and_later()
.run();
}
#[test]
fn single_attestation() {
SszStaticHandler::<SingleAttestation, MinimalEthSpec>::electra_and_later().run();
SszStaticHandler::<SingleAttestation, MainnetEthSpec>::electra_and_later().run();
}
#[test]
fn attester_slashing() {
SszStaticHandler::<AttesterSlashingBase<MinimalEthSpec>, MinimalEthSpec>::pre_electra()
.run();
SszStaticHandler::<AttesterSlashingBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra()
.run();
SszStaticHandler::<AttesterSlashingElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only()
SszStaticHandler::<AttesterSlashingElectra<MinimalEthSpec>, MinimalEthSpec>::electra_and_later()
.run();
SszStaticHandler::<AttesterSlashingElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only()
SszStaticHandler::<AttesterSlashingElectra<MainnetEthSpec>, MainnetEthSpec>::electra_and_later()
.run();
}
@@ -300,9 +306,9 @@ mod ssz_static {
.run();
SszStaticHandler::<IndexedAttestationBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra()
.run();
SszStaticHandler::<IndexedAttestationElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only()
SszStaticHandler::<IndexedAttestationElectra<MinimalEthSpec>, MinimalEthSpec>::electra_and_later()
.run();
SszStaticHandler::<IndexedAttestationElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only()
SszStaticHandler::<IndexedAttestationElectra<MainnetEthSpec>, MainnetEthSpec>::electra_and_later()
.run();
}
@@ -314,10 +320,10 @@ mod ssz_static {
SszStaticHandler::<SignedAggregateAndProofBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra(
)
.run();
SszStaticHandler::<SignedAggregateAndProofElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only(
SszStaticHandler::<SignedAggregateAndProofElectra<MinimalEthSpec>, MinimalEthSpec>::electra_and_later(
)
.run();
SszStaticHandler::<SignedAggregateAndProofElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
SszStaticHandler::<SignedAggregateAndProofElectra<MainnetEthSpec>, MainnetEthSpec>::electra_and_later(
)
.run();
}
@@ -328,10 +334,10 @@ mod ssz_static {
.run();
SszStaticHandler::<AggregateAndProofBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra()
.run();
SszStaticHandler::<AggregateAndProofElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only(
SszStaticHandler::<AggregateAndProofElectra<MinimalEthSpec>, MinimalEthSpec>::electra_and_later(
)
.run();
SszStaticHandler::<AggregateAndProofElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
SszStaticHandler::<AggregateAndProofElectra<MainnetEthSpec>, MainnetEthSpec>::electra_and_later(
)
.run();
}
@@ -361,6 +367,8 @@ mod ssz_static {
.run();
SszStaticHandler::<BeaconBlockBodyElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only()
.run();
SszStaticHandler::<BeaconBlockBodyFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only().run();
SszStaticHandler::<BeaconBlockBodyFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only().run();
}
// Altair and later
@@ -399,6 +407,10 @@ mod ssz_static {
.run();
SszStaticHandler::<LightClientBootstrapElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only()
.run();
SszStaticHandler::<LightClientBootstrapFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only()
.run();
SszStaticHandler::<LightClientBootstrapFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only()
.run();
}
// LightClientHeader has no internal indicator of which fork it is for, so we test it separately.
@@ -430,6 +442,10 @@ mod ssz_static {
SszStaticHandler::<LightClientHeaderElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
)
.run();
SszStaticHandler::<LightClientHeaderFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only()
.run();
SszStaticHandler::<LightClientHeaderFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only()
.run();
}
// LightClientOptimisticUpdate has no internal indicator of which fork it is for, so we test it separately.
@@ -445,6 +461,8 @@ mod ssz_static {
SszStaticHandler::<LightClientOptimisticUpdateDeneb<MainnetEthSpec>, MainnetEthSpec>::deneb_only().run();
SszStaticHandler::<LightClientOptimisticUpdateElectra<MinimalEthSpec>, MinimalEthSpec>::electra_only().run();
SszStaticHandler::<LightClientOptimisticUpdateElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only().run();
SszStaticHandler::<LightClientOptimisticUpdateFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only().run();
SszStaticHandler::<LightClientOptimisticUpdateFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only().run();
}
// LightClientFinalityUpdate has no internal indicator of which fork it is for, so we test it separately.
@@ -480,6 +498,12 @@ mod ssz_static {
SszStaticHandler::<LightClientFinalityUpdateElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
)
.run();
SszStaticHandler::<LightClientFinalityUpdateFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only(
)
.run();
SszStaticHandler::<LightClientFinalityUpdateFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only(
)
.run();
}
// LightClientUpdate has no internal indicator of which fork it is for, so we test it separately.
@@ -509,6 +533,10 @@ mod ssz_static {
SszStaticHandler::<LightClientUpdateElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only(
)
.run();
SszStaticHandler::<LightClientUpdateFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only()
.run();
SszStaticHandler::<LightClientUpdateFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only()
.run();
}
#[test]
@@ -566,6 +594,8 @@ mod ssz_static {
.run();
SszStaticHandler::<ExecutionPayloadElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only()
.run();
SszStaticHandler::<ExecutionPayloadFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only().run();
SszStaticHandler::<ExecutionPayloadFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only().run();
}
#[test]
@@ -586,6 +616,10 @@ mod ssz_static {
::electra_only().run();
SszStaticHandler::<ExecutionPayloadHeaderElectra<MainnetEthSpec>, MainnetEthSpec>
::electra_only().run();
SszStaticHandler::<ExecutionPayloadHeaderFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only()
.run();
SszStaticHandler::<ExecutionPayloadHeaderFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only()
.run();
}
#[test]
@@ -626,17 +660,17 @@ mod ssz_static {
#[test]
fn data_column_sidecar() {
SszStaticHandler::<DataColumnSidecar<MinimalEthSpec>, MinimalEthSpec>::deneb_only()
SszStaticHandler::<DataColumnSidecar<MinimalEthSpec>, MinimalEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnSidecar<MainnetEthSpec>, MainnetEthSpec>::deneb_only()
SszStaticHandler::<DataColumnSidecar<MainnetEthSpec>, MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
}
#[test]
fn data_column_identifier() {
SszStaticHandler::<DataColumnIdentifier, MinimalEthSpec>::deneb_only()
SszStaticHandler::<DataColumnIdentifier, MinimalEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnIdentifier, MainnetEthSpec>::deneb_only()
SszStaticHandler::<DataColumnIdentifier, MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
}
@@ -852,6 +886,12 @@ fn fork_choice_get_proposer_head() {
ForkChoiceHandler::<MainnetEthSpec>::new("get_proposer_head").run();
}
#[test]
fn fork_choice_deposit_with_reorg() {
ForkChoiceHandler::<MinimalEthSpec>::new("deposit_with_reorg").run();
// There is no mainnet variant for this test.
}
#[test]
fn optimistic_sync() {
OptimisticSyncHandler::<MinimalEthSpec>::default().run();
@@ -901,20 +941,17 @@ fn kzg_verify_kzg_proof() {
#[test]
fn kzg_compute_cells_and_proofs() {
KZGComputeCellsAndKZGProofHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
KZGComputeCellsAndKZGProofHandler::<MainnetEthSpec>::default().run();
}
#[test]
fn kzg_verify_cell_proof_batch() {
KZGVerifyCellKZGProofBatchHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
KZGVerifyCellKZGProofBatchHandler::<MainnetEthSpec>::default().run();
}
#[test]
fn kzg_recover_cells_and_proofs() {
KZGRecoverCellsAndKZGProofHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
KZGRecoverCellsAndKZGProofHandler::<MainnetEthSpec>::default().run();
}
#[test]
@@ -949,14 +986,12 @@ fn rewards() {
#[test]
fn get_custody_groups() {
GetCustodyGroupsHandler::<MainnetEthSpec>::default().run_for_feature(FeatureName::Fulu);
GetCustodyGroupsHandler::<MinimalEthSpec>::default().run_for_feature(FeatureName::Fulu);
GetCustodyGroupsHandler::<MainnetEthSpec>::default().run();
GetCustodyGroupsHandler::<MinimalEthSpec>::default().run()
}
#[test]
fn compute_columns_for_custody_group() {
ComputeColumnsForCustodyGroupHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
ComputeColumnsForCustodyGroupHandler::<MinimalEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
ComputeColumnsForCustodyGroupHandler::<MainnetEthSpec>::default().run();
ComputeColumnsForCustodyGroupHandler::<MinimalEthSpec>::default().run();
}

View File

@@ -7,7 +7,10 @@ use std::{env, fs};
use tempfile::TempDir;
use unused_port::unused_tcp4_port;
const GETH_BRANCH: &str = "master";
// This is not currently used due to the following breaking changes in geth that requires updating our tests:
// 1. removal of `personal` namespace in v1.14.12: See #30704
// 2. removal of `totalDifficulty` field from RPC in v1.14.11. See #30386.
// const GETH_BRANCH: &str = "master";
const GETH_REPO_URL: &str = "https://github.com/ethereum/go-ethereum";
pub fn build_result(repo_dir: &Path) -> Output {
@@ -27,12 +30,14 @@ pub fn build(execution_clients_dir: &Path) {
}
// Get the latest tag on the branch
let last_release = build_utils::get_latest_release(&repo_dir, GETH_BRANCH).unwrap();
build_utils::checkout(&repo_dir, dbg!(&last_release)).unwrap();
// let last_release = build_utils::get_latest_release(&repo_dir, GETH_BRANCH).unwrap();
// Using an older release due to breaking changes in recent releases. See comment on `GETH_BRANCH` const.
let release_tag = "v1.14.10";
build_utils::checkout(&repo_dir, dbg!(release_tag)).unwrap();
// Build geth
build_utils::check_command_output(build_result(&repo_dir), || {
format!("geth make failed using release {last_release}")
format!("geth make failed using release {release_tag}")
});
}

View File

@@ -0,0 +1,14 @@
[package]
name = "validator_test_rig"
version = "0.1.0"
edition = { workspace = true }
[dependencies]
eth2 = { workspace = true }
logging = { workspace = true }
mockito = { workspace = true }
regex = { workspace = true }
sensitive_url = { workspace = true }
serde_json = { workspace = true }
slog = { workspace = true }
types = { workspace = true }

View File

@@ -0,0 +1 @@
pub mod mock_beacon_node;

View File

@@ -0,0 +1,132 @@
use eth2::types::{GenericResponse, SyncingData};
use eth2::{BeaconNodeHttpClient, StatusCode, Timeouts};
use logging::test_logger;
use mockito::{Matcher, Mock, Server, ServerGuard};
use regex::Regex;
use sensitive_url::SensitiveUrl;
use slog::{info, Logger};
use std::marker::PhantomData;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use types::{ChainSpec, ConfigAndPreset, EthSpec, SignedBlindedBeaconBlock};
pub struct MockBeaconNode<E: EthSpec> {
server: ServerGuard,
pub beacon_api_client: BeaconNodeHttpClient,
log: Logger,
_phantom: PhantomData<E>,
pub received_blocks: Arc<Mutex<Vec<SignedBlindedBeaconBlock<E>>>>,
}
impl<E: EthSpec> MockBeaconNode<E> {
pub async fn new() -> Self {
// mock server logging
let server = Server::new_async().await;
let beacon_api_client = BeaconNodeHttpClient::new(
SensitiveUrl::from_str(&server.url()).unwrap(),
Timeouts::set_all(Duration::from_secs(1)),
);
let log = test_logger();
Self {
server,
beacon_api_client,
log,
_phantom: PhantomData,
received_blocks: Arc::new(Mutex::new(Vec::new())),
}
}
/// Resets all mocks
#[allow(dead_code)]
pub fn reset_mocks(&mut self) {
self.server.reset();
}
pub fn mock_config_spec(&mut self, spec: &ChainSpec) {
let path_pattern = Regex::new(r"^/eth/v1/config/spec$").unwrap();
let config_and_preset = ConfigAndPreset::from_chain_spec::<E>(spec, None);
let data = GenericResponse::from(config_and_preset);
self.server
.mock("GET", Matcher::Regex(path_pattern.to_string()))
.with_status(200)
.with_body(serde_json::to_string(&data).unwrap())
.create();
}
pub fn mock_get_node_syncing(&mut self, response: SyncingData) {
let path_pattern = Regex::new(r"^/eth/v1/node/syncing$").unwrap();
let data = GenericResponse::from(response);
self.server
.mock("GET", Matcher::Regex(path_pattern.to_string()))
.with_status(200)
.with_body(serde_json::to_string(&data).unwrap())
.create();
}
/// Mocks the `post_beacon_blinded_blocks_v2_ssz` response with an optional `delay`.
pub fn mock_post_beacon_blinded_blocks_v2_ssz(&mut self, delay: Duration) -> Mock {
let path_pattern = Regex::new(r"^/eth/v2/beacon/blinded_blocks$").unwrap();
let log = self.log.clone();
let url = self.server.url();
let received_blocks = Arc::clone(&self.received_blocks);
self.server
.mock("POST", Matcher::Regex(path_pattern.to_string()))
.match_header("content-type", "application/octet-stream")
.with_status(200)
.with_body_from_request(move |request| {
info!(
log,
"{}",
format!(
"Received published block request on server {} with delay {} s",
url,
delay.as_secs(),
)
);
let body = request.body().expect("Failed to get request body");
let block: SignedBlindedBeaconBlock<E> =
SignedBlindedBeaconBlock::any_from_ssz_bytes(body)
.expect("Failed to deserialize body as SignedBlindedBeaconBlock");
received_blocks.lock().unwrap().push(block);
std::thread::sleep(delay);
vec![]
})
.create()
}
pub fn mock_offline_node(&mut self) -> Mock {
let path_pattern = Regex::new(r"^/eth/v1/node/version$").unwrap();
self.server
.mock("GET", Matcher::Regex(path_pattern.to_string()))
.with_status(StatusCode::INTERNAL_SERVER_ERROR.as_u16() as usize)
.with_header("content-type", "application/json")
.with_body(r#"{"message":"Internal Server Error"}"#)
.create()
}
pub fn mock_online_node(&mut self) -> Mock {
let path_pattern = Regex::new(r"^/eth/v1/node/version$").unwrap();
self.server
.mock("GET", Matcher::Regex(path_pattern.to_string()))
.with_status(200)
.with_header("content-type", "application/json")
.with_body(
r#"{
"data": {
"version": "lighthouse-mock"
}
}"#,
)
.create()
}
}