Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stabilize bandwidth scheduler #12768

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chain/chain/src/tests/simple_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn build_chain() {
if cfg!(feature = "nightly") {
insta::assert_snapshot!(hash, @"GARF4HBtQJ41quFA9fvjHpbVYT4o15syhL3FkH1o7poT");
} else {
insta::assert_snapshot!(hash, @"5LkmueLrB2cc3vURr6VKvT9acRTuNzWGTvzLGFJkRD9c");
insta::assert_snapshot!(hash, @"3JFsPBWs2CmNmvDD49ytuk26H6d4gryBueLBgeD2YojF");
}

for i in 1..5 {
Expand All @@ -53,7 +53,7 @@ fn build_chain() {
if cfg!(feature = "nightly") {
insta::assert_snapshot!(hash, @"HiXuBfW5Xd6e8ZTbMhwtPEXeZxe7macc8DvaWryNdvcf");
} else {
insta::assert_snapshot!(hash, @"5txsrLCmQp9kn3jYRp1VHrCDt7oBTnhyi71rEPZmm8Ce");
insta::assert_snapshot!(hash, @"5pEwiJcPbEExts9j2fmVSLUYCVRYHbhMDiyaa1LqpxcU");
}
}

Expand Down
5 changes: 5 additions & 0 deletions core/parameters/res/runtime_configs/74.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Bandwidth scheduler
max_shard_bandwidth: { old: 999_999_999_999_999, new: 4_500_000 }
max_single_grant: { old: 999_999_999_999_999, new: 4194304 }
max_allowance: { old: 999_999_999_999_999, new: 4_500_000 }
max_base_bandwidth: { old: 999_999_999_999_999, new: 100_000 }
4 changes: 4 additions & 0 deletions core/parameters/res/runtime_configs/parameters.snap
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,7 @@ max_tx_gas 500_000_000_000_000
min_tx_gas 20_000_000_000_000
reject_tx_congestion_threshold 80 / 100
use_state_stored_receipt true
max_shard_bandwidth 4_500_000
max_single_grant 4_194_304
max_allowance 4_500_000
max_base_bandwidth 100_000
9 changes: 8 additions & 1 deletion core/parameters/res/runtime_configs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,11 @@ reject_tx_congestion_threshold: {
denominator: 1,
}

use_state_stored_receipt: false
use_state_stored_receipt: false

# Bandwidth scheduler

max_shard_bandwidth: 999_999_999_999_999
max_single_grant: 999_999_999_999_999
max_allowance: 999_999_999_999_999
max_base_bandwidth: 999_999_999_999_999
6 changes: 6 additions & 0 deletions core/parameters/res/runtime_configs/parameters_testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,9 @@ reject_tx_congestion_threshold: {
}

use_state_stored_receipt: false

# Bandwidth scheduler
max_shard_bandwidth: 999_999_999_999_999
max_single_grant: 999_999_999_999_999
max_allowance: 999_999_999_999_999
max_base_bandwidth: 999_999_999_999_999
14 changes: 14 additions & 0 deletions core/parameters/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub struct RuntimeConfig {
pub congestion_control_config: CongestionControlConfig,
/// Configuration specific to ChunkStateWitness.
pub witness_config: WitnessConfig,
/// Configuration specific to BandwidthScheduler.
pub bandwidth_scheduler_config: BandwidthSchedulerConfig,

/// Whether receipts should be stored as [StateStoredReceipt].
pub use_state_stored_receipt: bool,
Expand Down Expand Up @@ -66,6 +68,7 @@ impl RuntimeConfig {
account_creation_config: AccountCreationConfig::default(),
congestion_control_config: runtime_config.congestion_control_config,
witness_config: runtime_config.witness_config,
bandwidth_scheduler_config: runtime_config.bandwidth_scheduler_config,
use_state_stored_receipt: runtime_config.use_state_stored_receipt,
}
}
Expand All @@ -83,6 +86,7 @@ impl RuntimeConfig {
account_creation_config: AccountCreationConfig::default(),
congestion_control_config: runtime_config.congestion_control_config,
witness_config: runtime_config.witness_config,
bandwidth_scheduler_config: runtime_config.bandwidth_scheduler_config,
use_state_stored_receipt: runtime_config.use_state_stored_receipt,
}
}
Expand Down Expand Up @@ -263,3 +267,13 @@ impl WitnessConfig {
}
}
}

/// Configuration specific to BandwidthScheduler
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct BandwidthSchedulerConfig {
// TODO: Comments
pub max_shard_bandwidth: u64,
pub max_single_grant: u64,
pub max_allowance: u64,
pub max_base_bandwidth: u64,
}
2 changes: 2 additions & 0 deletions core/parameters/src/config_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static CONFIG_DIFFS: &[(ProtocolVersion, &str)] = &[
(72, include_config!("72.yaml")),
// Fix wasm_yield_resume_byte and relax congestion control.
(73, include_config!("73.yaml")),
(74, include_config!("74.yaml")),
(129, include_config!("129.yaml")),
];

Expand Down Expand Up @@ -121,6 +122,7 @@ impl RuntimeConfigStore {
account_creation_config: runtime_config.account_creation_config.clone(),
congestion_control_config: runtime_config.congestion_control_config,
witness_config: runtime_config.witness_config,
bandwidth_scheduler_config: runtime_config.bandwidth_scheduler_config,
use_state_stored_receipt: runtime_config.use_state_stored_receipt,
}),
);
Expand Down
6 changes: 6 additions & 0 deletions core/parameters/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ pub enum Parameter {

// Use the StateStoredReceipt structure when storing receipts in State.
UseStateStoredReceipt,

// Bandwidth scheduler
MaxShardBandwidth,
MaxSingleGrant,
MaxAllowance,
MaxBaseBandwidth,
}

#[derive(
Expand Down
8 changes: 7 additions & 1 deletion core/parameters/src/parameter_table.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::config::{AccountCreationConfig, RuntimeConfig};
use crate::config::{CongestionControlConfig, WitnessConfig};
use crate::config::{BandwidthSchedulerConfig, CongestionControlConfig, WitnessConfig};
use crate::cost::{
ActionCosts, ExtCostsConfig, Fee, ParameterCost, RuntimeFeesConfig, StorageUsageConfig,
};
Expand Down Expand Up @@ -344,6 +344,12 @@ impl TryFrom<&ParameterTable> for RuntimeConfig {
new_transactions_validation_state_size_soft_limit: params
.get(Parameter::NewTransactionsValidationStateSizeSoftLimit)?,
},
bandwidth_scheduler_config: BandwidthSchedulerConfig {
max_shard_bandwidth: params.get(Parameter::MaxShardBandwidth)?,
max_single_grant: params.get(Parameter::MaxSingleGrant)?,
max_allowance: params.get(Parameter::MaxAllowance)?,
max_base_bandwidth: params.get(Parameter::MaxBaseBandwidth)?,
},
use_state_stored_receipt: params.get(Parameter::UseStateStoredReceipt)?,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,11 @@ expression: config_view
"main_storage_proof_size_soft_limit": 3000000,
"combined_transactions_size_limit": 4194304,
"new_transactions_validation_state_size_soft_limit": 572864
},
"bandwidth_scheduler_config": {
"max_shard_bandwidth": 4500000,
"max_single_grant": 4194304,
"max_allowance": 4500000,
"max_base_bandwidth": 100000
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,11 @@ expression: config_view
"main_storage_proof_size_soft_limit": 3000000,
"combined_transactions_size_limit": 4194304,
"new_transactions_validation_state_size_soft_limit": 572864
},
"bandwidth_scheduler_config": {
"max_shard_bandwidth": 4500000,
"max_single_grant": 4194304,
"max_allowance": 4500000,
"max_base_bandwidth": 100000
}
}
Loading
Loading