Skip to content

Commit

Permalink
Guard production behind a feature
Browse files Browse the repository at this point in the history
  • Loading branch information
VanBarbascu committed Jan 23, 2025
1 parent d9d8f36 commit 64000a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 0 additions & 3 deletions chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ const BLOCK_HORIZON: u64 = 500;
/// number of blocks at the epoch start for which we will log more detailed info
pub const EPOCH_START_INFO_BLOCKS: u64 = 500;

/// Cache size for the produced optimistic blocks.
pub const PRODUCED_OPTIMISTIC_BLOCK_POOL: usize = 10;

/// Defines whether in case of adversarial block production invalid blocks can
/// be produced.
#[cfg(feature = "test_features")]
Expand Down
5 changes: 4 additions & 1 deletion chain/client/src/client_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,11 +1156,14 @@ impl ClientActorInner {
}
}

let protocol_version = self.client.epoch_manager.get_epoch_protocol_version(&epoch_id)?;
if !ProtocolFeature::ProduceOptimisticBlock.enabled(protocol_version) {
return Ok(());
}
let optimistic_block_height = self.client.doomslug.get_timer_height();
if self.client.epoch_manager.get_block_producer(&epoch_id, optimistic_block_height)? != me {
return Ok(());
}

if let Err(err) = self.produce_optimistic_block(optimistic_block_height) {
// If there is an error, report it and let it retry.
error!(target: "client", optimistic_block_height, ?err, "Optimistic block production failed!");
Expand Down
5 changes: 4 additions & 1 deletion core/primitives-core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ pub enum ProtocolFeature {
ExcludeExistingCodeFromWitnessForCodeLen,
/// Use the block height instead of the block hash to calculate the receipt ID.
BlockHeightForReceiptId,
ProduceOptimisticBlock,
GlobalContracts,
}

Expand Down Expand Up @@ -285,7 +286,9 @@ impl ProtocolFeature {
#[cfg(feature = "protocol_feature_relaxed_chunk_validation")]
ProtocolFeature::RelaxedChunkValidation => 147,
ProtocolFeature::ExcludeExistingCodeFromWitnessForCodeLen => 148,
ProtocolFeature::BlockHeightForReceiptId => 149,
ProtocolFeature::BlockHeightForReceiptId | ProtocolFeature::ProduceOptimisticBlock => {
149
}
// Place features that are not yet in Nightly below this line.
ProtocolFeature::GlobalContracts => 200,
}
Expand Down

0 comments on commit 64000a7

Please sign in to comment.