From 3b66c8485f9042ea050ce2837da18d9f5be41e19 Mon Sep 17 00:00:00 2001 From: utkarshg6 Date: Mon, 24 Mar 2025 13:53:31 +0530 Subject: [PATCH 1/7] GH-538: introduce a limit for batch size --- node/src/blockchain/blockchain_bridge.rs | 24 ++++++------------- .../blockchain_interface_web3/mod.rs | 9 ++++++- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/node/src/blockchain/blockchain_bridge.rs b/node/src/blockchain/blockchain_bridge.rs index e4275b036..7029f7138 100644 --- a/node/src/blockchain/blockchain_bridge.rs +++ b/node/src/blockchain/blockchain_bridge.rs @@ -553,7 +553,7 @@ mod tests { use crate::accountant::scanners::mid_scan_msg_handling::payable_scanner::test_utils::BlockchainAgentMock; use crate::accountant::scanners::test_utils::protect_payables_in_test; use crate::accountant::test_utils::{make_payable_account, make_pending_payable_fingerprint}; - use crate::blockchain::blockchain_interface::blockchain_interface_web3::BlockchainInterfaceWeb3; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::{BlockchainInterfaceWeb3, MAX_BATCH_SIZE}; use crate::blockchain::blockchain_interface::data_structures::errors::PayableTransactionError::TransactionID; use crate::blockchain::blockchain_interface::data_structures::errors::{ BlockchainAgentBuildError, PayableTransactionError, @@ -1027,21 +1027,20 @@ mod tests { } #[test] - fn process_payments_works() { + fn process_payments_works_with_limited_batch_size() { let test_name = "process_payments_works"; let port = find_free_port(); let _blockchain_client_server = MBCSBuilder::new(port) .ok_response("0x01".to_string(), 1) .begin_batch() .ok_response("rpc_result".to_string(), 7) - .ok_response("rpc_result_2".to_string(), 7) + .ok_response("rpc_result".to_string(), 7) .end_batch() .start(); let blockchain_interface_web3 = make_blockchain_interface_web3(port); let consuming_wallet = make_paying_wallet(b"consuming_wallet"); - let accounts_1 = make_payable_account(1); - let accounts_2 = make_payable_account(2); - let accounts = vec![accounts_1.clone(), accounts_2.clone()]; + let accounts: Vec = (1..=1000).map(make_payable_account).collect(); + let accounts_1_wallet = accounts[0].wallet.clone(); let system = System::new(test_name); let agent = BlockchainAgentMock::default() .consuming_wallet_result(consuming_wallet) @@ -1066,26 +1065,17 @@ mod tests { System::current().stop(); system.run(); let processed_payments = result.unwrap(); + assert_eq!(processed_payments.len(), MAX_BATCH_SIZE); assert_eq!( processed_payments[0], Correct(PendingPayable { - recipient_wallet: accounts_1.wallet, + recipient_wallet: accounts_1_wallet, hash: H256::from_str( "cc73f3d5fe9fc3dac28b510ddeb157b0f8030b201e809014967396cdf365488a" ) .unwrap() }) ); - assert_eq!( - processed_payments[1], - Correct(PendingPayable { - recipient_wallet: accounts_2.wallet, - hash: H256::from_str( - "891d9ffa838aedc0bb2f6f7e9737128ce98bb33d07b4c8aa5645871e20d6cd13" - ) - .unwrap() - }) - ); let recording = accountant_recording.lock().unwrap(); assert_eq!(recording.len(), 1); } diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs index 92f8e9145..d740bb7c7 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs @@ -55,6 +55,8 @@ pub const TRANSFER_METHOD_ID: [u8; 4] = [0xa9, 0x05, 0x9c, 0xbb]; pub const REQUESTS_IN_PARALLEL: usize = 1; +pub const MAX_BATCH_SIZE: usize = 1; + pub const FRESH_START_BLOCK: u64 = 0; pub const BLOCKCHAIN_SERVICE_URL_NOT_SPECIFIED: &str = @@ -255,6 +257,10 @@ impl BlockchainInterface for BlockchainInterfaceWeb3 { .lower_interface() .get_transaction_id(consuming_wallet.address()); let gas_price_wei = agent.agreed_fee_per_computation_unit(); + let allowed_accounts_per_batch = affordable_accounts + .into_iter() + .take(MAX_BATCH_SIZE) + .collect::>(); let chain = agent.get_chain(); Box::new( @@ -269,7 +275,7 @@ impl BlockchainInterface for BlockchainInterfaceWeb3 { gas_price_wei, pending_nonce, fingerprints_recipient, - affordable_accounts, + allowed_accounts_per_batch, ) }), ) @@ -498,6 +504,7 @@ mod tests { "transfer(address,uint256)".keccak256()[0..4], ); assert_eq!(FRESH_START_BLOCK, 0); + assert_eq!(MAX_BATCH_SIZE, 1); } #[test] From ba36cd7ff704d62ac27d811ff8a9833d08a6f6ac Mon Sep 17 00:00:00 2001 From: utkarshg6 Date: Tue, 25 Mar 2025 17:03:25 +0530 Subject: [PATCH 2/7] Revert "GH-539: introduce a limit for batch size" This reverts commit 3b66c8485f9042ea050ce2837da18d9f5be41e19. --- node/src/blockchain/blockchain_bridge.rs | 24 +++++++++++++------ .../blockchain_interface_web3/mod.rs | 9 +------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/node/src/blockchain/blockchain_bridge.rs b/node/src/blockchain/blockchain_bridge.rs index 7029f7138..e4275b036 100644 --- a/node/src/blockchain/blockchain_bridge.rs +++ b/node/src/blockchain/blockchain_bridge.rs @@ -553,7 +553,7 @@ mod tests { use crate::accountant::scanners::mid_scan_msg_handling::payable_scanner::test_utils::BlockchainAgentMock; use crate::accountant::scanners::test_utils::protect_payables_in_test; use crate::accountant::test_utils::{make_payable_account, make_pending_payable_fingerprint}; - use crate::blockchain::blockchain_interface::blockchain_interface_web3::{BlockchainInterfaceWeb3, MAX_BATCH_SIZE}; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::BlockchainInterfaceWeb3; use crate::blockchain::blockchain_interface::data_structures::errors::PayableTransactionError::TransactionID; use crate::blockchain::blockchain_interface::data_structures::errors::{ BlockchainAgentBuildError, PayableTransactionError, @@ -1027,20 +1027,21 @@ mod tests { } #[test] - fn process_payments_works_with_limited_batch_size() { + fn process_payments_works() { let test_name = "process_payments_works"; let port = find_free_port(); let _blockchain_client_server = MBCSBuilder::new(port) .ok_response("0x01".to_string(), 1) .begin_batch() .ok_response("rpc_result".to_string(), 7) - .ok_response("rpc_result".to_string(), 7) + .ok_response("rpc_result_2".to_string(), 7) .end_batch() .start(); let blockchain_interface_web3 = make_blockchain_interface_web3(port); let consuming_wallet = make_paying_wallet(b"consuming_wallet"); - let accounts: Vec = (1..=1000).map(make_payable_account).collect(); - let accounts_1_wallet = accounts[0].wallet.clone(); + let accounts_1 = make_payable_account(1); + let accounts_2 = make_payable_account(2); + let accounts = vec![accounts_1.clone(), accounts_2.clone()]; let system = System::new(test_name); let agent = BlockchainAgentMock::default() .consuming_wallet_result(consuming_wallet) @@ -1065,17 +1066,26 @@ mod tests { System::current().stop(); system.run(); let processed_payments = result.unwrap(); - assert_eq!(processed_payments.len(), MAX_BATCH_SIZE); assert_eq!( processed_payments[0], Correct(PendingPayable { - recipient_wallet: accounts_1_wallet, + recipient_wallet: accounts_1.wallet, hash: H256::from_str( "cc73f3d5fe9fc3dac28b510ddeb157b0f8030b201e809014967396cdf365488a" ) .unwrap() }) ); + assert_eq!( + processed_payments[1], + Correct(PendingPayable { + recipient_wallet: accounts_2.wallet, + hash: H256::from_str( + "891d9ffa838aedc0bb2f6f7e9737128ce98bb33d07b4c8aa5645871e20d6cd13" + ) + .unwrap() + }) + ); let recording = accountant_recording.lock().unwrap(); assert_eq!(recording.len(), 1); } diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs index d740bb7c7..92f8e9145 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs @@ -55,8 +55,6 @@ pub const TRANSFER_METHOD_ID: [u8; 4] = [0xa9, 0x05, 0x9c, 0xbb]; pub const REQUESTS_IN_PARALLEL: usize = 1; -pub const MAX_BATCH_SIZE: usize = 1; - pub const FRESH_START_BLOCK: u64 = 0; pub const BLOCKCHAIN_SERVICE_URL_NOT_SPECIFIED: &str = @@ -257,10 +255,6 @@ impl BlockchainInterface for BlockchainInterfaceWeb3 { .lower_interface() .get_transaction_id(consuming_wallet.address()); let gas_price_wei = agent.agreed_fee_per_computation_unit(); - let allowed_accounts_per_batch = affordable_accounts - .into_iter() - .take(MAX_BATCH_SIZE) - .collect::>(); let chain = agent.get_chain(); Box::new( @@ -275,7 +269,7 @@ impl BlockchainInterface for BlockchainInterfaceWeb3 { gas_price_wei, pending_nonce, fingerprints_recipient, - allowed_accounts_per_batch, + affordable_accounts, ) }), ) @@ -504,7 +498,6 @@ mod tests { "transfer(address,uint256)".keccak256()[0..4], ); assert_eq!(FRESH_START_BLOCK, 0); - assert_eq!(MAX_BATCH_SIZE, 1); } #[test] From ea9cb68d4709d06e54ec14c649ea3915e50c038d Mon Sep 17 00:00:00 2001 From: utkarshg6 Date: Tue, 25 Mar 2025 20:19:18 +0530 Subject: [PATCH 3/7] GH-538: increase gas price by 30% --- node/src/accountant/mod.rs | 16 ++++++++-------- node/src/blockchain/blockchain_bridge.rs | 5 +++-- .../lower_level_interface_web3.rs | 16 ++++++++++++++-- .../blockchain_interface_web3/mod.rs | 2 +- .../blockchain_interface_initializer.rs | 2 +- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/node/src/accountant/mod.rs b/node/src/accountant/mod.rs index 0a74d076c..61308ef7f 100644 --- a/node/src/accountant/mod.rs +++ b/node/src/accountant/mod.rs @@ -3437,10 +3437,10 @@ mod tests { init_test_logging(); let port = find_free_port(); let pending_tx_hash_1 = - H256::from_str("e66814b2812a80d619813f51aa999c0df84eb79d10f4923b2b7667b30d6b33d3") + H256::from_str("758b00d9041ce3afe0f88c672ee07bf524d70aa101147942212cada6a753bc40") .unwrap(); let pending_tx_hash_2 = - H256::from_str("0288ef000581b3bca8a2017eac9aea696366f8f1b7437f18d1aad57bccb7032c") + H256::from_str("4f2cd80b817ca717e33b27d73b4483bbe2baf15fdf3e72a59c0d554b96b76192") .unwrap(); let _blockchain_client_server = MBCSBuilder::new(port) // Blockchain Agent Gas Price @@ -3770,16 +3770,16 @@ mod tests { ); let log_handler = TestLogHandler::new(); log_handler.exists_log_containing( - "WARN: Accountant: Broken transactions 0xe66814b2812a80d619813f51aa999c0df84eb79d10f\ - 4923b2b7667b30d6b33d3 marked as an error. You should take over the care of those to make sure \ + "WARN: Accountant: Broken transactions 0x758b00d9041ce3afe0f88c672ee07bf524d70\ + aa101147942212cada6a753bc40 marked as an error. You should take over the care of those to make sure \ your debts are going to be settled properly. At the moment, there is no automated process \ fixing that without your assistance"); - log_handler.exists_log_matching("INFO: Accountant: Transaction 0x0288ef000581b3bca8a2017eac9\ - aea696366f8f1b7437f18d1aad57bccb7032c has been added to the blockchain; detected locally at \ + log_handler.exists_log_matching("INFO: Accountant: Transaction 0x4f2cd80b817ca717e\ + 33b27d73b4483bbe2baf15fdf3e72a59c0d554b96b76192 has been added to the blockchain; detected locally at \ attempt 4 at \\d{2,}ms after its sending"); log_handler.exists_log_containing( - "INFO: Accountant: Transactions 0x0288ef000581b3bca8a2017eac9aea696366f8f1b7437f18d1aad5\ - 7bccb7032c completed their confirmation process succeeding", + "INFO: Accountant: Transactions 0x4f2cd80b817ca717e33b27d73b4483\ + bbe2baf15fdf3e72a59c0d554b96b76192 completed their confirmation process succeeding", ); } diff --git a/node/src/blockchain/blockchain_bridge.rs b/node/src/blockchain/blockchain_bridge.rs index e4275b036..d4b66f9bb 100644 --- a/node/src/blockchain/blockchain_bridge.rs +++ b/node/src/blockchain/blockchain_bridge.rs @@ -745,6 +745,7 @@ mod tests { let accountant_received_payment = accountant_recording_arc.lock().unwrap(); let blockchain_agent_with_context_msg_actual: &BlockchainAgentWithContextMessage = accountant_received_payment.get_record(0); + let expected_gas_price = (9395240960 * 13) / 10; // 30% increase assert_eq!( blockchain_agent_with_context_msg_actual.protected_qualified_payables, qualified_payables @@ -759,7 +760,7 @@ mod tests { blockchain_agent_with_context_msg_actual .agent .agreed_fee_per_computation_unit(), - 0x230000000 + expected_gas_price ); assert_eq!( blockchain_agent_with_context_msg_actual @@ -776,7 +777,7 @@ mod tests { blockchain_agent_with_context_msg_actual .agent .estimated_transaction_fee_total(1), - (1 * 0x230000000 * (gas_limit_const_part + WEB3_MAXIMAL_GAS_LIMIT_MARGIN)) + (1 * expected_gas_price * (gas_limit_const_part + WEB3_MAXIMAL_GAS_LIMIT_MARGIN)) ); assert_eq!( blockchain_agent_with_context_msg_actual.response_skeleton_opt, diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs index 5879a47a3..ff78110e8 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs @@ -12,6 +12,8 @@ use web3::transports::{Batch, Http}; use web3::types::{Address, BlockNumber, Filter, Log, TransactionReceipt}; use web3::{Error, Web3}; +const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 30; + #[derive(Debug, PartialEq, Eq, Clone)] pub enum TransactionReceiptResult { RpcResponse(TxReceipt), @@ -93,7 +95,12 @@ impl LowBlockchainInt for LowBlockchainIntWeb3 { self.web3 .eth() .gas_price() - .map_err(|e| QueryFailed(e.to_string())), + .map_err(|e| QueryFailed(e.to_string())) + .map(|price| { + let increase = + price * U256::from(GAS_PRICE_INCREASE_PERCENTAGE) / U256::from(100); + price + increase + }), ) } @@ -184,7 +191,12 @@ mod tests { use masq_lib::utils::find_free_port; use std::str::FromStr; use web3::types::{BlockNumber, Bytes, FilterBuilder, Log, TransactionReceipt, U256}; - use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TxReceipt, TxStatus}; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TxReceipt, TxStatus, GAS_PRICE_INCREASE_PERCENTAGE}; + + #[test] + fn constants_have_correct_values() { + assert_eq!(GAS_PRICE_INCREASE_PERCENTAGE, 30); + } #[test] fn get_transaction_fee_balance_works() { diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs index 92f8e9145..04fd4fc4a 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs @@ -855,7 +855,7 @@ mod tests { let expected_transaction_fee_balance = U256::from(65_520); let expected_masq_balance = U256::from(65_535); - let expected_gas_price_wei = 1_000_000_000; + let expected_gas_price_wei = 1_000_000_000 + 300_000_000; assert_eq!(result.consuming_wallet(), &wallet); assert_eq!( result.consuming_wallet_balances(), diff --git a/node/src/blockchain/blockchain_interface_initializer.rs b/node/src/blockchain/blockchain_interface_initializer.rs index ee87519a0..66c24530f 100644 --- a/node/src/blockchain/blockchain_interface_initializer.rs +++ b/node/src/blockchain/blockchain_interface_initializer.rs @@ -86,7 +86,7 @@ mod tests { assert_eq!(blockchain_agent.consuming_wallet(), &wallet); assert_eq!( blockchain_agent.agreed_fee_per_computation_unit(), - 1_000_000_000 + 1_000_000_000 + 300_000_000 ); } From 2c3fb06fb975ff06121fb42004a6fc7ac2c70c8a Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Wed, 26 Mar 2025 12:27:54 +0530 Subject: [PATCH 4/7] GH-538: fix multinode tests --- .../tests/verify_bill_payment.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multinode_integration_tests/tests/verify_bill_payment.rs b/multinode_integration_tests/tests/verify_bill_payment.rs index 5d682fea4..56f87a1d0 100644 --- a/multinode_integration_tests/tests/verify_bill_payment.rs +++ b/multinode_integration_tests/tests/verify_bill_payment.rs @@ -234,7 +234,7 @@ fn verify_bill_payment() { assert_balances( &contract_owner_wallet, &blockchain_interface, - "99995231980000000000", + "99994287232000000000", "471999999700000000000000000", ); @@ -409,7 +409,7 @@ fn verify_pending_payables() { assert_balances( &contract_owner_wallet, &blockchain_interface, - "99995231980000000000", + "99994287232000000000", "471999999700000000000000000", ); assert_balances( @@ -450,17 +450,17 @@ fn verify_pending_payables() { ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0x75a8f185b7fb3ac0c4d1ee6b402a46940c9ae0477c0c7378a1308fb4bf539c5c has been added to the blockchain;", + "Transaction 0xecab1c73ca90ebcb073526e28f1f8d4678704b74d1e0209779ddeefc8fb861f5 has been added to the blockchain;", Duration::from_secs(5), ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0x384a3bb5bbd9718a97322be2878fa88c7cacacb2ac3416f521a621ca1946ddfc has been added to the blockchain;", + "Transaction 0xae0bf6400f0b9950a1d456e488549414d118714b81a39233b811b629cf41399b has been added to the blockchain;", Duration::from_secs(5), ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0x6bc98d5db61ddd7676de1f25cb537156b3d9e066cec414fef8dbe9c695908215 has been added to the blockchain;", + "Transaction 0x89acc46da0df6ef8c6f5574307ae237a812bd28af524a62131013b5e19ca3e26 has been added to the blockchain;", Duration::from_secs(5), ); } From 32616df9274c09a61f6ce07a624ecd339bb8c42a Mon Sep 17 00:00:00 2001 From: utkarshg6 Date: Tue, 8 Apr 2025 10:31:05 +0530 Subject: [PATCH 5/7] GH-538: increase gas price by 80% --- .../blockchain_interface_web3/lower_level_interface_web3.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs index ff78110e8..3bc4b9f2b 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs @@ -12,7 +12,7 @@ use web3::transports::{Batch, Http}; use web3::types::{Address, BlockNumber, Filter, Log, TransactionReceipt}; use web3::{Error, Web3}; -const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 30; +const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 80; #[derive(Debug, PartialEq, Eq, Clone)] pub enum TransactionReceiptResult { @@ -195,7 +195,7 @@ mod tests { #[test] fn constants_have_correct_values() { - assert_eq!(GAS_PRICE_INCREASE_PERCENTAGE, 30); + assert_eq!(GAS_PRICE_INCREASE_PERCENTAGE, 80); } #[test] From 1177696070a0800987c092cb7bbccf238ba96a65 Mon Sep 17 00:00:00 2001 From: utkarshg6 Date: Tue, 8 Apr 2025 10:59:19 +0530 Subject: [PATCH 6/7] GH-538: pass unit test --- node/src/accountant/mod.rs | 16 ++++++++-------- node/src/blockchain/blockchain_bridge.rs | 6 ++++-- .../lower_level_interface_web3.rs | 2 +- .../blockchain_interface_web3/mod.rs | 6 ++++-- .../blockchain_interface_initializer.rs | 5 ++++- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/node/src/accountant/mod.rs b/node/src/accountant/mod.rs index 61308ef7f..923a6d0fc 100644 --- a/node/src/accountant/mod.rs +++ b/node/src/accountant/mod.rs @@ -3437,10 +3437,10 @@ mod tests { init_test_logging(); let port = find_free_port(); let pending_tx_hash_1 = - H256::from_str("758b00d9041ce3afe0f88c672ee07bf524d70aa101147942212cada6a753bc40") + H256::from_str("acc64bde11847ec2186914c8cf18b9b153bf1b6e02b534aa314946fc3a828df0") .unwrap(); let pending_tx_hash_2 = - H256::from_str("4f2cd80b817ca717e33b27d73b4483bbe2baf15fdf3e72a59c0d554b96b76192") + H256::from_str("e91c8324cb47305eefc0bff30b5981353326910eede7d3cf41579b5fcce712b4") .unwrap(); let _blockchain_client_server = MBCSBuilder::new(port) // Blockchain Agent Gas Price @@ -3770,16 +3770,16 @@ mod tests { ); let log_handler = TestLogHandler::new(); log_handler.exists_log_containing( - "WARN: Accountant: Broken transactions 0x758b00d9041ce3afe0f88c672ee07bf524d70\ - aa101147942212cada6a753bc40 marked as an error. You should take over the care of those to make sure \ + "WARN: Accountant: Broken transactions 0xacc64bde11847ec2186914c8cf18b9b153bf\ + 1b6e02b534aa314946fc3a828df0 marked as an error. You should take over the care of those to make sure \ your debts are going to be settled properly. At the moment, there is no automated process \ fixing that without your assistance"); - log_handler.exists_log_matching("INFO: Accountant: Transaction 0x4f2cd80b817ca717e\ - 33b27d73b4483bbe2baf15fdf3e72a59c0d554b96b76192 has been added to the blockchain; detected locally at \ + log_handler.exists_log_matching("INFO: Accountant: Transaction 0xe91c8324cb47305eef\ + c0bff30b5981353326910eede7d3cf41579b5fcce712b4 has been added to the blockchain; detected locally at \ attempt 4 at \\d{2,}ms after its sending"); log_handler.exists_log_containing( - "INFO: Accountant: Transactions 0x4f2cd80b817ca717e33b27d73b4483\ - bbe2baf15fdf3e72a59c0d554b96b76192 completed their confirmation process succeeding", + "INFO: Accountant: Transactions 0xe91c8324cb47305eefc0bff30b5981353326910eede7\ + d3cf41579b5fcce712b4 completed their confirmation process succeeding", ); } diff --git a/node/src/blockchain/blockchain_bridge.rs b/node/src/blockchain/blockchain_bridge.rs index d4b66f9bb..ab95ab6fb 100644 --- a/node/src/blockchain/blockchain_bridge.rs +++ b/node/src/blockchain/blockchain_bridge.rs @@ -598,7 +598,7 @@ mod tests { use std::time::{Duration, SystemTime}; use web3::types::{TransactionReceipt, H160}; use masq_lib::constants::DEFAULT_MAX_BLOCK_COUNT; - use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt}; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, GAS_PRICE_INCREASE_PERCENTAGE}; impl Handler> for BlockchainBridge { type Result = (); @@ -745,7 +745,9 @@ mod tests { let accountant_received_payment = accountant_recording_arc.lock().unwrap(); let blockchain_agent_with_context_msg_actual: &BlockchainAgentWithContextMessage = accountant_received_payment.get_record(0); - let expected_gas_price = (9395240960 * 13) / 10; // 30% increase + let gas_price_from_rpc = 9395240960; + let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100; + let expected_gas_price = gas_price_from_rpc + gas_price_increase; assert_eq!( blockchain_agent_with_context_msg_actual.protected_qualified_payables, qualified_payables diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs index 3bc4b9f2b..9c9e9cd78 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/lower_level_interface_web3.rs @@ -12,7 +12,7 @@ use web3::transports::{Batch, Http}; use web3::types::{Address, BlockNumber, Filter, Log, TransactionReceipt}; use web3::{Error, Web3}; -const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 80; +pub const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 80; #[derive(Debug, PartialEq, Eq, Clone)] pub enum TransactionReceiptResult { diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs index 04fd4fc4a..9ec9c052a 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/mod.rs @@ -459,7 +459,7 @@ mod tests { use std::str::FromStr; use web3::transports::Http; use web3::types::{H256, U256}; - use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, TxStatus}; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, TxStatus, GAS_PRICE_INCREASE_PERCENTAGE}; #[test] fn constants_are_correct() { @@ -855,7 +855,9 @@ mod tests { let expected_transaction_fee_balance = U256::from(65_520); let expected_masq_balance = U256::from(65_535); - let expected_gas_price_wei = 1_000_000_000 + 300_000_000; + let gas_price_from_rpc = 1_000_000_000; + let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100; + let expected_gas_price_wei = gas_price_from_rpc + gas_price_increase; assert_eq!(result.consuming_wallet(), &wallet); assert_eq!( result.consuming_wallet_balances(), diff --git a/node/src/blockchain/blockchain_interface_initializer.rs b/node/src/blockchain/blockchain_interface_initializer.rs index 66c24530f..3d8306e86 100644 --- a/node/src/blockchain/blockchain_interface_initializer.rs +++ b/node/src/blockchain/blockchain_interface_initializer.rs @@ -58,6 +58,7 @@ mod tests { use masq_lib::constants::DEFAULT_CHAIN; use masq_lib::test_utils::mock_blockchain_client_server::MBCSBuilder; use masq_lib::utils::find_free_port; + use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::GAS_PRICE_INCREASE_PERCENTAGE; #[test] fn initialize_web3_interface_works() { @@ -83,10 +84,12 @@ mod tests { .wait() .unwrap(); + let gas_price_from_rpc = 1_000_000_000; + let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100; assert_eq!(blockchain_agent.consuming_wallet(), &wallet); assert_eq!( blockchain_agent.agreed_fee_per_computation_unit(), - 1_000_000_000 + 300_000_000 + gas_price_from_rpc + gas_price_increase ); } From aec99a2f2e8ae8c6cb4a610a7385f1ca05955a04 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Tue, 8 Apr 2025 11:02:29 +0530 Subject: [PATCH 7/7] GH-538: fix multinode tests --- .../tests/verify_bill_payment.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multinode_integration_tests/tests/verify_bill_payment.rs b/multinode_integration_tests/tests/verify_bill_payment.rs index 56f87a1d0..edb264fed 100644 --- a/multinode_integration_tests/tests/verify_bill_payment.rs +++ b/multinode_integration_tests/tests/verify_bill_payment.rs @@ -234,7 +234,7 @@ fn verify_bill_payment() { assert_balances( &contract_owner_wallet, &blockchain_interface, - "99994287232000000000", + "99992712652000000000", "471999999700000000000000000", ); @@ -409,7 +409,7 @@ fn verify_pending_payables() { assert_balances( &contract_owner_wallet, &blockchain_interface, - "99994287232000000000", + "99992712652000000000", "471999999700000000000000000", ); assert_balances( @@ -450,17 +450,17 @@ fn verify_pending_payables() { ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0xecab1c73ca90ebcb073526e28f1f8d4678704b74d1e0209779ddeefc8fb861f5 has been added to the blockchain;", + "Transaction 0x7e08536811791ff20855e459fed222e1cc06bcd684524ae1beaa36fb28dca4f8 has been added to the blockchain;", Duration::from_secs(5), ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0xae0bf6400f0b9950a1d456e488549414d118714b81a39233b811b629cf41399b has been added to the blockchain;", + "Transaction 0x21aee15c389bd8894e4b8ffbc35a9f5084c4eea91d01d6ba5b7a93a58555d4e8 has been added to the blockchain;", Duration::from_secs(5), ); MASQNodeUtils::assert_node_wrote_log_containing( real_consuming_node.name(), - "Transaction 0x89acc46da0df6ef8c6f5574307ae237a812bd28af524a62131013b5e19ca3e26 has been added to the blockchain;", + "Transaction 0x619c64860fea5593d74fccb48fd8e3d44fe374345ff4bb657c053b2d83b71138 has been added to the blockchain;", Duration::from_secs(5), ); }