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

[feature] #3088: Introduce queue throttling #3563

Merged
merged 2 commits into from
Jun 5, 2023
Merged
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
2 changes: 1 addition & 1 deletion config/iroha_test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"QUEUE": {
"MAX_TRANSACTIONS_IN_QUEUE": 65536,
"MAX_TRANSACTIONS_IN_SIGNATURE_BUFFER": 65536,
"MAX_TRANSACTIONS_IN_QUEUE_PER_USER": 65536,
"TRANSACTION_TIME_TO_LIVE_MS": 86400000,
"FUTURE_THRESHOLD_MS": 1000
},
Expand Down
15 changes: 7 additions & 8 deletions config/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use iroha_config_base::derive::{Documented, Proxy};
use serde::{Deserialize, Serialize};

const DEFAULT_MAX_TRANSACTIONS_IN_QUEUE: u32 = 2_u32.pow(16);
const DEFAULT_MAX_TRANSACTIONS_IN_SIGNATURE_BUFFER: u32 = 2_u32.pow(16);
const DEFAULT_MAX_TRANSACTIONS_IN_QUEUE_PER_USER: u32 = 2_u32.pow(16);
appetrosyan marked this conversation as resolved.
Show resolved Hide resolved
// 24 hours
const DEFAULT_TRANSACTION_TIME_TO_LIVE_MS: u64 = 24 * 60 * 60 * 1000;
const DEFAULT_FUTURE_THRESHOLD_MS: u64 = 1000;
Expand All @@ -16,8 +16,9 @@ const DEFAULT_FUTURE_THRESHOLD_MS: u64 = 1000;
pub struct Configuration {
/// The upper limit of the number of transactions waiting in the queue.
pub max_transactions_in_queue: u32,
/// The upper limit of the number of transactions waiting for more signatures.
pub max_transactions_in_signature_buffer: u32,
/// The upper limit of the number of transactions waiting in the queue for single user.
/// Use this option to apply throttling.
pub max_transactions_in_queue_per_user: u32,
/// The transaction will be dropped after this time if it is still in the queue.
pub transaction_time_to_live_ms: u64,
/// The threshold to determine if a transaction has been tampered to have a future timestamp.
Expand All @@ -28,9 +29,7 @@ impl Default for ConfigurationProxy {
fn default() -> Self {
Self {
max_transactions_in_queue: Some(DEFAULT_MAX_TRANSACTIONS_IN_QUEUE),
max_transactions_in_signature_buffer: Some(
DEFAULT_MAX_TRANSACTIONS_IN_SIGNATURE_BUFFER,
),
max_transactions_in_queue_per_user: Some(DEFAULT_MAX_TRANSACTIONS_IN_QUEUE_PER_USER),
transaction_time_to_live_ms: Some(DEFAULT_TRANSACTION_TIME_TO_LIVE_MS),
future_threshold_ms: Some(DEFAULT_FUTURE_THRESHOLD_MS),
}
Expand All @@ -47,12 +46,12 @@ pub mod tests {
pub fn arb_proxy()
(
max_transactions_in_queue in prop::option::of(Just(DEFAULT_MAX_TRANSACTIONS_IN_QUEUE)),
max_transactions_in_signature_buffer in prop::option::of(Just(DEFAULT_MAX_TRANSACTIONS_IN_SIGNATURE_BUFFER)),
max_transactions_in_queue_per_user in prop::option::of(Just(DEFAULT_MAX_TRANSACTIONS_IN_QUEUE_PER_USER)),
transaction_time_to_live_ms in prop::option::of(Just(DEFAULT_TRANSACTION_TIME_TO_LIVE_MS)),
future_threshold_ms in prop::option::of(Just(DEFAULT_FUTURE_THRESHOLD_MS)),
)
-> ConfigurationProxy {
ConfigurationProxy { max_transactions_in_queue, max_transactions_in_signature_buffer, transaction_time_to_live_ms, future_threshold_ms }
ConfigurationProxy { max_transactions_in_queue, max_transactions_in_queue_per_user, transaction_time_to_live_ms, future_threshold_ms }
}
}
}
2 changes: 1 addition & 1 deletion configs/peer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"QUEUE": {
"MAX_TRANSACTIONS_IN_QUEUE": 65536,
"MAX_TRANSACTIONS_IN_SIGNATURE_BUFFER": 65536,
"MAX_TRANSACTIONS_IN_QUEUE_PER_USER": 65536,
"TRANSACTION_TIME_TO_LIVE_MS": 86400000,
"FUTURE_THRESHOLD_MS": 1000
},
Expand Down
Binary file modified configs/peer/validator.wasm
Binary file not shown.
Loading