Skip to content
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
19 changes: 10 additions & 9 deletions USER-INTERFACE-INTERFACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ Another reason the secrets might be missing is that there are not yet any secret
"exitServiceRate: <number>"
},
"scanIntervals": {
"pendingPayableSec": <number>,
"payableSec": <number>,
"pendingPayableSec": <number>,
"receivableSec": <number>
},
}
Expand Down Expand Up @@ -453,20 +453,21 @@ database password. If you want to know whether the password you have is the corr

* `scanIntervals`: These three intervals describe the length of three different scan cycles running automatically in the
background since the Node has connected to a qualified neighborhood that consists of neighbors enabling a complete
3-hop route. Each parameter can be set independently, but by default are all the same which currently is most desirable
for the consistency of service payments to and from your Node. Technically, there doesn't have to be any lower limit
for the minimum of time you can set; two scans of the same sort would never run at the same time but the next one is
3-hop route. Each parameter can be set independently. Technically, there doesn't have to be any lower limit for
* the minimum of time you can set; two scans of the same sort would never run at the same time but the next one is
always scheduled not earlier than the end of the previous one. These are ever present values, no matter if the user's
set any value, because defaults are prepared.

* `pendingPayableSec`: Amount of seconds between two sequential cycles of scanning for payments that are marked as currently
pending; the payments were sent to pay our debts, the payable. The purpose of this process is to confirm the status of
the pending payment; either the payment transaction was written on blockchain as successful or failed.

* `payableSec`: Amount of seconds between two sequential cycles of scanning aimed to find payable accounts of that meet
* `payableSec`: Amount of seconds between two sequential cycles of scanning aimed to find payable accounts that meet
the criteria set by the Payment Thresholds; these accounts are tracked on behalf of our creditors. If they meet the
Payment Threshold criteria, our Node will send a debt payment transaction to the creditor in question.

* `pendingPayableSec`: The time elapsed since the last payable transaction was processed. This scan operates
on an irregular schedule and is triggered after new transactions are sent or when failed transactions need
to be replaced. The scanner monitors pending transactions and verifies their blockchain status, determining whether
each payment was successfully recorded or failed. Any failed transaction is automatically resubmitted as soon
as the failure is detected.

* `receivableSec`: Amount of seconds between two sequential cycles of scanning for payments on the blockchain that have
been sent by our creditors to us, which are credited against receivables recorded for services provided.

Expand Down
29 changes: 24 additions & 5 deletions masq_lib/src/blockchains/blockchain_records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use crate::blockchains::chains::Chain;
use crate::constants::{
BASE_GAS_PRICE_CEILING_WEI, BASE_MAINNET_CHAIN_ID, BASE_MAINNET_CONTRACT_CREATION_BLOCK,
BASE_MAINNET_FULL_IDENTIFIER, BASE_SEPOLIA_CHAIN_ID, BASE_SEPOLIA_CONTRACT_CREATION_BLOCK,
BASE_SEPOLIA_FULL_IDENTIFIER, DEV_CHAIN_FULL_IDENTIFIER, DEV_CHAIN_ID,
BASE_SEPOLIA_FULL_IDENTIFIER, DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC,
DEFAULT_PENDING_PAYABLE_INTERVAL_DEV_SEC, DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC,
DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC, DEV_CHAIN_FULL_IDENTIFIER, DEV_CHAIN_ID,
DEV_GAS_PRICE_CEILING_WEI, ETH_GAS_PRICE_CEILING_WEI, ETH_MAINNET_CHAIN_ID,
ETH_MAINNET_CONTRACT_CREATION_BLOCK, ETH_MAINNET_FULL_IDENTIFIER, ETH_ROPSTEN_CHAIN_ID,
ETH_ROPSTEN_CONTRACT_CREATION_BLOCK, ETH_ROPSTEN_FULL_IDENTIFIER,
Expand All @@ -15,14 +17,13 @@ use crate::constants::{
};
use ethereum_types::{Address, H160};

// TODO these should probably be a static (it's a shame that we construct the data every time anew
// when we ask for the chain specs), and dynamic initialization should be allowed as well
pub const CHAINS: [BlockchainRecord; 7] = [
pub static CHAINS: [BlockchainRecord; 7] = [
BlockchainRecord {
self_id: Chain::PolyMainnet,
num_chain_id: POLYGON_MAINNET_CHAIN_ID,
literal_identifier: POLYGON_MAINNET_FULL_IDENTIFIER,
gas_price_safe_ceiling_minor: POLYGON_GAS_PRICE_CEILING_WEI,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC,
contract: POLYGON_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: POLYGON_MAINNET_CONTRACT_CREATION_BLOCK,
},
Expand All @@ -31,6 +32,7 @@ pub const CHAINS: [BlockchainRecord; 7] = [
num_chain_id: ETH_MAINNET_CHAIN_ID,
literal_identifier: ETH_MAINNET_FULL_IDENTIFIER,
gas_price_safe_ceiling_minor: ETH_GAS_PRICE_CEILING_WEI,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC,
contract: ETH_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: ETH_MAINNET_CONTRACT_CREATION_BLOCK,
},
Expand All @@ -39,6 +41,7 @@ pub const CHAINS: [BlockchainRecord; 7] = [
num_chain_id: BASE_MAINNET_CHAIN_ID,
literal_identifier: BASE_MAINNET_FULL_IDENTIFIER,
gas_price_safe_ceiling_minor: BASE_GAS_PRICE_CEILING_WEI,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC,
contract: BASE_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_MAINNET_CONTRACT_CREATION_BLOCK,
},
Expand All @@ -47,6 +50,7 @@ pub const CHAINS: [BlockchainRecord; 7] = [
num_chain_id: BASE_SEPOLIA_CHAIN_ID,
literal_identifier: BASE_SEPOLIA_FULL_IDENTIFIER,
gas_price_safe_ceiling_minor: BASE_GAS_PRICE_CEILING_WEI,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC,
contract: BASE_SEPOLIA_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_SEPOLIA_CONTRACT_CREATION_BLOCK,
},
Expand All @@ -55,6 +59,7 @@ pub const CHAINS: [BlockchainRecord; 7] = [
num_chain_id: POLYGON_AMOY_CHAIN_ID,
literal_identifier: POLYGON_AMOY_FULL_IDENTIFIER,
gas_price_safe_ceiling_minor: POLYGON_GAS_PRICE_CEILING_WEI,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC,
contract: POLYGON_AMOY_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: POLYGON_AMOY_CONTRACT_CREATION_BLOCK,
},
Expand All @@ -63,6 +68,7 @@ pub const CHAINS: [BlockchainRecord; 7] = [
num_chain_id: ETH_ROPSTEN_CHAIN_ID,
literal_identifier: ETH_ROPSTEN_FULL_IDENTIFIER,
gas_price_safe_ceiling_minor: ETH_GAS_PRICE_CEILING_WEI,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC,
contract: ETH_ROPSTEN_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: ETH_ROPSTEN_CONTRACT_CREATION_BLOCK,
},
Expand All @@ -71,6 +77,7 @@ pub const CHAINS: [BlockchainRecord; 7] = [
num_chain_id: DEV_CHAIN_ID,
literal_identifier: DEV_CHAIN_FULL_IDENTIFIER,
gas_price_safe_ceiling_minor: DEV_GAS_PRICE_CEILING_WEI,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_DEV_SEC,
contract: MULTINODE_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK,
},
Expand All @@ -82,6 +89,7 @@ pub struct BlockchainRecord {
pub num_chain_id: u64,
pub literal_identifier: &'static str,
pub gas_price_safe_ceiling_minor: u128,
pub default_pending_payable_interval_sec: u64,
pub contract: Address,
pub contract_creation_block: u64,
}
Expand Down Expand Up @@ -128,7 +136,11 @@ const POLYGON_MAINNET_CONTRACT_ADDRESS: Address = H160([
mod tests {
use super::*;
use crate::blockchains::chains::chain_from_chain_identifier_opt;
use crate::constants::{BASE_MAINNET_CONTRACT_CREATION_BLOCK, WEIS_IN_GWEI};
use crate::constants::{
BASE_MAINNET_CONTRACT_CREATION_BLOCK, DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC,
DEFAULT_PENDING_PAYABLE_INTERVAL_DEV_SEC, DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC,
DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC, WEIS_IN_GWEI,
};
use std::collections::HashSet;
use std::iter::FromIterator;

Expand Down Expand Up @@ -209,6 +221,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "eth-mainnet",
gas_price_safe_ceiling_minor: 100 * WEIS_IN_GWEI as u128,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC,
contract: ETH_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: ETH_MAINNET_CONTRACT_CREATION_BLOCK,
}
Expand All @@ -226,6 +239,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "eth-ropsten",
gas_price_safe_ceiling_minor: 100 * WEIS_IN_GWEI as u128,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC,
contract: ETH_ROPSTEN_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: ETH_ROPSTEN_CONTRACT_CREATION_BLOCK,
}
Expand All @@ -243,6 +257,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "polygon-mainnet",
gas_price_safe_ceiling_minor: 200 * WEIS_IN_GWEI as u128,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC,
contract: POLYGON_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: POLYGON_MAINNET_CONTRACT_CREATION_BLOCK,
}
Expand All @@ -260,6 +275,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "polygon-amoy",
gas_price_safe_ceiling_minor: 200 * WEIS_IN_GWEI as u128,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC,
contract: POLYGON_AMOY_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: POLYGON_AMOY_CONTRACT_CREATION_BLOCK,
}
Expand All @@ -277,6 +293,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "base-mainnet",
gas_price_safe_ceiling_minor: 50 * WEIS_IN_GWEI as u128,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC,
contract: BASE_MAINNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_MAINNET_CONTRACT_CREATION_BLOCK,
}
Expand All @@ -294,6 +311,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "base-sepolia",
gas_price_safe_ceiling_minor: 50 * WEIS_IN_GWEI as u128,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC,
contract: BASE_SEPOLIA_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: BASE_SEPOLIA_CONTRACT_CREATION_BLOCK,
}
Expand All @@ -311,6 +329,7 @@ mod tests {
self_id: examined_chain,
literal_identifier: "dev",
gas_price_safe_ceiling_minor: 200 * WEIS_IN_GWEI as u128,
default_pending_payable_interval_sec: DEFAULT_PENDING_PAYABLE_INTERVAL_DEV_SEC,
contract: MULTINODE_TESTNET_CONTRACT_ADDRESS,
contract_creation_block: MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK,
}
Expand Down
1 change: 1 addition & 0 deletions masq_lib/src/blockchains/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ mod tests {
self_id: Chain::PolyMainnet,
literal_identifier: "",
gas_price_safe_ceiling_minor: 0,
default_pending_payable_interval_sec: 0,
contract: Default::default(),
contract_creation_block: 0,
}
Expand Down
42 changes: 26 additions & 16 deletions masq_lib/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,16 @@ pub const MASQ_URL_PREFIX: &str = "masq://";
pub const CURRENT_LOGFILE_NAME: &str = "MASQNode_rCURRENT.log";
pub const MASQ_PROMPT: &str = "masq> ";

pub const DEFAULT_GAS_PRICE: u64 = 1; //TODO ?? Really
pub const DEFAULT_GAS_PRICE_MARGIN: u64 = 30;

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

pub const DEFAULT_MAX_BLOCK_COUNT: u64 = 100_000;
pub const COMBINED_PARAMETERS_DELIMITER: char = '|';

pub const PAYLOAD_ZERO_SIZE: usize = 0usize;

pub const ETH_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 11_170_708;
pub const ETH_ROPSTEN_CONTRACT_CREATION_BLOCK: u64 = 8_688_171;
pub const POLYGON_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 14_863_650;
pub const POLYGON_AMOY_CONTRACT_CREATION_BLOCK: u64 = 5_323_366;
pub const BASE_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 19_711_235;
pub const BASE_SEPOLIA_CONTRACT_CREATION_BLOCK: u64 = 14_732_730;
pub const MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 0;
//descriptor
pub const CENTRAL_DELIMITER: char = '@';
pub const CHAIN_IDENTIFIER_DELIMITER: char = ':';

//Migration versions
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -88,11 +80,11 @@ pub const VALUE_EXCEEDS_ALLOWED_LIMIT: u64 = ACCOUNTANT_PREFIX | 3;

////////////////////////////////////////////////////////////////////////////////////////////////////

pub const COMBINED_PARAMETERS_DELIMITER: char = '|';
pub const MASQ_TOTAL_SUPPLY: u64 = 37_500_000;

//descriptor
pub const CENTRAL_DELIMITER: char = '@';
pub const CHAIN_IDENTIFIER_DELIMITER: char = ':';
pub const DEFAULT_GAS_PRICE: u64 = 1; //TODO ?? Really
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go away and wherever the constant is being used too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a card addressing a removal of the gas-price parameter from the user interface and replacement by gas-price-margin instead.

pub const DEFAULT_GAS_PRICE_MARGIN: u64 = 30;
pub const DEFAULT_MAX_BLOCK_COUNT: u64 = 100_000;

//chains
pub const POLYGON_MAINNET_CHAIN_ID: u64 = 137;
Expand All @@ -114,11 +106,25 @@ pub const ETH_ROPSTEN_FULL_IDENTIFIER: &str = concatcp!(ETH_FAMILY, LINK, "ropst
pub const BASE_MAINNET_FULL_IDENTIFIER: &str = concatcp!(BASE_FAMILY, LINK, MAINNET);
pub const BASE_SEPOLIA_FULL_IDENTIFIER: &str = concatcp!(BASE_FAMILY, LINK, "sepolia");
pub const DEV_CHAIN_FULL_IDENTIFIER: &str = "dev";

pub const ETH_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 11_170_708;
pub const ETH_ROPSTEN_CONTRACT_CREATION_BLOCK: u64 = 8_688_171;
pub const POLYGON_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 14_863_650;
pub const POLYGON_AMOY_CONTRACT_CREATION_BLOCK: u64 = 5_323_366;
pub const BASE_MAINNET_CONTRACT_CREATION_BLOCK: u64 = 19_711_235;
pub const BASE_SEPOLIA_CONTRACT_CREATION_BLOCK: u64 = 14_732_730;
pub const MULTINODE_TESTNET_CONTRACT_CREATION_BLOCK: u64 = 0;

pub const POLYGON_GAS_PRICE_CEILING_WEI: u128 = 200_000_000_000;
pub const ETH_GAS_PRICE_CEILING_WEI: u128 = 100_000_000_000;
pub const BASE_GAS_PRICE_CEILING_WEI: u128 = 50_000_000_000;
pub const DEV_GAS_PRICE_CEILING_WEI: u128 = 200_000_000_000;

pub const DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC: u64 = 600;
pub const DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC: u64 = 120;
pub const DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC: u64 = 180;
pub const DEFAULT_PENDING_PAYABLE_INTERVAL_DEV_SEC: u64 = 120;

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -204,6 +210,10 @@ mod tests {
assert_eq!(ETH_GAS_PRICE_CEILING_WEI, 100_000_000_000);
assert_eq!(BASE_GAS_PRICE_CEILING_WEI, 50_000_000_000);
assert_eq!(DEV_GAS_PRICE_CEILING_WEI, 200_000_000_000);
assert_eq!(DEFAULT_PENDING_PAYABLE_INTERVAL_ETH_SEC, 600);
assert_eq!(DEFAULT_PENDING_PAYABLE_INTERVAL_BASE_SEC, 120);
assert_eq!(DEFAULT_PENDING_PAYABLE_INTERVAL_POLYGON_SEC, 180);
assert_eq!(DEFAULT_PENDING_PAYABLE_INTERVAL_DEV_SEC, 120);
assert_eq!(
CLIENT_REQUEST_PAYLOAD_CURRENT_VERSION,
DataVersion { major: 0, minor: 1 }
Expand Down
Loading