Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Longarithm committed Oct 8, 2024
1 parent 4e6a949 commit fcaf3e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
5 changes: 3 additions & 2 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2348,8 +2348,9 @@ impl Chain {
let result = epoch_manager.will_shard_layout_change(parent_hash);
let will_shard_layout_change = match result {
Ok(_will_shard_layout_change) => {
// Before state sync is fixed, we don't catch up split shards.
// Assume that all needed shards are tracked already.
// TODO(#11881): before state sync is fixed, we don't catch up
// split shards. Assume that all needed shards are tracked
// already.
// will_shard_layout_change,
false
}
Expand Down
9 changes: 9 additions & 0 deletions core/primitives/src/epoch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ pub struct EpochConfig {
pub validator_selection_config: ValidatorSelectionConfig,
}

impl EpochConfig {
/// Total number of validator seats in the epoch since protocol version 69.
pub fn num_validators(&self) -> NumSeats {
self.num_block_producer_seats
.max(self.validator_selection_config.num_chunk_producer_seats)
.max(self.validator_selection_config.num_chunk_validator_seats)
}
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ShardConfig {
pub num_block_producer_seats_per_shard: Vec<NumSeats>,
Expand Down
17 changes: 5 additions & 12 deletions integration-tests/src/test_loop/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,14 @@ impl TestLoopBuilder {
// Configure tracked shards.
// * single shard tracking for validators
// * all shard tracking for non-validators (RPCs and archival)
let not_a_validator = {
let is_validator = {
let epoch_config = epoch_config_store.get_config(genesis.config.protocol_version);
let num_block_producer = epoch_config.num_block_producer_seats;
let num_chunk_producer =
epoch_config.validator_selection_config.num_chunk_producer_seats;
let num_chunk_validator =
epoch_config.validator_selection_config.num_chunk_validator_seats;
let validator_num =
num_block_producer.max(num_chunk_producer).max(num_chunk_validator) as usize;
idx >= validator_num
idx < epoch_config.num_validators() as usize
};
if self.track_all_shards || not_a_validator {
client_config.tracked_shards = vec![666];
} else {
if is_validator && !self.track_all_shards {
client_config.tracked_shards = Vec::new();
} else {
client_config.tracked_shards = vec![666];
}

if let Some(config_modifier) = &self.config_modifier {
Expand Down
11 changes: 8 additions & 3 deletions integration-tests/src/test_loop/tests/resharding_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ use crate::test_loop::utils::ONE_NEAR;
/// which is incorrect!!!
/// - Nodes must not track all shards. State sync must succeed.
/// - Set up chunk validator-only nodes. State witness must pass validation.
/// - Tx load must be consistent. Txs and receipts must cross resharding
/// boundary. All txs must succeed.
/// - Consistent tx load. All txs must succeed.
/// - Delayed receipts, congestion control computation.
/// - Cross-shard receipts of all kinds, crossing resharding boundary.
/// - Shard layout v2 -> v2 transition.
/// - Shard layout can be taken from mainnet.
#[test]
fn test_resharding_v3() {
Expand All @@ -36,6 +38,7 @@ fn test_resharding_v3() {
let epoch_length = 6;
let accounts =
(0..8).map(|i| format!("account{}", i).parse().unwrap()).collect::<Vec<AccountId>>();
// #12195 prevents number of BPs bigger than `epoch_length`.
let clients = vec![accounts[0].clone(), accounts[3].clone(), accounts[6].clone()];
let block_and_chunk_producers =
clients.iter().map(|account: &AccountId| account.as_str()).collect_vec();
Expand All @@ -47,6 +50,8 @@ fn test_resharding_v3() {
base_epoch_config_store.get_config(base_protocol_version).as_ref().clone();
base_epoch_config.validator_selection_config.shuffle_shard_assignment_for_chunk_producers =
false;
// TODO(#11881): enable kickouts when blocks and chunks are produced
// properly.
base_epoch_config.block_producer_kickout_threshold = 0;
base_epoch_config.chunk_producer_kickout_threshold = 0;
base_epoch_config.chunk_validator_only_kickout_threshold = 0;
Expand All @@ -59,7 +64,7 @@ fn test_resharding_v3() {
let last_shard_id = shard_ids.pop().unwrap();
let mut shards_split_map: BTreeMap<ShardId, Vec<ShardId>> =
shard_ids.iter().map(|shard_id| (*shard_id, vec![*shard_id])).collect();
// Keep this way until non-contiguous shard ids are supported.
// TODO(#11881): keep this way until non-contiguous shard ids are supported.
// let new_shards = vec![max_shard_id + 1, max_shard_id + 2];
let new_shards = vec![max_shard_id, max_shard_id + 1];
shard_ids.extend(new_shards.clone());
Expand Down

0 comments on commit fcaf3e8

Please sign in to comment.