Skip to content

Commit 4b9c16f

Browse files
authored
Add Electra forks to basic sim tests (#7199)
This PR adds transitions to Electra ~~and Fulu~~ fork epochs in the simulator tests. ~~It also covers blob inclusion verification and data column syncing on a full node in Fulu.~~ UPDATE: Remove fulu fork from sim tests due to #7199 (comment)
1 parent e90fcbe commit 4b9c16f

File tree

6 files changed

+46
-34
lines changed

6 files changed

+46
-34
lines changed

.github/workflows/test-suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ jobs:
295295
with:
296296
channel: stable
297297
cache-target: release
298-
- name: Run a basic beacon chain sim that starts from Bellatrix
298+
- name: Run a basic beacon chain sim that starts from Deneb
299299
run: cargo run --release --bin simulator basic-sim
300300
fallback-simulator-ubuntu:
301301
name: fallback-simulator-ubuntu

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl<E: EthSpec> PendingComponents<E> {
331331
format!(
332332
"block {} blobs {}/{}",
333333
block_count,
334-
self.verified_blobs.len(),
334+
self.verified_blobs.iter().flatten().count(),
335335
num_expected_blobs
336336
)
337337
}

beacon_node/beacon_chain/src/data_column_verification.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use derivative::Derivative;
1010
use fork_choice::ProtoBlock;
1111
use kzg::{Error as KzgError, Kzg};
1212
use proto_array::Block;
13-
use slasher::test_utils::E;
1413
use slot_clock::SlotClock;
1514
use ssz_derive::{Decode, Encode};
1615
use std::iter;
@@ -589,19 +588,19 @@ fn verify_proposer_and_signature<T: BeaconChainTypes>(
589588
chain: &BeaconChain<T>,
590589
) -> Result<(), GossipDataColumnError> {
591590
let column_slot = data_column.slot();
592-
let column_epoch = column_slot.epoch(E::slots_per_epoch());
591+
let slots_per_epoch = T::EthSpec::slots_per_epoch();
592+
let column_epoch = column_slot.epoch(slots_per_epoch);
593593
let column_index = data_column.index;
594594
let block_root = data_column.block_root();
595595
let block_parent_root = data_column.block_parent_root();
596596

597-
let proposer_shuffling_root =
598-
if parent_block.slot.epoch(T::EthSpec::slots_per_epoch()) == column_epoch {
599-
parent_block
600-
.next_epoch_shuffling_id
601-
.shuffling_decision_block
602-
} else {
603-
parent_block.root
604-
};
597+
let proposer_shuffling_root = if parent_block.slot.epoch(slots_per_epoch) == column_epoch {
598+
parent_block
599+
.next_epoch_shuffling_id
600+
.shuffling_decision_block
601+
} else {
602+
parent_block.root
603+
};
605604

606605
// We lock the cache briefly to get or insert a OnceCell, then drop the lock
607606
// before doing proposer shuffling calculation via `OnceCell::get_or_try_init`. This avoids
@@ -649,7 +648,7 @@ fn verify_proposer_and_signature<T: BeaconChainTypes>(
649648

650649
let proposer_index = *epoch_proposers
651650
.proposers
652-
.get(column_slot.as_usize() % T::EthSpec::slots_per_epoch() as usize)
651+
.get(column_slot.as_usize() % slots_per_epoch as usize)
653652
.ok_or_else(|| BeaconChainError::NoProposerForSlot(column_slot))?;
654653

655654
let fork = epoch_proposers.fork;

testing/node_test_rig/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use environment::RuntimeContext;
77
use eth2::{reqwest::ClientBuilder, BeaconNodeHttpClient, Timeouts};
88
use sensitive_url::SensitiveUrl;
99
use std::path::PathBuf;
10-
use std::sync::Arc;
1110
use std::time::Duration;
1211
use std::time::{SystemTime, UNIX_EPOCH};
1312
use tempfile::{Builder as TempBuilder, TempDir};
@@ -249,7 +248,7 @@ impl<E: EthSpec> LocalExecutionNode<E> {
249248
if let Err(e) = std::fs::write(jwt_file_path, config.jwt_key.hex_string()) {
250249
panic!("Failed to write jwt file {}", e);
251250
}
252-
let spec = Arc::new(E::default_spec());
251+
let spec = context.eth2_config.spec.clone();
253252
Self {
254253
server: MockServer::new_with_config(
255254
&context.executor.handle().unwrap(),

testing/simulator/src/basic_sim.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ use environment::tracing_common;
1818
use tracing_subscriber::prelude::*;
1919
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
2020

21+
use logging::build_workspace_filter;
2122
use tokio::time::sleep;
2223
use types::{Epoch, EthSpec, MinimalEthSpec};
2324

2425
const END_EPOCH: u64 = 16;
2526
const GENESIS_DELAY: u64 = 32;
2627
const ALTAIR_FORK_EPOCH: u64 = 0;
2728
const BELLATRIX_FORK_EPOCH: u64 = 0;
28-
const CAPELLA_FORK_EPOCH: u64 = 1;
29-
const DENEB_FORK_EPOCH: u64 = 2;
30-
// const ELECTRA_FORK_EPOCH: u64 = 3;
31-
// const FULU_FORK_EPOCH: u64 = 4;
29+
const CAPELLA_FORK_EPOCH: u64 = 0;
30+
const DENEB_FORK_EPOCH: u64 = 0;
31+
const ELECTRA_FORK_EPOCH: u64 = 2;
3232

3333
const SUGGESTED_FEE_RECIPIENT: [u8; 20] =
3434
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
@@ -116,7 +116,11 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
116116
);
117117

118118
if let Err(e) = tracing_subscriber::registry()
119-
.with(stdout_logging_layer.with_filter(logger_config.debug_level))
119+
.with(
120+
stdout_logging_layer
121+
.with_filter(logger_config.debug_level)
122+
.with_filter(build_workspace_filter()?),
123+
)
120124
.try_init()
121125
{
122126
eprintln!("Failed to initialize dependency logging: {e}");
@@ -130,8 +134,8 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
130134
let genesis_delay = GENESIS_DELAY;
131135

132136
// Convenience variables. Update these values when adding a newer fork.
133-
let latest_fork_version = spec.deneb_fork_version;
134-
let latest_fork_start_epoch = DENEB_FORK_EPOCH;
137+
let latest_fork_version = spec.electra_fork_version;
138+
let latest_fork_start_epoch = ELECTRA_FORK_EPOCH;
135139

136140
spec.seconds_per_slot /= speed_up_factor;
137141
spec.seconds_per_slot = max(1, spec.seconds_per_slot);
@@ -142,8 +146,7 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
142146
spec.bellatrix_fork_epoch = Some(Epoch::new(BELLATRIX_FORK_EPOCH));
143147
spec.capella_fork_epoch = Some(Epoch::new(CAPELLA_FORK_EPOCH));
144148
spec.deneb_fork_epoch = Some(Epoch::new(DENEB_FORK_EPOCH));
145-
//spec.electra_fork_epoch = Some(Epoch::new(ELECTRA_FORK_EPOCH));
146-
//spec.fulu_fork_epoch = Some(Epoch::new(FULU_FORK_EPOCH));
149+
spec.electra_fork_epoch = Some(Epoch::new(ELECTRA_FORK_EPOCH));
147150
let spec = Arc::new(spec);
148151
env.eth2_config.spec = spec.clone();
149152

testing/simulator/src/checks.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,23 @@ pub async fn verify_full_block_production_up_to<E: EthSpec>(
128128
slot_delay(slot, slot_duration).await;
129129
let beacon_nodes = network.beacon_nodes.read();
130130
let beacon_chain = beacon_nodes[0].client.beacon_chain().unwrap();
131-
let num_blocks = beacon_chain
131+
let block_slots = beacon_chain
132132
.chain_dump()
133133
.unwrap()
134134
.iter()
135135
.take_while(|s| s.beacon_block.slot() <= slot)
136-
.count();
136+
.map(|s| s.beacon_block.slot().as_usize())
137+
.collect::<Vec<_>>();
138+
let num_blocks = block_slots.len();
137139
if num_blocks != slot.as_usize() + 1 {
140+
let missed_slots = (0..slot.as_usize())
141+
.filter(|slot| !block_slots.contains(slot))
142+
.collect::<Vec<_>>();
138143
return Err(format!(
139-
"There wasn't a block produced at every slot, got: {}, expected: {}",
144+
"There wasn't a block produced at every slot, got: {}, expected: {}, missed: {:?}",
140145
num_blocks,
141-
slot.as_usize() + 1
146+
slot.as_usize() + 1,
147+
missed_slots
142148
));
143149
}
144150
Ok(())
@@ -185,12 +191,17 @@ pub async fn verify_full_sync_aggregates_up_to<E: EthSpec>(
185191
.get_beacon_blocks::<E>(BlockId::Slot(Slot::new(slot)))
186192
.await
187193
.map(|resp| {
188-
resp.unwrap()
189-
.data
190-
.message()
191-
.body()
192-
.sync_aggregate()
193-
.map(|agg| agg.num_set_bits())
194+
resp.unwrap_or_else(|| {
195+
panic!(
196+
"Beacon block for slot {} not returned from Beacon API",
197+
slot
198+
)
199+
})
200+
.data
201+
.message()
202+
.body()
203+
.sync_aggregate()
204+
.map(|agg| agg.num_set_bits())
194205
})
195206
.map_err(|e| format!("Error while getting beacon block: {:?}", e))?
196207
.map_err(|_| format!("Altair block {} should have sync aggregate", slot))?;

0 commit comments

Comments
 (0)