Skip to content

Commit

Permalink
fix: no chunk-only producer in stateless validation (#11561)
Browse files Browse the repository at this point in the history
We had this code change that forced 20 block producers on chain ids that
are not mainnet. However, it makes no sense in stateless validation
where there is no chunk-only producers. Fixed this by introducing a new
protocol version.
  • Loading branch information
bowenwang1996 authored Jun 12, 2024
1 parent 0c09325 commit 164b7a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/primitives-core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ pub enum ProtocolFeature {
WitnessTransactionLimits,
/// Size limit on outgoing receipts.
OutgoingReceiptsSizeLimit,
/// No chunk-only producers in stateless validation
NoChunkOnlyProducers,
}

impl ProtocolFeature {
Expand Down Expand Up @@ -233,7 +235,8 @@ impl ProtocolFeature {
ProtocolFeature::WitnessTransactionLimits
| ProtocolFeature::CongestionControl
| ProtocolFeature::OutgoingReceiptsSizeLimit => 87,
ProtocolFeature::CongestionControlAllowedShardValidation => 88,
ProtocolFeature::CongestionControlAllowedShardValidation
| ProtocolFeature::NoChunkOnlyProducers => 88,

// Nightly features
#[cfg(feature = "protocol_feature_fix_staking_threshold")]
Expand Down
6 changes: 6 additions & 0 deletions core/primitives/src/epoch_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ impl AllEpochConfig {
// mainnet, to make it easier to test the change.
if chain_id != near_primitives_core::chains::MAINNET
&& checked_feature!("stable", TestnetFewerBlockProducers, protocol_version)
&& !checked_feature!("stable", NoChunkOnlyProducers, protocol_version)
{
let shard_ids = config.shard_layout.shard_ids();
// Decrease the number of block producers from 100 to 20.
Expand All @@ -270,6 +271,11 @@ impl AllEpochConfig {
// Decrease the number of chunk producers.
config.validator_selection_config.num_chunk_only_producer_seats = 100;
}

if checked_feature!("stable", NoChunkOnlyProducers, protocol_version) {
// Make sure there is no chunk only producer in stateless validation
config.validator_selection_config.num_chunk_only_producer_seats = 0;
}
}

fn config_max_kickout_stake(config: &mut EpochConfig, protocol_version: u32) {
Expand Down

0 comments on commit 164b7a3

Please sign in to comment.