Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
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
31 changes: 16 additions & 15 deletions runtime/src/block_cost_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ use {
/// Static configurations:
///
/// Number of microseconds replaying a block should take, 400 millisecond block times
/// is curerntly publicly communicated on solana.com
/// is currently publicly communicated on solana.com
pub const MAX_BLOCK_REPLAY_TIME_US: u64 = 400_000;
/// number of concurrent processes,
pub const MAX_CONCURRENCY: u64 = 10;
pub const MAX_CONCURRENCY: u64 = 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean? Max Block = 4* max compute per account?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally, banking threads run concurrently without being blocked by each other (on accounts). MAX_CONCURRENCY represents number of threads under such condition. Therefore the block_max = account_max * MAX_CONCURRENCY


/// Cluster data, method of collecting at https://github.com/solana-labs/solana/issues/19627
/// Dashboard: https://metrics.solana.com:8889/sources/0/dashboards/10?refresh=Paused&lower=now%28%29%20-%2012h
///
/// cluster avergaed compute unit to microsec conversion rate
pub const COMPUTE_UNIT_TO_US_RATIO: u64 = 40;
/// cluster averaged compute unit to micro-sec conversion rate
pub const COMPUTE_UNIT_TO_US_RATIO: u64 = 30;
/// Number of compute units for one signature verification.
pub const SIGNATURE_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 130;
pub const SIGNATURE_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 24;
/// Number of compute units for one write lock
pub const WRITE_LOCK_UNITS: u64 = COMPUTE_UNIT_TO_US_RATIO * 10;
/// Number of data bytes per compute units
pub const DATA_BYTES_UNITS: u64 = 220 /*bytes per us*/ / COMPUTE_UNIT_TO_US_RATIO;
pub const DATA_BYTES_UNITS: u64 = 550 /*bytes per us*/ / COMPUTE_UNIT_TO_US_RATIO;
// Number of compute units for each built-in programs
lazy_static! {
/// Number of compute units for each built-in programs
Expand All @@ -37,9 +37,10 @@ lazy_static! {
(solana_sdk::stake::config::id(), COMPUTE_UNIT_TO_US_RATIO * 2),
(solana_sdk::stake::program::id(), COMPUTE_UNIT_TO_US_RATIO * 25),
(solana_config_program::id(), COMPUTE_UNIT_TO_US_RATIO * 15),
(solana_vote_program::id(), COMPUTE_UNIT_TO_US_RATIO * 85),
(secp256k1_program::id(), COMPUTE_UNIT_TO_US_RATIO * 4),
(system_program::id(), COMPUTE_UNIT_TO_US_RATIO * 10),
(solana_vote_program::id(), COMPUTE_UNIT_TO_US_RATIO * 70),
// secp256k1 is executed in banking stage, it should cost similar to sigverify
(secp256k1_program::id(), COMPUTE_UNIT_TO_US_RATIO * 24),
(system_program::id(), COMPUTE_UNIT_TO_US_RATIO * 5),
]
.iter()
.cloned()
Expand All @@ -49,15 +50,15 @@ lazy_static! {
/// Statically computed data:
///
/// Number of compute units that a block is allowed. A block's compute units are
/// accumualted by Transactions added to it; A transaction's compute units are
/// calculated by cost_model, based on transaction's signarures, write locks,
/// data size and built-in and BPF instructinos.
/// accumulated by Transactions added to it; A transaction's compute units are
/// calculated by cost_model, based on transaction's signatures, write locks,
/// data size and built-in and BPF instructions.
pub const MAX_BLOCK_UNITS: u64 =
MAX_BLOCK_REPLAY_TIME_US * COMPUTE_UNIT_TO_US_RATIO * MAX_CONCURRENCY;
/// Number of compute units that a writable account in a block is allowed. The
/// limit is to prevent too many transactions write to same account, threrefore
/// reduce block's paralellism.
/// limit is to prevent too many transactions write to same account, therefore
/// reduce block's parallelism.
pub const MAX_WRITABLE_ACCOUNT_UNITS: u64 = MAX_BLOCK_REPLAY_TIME_US * COMPUTE_UNIT_TO_US_RATIO;

/// max len of account data in a slot (bytes)
/// max length of account data in a slot (bytes)
pub const MAX_ACCOUNT_DATA_LEN: u64 = 100_000_000;