merge unstable

This commit is contained in:
Eitan Seri-Levi
2025-03-26 12:42:55 -06:00
391 changed files with 12855 additions and 29793 deletions

View File

@@ -39,6 +39,9 @@ type E = MainnetEthSpec;
*
*/
// Default custody group count for tests
const CGC: usize = 8;
/// This test checks that a block that is **invalid** from a gossip perspective gets rejected when using `broadcast_validation=gossip`.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
pub async fn gossip_invalid() {
@@ -331,7 +334,6 @@ pub async fn consensus_partial_pass_only_consensus() {
let validator_count = 64;
let num_initial: u64 = 31;
let tester = InteractiveTester::<E>::new(None, validator_count).await;
let test_logger = tester.harness.logger().clone();
// Create some chain depth.
tester.harness.advance_slot();
@@ -365,9 +367,9 @@ pub async fn consensus_partial_pass_only_consensus() {
);
assert_ne!(block_a.state_root(), block_b.state_root());
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain);
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain, CGC);
assert!(gossip_block_b.is_ok());
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain);
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain, CGC);
assert!(gossip_block_a.is_err());
/* submit `block_b` which should induce equivocation */
@@ -379,7 +381,6 @@ pub async fn consensus_partial_pass_only_consensus() {
ProvenancedBlock::local(gossip_block_b.unwrap(), blobs_b),
tester.harness.chain.clone(),
&channel.0,
test_logger,
validation_level,
StatusCode::ACCEPTED,
network_globals,
@@ -624,7 +625,6 @@ pub async fn equivocation_consensus_late_equivocation() {
let validator_count = 64;
let num_initial: u64 = 31;
let tester = InteractiveTester::<E>::new(None, validator_count).await;
let test_logger = tester.harness.logger().clone();
// Create some chain depth.
tester.harness.advance_slot();
@@ -657,10 +657,10 @@ pub async fn equivocation_consensus_late_equivocation() {
);
assert_ne!(block_a.state_root(), block_b.state_root());
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain);
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain, CGC);
assert!(gossip_block_b.is_ok());
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain);
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain, CGC);
assert!(gossip_block_a.is_err());
let channel = tokio::sync::mpsc::unbounded_channel();
@@ -671,7 +671,6 @@ pub async fn equivocation_consensus_late_equivocation() {
ProvenancedBlock::local(gossip_block_b.unwrap(), blobs_b),
tester.harness.chain,
&channel.0,
test_logger,
validation_level,
StatusCode::ACCEPTED,
network_globals,
@@ -1236,7 +1235,6 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
let validator_count = 64;
let num_initial: u64 = 31;
let tester = InteractiveTester::<E>::new(None, validator_count).await;
let test_logger = tester.harness.logger().clone();
// Create some chain depth.
tester.harness.advance_slot();
@@ -1276,7 +1274,6 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
tester.harness.chain.clone(),
block_a.canonical_root(),
Arc::new(block_a),
test_logger.clone(),
)
.await
.unwrap();
@@ -1284,7 +1281,6 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
tester.harness.chain.clone(),
block_b.canonical_root(),
block_b.clone(),
test_logger.clone(),
)
.await
.unwrap();
@@ -1298,9 +1294,9 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
ProvenancedBlock::Builder(b, _, _) => b,
};
let gossip_block_b = GossipVerifiedBlock::new(inner_block_b, &tester.harness.chain);
let gossip_block_b = GossipVerifiedBlock::new(inner_block_b, &tester.harness.chain, CGC);
assert!(gossip_block_b.is_ok());
let gossip_block_a = GossipVerifiedBlock::new(inner_block_a, &tester.harness.chain);
let gossip_block_a = GossipVerifiedBlock::new(inner_block_a, &tester.harness.chain, CGC);
assert!(gossip_block_a.is_err());
let channel = tokio::sync::mpsc::unbounded_channel();
@@ -1310,7 +1306,6 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
block_b,
tester.harness.chain,
&channel.0,
test_logger,
validation_level,
StatusCode::ACCEPTED,
network_globals,
@@ -1403,7 +1398,7 @@ pub async fn block_seen_on_gossip_without_blobs() {
// Simulate the block being seen on gossip.
block
.clone()
.into_gossip_verified_block(&tester.harness.chain)
.into_gossip_verified_block(&tester.harness.chain, CGC)
.unwrap();
// It should not yet be added to fork choice because blobs have not been seen.
@@ -1472,7 +1467,7 @@ pub async fn block_seen_on_gossip_with_some_blobs() {
// Simulate the block being seen on gossip.
block
.clone()
.into_gossip_verified_block(&tester.harness.chain)
.into_gossip_verified_block(&tester.harness.chain, CGC)
.unwrap();
// Simulate some of the blobs being seen on gossip.

View File

@@ -26,7 +26,6 @@ use http_api::{
BlockId, StateId,
};
use lighthouse_network::{types::SyncState, Enr, EnrExt, PeerId};
use logging::test_logger;
use network::NetworkReceivers;
use proto_array::ExecutionStatus;
use sensitive_url::SensitiveUrl;
@@ -135,7 +134,6 @@ impl ApiTester {
reconstruct_historic_states: config.retain_historic_states,
..ChainConfig::default()
})
.logger(logging::test_logger())
.deterministic_keypairs(VALIDATOR_COUNT)
.deterministic_withdrawal_keypairs(VALIDATOR_COUNT)
.fresh_ephemeral_store()
@@ -277,8 +275,6 @@ impl ApiTester {
"precondition: justification"
);
let log = test_logger();
let ApiServer {
ctx,
server,
@@ -286,7 +282,7 @@ impl ApiTester {
network_rx,
local_enr,
external_peer_id,
} = create_api_server(chain.clone(), &harness.runtime, log).await;
} = create_api_server(chain.clone(), &harness.runtime).await;
harness.runtime.task_executor.spawn(server, "api_server");
@@ -375,7 +371,6 @@ impl ApiTester {
let bls_to_execution_change = harness.make_bls_to_execution_change(4, Address::zero());
let chain = harness.chain.clone();
let log = test_logger();
let ApiServer {
ctx,
@@ -384,7 +379,7 @@ impl ApiTester {
network_rx,
local_enr,
external_peer_id,
} = create_api_server(chain.clone(), &harness.runtime, log).await;
} = create_api_server(chain.clone(), &harness.runtime).await;
harness.runtime.task_executor.spawn(server, "api_server");
@@ -1192,6 +1187,60 @@ impl ApiTester {
self
}
pub async fn test_beacon_states_pending_deposits(self) -> Self {
for state_id in self.interesting_state_ids() {
let mut state_opt = state_id
.state(&self.chain)
.ok()
.map(|(state, _execution_optimistic, _finalized)| state);
let result = self
.client
.get_beacon_states_pending_deposits(state_id.0)
.await
.unwrap()
.map(|res| res.data);
if result.is_none() && state_opt.is_none() {
continue;
}
let state = state_opt.as_mut().expect("result should be none");
let expected = state.pending_deposits().unwrap();
assert_eq!(result.unwrap(), expected.to_vec());
}
self
}
pub async fn test_beacon_states_pending_partial_withdrawals(self) -> Self {
for state_id in self.interesting_state_ids() {
let mut state_opt = state_id
.state(&self.chain)
.ok()
.map(|(state, _execution_optimistic, _finalized)| state);
let result = self
.client
.get_beacon_states_pending_partial_withdrawals(state_id.0)
.await
.unwrap()
.map(|res| res.data);
if result.is_none() && state_opt.is_none() {
continue;
}
let state = state_opt.as_mut().expect("result should be none");
let expected = state.pending_partial_withdrawals().unwrap();
assert_eq!(result.unwrap(), expected.to_vec());
}
self
}
pub async fn test_beacon_headers_all_slots(self) -> Self {
for slot in 0..CHAIN_LENGTH {
let slot = Slot::from(slot);
@@ -5706,19 +5755,6 @@ impl ApiTester {
self
}
pub async fn test_get_lighthouse_database_info(self) -> Self {
let info = self.client.get_lighthouse_database_info().await.unwrap();
assert_eq!(info.anchor, self.chain.store.get_anchor_info());
assert_eq!(info.split, self.chain.store.get_split_info());
assert_eq!(
info.schema_version,
store::metadata::CURRENT_SCHEMA_VERSION.as_u64()
);
self
}
pub async fn test_post_lighthouse_database_reconstruct(self) -> Self {
let response = self
.client
@@ -6346,6 +6382,22 @@ async fn beacon_get_state_info() {
.await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn beacon_get_state_info_electra() {
let mut config = ApiTesterConfig::default();
config.spec.altair_fork_epoch = Some(Epoch::new(0));
config.spec.bellatrix_fork_epoch = Some(Epoch::new(0));
config.spec.capella_fork_epoch = Some(Epoch::new(0));
config.spec.deneb_fork_epoch = Some(Epoch::new(0));
config.spec.electra_fork_epoch = Some(Epoch::new(0));
ApiTester::new_from_config(config)
.await
.test_beacon_states_pending_deposits()
.await
.test_beacon_states_pending_partial_withdrawals()
.await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn beacon_get_blocks() {
ApiTester::new()
@@ -7289,8 +7341,6 @@ async fn lighthouse_endpoints() {
.await
.test_get_lighthouse_staking()
.await
.test_get_lighthouse_database_info()
.await
.test_post_lighthouse_database_reconstruct()
.await
.test_post_lighthouse_liveness()