Skip to content

Commit

Permalink
feat(statelessnet): disable resharding V3 in StatelessNet (#10783)
Browse files Browse the repository at this point in the history
it's not pretty but it should work
making sure that we don't accidently trigger resharding in statelessnet
  • Loading branch information
wacban authored Mar 13, 2024
1 parent 7d9aa40 commit b1f02e9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/primitives-core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ impl ProtocolFeature {
ProtocolFeature::RestrictTla
| ProtocolFeature::TestnetFewerBlockProducers
| ProtocolFeature::SimpleNightshadeV2 => 64,
// The SimpleNightshadeV3 should not be enabled in statelessnet.
// TODO(resharding) clean up after stake wars is over.
#[cfg(not(feature = "statelessnet_protocol"))]
ProtocolFeature::SimpleNightshadeV3 => 65,

// StatelessNet features
Expand All @@ -206,6 +209,8 @@ impl ProtocolFeature {
ProtocolFeature::EthImplicitAccounts => 138,
#[cfg(feature = "protocol_feature_nonrefundable_transfer_nep491")]
ProtocolFeature::NonRefundableBalance => 140,
#[cfg(feature = "statelessnet_protocol")]
ProtocolFeature::SimpleNightshadeV3 => 141,
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions integration-tests/src/tests/client/resharding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const SIMPLE_NIGHTSHADE_PROTOCOL_VERSION: ProtocolVersion =
const SIMPLE_NIGHTSHADE_V2_PROTOCOL_VERSION: ProtocolVersion =
ProtocolFeature::SimpleNightshadeV2.protocol_version();

#[cfg(not(feature = "statelessnet_protocol"))]
const SIMPLE_NIGHTSHADE_V3_PROTOCOL_VERSION: ProtocolVersion =
ProtocolFeature::SimpleNightshadeV3.protocol_version();

Expand All @@ -54,13 +55,15 @@ enum ReshardingType {
// In the V1->V2 resharding outgoing receipts are reassigned to lowest index child.
V2,
// In the V2->V3 resharding outgoing receipts are reassigned to lowest index child.
#[cfg(not(feature = "statelessnet_protocol"))]
V3,
}

fn get_target_protocol_version(resharding_type: &ReshardingType) -> ProtocolVersion {
match resharding_type {
ReshardingType::V1 => SIMPLE_NIGHTSHADE_PROTOCOL_VERSION,
ReshardingType::V2 => SIMPLE_NIGHTSHADE_V2_PROTOCOL_VERSION,
#[cfg(not(feature = "statelessnet_protocol"))]
ReshardingType::V3 => SIMPLE_NIGHTSHADE_V3_PROTOCOL_VERSION,
}
}
Expand All @@ -69,6 +72,7 @@ fn get_genesis_protocol_version(resharding_type: &ReshardingType) -> ProtocolVer
match resharding_type {
ReshardingType::V1 => SIMPLE_NIGHTSHADE_PROTOCOL_VERSION - 1,
ReshardingType::V2 => SIMPLE_NIGHTSHADE_V2_PROTOCOL_VERSION - 1,
#[cfg(not(feature = "statelessnet_protocol"))]
ReshardingType::V3 => SIMPLE_NIGHTSHADE_V3_PROTOCOL_VERSION - 1,
}
}
Expand All @@ -77,6 +81,7 @@ fn get_parent_shard_uids(resharding_type: &ReshardingType) -> Vec<ShardUId> {
let shard_layout = match resharding_type {
ReshardingType::V1 => ShardLayout::v0_single_shard(),
ReshardingType::V2 => ShardLayout::get_simple_nightshade_layout(),
#[cfg(not(feature = "statelessnet_protocol"))]
ReshardingType::V3 => ShardLayout::get_simple_nightshade_layout_v2(),
};
shard_layout.shard_uids().collect()
Expand All @@ -92,12 +97,14 @@ fn get_expected_shards_num(
match resharding_type {
ReshardingType::V1 => 1,
ReshardingType::V2 => 4,
#[cfg(not(feature = "statelessnet_protocol"))]
ReshardingType::V3 => 5,
}
} else {
match resharding_type {
ReshardingType::V1 => 4,
ReshardingType::V2 => 5,
#[cfg(not(feature = "statelessnet_protocol"))]
ReshardingType::V3 => 6,
}
}
Expand Down Expand Up @@ -800,6 +807,7 @@ fn check_outgoing_receipts_reassigned_impl(
assert!(outgoing_receipts.is_empty());
}
}
#[cfg(not(feature = "statelessnet_protocol"))]
ReshardingType::V3 => {
// In V2->V3 resharding the outgoing receipts should be reassigned
// to the lowest index child of the parent shard.
Expand Down Expand Up @@ -1039,16 +1047,19 @@ fn test_shard_layout_upgrade_simple_v2_seed_44() {
test_shard_layout_upgrade_simple_impl(ReshardingType::V2, 44, false);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_simple_v3_seed_42() {
test_shard_layout_upgrade_simple_impl(ReshardingType::V3, 42, false);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_simple_v3_seed_43() {
test_shard_layout_upgrade_simple_impl(ReshardingType::V3, 43, false);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_simple_v3_seed_44() {
test_shard_layout_upgrade_simple_impl(ReshardingType::V3, 44, false);
Expand Down Expand Up @@ -1093,6 +1104,7 @@ fn test_resharding_with_different_db_kind_v2() {
test_resharding_with_different_db_kind_impl(ReshardingType::V2);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_resharding_with_different_db_kind_v3() {
test_resharding_with_different_db_kind_impl(ReshardingType::V3);
Expand Down Expand Up @@ -1146,6 +1158,7 @@ fn test_shard_layout_upgrade_gc_v2() {
test_shard_layout_upgrade_gc_impl(ReshardingType::V2, 44);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_gc_v3() {
test_shard_layout_upgrade_gc_impl(ReshardingType::V3, 44);
Expand Down Expand Up @@ -1427,6 +1440,7 @@ fn test_shard_layout_upgrade_cross_contract_calls_v2_seed_42() {

// Test cross contract calls
// This test case tests postponed receipts and delayed receipts
#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_cross_contract_calls_v2_seed_43() {
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V2, 43);
Expand All @@ -1442,20 +1456,23 @@ fn test_shard_layout_upgrade_cross_contract_calls_v2_seed_44() {
// Test cross contract calls
// This test case tests postponed receipts and delayed receipts
#[test]
#[cfg(not(feature = "statelessnet_protocol"))]
fn test_shard_layout_upgrade_cross_contract_calls_v3_seed_42() {
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V3, 42);
}

// Test cross contract calls
// This test case tests postponed receipts and delayed receipts
#[test]
#[cfg(not(feature = "statelessnet_protocol"))]
fn test_shard_layout_upgrade_cross_contract_calls_v3_seed_43() {
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V3, 43);
}

// Test cross contract calls
// This test case tests postponed receipts and delayed receipts
#[test]
#[cfg(not(feature = "statelessnet_protocol"))]
fn test_shard_layout_upgrade_cross_contract_calls_v3_seed_44() {
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V3, 44);
}
Expand Down Expand Up @@ -1530,16 +1547,19 @@ fn test_shard_layout_upgrade_incoming_receipts_v2_seed_44() {
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V2, 44);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_incoming_receipts_v3_seed_42() {
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V3, 42);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_incoming_receipts_v3_seed_43() {
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V3, 43);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_incoming_receipts_v3_seed_44() {
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V3, 44);
Expand Down Expand Up @@ -1694,16 +1714,19 @@ fn test_shard_layout_upgrade_missing_chunks_high_missing_prob_v2_seed_44() {

// V3 tests

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_missing_chunks_low_missing_prob_v3() {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V3, 0.1, 42);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_missing_chunks_mid_missing_prob_v3() {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V3, 0.5, 42);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_missing_chunks_high_missing_prob_v3() {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V3, 0.9, 42);
Expand Down Expand Up @@ -1811,6 +1834,7 @@ fn test_shard_layout_upgrade_error_handling_v2() {
test_shard_layout_upgrade_error_handling_impl(ReshardingType::V2, 42, false);
}

#[cfg(not(feature = "statelessnet_protocol"))]
#[test]
fn test_shard_layout_upgrade_error_handling_v3() {
test_shard_layout_upgrade_error_handling_impl(ReshardingType::V3, 42, false);
Expand Down

0 comments on commit b1f02e9

Please sign in to comment.