Skip to content

Commit

Permalink
[refactor] #3039: Introduce waiting buffer for the multisigs
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara committed Jan 17, 2023
1 parent 92161c9 commit c44abe4
Show file tree
Hide file tree
Showing 9 changed files with 480 additions and 79 deletions.
2 changes: 1 addition & 1 deletion cli/src/torii/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub(crate) async fn handle_instructions(
#[allow(clippy::map_err_ignore)]
queue
.push(transaction, &sumeragi.wsv_mutex_access())
.map_err(|(tx, err)| {
.map_err(|queue::Failure { tx, err }| {
iroha_logger::warn!(
tx_hash=%tx.hash(), ?err,
"Failed to push into queue"
Expand Down
1 change: 1 addition & 0 deletions config/iroha_test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"QUEUE": {
"MAXIMUM_TRANSACTIONS_IN_BLOCK": 8192,
"MAXIMUM_TRANSACTIONS_IN_QUEUE": 65536,
"MAXIMUM_TRANSACTIONS_IN_SIGNATURE_BUFFER": 65536,
"TRANSACTION_TIME_TO_LIVE_MS": 86400000,
"FUTURE_THRESHOLD_MS": 1000
},
Expand Down
9 changes: 8 additions & 1 deletion config/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};

const DEFAULT_MAXIMUM_TRANSACTIONS_IN_BLOCK: u32 = 2_u32.pow(9);
const DEFAULT_MAXIMUM_TRANSACTIONS_IN_QUEUE: u32 = 2_u32.pow(16);
const DEFAULT_MAXIMUM_TRANSACTIONS_IN_SIGNATURE_BUFFER: u32 = 2_u32.pow(16);
// 24 hours
const DEFAULT_TRANSACTION_TIME_TO_LIVE_MS: u64 = 24 * 60 * 60 * 1000;
const DEFAULT_FUTURE_THRESHOLD_MS: u64 = 1000;
Expand All @@ -18,6 +19,8 @@ pub struct Configuration {
pub maximum_transactions_in_block: u32,
/// The upper limit of the number of transactions waiting in the queue.
pub maximum_transactions_in_queue: u32,
/// The upper limit of the number of transactions waiting for more signatures.
pub maximum_transactions_in_signature_buffer: 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 @@ -29,6 +32,9 @@ impl Default for ConfigurationProxy {
Self {
maximum_transactions_in_block: Some(DEFAULT_MAXIMUM_TRANSACTIONS_IN_BLOCK),
maximum_transactions_in_queue: Some(DEFAULT_MAXIMUM_TRANSACTIONS_IN_QUEUE),
maximum_transactions_in_signature_buffer: Some(
DEFAULT_MAXIMUM_TRANSACTIONS_IN_SIGNATURE_BUFFER,
),
transaction_time_to_live_ms: Some(DEFAULT_TRANSACTION_TIME_TO_LIVE_MS),
future_threshold_ms: Some(DEFAULT_FUTURE_THRESHOLD_MS),
}
Expand All @@ -46,11 +52,12 @@ pub mod tests {
(
maximum_transactions_in_block in prop::option::of(Just(DEFAULT_MAXIMUM_TRANSACTIONS_IN_BLOCK)),
maximum_transactions_in_queue in prop::option::of(Just(DEFAULT_MAXIMUM_TRANSACTIONS_IN_QUEUE)),
maximum_transactions_in_signature_buffer in prop::option::of(Just(DEFAULT_MAXIMUM_TRANSACTIONS_IN_SIGNATURE_BUFFER)),
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 { maximum_transactions_in_block, maximum_transactions_in_queue, transaction_time_to_live_ms, future_threshold_ms }
ConfigurationProxy { maximum_transactions_in_block, maximum_transactions_in_queue, maximum_transactions_in_signature_buffer, transaction_time_to_live_ms, future_threshold_ms }
}
}
}
1 change: 1 addition & 0 deletions configs/peer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"QUEUE": {
"MAXIMUM_TRANSACTIONS_IN_BLOCK": 512,
"MAXIMUM_TRANSACTIONS_IN_QUEUE": 65536,
"MAXIMUM_TRANSACTIONS_IN_SIGNATURE_BUFFER": 65536,
"TRANSACTION_TIME_TO_LIVE_MS": 86400000,
"FUTURE_THRESHOLD_MS": 1000
},
Expand Down
Loading

0 comments on commit c44abe4

Please sign in to comment.