Skip to content

Commit

Permalink
try removing v0()
Browse files Browse the repository at this point in the history
  • Loading branch information
eagr committed Oct 27, 2024
1 parent d709cf9 commit 02b02f4
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 16 deletions.
8 changes: 1 addition & 7 deletions chain/chain/src/resharding/event_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,7 @@ mod tests {
let s4 = ShardId::new(4);
let s5 = ShardId::new(5);

// Shard layouts V0 and V1 are rejected.
assert!(ReshardingEventType::from_shard_layout(
&ShardLayout::v0(1, 0),
block,
prev_block
)
.is_err());
// V1 is rejected.
assert!(ReshardingEventType::from_shard_layout(&ShardLayout::v1_test(), block, prev_block)
.is_err());

Expand Down
2 changes: 1 addition & 1 deletion chain/chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ mod test {
}

fn test_build_receipt_hashes_with_num_shard(num_shards: NumShards) {
let shard_layout = ShardLayout::v0(num_shards, 0);
let shard_layout = ShardLayout::of_num_shards(num_shards, 0);
let create_receipt_from_receiver_id =
|receiver_id| Receipt::new_balance_refund(&receiver_id, 0, ReceiptPriority::NoPriority);
let mut rng = rand::thread_rng();
Expand Down
6 changes: 3 additions & 3 deletions chain/chain/src/test_utils/kv_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl KeyValueRuntime {
}

pub fn account_id_to_shard_id(account_id: &AccountId, num_shards: NumShards) -> ShardId {
let shard_layout = ShardLayout::v0(num_shards, 0);
let shard_layout = ShardLayout::of_num_shards(num_shards, 0);
shard_layout::account_id_to_shard_id(account_id, &shard_layout)
}

Expand Down Expand Up @@ -564,7 +564,7 @@ impl EpochManagerAdapter for MockEpochManager {
}

fn get_shard_layout(&self, _epoch_id: &EpochId) -> Result<ShardLayout, EpochError> {
Ok(ShardLayout::v0(self.num_shards, 0))
Ok(ShardLayout::of_num_shards(self.num_shards, 0))
}

fn get_shard_config(&self, _epoch_id: &EpochId) -> Result<ShardConfig, EpochError> {
Expand Down Expand Up @@ -648,7 +648,7 @@ impl EpochManagerAdapter for MockEpochManager {
&self,
_parent_hash: &CryptoHash,
) -> Result<ShardLayout, EpochError> {
Ok(ShardLayout::v0(self.num_shards, 0))
Ok(ShardLayout::of_num_shards(self.num_shards, 0))
}

fn get_epoch_id(&self, block_hash: &CryptoHash) -> Result<EpochId, EpochError> {
Expand Down
2 changes: 2 additions & 0 deletions chain/client/src/tests/process_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ fn test_not_process_height_twice() {
}

/// Test that if a block contains chunks with invalid shard_ids, the client will return error.
// FIXME eagr unsure if this is expected behavior
#[test]
#[should_panic(expected = "no entry found for key")]
fn test_bad_shard_id() {
let mut env = TestEnv::default_builder().num_shards(4).mock_epoch_managers().build();
let prev_block = env.clients[0].produce_block(1).unwrap().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion chain/epoch-manager/src/shard_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ mod tests {
online_min_threshold: Ratio::new(90, 100),
minimum_stake_divisor: 1,
protocol_upgrade_stake_threshold: Ratio::new(80, 100),
shard_layout: ShardLayout::v0(num_shards, 0),
shard_layout: ShardLayout::of_num_shards(num_shards, 0),
validator_selection_config: Default::default(),
validator_max_kickout_stake_perc: 100,
};
Expand Down
2 changes: 1 addition & 1 deletion chain/epoch-manager/src/validator_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ mod tests {
fishermen_threshold: 0,
minimum_stake_divisor: 0,
protocol_upgrade_stake_threshold: 0.into(),
shard_layout: ShardLayout::v0(num_shards, 0),
shard_layout: ShardLayout::of_num_shards(num_shards, 0),
validator_selection_config,
}
}
Expand Down
2 changes: 2 additions & 0 deletions chain/jsonrpc/jsonrpc-tests/tests/rpc_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ fn test_chunk_by_hash() {
}

/// Retrieve chunk via json rpc
// FIXME eagr unsure if this is expected behavior
#[test]
#[should_panic(expected = "no entry found for key")]
fn test_chunk_invalid_shard_id() {
test_with_client!(test_utils::NodeType::NonValidator, client, async move {
let chunk =
Expand Down
1 change: 1 addition & 0 deletions core/chain-configs/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ pub struct GenesisConfig {
pub minimum_stake_divisor: u64,
/// Layout information regarding how to split accounts to shards
#[serde(default = "default_shard_layout")]
// FIXME eagr what should be the default?
#[default(ShardLayout::v0(1, 0))]
pub shard_layout: ShardLayout,
#[serde(default = "default_num_chunk_only_producer_seats")]
Expand Down
4 changes: 2 additions & 2 deletions core/chain-configs/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Genesis {
accounts,
num_validator_seats,
num_validator_seats_per_shard,
ShardLayout::v0(num_shards, 0),
ShardLayout::of_num_shards(num_shards, 0),
)
}

Expand All @@ -169,7 +169,7 @@ impl Genesis {
accounts,
num_validator_seats,
num_validator_seats_per_shard,
ShardLayout::v0(num_shards, 1),
ShardLayout::of_num_shards(num_shards, 1),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ fn test_protocol_upgrade_81() {
}

/// Test that Client rejects ChunkStateWitnesses with invalid shard_id
// FIXME eagr unsure if this is expected behavior
#[test]
#[should_panic(expected = "no entry found for key")]
fn test_chunk_state_witness_bad_shard_id() {
Expand Down
1 change: 0 additions & 1 deletion tools/database/src/corrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ impl CorruptStateSnapshotCommand {
let mut store_update = store.store_update();
// TODO(resharding) automatically detect the shard version
let shard_layout = match self.shard_layout_version {
0 => ShardLayout::v0(1, 0),
1 => ShardLayout::get_simple_nightshade_layout(),
2 => ShardLayout::get_simple_nightshade_layout_v2(),
_ => {
Expand Down

0 comments on commit 02b02f4

Please sign in to comment.