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

GH-671: base for PaymentAdjuster-checked payables #233

Merged
merged 32 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6eaf111
GH-671: started with the reconstruction slowly; however, found weakne…
Feb 21, 2023
3032570
GH-671: I stopped before I create another branch to fix some discrepa…
Feb 22, 2023
efaaf1a
testing_area_fixes: one test counted on a premise that could not be m…
Feb 22, 2023
a496186
GH-673: making three tests into more stronger ones; these will embrac…
Feb 22, 2023
bac821f
GH-673: first phase of smooth use of stop conditions for recorder
Feb 25, 2023
927385c
GH-673: first moment hitting wall hard
Feb 25, 2023
67c01e3
GH-673: StopConditions considered implemented; might change some details
Feb 25, 2023
71824f7
GH-673: added some tests... of test code...
Feb 25, 2023
fe3c7ab
GH-673: finishing tests and adding required PartialEq and Eq traits t…
Feb 27, 2023
6bc1e46
GH-673: most of things from the review addressed; preparing for reduc…
Feb 27, 2023
4201381
GH-673: review answered
Feb 27, 2023
eea1802
GH-673: adding notify later 'facelift'
Feb 27, 2023
dfd23b6
GH-673: simplifying default impl for NotifyLaterHandler
Feb 28, 2023
e8f58af
GH-671: interim: not compaling after the merge
Feb 28, 2023
6f56071
GH-671: merge from GH-673 finished
Feb 28, 2023
d56e4c5
GH-671: interim commit
Mar 1, 2023
cbeaabc
GH-671: finished master merge
Mar 1, 2023
5574e63
GH-671: blockchain bridge with implemented check for balances for pay…
Mar 2, 2023
c629458
GH-671: enclosed the circle; functionality stable again; fully tested…
Mar 2, 2023
3104d65
GH-671: last changes begun with auto review
Mar 2, 2023
cdd4c76
GH-671: formatting
Mar 2, 2023
d7d4877
GH-671: removing www.failingFailing.com as non-http anymore for www.n…
Mar 3, 2023
5c57016
GH-671: formatting
Mar 3, 2023
2d228ad
GH-671: merged master in
Mar 30, 2023
d00a412
GH-671: first part of addressing the review
Apr 5, 2023
82da76c
GH-671: problematic parts that required discussion resolved now
Apr 5, 2023
59a1c84
GH-671: refactoring my older code in setup_reporter.rs so that it mak…
Apr 5, 2023
afc6770
GH-671: weis of gwei constant renamed
Apr 6, 2023
189a2cf
GH-671: making function clearer by using better names for variables etc
Apr 6, 2023
311d5f9
GH-671: added a comment to explain more about the fn
Apr 6, 2023
caf7765
Merge branch 'master' into GH-671
Apr 6, 2023
adcd28c
GH-671: little mistake in multinode tests
Apr 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pub(in crate::commands::financials_command) mod restricted {
use crate::commands::financials_command::data_structures::restricted::UserOriginalTypingOfRanges;
use masq_lib::constants::{MASQ_TOTAL_SUPPLY, WEIS_OF_GWEI};
use masq_lib::constants::{MASQ_TOTAL_SUPPLY, WEIS_IN_GWEI};
use masq_lib::utils::ExpectValue;
use num::CheckedMul;
use regex::{Captures, Regex};
Expand All @@ -15,8 +15,8 @@ pub(in crate::commands::financials_command) mod restricted {

pub fn convert_masq_from_gwei_and_dress_well(balance_gwei: i64) -> String {
const MASK_FOR_NON_SIGNIFICANT_DIGITS: i64 = 10_000_000;
let balance_masq_int = (balance_gwei / WEIS_OF_GWEI as i64).abs();
let balance_masq_frac = (balance_gwei % WEIS_OF_GWEI as i64).abs();
let balance_masq_int = (balance_gwei / WEIS_IN_GWEI as i64).abs();
let balance_masq_frac = (balance_gwei % WEIS_IN_GWEI as i64).abs();
let balance_masq_frac_trunc = balance_masq_frac / MASK_FOR_NON_SIGNIFICANT_DIGITS;
match (
(balance_masq_int == 0) && (balance_masq_frac_trunc == 0),
Expand Down Expand Up @@ -310,7 +310,7 @@ mod tests {
process_optionally_fractional_number,
};
use crate::commands::financials_command::test_utils::transpose_inputs_to_nested_tuples;
use masq_lib::constants::{MASQ_TOTAL_SUPPLY, WEIS_OF_GWEI};
use masq_lib::constants::{MASQ_TOTAL_SUPPLY, WEIS_IN_GWEI};
use regex::Regex;

#[test]
Expand Down Expand Up @@ -482,7 +482,7 @@ mod tests {

#[test]
fn i64_interpretation_capabilities_are_good_enough_for_masq_total_supply_in_gwei() {
let _: i64 = (MASQ_TOTAL_SUPPLY * WEIS_OF_GWEI as u64)
let _: i64 = (MASQ_TOTAL_SUPPLY * WEIS_IN_GWEI as u64)
.try_into()
.unwrap();
}
Expand Down
4 changes: 2 additions & 2 deletions masq_lib/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub const DEFAULT_GAS_PRICE: u64 = 1; //TODO ?? Really

pub const WALLET_ADDRESS_LENGTH: usize = 42;
pub const MASQ_TOTAL_SUPPLY: u64 = 37_500_000;
pub const WEIS_OF_GWEI: i128 = 1_000_000_000;
pub const WEIS_IN_GWEI: i128 = 1_000_000_000;

pub const ETH_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 11_170_708;
pub const ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 8_688_171;
Expand Down Expand Up @@ -102,7 +102,7 @@ mod tests {
assert_eq!(DEFAULT_GAS_PRICE, 1);
assert_eq!(WALLET_ADDRESS_LENGTH, 42);
assert_eq!(MASQ_TOTAL_SUPPLY, 37_500_000);
assert_eq!(WEIS_OF_GWEI, 1_000_000_000);
assert_eq!(WEIS_IN_GWEI, 1_000_000_000);
assert_eq!(ETH_MAINNET_CONTRACT_CREATION_BLOCK, 11_170_708);
assert_eq!(ROPSTEN_TESTNET_CONTRACT_CREATION_BLOCK, 8_688_171);
assert_eq!(MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK, 0);
Expand Down
38 changes: 22 additions & 16 deletions multinode_integration_tests/tests/verify_bill_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use bip39::{Language, Mnemonic, Seed};
use futures::Future;
use masq_lib::blockchains::chains::Chain;
use masq_lib::constants::WEIS_OF_GWEI;
use masq_lib::constants::WEIS_IN_GWEI;
use masq_lib::utils::{derivation_path, NeighborhoodModeLight};
use multinode_integration_tests_lib::blockchain::BlockchainServer;
use multinode_integration_tests_lib::masq_node::{MASQNode, MASQNodeUtils};
Expand Down Expand Up @@ -96,7 +96,7 @@ fn verify_bill_payment() {
derivation_path(0, 3),
);

let amount = 10 * payment_thresholds.permanent_debt_allowed_gwei as u128 * WEIS_OF_GWEI as u128;
let amount = 10 * payment_thresholds.permanent_debt_allowed_gwei as u128 * WEIS_IN_GWEI as u128;

let project_root = MASQNodeUtils::find_project_root();
let (consuming_node_name, consuming_node_index) = cluster.prepare_real_node(&consuming_config);
Expand Down Expand Up @@ -323,20 +323,26 @@ fn assert_balances(
expected_eth_balance: &str,
expected_token_balance: &str,
) {
if let (Ok(eth_balance), Ok(token_balance)) = blockchain_interface.get_balances(&wallet) {
assert_eq!(
format!("{}", eth_balance),
String::from(expected_eth_balance),
"EthBalance"
);
assert_eq!(
token_balance,
web3::types::U256::from_dec_str(expected_token_balance).unwrap(),
"TokenBalance"
);
} else {
assert!(false, "Failed to retrieve balances {}", wallet);
}
let eth_balance = blockchain_interface
.get_gas_balance(&wallet)
.unwrap_or_else(|_| panic!("Failed to retrieve gas balance for {}", wallet));
assert_eq!(
format!("{}", eth_balance),
String::from(expected_eth_balance),
"Actual EthBalance {} doesn't much with expected {}",
eth_balance,
expected_eth_balance
);
let token_balance = blockchain_interface
.get_token_balance(&wallet)
.unwrap_or_else(|_| panic!("Failed to retrieve token balance for {}", wallet));
assert_eq!(
token_balance,
web3::types::U256::from_dec_str(expected_token_balance).unwrap(),
"Actual TokenBalance {} doesn't match with expected {}",
token_balance,
expected_token_balance
);
}

fn deploy_smart_contract(wallet: &Wallet, web3: &Web3<Http>, chain: Chain) -> Address {
Expand Down
12 changes: 6 additions & 6 deletions node/src/accountant/dao_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::database::db_initializer::{
connection_or_panic, DbInitializationConfig, DbInitializerReal,
};
use crate::sub_lib::accountant::PaymentThresholds;
use masq_lib::constants::WEIS_OF_GWEI;
use masq_lib::constants::WEIS_IN_GWEI;
use masq_lib::messages::{
RangeQuery, TopRecordsConfig, TopRecordsOrdering, UiPayableAccount, UiReceivableAccount,
};
Expand Down Expand Up @@ -211,7 +211,7 @@ impl<N: Copy + Display> CustomQuery<N> {
.into_iter()
.zip([min_amount, max_amount].into_iter())
.flat_map(|(param_names, gwei_num)| {
let wei_num = i128::from(gwei_num) * WEIS_OF_GWEI;
let wei_num = i128::from(gwei_num) * WEIS_IN_GWEI;
let big_int_divided = BigIntDivider::deconstruct(wei_num);
Self::balance_constraint_as_integer_pair(param_names, big_int_divided)
})
Expand Down Expand Up @@ -260,7 +260,7 @@ pub fn remap_payable_accounts(accounts: Vec<PayableAccount>) -> Vec<UiPayableAcc
wallet: account.wallet.to_string(),
age_s: to_age(account.last_paid_timestamp),
balance_gwei: {
let gwei = (account.balance_wei / (WEIS_OF_GWEI as u128)) as u64;
let gwei = (account.balance_wei / (WEIS_IN_GWEI as u128)) as u64;
if gwei > 0 {
gwei
} else {
Expand All @@ -285,7 +285,7 @@ pub fn remap_receivable_accounts(accounts: Vec<ReceivableAccount>) -> Vec<UiRece
wallet: account.wallet.to_string(),
age_s: to_age(account.last_received_timestamp),
balance_gwei:{
let gwei = (account.balance_wei / (WEIS_OF_GWEI as i128)) as i64;
let gwei = (account.balance_wei / (WEIS_IN_GWEI as i128)) as i64;
if gwei != 0 {gwei} else {panic!("Broken code: ReceivableAccount with balance \
between {} and 0 gwei passed through db query constraints; wallet: {}, balance: {}",
if account.balance_wei.is_positive() {"1"}else{"-1"},
Expand Down Expand Up @@ -759,7 +759,7 @@ mod tests {
maturity_threshold_sec: 20,
payment_grace_period_sec: 33,
permanent_debt_allowed_gwei: 1,
debt_threshold_gwei: MASQ_TOTAL_SUPPLY * WEIS_OF_GWEI as u64,
debt_threshold_gwei: MASQ_TOTAL_SUPPLY * WEIS_IN_GWEI as u64,
threshold_interval_sec: 1,
unban_below_gwei: 0,
};
Expand All @@ -775,7 +775,7 @@ mod tests {
);
slope * (payment_thresholds.maturity_threshold_sec + 1) as i128 + y_interception
};
assert_eq!(check, WEIS_OF_GWEI)
assert_eq!(check, WEIS_IN_GWEI)
}

#[test]
Expand Down
Loading