Skip to content

Commit

Permalink
[refactor] hyperledger#4229: Removed MST aggregation
Browse files Browse the repository at this point in the history
Signed-off-by: Stukalov-A-M <stukalov07@gmail.com>
  • Loading branch information
Stukalov-A-M committed Feb 26, 2024
1 parent aec910d commit eb32d88
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 50 deletions.
4 changes: 2 additions & 2 deletions client/tests/integration/multisignature_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn multisignature_transactions_should_be_accepted_after_fully_signed() -> Result
let client = Client::new(client_config.clone());
let instructions = [mint_asset.clone()];
let transaction = client.build_transaction(instructions, UnlimitedMetadata::new());
//The tx signed by the first account
// The tx signed by the first account
let _ = client
.submit_transaction(&client.sign_transaction(transaction.clone()))
.expect_err("Transaction should not be added into the queue");
Expand All @@ -82,7 +82,7 @@ fn multisignature_transactions_should_be_accepted_after_fully_signed() -> Result

client_config.key_pair = key_pair_2;
let client_2 = Client::new(client_config);
//The tx signed by the second account
// The tx signed by the second account
client_2.submit_transaction(&client_2.sign_transaction(transaction))?;

thread::sleep(pipeline_time);
Expand Down
2 changes: 1 addition & 1 deletion client_cli/pytests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ The variables:
```shell
CLIENT_CLI_BINARY=/path/to/iroha_client_cli
CLIENT_CLI_CONFIG=/path/to/config.toml
CLIENT_CLI_CONFIG=/path/to/client.toml
TORII_API_PORT_MIN=8080
TORII_API_PORT_MAX=8083
```
Expand Down
6 changes: 3 additions & 3 deletions client_cli/pytests/src/client_cli/client_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def domain(self, domain: str):
:return: The current ClientCli object.
:rtype: ClientCli
"""
self.command.insert(3, "domain")
self.command.insert(2, "domain")
self.command.append("--id=" + domain)
self.execute()
return self
Expand All @@ -147,7 +147,7 @@ def account(self, account: str, domain: str, key: str):
:return: The current ClientCli object.
:rtype: ClientCli
"""
self.command.insert(3, "account")
self.command.insert(2, "account")
self.command.append("--id=" + account + "@" + domain)
self.command.append("--key=ed0120" + key)
self.execute()
Expand All @@ -166,7 +166,7 @@ def asset(self, asset_definition=None, account=None, value_of_value_type=None):
:return: The current ClientCli object.
:rtype: ClientCli
"""
self.command.insert(3, "asset")
self.command.insert(2, "asset")
if asset_definition and account and value_of_value_type:
self.command.append(
"--asset-id="
Expand Down
4 changes: 4 additions & 0 deletions client_cli/pytests/src/client_cli/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def load(self, path_config_client_cli):
"""
if not os.path.exists(path_config_client_cli):
raise IOError(f"No config file found at {path_config_client_cli}")

if not os.path.isfile(path_config_client_cli):
raise IOError(f"The path is not a file: {path_config_client_cli}")

with open(path_config_client_cli, "r", encoding="utf-8") as config_file:
self._config = tomlkit.load(config_file)
self.file = path_config_client_cli
Expand Down
2 changes: 1 addition & 1 deletion client_cli/pytests/src/client_cli/iroha.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _execute_command(self, command_name: str):
:param command_name: The name of the command to execute.
:type command_name: str
"""
self.command.insert(3, command_name)
self.command.insert(2, command_name)
self.execute()

def should(self, *args, **kwargs):
Expand Down
68 changes: 25 additions & 43 deletions core/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ impl AcceptedTransaction {
.collect();

wsv.map_account(authority, |account| {
Ok(account.check_signature_check_condition(&transaction_signatories))
})?
account.check_signature_check_condition(&transaction_signatories)
})
.unwrap_or(MustUse(false))
}

/// Check if [`self`] is committed or rejected.
Expand Down Expand Up @@ -76,7 +77,7 @@ pub enum Error {
InBlockchain,
/// User reached maximum number of transactions in the queue
MaximumTransactionsPerUser,
/// The transaction is in the queue
/// The transaction is already in the queue
IsInQueue,
/// Failure during signature condition execution
SignatureCondition,
Expand Down Expand Up @@ -153,21 +154,20 @@ impl Queue {
)
}

fn check_tx(
&self,
tx: &AcceptedTransaction,
wsv: &WorldStateView,
) -> Result<MustUse<bool>, Error> {
fn check_tx(&self, tx: &AcceptedTransaction, wsv: &WorldStateView) -> Result<(), Error> {
if self.is_in_future(tx) {
Err(Error::InFuture)
} else if self.is_expired(tx) {
debug!("Transaction is expired");
Err(Error::Expired)
} else if tx.is_in_blockchain(wsv) {
debug!("Transaction is already in blockchain");
Err(Error::InBlockchain)
} else if !tx.check_signature_condition(wsv).into_inner() {
debug!("Signature condition appeared");
Err(Error::SignatureCondition)
} else {
Ok(MustUse(true))
Ok(())
}
}

Expand Down Expand Up @@ -227,7 +227,7 @@ impl Queue {
Ok(())
}

/// Pop single transaction from the queue. Record all visited and not removed transactions in `seen`.
/// Pop single transaction from the queue. Removes all transaction that fail the `tx_check`.
fn pop_from_queue(
&self,
seen: &mut Vec<HashOf<SignedTransaction>>,
Expand All @@ -249,23 +249,19 @@ impl Queue {
};

let tx = entry.get();
if tx.is_in_blockchain(wsv) {
debug!("Transaction is already in blockchain");
let (_, tx) = entry.remove_entry();
self.decrease_per_user_tx_count(tx.as_ref().authority());
continue;
}
if self.is_expired(tx) {
debug!("Transaction is expired");
let (_, tx) = entry.remove_entry();
self.decrease_per_user_tx_count(tx.as_ref().authority());
expired_transactions.push(tx);
continue;
}
seen.push(hash);
if *tx.check_signature_condition(wsv) {
// Transactions are not removed from the queue until expired or committed
return Some(entry.get().clone());
match self.check_tx(tx, wsv) {
Err(e) => {
let (_, tx) = entry.remove_entry();
self.decrease_per_user_tx_count(tx.as_ref().authority());
if let Error::Expired = e {
expired_transactions.push(tx);
}
continue;
}
Ok(()) => {
seen.push(hash);
return Some(tx.clone());
}
}
}
}
Expand Down Expand Up @@ -513,7 +509,7 @@ mod tests {
AcceptedTransaction::accept(signed_tx, &chain_id, &tx_limits)
.expect("Failed to accept Transaction.")
};
// Check that fully signed transaction pass signature check
// Check that fully signed transaction passes signature check
assert!(matches!(
fully_signed_tx.check_signature_condition(&wsv),
MustUse(true)
Expand All @@ -525,7 +521,7 @@ mod tests {
};
for key_pair in key_pairs {
let partially_signed_tx: AcceptedTransaction = get_tx(key_pair);
// Check that none of partially signed txs does not pass signature check
// Check that none of partially signed txs passes signature check
assert_eq!(
partially_signed_tx.check_signature_condition(&wsv),
MustUse(false)
Expand All @@ -535,20 +531,6 @@ mod tests {
Error::SignatureCondition
))
}
/*
// Check that transactions combined into one instead of duplicating
assert_eq!(queue.tx_len(), 1);
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),
MustUse(true)
));
*/
}

#[test]
Expand Down

0 comments on commit eb32d88

Please sign in to comment.