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

feat: make the make_it_rain submission rate a float #6180

Merged
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
13 changes: 10 additions & 3 deletions applications/minotari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ pub async fn discover_peer(
pub async fn make_it_rain(
wallet_transaction_service: TransactionServiceHandle,
fee_per_gram: u64,
transactions_per_second: u32,
transactions_per_second: f64,
duration: Duration,
start_amount: MicroMinotari,
increase_amount: MicroMinotari,
Expand All @@ -358,6 +358,13 @@ pub async fn make_it_rain(
transaction_type: MakeItRainTransactionType,
message: String,
) -> Result<(), CommandError> {
// Limit the transactions per second to a reasonable range
// Notes:
// - The 'transactions_per_second' is best effort and not guaranteed.
// - If a slower rate is requested as what is achievable, transactions will be delayed to match the rate.
// - If a faster rate is requested as what is achievable, the maximum rate will be that of the integrated system.
// - The default value of 25/s may not be achievable.
let transactions_per_second = transactions_per_second.abs().max(0.01).min(250.0);
// We are spawning this command in parallel, thus not collecting transaction IDs
tokio::task::spawn(async move {
// Wait until specified test start time
Expand All @@ -378,7 +385,7 @@ pub async fn make_it_rain(
);
sleep(Duration::from_millis(delay_ms)).await;

let num_txs = (f64::from(transactions_per_second) * duration.as_secs() as f64) as usize;
let num_txs = (transactions_per_second * duration.as_secs() as f64) as usize;
let started_at = Utc::now();

struct TransactionSendStats {
Expand Down Expand Up @@ -409,7 +416,7 @@ pub async fn make_it_rain(

// Manage transaction submission rate
let actual_ms = (Utc::now() - started_at).num_milliseconds();
let target_ms = (i as f64 * (1000.0 / f64::from(transactions_per_second))) as i64;
let target_ms = (i as f64 * (1000.0 / transactions_per_second)) as i64;
trace!(
target: LOG_TARGET,
"make-it-rain {}: target {:?} ms vs. actual {:?} ms", i, target_ms, actual_ms
Expand Down
4 changes: 2 additions & 2 deletions applications/minotari_console_wallet/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ pub struct MakeItRainArgs {
pub destination: TariAddress,
#[clap(short, long, alias="amount", default_value_t = tari_amount::T)]
pub start_amount: MicroMinotari,
#[clap(short, long, alias = "tps", default_value_t = 25)]
pub transactions_per_second: u32,
#[clap(short, long, alias = "tps", default_value_t = 25.0)]
pub transactions_per_second: f64,
#[clap(short, long, parse(try_from_str = parse_duration), default_value="60")]
pub duration: Duration,
#[clap(long, default_value_t=tari_amount::T)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,26 +736,31 @@ impl wallet_server::Wallet for WalletGrpcServer {
) -> Result<Response<Self::GetCompletedTransactionsStream>, Status> {
debug!(
target: LOG_TARGET,
"Incoming GRPC request for GetAllCompletedTransactions"
"GetAllCompletedTransactions: Incoming GRPC request"
);
let mut transaction_service = self.get_transaction_service();
let transactions = transaction_service
.get_completed_transactions()
.await
.map_err(|err| Status::not_found(format!("No completed transactions found: {:?}", err)))?;
debug!(
target: LOG_TARGET,
"GetAllCompletedTransactions: Found {} completed transactions",
transactions.len()
);

let (mut sender, receiver) = mpsc::channel(transactions.len());
task::spawn(async move {
for (_, txn) in transactions {
for (i, (_, txn)) in transactions.iter().enumerate() {
let response = GetCompletedTransactionsResponse {
transaction: Some(TransactionInfo {
tx_id: txn.tx_id.into(),
source_address: txn.source_address.to_bytes().to_vec(),
dest_address: txn.destination_address.to_bytes().to_vec(),
status: TransactionStatus::from(txn.status) as i32,
status: TransactionStatus::from(txn.status.clone()) as i32,
amount: txn.amount.into(),
is_cancelled: txn.cancelled.is_some(),
direction: TransactionDirection::from(txn.direction) as i32,
direction: TransactionDirection::from(txn.direction.clone()) as i32,
fee: txn.fee.into(),
timestamp: txn.timestamp.timestamp() as u64,
excess_sig: txn
Expand All @@ -764,11 +769,19 @@ impl wallet_server::Wallet for WalletGrpcServer {
.unwrap_or(&Signature::default())
.get_signature()
.to_vec(),
message: txn.message,
message: txn.message.clone(),
}),
};
match sender.send(Ok(response)).await {
Ok(_) => (),
Ok(_) => {
debug!(
target: LOG_TARGET,
"GetAllCompletedTransactions: Sent transaction TxId: {} ({} of {})",
txn.tx_id,
i + 1,
transactions.len()
);
},
Err(err) => {
warn!(target: LOG_TARGET, "Error sending transaction via GRPC: {}", err);
match sender.send(Err(Status::unknown("Error sending data"))).await {
Expand Down
16 changes: 8 additions & 8 deletions integration_tests/tests/features/StressTest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ Feature: Stress Test
# When mining node MINER mines 3 blocks
# When mining node MINER mines <NumCoinsplitsNeeded> blocks
# Then all nodes are on the same chain tip
# Then wallet WALLET_A detects all transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_A detects all transactions as Mined_or_OneSidedConfirmed
# When I send <NumTransactions> transactions of 1111 uT each from wallet WALLET_A to wallet WALLET_B at fee_per_gram 4
# # Mine enough blocks for the first block of transactions to be confirmed.
# When mining node MINER mines 4 blocks
# Then all nodes are on the same chain tip
# # Now wait until all transactions are detected as confirmed in WALLET_A, continue to mine blocks if transactions
# # are not found to be confirmed as sometimes the previous mining occurs faster than transactions are submitted
# # to the mempool
# Then while mining via SHA3 miner MINER all transactions in wallet WALLET_A are found to be Mined_or_Faux_Confirmed
# # Then wallet WALLET_B detects all transactions as Mined_or_Faux_Confirmed
# Then while mining via node NODE1 all transactions in wallet WALLET_B are found to be Mined_or_Faux_Confirmed
# Then while mining via SHA3 miner MINER all transactions in wallet WALLET_A are found to be Mined_or_OneSidedConfirmed
# # Then wallet WALLET_B detects all transactions as Mined_or_OneSidedConfirmed
# Then while mining via node NODE1 all transactions in wallet WALLET_B are found to be Mined_or_OneSidedConfirmed

# @flaky
# Examples:
Expand Down Expand Up @@ -71,14 +71,14 @@ Feature: Stress Test
# When mining node MINER mines 8 blocks

# Then all nodes are on the same chain tip
# Then wallet WALLET_A detects all transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_A detects all transactions as Mined_or_OneSidedConfirmed
# When I send 2000 transactions of 1111 uT each from wallet WALLET_A to wallet WALLET_B at fee_per_gram 4
# # Mine enough blocks for the first block of transactions to be confirmed.
# When mining node MINER mines 4 blocks
# Then all nodes are on the same chain tip
# # Now wait until all transactions are detected as confirmed in WALLET_A, continue to mine blocks if transactions
# # are not found to be confirmed as sometimes the previous mining occurs faster than transactions are submitted
# # to the mempool
# Then while mining via SHA3 miner MINER all transactions in wallet WALLET_A are found to be Mined_or_Faux_Confirmed
# # Then wallet WALLET_B detects all transactions as Mined_or_Faux_Confirmed
# Then while mining via node NODE1 all transactions in wallet WALLET_B are found to be Mined_or_Faux_Confirmed
# Then while mining via SHA3 miner MINER all transactions in wallet WALLET_A are found to be Mined_or_OneSidedConfirmed
# # Then wallet WALLET_B detects all transactions as Mined_or_OneSidedConfirmed
# Then while mining via node NODE1 all transactions in wallet WALLET_B are found to be Mined_or_OneSidedConfirmed
8 changes: 4 additions & 4 deletions integration_tests/tests/features/TransactionInfo.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Scenario: Get Transaction Info
Then wallet WALLET_B detects all transactions are at least Broadcast
When mining node MINER2 mines 1 blocks
Then all nodes are at height 5
Then wallet WALLET_A detects all transactions are at least Mined_or_Faux_Unconfirmed
Then wallet WALLET_B detects all transactions are at least Mined_or_Faux_Unconfirmed
Then wallet WALLET_A detects all transactions are at least Mined_or_OneSidedUnconfirmed
Then wallet WALLET_B detects all transactions are at least Mined_or_OneSidedUnconfirmed
When mining node MINER2 mines 10 blocks
Then all nodes are at height 15
Then wallet WALLET_A detects all transactions as Mined_or_Faux_Confirmed
Then wallet WALLET_B detects all transactions as Mined_or_Faux_Confirmed
Then wallet WALLET_A detects all transactions as Mined_or_OneSidedConfirmed
Then wallet WALLET_B detects all transactions as Mined_or_OneSidedConfirmed
# This wait is needed to stop base nodes from shutting down
When I wait 1 seconds
3 changes: 1 addition & 2 deletions integration_tests/tests/features/WalletCli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ Feature: Wallet CLI
When I have mining node MINE connected to base node BASE and wallet SENDER
When mining node MINE mines 15 blocks
Then wallets SENDER should have AT_LEAST 12 spendable coinbase outputs
When I wait 30 seconds
Then I stop wallet SENDER
When I make it rain from wallet SENDER 1 tx per sec 10 sec 8000 uT 100 increment to RECEIVER via command line
When I make-it-rain from SENDER rate 10 txns_per_sec duration 1 sec value 8000 uT increment 100 uT to RECEIVER via command line
Then wallet SENDER has at least 10 transactions that are all TRANSACTION_STATUS_BROADCAST and not cancelled
Then wallet RECEIVER has at least 10 transactions that are all TRANSACTION_STATUS_BROADCAST and not cancelled
When mining node MINE mines 5 blocks
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/tests/features/WalletFFI.feature
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ Feature: Wallet FFI
Then ffi wallet FFI_WALLET detects AT_LEAST 3 ffi transactions to be TRANSACTION_STATUS_BROADCAST
When mining node MINER mines 2 blocks
Then all nodes are at height 22
Then wallet RECEIVER has at least 1 transactions that are all TRANSACTION_STATUS_FAUX_UNCONFIRMED and not cancelled
Then wallet RECEIVER has at least 1 transactions that are all TRANSACTION_STATUS_ONE_SIDED_UNCONFIRMED and not cancelled
When mining node MINER mines 5 blocks
Then all nodes are at height 27
Then wallet RECEIVER has at least 1 transactions that are all TRANSACTION_STATUS_FAUX_CONFIRMED and not cancelled
Then wallet RECEIVER has at least 1 transactions that are all TRANSACTION_STATUS_ONE_SIDED_CONFIRMED and not cancelled
And I stop ffi wallet FFI_WALLET

@critical @brokenFFI @broken
Expand All @@ -221,12 +221,12 @@ Feature: Wallet FFI
Then I send a one-sided transaction of 1000000 uT from SENDER to FFI_RECEIVER at fee 20
When mining node MINER mines 2 blocks
Then all nodes are at height 12
Then ffi wallet FFI_RECEIVER detects AT_LEAST 1 ffi transactions to be TRANSACTION_STATUS_FAUX_UNCONFIRMED
Then ffi wallet FFI_RECEIVER detects AT_LEAST 1 ffi transactions to be TRANSACTION_STATUS_ONE_SIDED_UNCONFIRMED
And I send 1000000 uT from wallet SENDER to wallet FFI_RECEIVER at fee 20
Then ffi wallet FFI_RECEIVER detects AT_LEAST 1 ffi transactions to be TRANSACTION_STATUS_BROADCAST
When mining node MINER mines 5 blocks
Then all nodes are at height 17
Then ffi wallet FFI_RECEIVER detects AT_LEAST 1 ffi transactions to be TRANSACTION_STATUS_FAUX_CONFIRMED
Then ffi wallet FFI_RECEIVER detects AT_LEAST 1 ffi transactions to be TRANSACTION_STATUS_ONE_SIDED_CONFIRMED
And I stop ffi wallet FFI_RECEIVER

Scenario: As a client I want to get fee per gram stats
Expand Down
20 changes: 10 additions & 10 deletions integration_tests/tests/features/WalletMonitoring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Wallet Monitoring
# And I list all COINBASE transactions for wallet WALLET_A1
# Then wallet WALLET_A1 has 10 coinbase transactions
# Then all COINBASE transactions for wallet WALLET_A1 are valid
# Then wallet WALLET_A1 detects at least 7 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_A1 detects at least 7 coinbase transactions as CoinbaseConfirmed
# #
# # Chain 2:
# # Collects 10 coinbases into one wallet
Expand All @@ -36,7 +36,7 @@ Feature: Wallet Monitoring
# And I list all COINBASE transactions for wallet WALLET_B1
# Then wallet WALLET_B1 has 10 coinbase transactions
# Then all COINBASE transactions for wallet WALLET_B1 are valid
# Then wallet WALLET_B1 detects at least 7 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_B1 detects at least 7 coinbase transactions as CoinbaseConfirmed
# #
# # Connect Chain 1 and 2
# #
Expand Down Expand Up @@ -66,15 +66,15 @@ Feature: Wallet Monitoring
# When mining node MINING_A mines 10 blocks with min difficulty 20 and max difficulty 9999999999
# Then node SEED_A is at height 10
# Then node NODE_A1 is at height 10
# Then wallet WALLET_A1 detects exactly 7 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_A1 detects exactly 7 coinbase transactions as CoinbaseConfirmed
# # Use 7 of the 10 coinbase UTXOs in transactions (others require 3 confirmations)
# And I multi-send 7 transactions of 1000000 uT from wallet WALLET_A1 to wallet WALLET_A2 at fee 100
# When mining node MINING_A mines 10 blocks with min difficulty 20 and max difficulty 9999999999
# Then node SEED_A is at height 20
# Then node NODE_A1 is at height 20
# Then wallet WALLET_A2 detects all transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_A2 detects all transactions as Mined_or_OneSidedConfirmed
# Then all NORMAL transactions for wallet WALLET_A1 are valid
# Then wallet WALLET_A1 detects exactly 17 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_A1 detects exactly 17 coinbase transactions as CoinbaseConfirmed
# #
# # Chain 2:
# # Collects 10 coinbases into one wallet, send 7 transactions
Expand All @@ -88,15 +88,15 @@ Feature: Wallet Monitoring
# When mining node MINING_B mines 10 blocks with min difficulty 1 and max difficulty 2
# Then node SEED_B is at height 10
# Then node NODE_B1 is at height 10
# Then wallet WALLET_B1 detects exactly 7 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_B1 detects exactly 7 coinbase transactions as CoinbaseConfirmed
# # Use 7 of the 10 coinbase UTXOs in transactions (others require 3 confirmations)
# And I multi-send 7 transactions of 1000000 uT from wallet WALLET_B1 to wallet WALLET_B2 at fee 100
# When mining node MINING_B mines 10 blocks with min difficulty 1 and max difficulty 2
# Then node SEED_B is at height 20
# Then node NODE_B1 is at height 20
# Then wallet WALLET_B2 detects all transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_B2 detects all transactions as Mined_or_OneSidedConfirmed
# Then all NORMAL transactions for wallet WALLET_B1 are valid
# Then wallet WALLET_B1 detects exactly 17 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_B1 detects exactly 17 coinbase transactions as CoinbaseConfirmed
# #
# # Connect Chain 1 and 2
# #
Expand All @@ -105,8 +105,8 @@ Feature: Wallet Monitoring
# # When tip advances past required confirmations, invalid coinbases still being monitored will be cancelled.
# And mining node NODE_C mines 6 blocks
# Then all nodes are at height 26
# Then wallet WALLET_A1 detects exactly 20 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_B1 detects exactly 17 coinbase transactions as Mined_or_Faux_Confirmed
# Then wallet WALLET_A1 detects exactly 20 coinbase transactions as CoinbaseConfirmed
# Then wallet WALLET_B1 detects exactly 17 coinbase transactions as CoinbaseConfirmed
# And I list all NORMAL transactions for wallet WALLET_A1
# And I list all NORMAL transactions for wallet WALLET_B1
# # Uncomment this step when wallets can handle reorg
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/tests/features/WalletQuery.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Wallet Querying
When mining node MINER mines 5 blocks
Then all nodes are at height 5
When I mine 5 blocks on NODE
Then all wallets detect all transactions as Mined_or_Faux_Confirmed
Then all wallets detect all transactions as Mined_or_OneSidedConfirmed

@critical
Scenario: As a wallet I want to submit a transaction
Expand All @@ -23,5 +23,5 @@ Feature: Wallet Querying
When I wait 5 seconds
When I transfer 5T from WALLET_A to WALLET_B
When I mine 5 blocks on NODE
Then all wallets detect all transactions as Mined_or_Faux_Confirmed
Then all wallets detect all transactions as Mined_or_OneSidedConfirmed

Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Feature: Wallet Routing Mechanism
When I wait 1 seconds
# And mining node MINER mines 1 blocks
# Then all nodes are at height 21
# Then all wallets detect all transactions as Mined_or_Faux_Unconfirmed
# Then all wallets detect all transactions as Mined_or_OneSidedUnconfirmed
# # This wait is needed to stop next merge mining task from continuing
When I wait 1 seconds
# And mining node MINER mines 11 blocks
# Then all nodes are at height 32
# Then all wallets detect all transactions as Mined_or_Faux_Confirmed
# Then all wallets detect all transactions as Mined_or_OneSidedConfirmed
# This wait is needed to stop base nodes from shutting down
When I wait 1 seconds
# @long-running
Expand Down
Loading
Loading