Skip to content

Commit

Permalink
[refactor]: change parameters to more optimal values determined with …
Browse files Browse the repository at this point in the history
…perf testing

Signed-off-by: Marin Veršić <[email protected]>
  • Loading branch information
mversic committed Nov 7, 2023
1 parent c3adf25 commit 0922950
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 53 deletions.
2 changes: 1 addition & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The environment variables replacing `config.json` should be passed as JSON strin
<details> <summary>Expand to see the example</summary>

``` bash
IROHA_TORII="{\"P2P_ADDR\": \"127.0.0.1:1339\", \"API_URL\": \"127.0.0.1:8080\"}" IROHA_SUMERAGI="{\"TRUSTED_PEERS\": [{\"address\": \"127.0.0.1:1337\",\"public_key\": \"ed01201C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B\"},{\"address\": \"127.0.0.1:1338\",\"public_key\": \"ed0120CC25624D62896D3A0BFD8940F928DC2ABF27CC57CEFEB442AA96D9081AAE58A1\"},{\"address\": \"127.0.0.1:1339\",\"public_key\": \"ed0120FACA9E8AA83225CB4D16D67F27DD4F93FC30FFA11ADC1F5C88FD5495ECC91020\"},{\"address\": \"127.0.0.1:1340\",\"public_key\": \"ed01208E351A70B6A603ED285D666B8D689B680865913BA03CE29FB7D13A166C4E7F1F\"}]}" IROHA_KURA="{\"INIT_MODE\": \"strict\",\"BLOCK_STORE_PATH\": \"./storage\"}" IROHA_BLOCK_SYNC="{\"GOSSIP_PERIOD_MS\": 10000,\"BATCH_SIZE\": 2}" IROHA_PUBLIC_KEY="ed01201C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B" IROHA_PRIVATE_KEY="{\"digest_function\": \"ed25519\",\"payload\": \"282ED9F3CF92811C3818DBC4AE594ED59DC1A2F78E4241E31924E101D6B1FB831C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B\"}" IROHA_GENESIS="{\"ACCOUNT_PUBLIC_KEY\": \"ed01204CFFD0EE429B1BDD36B3910EC570852B8BB63F18750341772FB46BC856C5CAAF\",\"ACCOUNT_PRIVATE_KEY\": {\"digest_function\": \"ed25519\",\"payload\": \"D748E18CE60CB30DEA3E73C9019B7AF45A8D465E3D71BCC9A5EF99A008205E534CFFD0EE429B1BDD36B3910EC570852B8BB63F18750341772FB46BC856C5CAAF\"}}" ./iroha
IROHA_TORII="{\"P2P_ADDR\": \"127.0.0.1:1339\", \"API_URL\": \"127.0.0.1:8080\"}" IROHA_SUMERAGI="{\"TRUSTED_PEERS\": [{\"address\": \"127.0.0.1:1337\",\"public_key\": \"ed01201C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B\"},{\"address\": \"127.0.0.1:1338\",\"public_key\": \"ed0120CC25624D62896D3A0BFD8940F928DC2ABF27CC57CEFEB442AA96D9081AAE58A1\"},{\"address\": \"127.0.0.1:1339\",\"public_key\": \"ed0120FACA9E8AA83225CB4D16D67F27DD4F93FC30FFA11ADC1F5C88FD5495ECC91020\"},{\"address\": \"127.0.0.1:1340\",\"public_key\": \"ed01208E351A70B6A603ED285D666B8D689B680865913BA03CE29FB7D13A166C4E7F1F\"}]}" IROHA_KURA="{\"INIT_MODE\": \"strict\",\"BLOCK_STORE_PATH\": \"./storage\"}" IROHA_BLOCK_SYNC="{\"GOSSIP_PERIOD_MS\": 1000,\"BATCH_SIZE\": 2}" IROHA_PUBLIC_KEY="ed01201C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B" IROHA_PRIVATE_KEY="{\"digest_function\": \"ed25519\",\"payload\": \"282ED9F3CF92811C3818DBC4AE594ED59DC1A2F78E4241E31924E101D6B1FB831C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B\"}" IROHA_GENESIS="{\"ACCOUNT_PUBLIC_KEY\": \"ed01204CFFD0EE429B1BDD36B3910EC570852B8BB63F18750341772FB46BC856C5CAAF\",\"ACCOUNT_PRIVATE_KEY\": {\"digest_function\": \"ed25519\",\"payload\": \"D748E18CE60CB30DEA3E73C9019B7AF45A8D465E3D71BCC9A5EF99A008205E534CFFD0EE429B1BDD36B3910EC570852B8BB63F18750341772FB46BC856C5CAAF\"}}" ./iroha
```

</details>
Expand Down
13 changes: 5 additions & 8 deletions client/tests/integration/multisignature_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ fn multisignature_transactions_should_wait_for_all_signatures() -> Result<()> {
let key_pair_2 = KeyPair::generate()?;
let asset_definition_id = AssetDefinitionId::from_str("camomile#wonderland")?;
let create_asset = RegisterExpr::new(AssetDefinition::quantity(asset_definition_id.clone()));
let set_signature_condition = MintExpr::new(
SignatureCheckCondition::AllAccountSignaturesAnd(
vec![key_pair_2.public_key().clone()].into(),
),
let mint_public_key = MintExpr::new(
key_pair_2.public_key().clone(),
IdBox::AccountId(alice_id.clone()),
);

let mut client_configuration = ClientConfiguration::test(&network.genesis.api_address);
let client = Client::new(&client_configuration)?;
let instructions: [InstructionExpr; 2] = [create_asset.into(), set_signature_condition.into()];
let instructions: [InstructionExpr; 2] = [create_asset.into(), mint_public_key.into()];
client.submit_all_blocking(instructions)?;

//When
Expand All @@ -55,7 +53,7 @@ fn multisignature_transactions_should_wait_for_all_signatures() -> Result<()> {
let instructions = [mint_asset.clone()];
let transaction = client.build_transaction(instructions, UnlimitedMetadata::new())?;
client.submit_transaction(&client.sign_transaction(transaction)?)?;
thread::sleep(pipeline_time);
thread::sleep(pipeline_time / 2);

//Then
client_configuration.torii_api_url = format!(
Expand Down Expand Up @@ -83,8 +81,7 @@ fn multisignature_transactions_should_wait_for_all_signatures() -> Result<()> {
let transaction = client_2
.get_original_transaction(&transaction, 3, Duration::from_millis(100))?
.expect("Found no pending transaction for this account.");
client_2.submit_transaction(&client_2.sign_transaction(transaction)?)?;
thread::sleep(pipeline_time);
client_2.submit_transaction_blocking(&client_2.sign_transaction(transaction)?)?;
let assets = client_1
.request(request)?
.collect::<QueryResult<Vec<_>>>()?;
Expand Down
6 changes: 3 additions & 3 deletions config/iroha_test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"public_key": "ed01208E351A70B6A603ED285D666B8D689B680865913BA03CE29FB7D13A166C4E7F1F"
}
],
"COMMIT_TIME_LIMIT_MS": 2000,
"MAX_TRANSACTIONS_IN_BLOCK": 8192,
"COMMIT_TIME_LIMIT_MS": 120000,
"MAX_TRANSACTIONS_IN_BLOCK": 20,
"ACTOR_CHANNEL_CAPACITY": 100,
"GOSSIP_BATCH_SIZE": 500,
"GOSSIP_PERIOD_MS": 1000,
Expand All @@ -47,7 +47,7 @@
"FETCH_SIZE": 10
},
"BLOCK_SYNC": {
"GOSSIP_PERIOD_MS": 10000,
"GOSSIP_PERIOD_MS": 1000,
"BLOCK_BATCH_SIZE": 4,
"ACTOR_CHANNEL_CAPACITY": 100
},
Expand Down
2 changes: 1 addition & 1 deletion config/src/block_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use iroha_config_base::derive::{Documented, Proxy};
use serde::{Deserialize, Serialize};

const DEFAULT_BLOCK_BATCH_SIZE: u32 = 4;
const DEFAULT_GOSSIP_PERIOD_MS: u64 = 10000;
const DEFAULT_GOSSIP_PERIOD_MS: u64 = 1000;
const DEFAULT_ACTOR_CHANNEL_CAPACITY: u32 = 100;

/// Configuration for `BlockSynchronizer`.
Expand Down
2 changes: 1 addition & 1 deletion config/src/iroha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ mod tests {
cfg_proxy.kura.unwrap().block_store_path.unwrap()
);
assert_eq!(
10000,
1000,
cfg_proxy
.block_sync
.expect("Block sync configuration was None")
Expand Down
6 changes: 3 additions & 3 deletions config/src/sumeragi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ use self::default::*;
/// Module with a set of default values.
pub mod default {
/// Default number of miliseconds the peer waits for transactions before creating a block.
pub const DEFAULT_BLOCK_TIME_MS: u64 = 2000;
pub const DEFAULT_BLOCK_TIME_MS: u64 = 1000;
/// Default amount of time allocated for voting on a block before a peer can ask for a view change.
pub const DEFAULT_COMMIT_TIME_LIMIT_MS: u64 = 4000;
pub const DEFAULT_COMMIT_TIME_LIMIT_MS: u64 = 120000;
/// Unused const. Should be removed in the future.
pub const DEFAULT_ACTOR_CHANNEL_CAPACITY: u32 = 100;
/// Default duration in ms between every transaction gossip.
pub const DEFAULT_GOSSIP_PERIOD_MS: u64 = 1000;
/// Default maximum number of transactions sent in single gossip message.
pub const DEFAULT_GOSSIP_BATCH_SIZE: u32 = 500;
/// Default maximum number of transactions in block.
pub const DEFAULT_MAX_TRANSACTIONS_IN_BLOCK: u32 = 2_u32.pow(9);
pub const DEFAULT_MAX_TRANSACTIONS_IN_BLOCK: u32 = 20;

/// Default estimation of consensus duration.
#[allow(clippy::integer_division)]
Expand Down
8 changes: 4 additions & 4 deletions configs/peer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"SUMERAGI": {
"KEY_PAIR": null,
"PEER_ID": null,
"BLOCK_TIME_MS": 2000,
"BLOCK_TIME_MS": 1000,
"TRUSTED_PEERS": null,
"COMMIT_TIME_LIMIT_MS": 4000,
"MAX_TRANSACTIONS_IN_BLOCK": 512,
"COMMIT_TIME_LIMIT_MS": 120000,
"MAX_TRANSACTIONS_IN_BLOCK": 20,
"ACTOR_CHANNEL_CAPACITY": 100,
"GOSSIP_BATCH_SIZE": 500,
"GOSSIP_PERIOD_MS": 1000
Expand All @@ -28,7 +28,7 @@
"FETCH_SIZE": 10
},
"BLOCK_SYNC": {
"GOSSIP_PERIOD_MS": 10000,
"GOSSIP_PERIOD_MS": 1000,
"BLOCK_BATCH_SIZE": 4,
"ACTOR_CHANNEL_CAPACITY": 100
},
Expand Down
6 changes: 3 additions & 3 deletions configs/peer/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@
"Sequence": [
{
"NewParameter": {
"Parameter": "?MaxTransactionsInBlock=512"
"Parameter": "?MaxTransactionsInBlock=20"
}
},
{
"NewParameter": {
"Parameter": "?BlockTime=2000"
"Parameter": "?BlockTime=1000"
}
},
{
"NewParameter": {
"Parameter": "?CommitTimeLimit=4000"
"Parameter": "?CommitTimeLimit=120000"
}
},
{
Expand Down
83 changes: 67 additions & 16 deletions core/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,7 @@ mod tests {
}

#[test]
async fn push_multisignature_tx() {
let max_txs_in_block = 2;
async fn push_any_account_signature() {
let key_pairs = [KeyPair::generate().unwrap(), KeyPair::generate().unwrap()];
let kura = Kura::blank_kura_for_testing();
let wsv = {
Expand All @@ -491,7 +490,7 @@ mod tests {
key_pairs.iter().map(KeyPair::public_key).cloned(),
)
.build(&account_id);
account.signature_check_condition = SignatureCheckCondition::all_account_signatures();
account.signature_check_condition = SignatureCheckCondition::any_account_signature();
assert!(domain.add_account(account).is_none());
let query_handle = LiveQueryStore::test().start();
Arc::new(WorldStateView::new(
Expand All @@ -515,23 +514,75 @@ mod tests {
max_instruction_number: 4096,
max_wasm_size_bytes: 0,
};
let fully_signed_tx: AcceptedTransaction = {
let mut signed_tx = tx
.clone()
let partially_signed_tx = AcceptedTransaction::accept(
tx.clone()
.sign(key_pairs[0].clone())
.expect("Failed to sign.");
for key_pair in &key_pairs[1..] {
signed_tx = signed_tx.sign(key_pair.clone()).expect("Failed to sign");
}
AcceptedTransaction::accept(signed_tx, &tx_limits)
.expect("Failed to accept Transaction.")
};
// Check that fully signed transaction pass signature check
.expect("Failed to sign."),
&tx_limits,
)
.expect("Failed to accept Transaction.");

// Check that partially signed transaction passes signature check
assert!(matches!(
fully_signed_tx.check_signature_condition(&wsv),
partially_signed_tx.check_signature_condition(&wsv),
Ok(MustUse(true))
));

queue
.push(partially_signed_tx, &wsv)
.expect("Should be possible to put partially signed transaction into the queue");

assert_eq!(queue.tx_len(), 1);

let max_txs_in_block = 2;
let mut available = queue.collect_transactions_for_block(&wsv, max_txs_in_block);
assert_eq!(available.len(), 1);
let tx_from_queue = available.pop().expect("Checked that have one transactions");
// Check that transaction from queue pass signature check
assert!(matches!(
tx_from_queue.check_signature_condition(&wsv),
Ok(MustUse(true))
));
}

#[test]
async fn push_multisignature_tx() {
let max_txs_in_block = 2;
let key_pairs = [KeyPair::generate().unwrap(), KeyPair::generate().unwrap()];
let kura = Kura::blank_kura_for_testing();
let wsv = {
let domain_id = DomainId::from_str("wonderland").expect("Valid");
let account_id = AccountId::from_str("alice@wonderland").expect("Valid");
let mut domain = Domain::new(domain_id).build(&account_id);
let account = Account::new(
account_id.clone(),
key_pairs.iter().map(KeyPair::public_key).cloned(),
)
.build(&account_id);
assert!(domain.add_account(account).is_none());
let query_handle = LiveQueryStore::test().start();
Arc::new(WorldStateView::new(
World::with([domain], PeersIds::new()),
kura,
query_handle,
))
};

let queue = Queue::from_configuration(&Configuration {
transaction_time_to_live_ms: 100_000,
max_transactions_in_queue: 100,
..ConfigurationProxy::default()
.build()
.expect("Default queue config should always build")
});
let instructions: [InstructionExpr; 0] = [];
let tx = TransactionBuilder::new("alice@wonderland".parse().expect("Valid"))
.with_instructions(instructions);
let tx_limits = TransactionLimits {
max_instruction_number: 4096,
max_wasm_size_bytes: 0,
};

let get_tx = |key_pair| {
AcceptedTransaction::accept(
tx.clone().sign(key_pair).expect("Failed to sign."),
Expand All @@ -541,7 +592,7 @@ mod tests {
};
for key_pair in key_pairs {
let partially_signed_tx: AcceptedTransaction = get_tx(key_pair);
// Check that non of partially signed pass signature check
// Check that none of partially signed pass signature check
assert!(matches!(
partially_signed_tx.check_signature_condition(&wsv),
Ok(MustUse(false))
Expand Down
2 changes: 1 addition & 1 deletion data_model/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl FromStr for AccountId {

impl Default for SignatureCheckCondition {
fn default() -> Self {
Self::AnyAccountSignatureOr(ConstVec::new_empty())
Self::AllAccountSignaturesAnd(ConstVec::new_empty())
}
}

Expand Down
24 changes: 12 additions & 12 deletions docs/source/references/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ The following is the default configuration used by Iroha.
"SUMERAGI": {
"KEY_PAIR": null,
"PEER_ID": null,
"BLOCK_TIME_MS": 2000,
"BLOCK_TIME_MS": 1000,
"TRUSTED_PEERS": null,
"COMMIT_TIME_LIMIT_MS": 4000,
"MAX_TRANSACTIONS_IN_BLOCK": 512,
"COMMIT_TIME_LIMIT_MS": 120000,
"MAX_TRANSACTIONS_IN_BLOCK": 20,
"ACTOR_CHANNEL_CAPACITY": 100,
"GOSSIP_BATCH_SIZE": 500,
"GOSSIP_PERIOD_MS": 1000
Expand All @@ -59,7 +59,7 @@ The following is the default configuration used by Iroha.
"FETCH_SIZE": 10
},
"BLOCK_SYNC": {
"GOSSIP_PERIOD_MS": 10000,
"GOSSIP_PERIOD_MS": 1000,
"BLOCK_BATCH_SIZE": 4,
"ACTOR_CHANNEL_CAPACITY": 100
},
Expand Down Expand Up @@ -141,7 +141,7 @@ Has type `Option<block_sync::ConfigurationProxy>`[^1]. Can be configured via env
{
"ACTOR_CHANNEL_CAPACITY": 100,
"BLOCK_BATCH_SIZE": 4,
"GOSSIP_PERIOD_MS": 10000
"GOSSIP_PERIOD_MS": 1000
}
```

Expand Down Expand Up @@ -172,7 +172,7 @@ The period of time to wait between sending requests for the latest block.
Has type `Option<u64>`[^1]. Can be configured via environment variable `BLOCK_SYNC_GOSSIP_PERIOD_MS`

```json
10000
1000
```

## `disable_panic_terminal_colors`
Expand Down Expand Up @@ -522,12 +522,12 @@ Has type `Option<Box<sumeragi::ConfigurationProxy>>`[^1]. Can be configured via
```json
{
"ACTOR_CHANNEL_CAPACITY": 100,
"BLOCK_TIME_MS": 2000,
"COMMIT_TIME_LIMIT_MS": 4000,
"BLOCK_TIME_MS": 1000,
"COMMIT_TIME_LIMIT_MS": 120000,
"GOSSIP_BATCH_SIZE": 500,
"GOSSIP_PERIOD_MS": 1000,
"KEY_PAIR": null,
"MAX_TRANSACTIONS_IN_BLOCK": 512,
"MAX_TRANSACTIONS_IN_BLOCK": 20,
"PEER_ID": null,
"TRUSTED_PEERS": null
}
Expand All @@ -550,7 +550,7 @@ The period of time a peer waits for the `CreatedBlock` message after getting a `
Has type `Option<u64>`[^1]. Can be configured via environment variable `SUMERAGI_BLOCK_TIME_MS`

```json
2000
1000
```

### `sumeragi.commit_time_limit_ms`
Expand All @@ -560,7 +560,7 @@ The period of time a peer waits for `CommitMessage` from the proxy tail.
Has type `Option<u64>`[^1]. Can be configured via environment variable `SUMERAGI_COMMIT_TIME_LIMIT_MS`

```json
4000
120000
```

### `sumeragi.gossip_batch_size`
Expand Down Expand Up @@ -600,7 +600,7 @@ The upper limit of the number of transactions per block.
Has type `Option<u32>`[^1]. Can be configured via environment variable `SUMERAGI_MAX_TRANSACTIONS_IN_BLOCK`

```json
512
20
```

### `sumeragi.peer_id`
Expand Down

0 comments on commit 0922950

Please sign in to comment.