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-606: Review 2 #429

Open
wants to merge 16 commits into
base: GH-606-Review-2
Choose a base branch
from
Open
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
106 changes: 106 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Basic `dependabot.yml` file with
# minimum configuration for two package managers

version: 2
updates:
# Enable version updates for node
- package-ecosystem: "cargo"
directory: "/node"
# Check the cargo registry for updates every day (weekdays)
schedule:
interval: "daily"
time: '14:00'
timezone: 'Etc/UTC'
allow:
- dependency-name: "*"
dependency-type: "direct"
ignore:
- dependency-name: "automap"
- dependency-name: "masq_lib"
- dependency-name: "actix"
- dependency-name: "tokio"
- dependency-name: "clap"
- dependency-name: "sodiumoxide"
- dependency-name: "web3"
- dependency-name: "websocket"
groups:
patch:
update-types:
- "patch"
minor:
update-types:
- "minor"
target-branch: 'master'
open-pull-requests-limit: 2

# Enable version updates for masq
- package-ecosystem: "cargo"
directory: "/masq"
# Check the cargo registry for updates every day (weekdays)
schedule:
interval: "daily"
time: '14:00'
timezone: 'Etc/UTC'
allow:
- dependency-name: "*"
dependency-type: "direct"
ignore:
- dependency-name: "masq_lib"
- dependency-name: "clap"
- dependency-name: "websocket"
groups:
patch:
update-types:
- "patch"
minor:
update-types:
- "minor"
target-branch: 'master'
open-pull-requests-limit: 2

# Enable version updates for masq_lib
- package-ecosystem: "cargo"
directory: "/masq_lib"
# Check the cargo registry for updates every day (weekdays)
schedule:
interval: "daily"
time: '14:00'
timezone: 'Etc/UTC'
allow:
- dependency-name: "*"
dependency-type: "direct"
ignore:
- dependency-name: "clap"
- dependency-name: "websocket"
groups:
patch:
update-types:
- "patch"
minor:
update-types:
- "minor"
target-branch: 'master'
open-pull-requests-limit: 2

# Enable version updates for automap
- package-ecosystem: "cargo"
directory: "/automap"
# Check the cargo registry for updates every day (weekdays)
schedule:
interval: "daily"
time: '14:00'
timezone: 'Etc/UTC'
allow:
- dependency-name: "*"
dependency-type: "direct"
ignore:
- dependency-name: "masq_lib"
groups:
patch:
update-types:
- "patch"
minor:
update-types:
- "minor"
target-branch: 'master'
open-pull-requests-limit: 2
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# MASQ Node ![masq-logo](images/masq-logo-sm.png)

<div align="center">

![ci-matrix](https://github.com/MASQ-Project/Node/workflows/ci-matrix/badge.svg)
[![GitHub Release](https://img.shields.io/github/v/release/MASQ-Project/Node?display_name=release&color=green)](https://github.com/MASQ-Project/Node/releases/latest)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/masq)

</div>

MASQ Node combines the benefits of VPN and Tor technology, to create superior next-generation privacy software, where
users are rewarded for supporting an uncensored, global Web. Users gain privacy and anonymity, while helping promote
Expand Down Expand Up @@ -43,7 +49,7 @@ A [Knowledge Base](https://docs.masq.ai/masq) and testing resources are being re
levels of technical ability.

There you can find further information, guides and configuration examples for running MASQ Node from:
- MASQ app - v0.2 (formerly called "GEMINI")
- [MASQ Browser](https://masqbrowser.com)
- CLI
- Docker image

Expand All @@ -66,7 +72,7 @@ To help navigate the codebase, here are the README.md links for all documented c

### Downloading Official Releases

We haven't set up any official releases yet; but when we do, instructions will appear here.
Releases will appear on our GitHub page - click on the badge above for the latest stable beta build, or go to our [Releases page](https://github.com/MASQ-Project/Node/releases/latest)

### Downloading the Latest Build

Expand Down
17 changes: 15 additions & 2 deletions USER-INTERFACE-INTERFACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ There are following three connection stages:

1. NotConnected: No external neighbor is connected to us.
2. ConnectedToNeighbor: External node(s) are connected to us.
3. ThreeHopsRouteFound: You can relay data over the network.
3. RouteFound: You can relay data over the network.

The Node can only be on one of these connection stages during any moment of the Node's lifetime.

Expand Down Expand Up @@ -1095,6 +1095,18 @@ even for parameters whose values are natively of other types.
##### Description:
If the value of the respective parameter was successfully changed, this is a simple acknowledgment that the change is complete.

The following commands can be configured using the `setConfiguration`:


| Name | Parameter | Possible Values |
|------------------|-----------------|------------------|
| Gas Price | `--gas-price` | > 0 |
| Start Block | `--start-block` | > 0 |
| Min Hops | `--min-hops` | [1, 6] |


Note: The descriptions for the above commands can be found [here](#permitted-names).

#### `setup`
##### Direction: Request
##### Correspondent: Daemon
Expand Down Expand Up @@ -1131,10 +1143,11 @@ be cleared.
* `db-password` - Password to unlock the sensitive values in the database.
* `dns-servers` - Comma-separated list of DNS servers to use.
* `earning-wallet` - Wallet into which earnings should be deposited.
* `gas-price` - Transaction fee to offer on the blockchain.
* `gas-price` - The fee per unit of computational effort in blockchain transactions, measured in gwei.
* `ip` - The public IP address of the Node.
* `log-level` - The lowest level of logs that should be recorded. `off`, `error`, `warn`, `info`, `debug`, `trace`
* `mapping-protocol` - The management protocol to try first with the router. `pcp`, `pmp`, `igdp`
* `min-hops`: The minimum number of hops required for the package to reach the Exit Node.
* `neighborhood-mode` - `zero-hop`, `originate-only`, `consume-only`, `standard`
* `neighbors` - Comma-separated list of Node descriptors for neighbors to contact on startup
* `real-user` - Non-Windows platforms only, only where required: <uid>:<gid>:<home directory>
Expand Down
17 changes: 10 additions & 7 deletions masq/src/commands/configuration_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ impl ConfigurationCommand {
dump_parameter_line(
stream,
"Start block:",
&configuration.start_block.to_string(),
&configuration
.start_block_opt
.map(|m| m.separate_with_commas())
.unwrap_or_else(|| "[Latest]".to_string()),
);
Self::dump_value_list(stream, "Past neighbors:", &configuration.past_neighbors);
let payment_thresholds = Self::preprocess_combined_parameters({
Expand Down Expand Up @@ -333,7 +336,7 @@ mod tests {
exit_byte_rate: 129000000,
exit_service_rate: 160000000,
},
start_block: 3456,
start_block_opt: None,
scan_intervals: UiScanIntervals {
pending_payable_sec: 150500,
payable_sec: 155000,
Expand Down Expand Up @@ -378,7 +381,7 @@ mod tests {
|Max block count: [Unlimited]\n\
|Neighborhood mode: standard\n\
|Port mapping protocol: PCP\n\
|Start block: 3456\n\
|Start block: [Latest]\n\
|Past neighbors: neighbor 1\n\
| neighbor 2\n\
|Payment thresholds: \n\
Expand Down Expand Up @@ -410,7 +413,7 @@ mod tests {
blockchain_service_url_opt: Some("https://infura.io/ID".to_string()),
current_schema_version: "schema version".to_string(),
clandestine_port: 1234,
chain_name: "mumbai".to_string(),
chain_name: "amoy".to_string(),
gas_price: 2345,
max_block_count_opt: Some(100_000),
neighborhood_mode: "zero-hop".to_string(),
Expand All @@ -433,7 +436,7 @@ mod tests {
exit_byte_rate: 20,
exit_service_rate: 30,
},
start_block: 3456,
start_block_opt: Some(1234567890u64),
scan_intervals: UiScanIntervals {
pending_payable_sec: 1000,
payable_sec: 1000,
Expand Down Expand Up @@ -467,7 +470,7 @@ mod tests {
"\
|NAME VALUE\n\
|Blockchain service URL: https://infura.io/ID\n\
|Chain: mumbai\n\
|Chain: amoy\n\
|Clandestine port: 1234\n\
|Consuming wallet private key: [?]\n\
|Current schema version: schema version\n\
Expand All @@ -476,7 +479,7 @@ mod tests {
|Max block count: 100,000\n\
|Neighborhood mode: zero-hop\n\
|Port mapping protocol: PCP\n\
|Start block: 3456\n\
|Start block: 1,234,567,890\n\
|Past neighbors: [?]\n\
|Payment thresholds: \n\
| Debt threshold: 2,500 gwei\n\
Expand Down
41 changes: 34 additions & 7 deletions masq/src/commands/set_configuration_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use masq_lib::shared_schema::gas_price_arg;
use masq_lib::shared_schema::min_hops_arg;
use masq_lib::short_writeln;
use masq_lib::utils::ExpectValue;
use std::num::IntErrorKind;

#[derive(Debug, PartialEq, Eq)]
pub struct SetConfigurationCommand {
Expand Down Expand Up @@ -35,9 +36,17 @@ impl SetConfigurationCommand {
}

fn validate_start_block(start_block: String) -> Result<(), String> {
match start_block.parse::<u64>() {
Ok(_) => Ok(()),
_ => Err(start_block),
if "latest".eq_ignore_ascii_case(&start_block) || "none".eq_ignore_ascii_case(&start_block) {
Ok(())
} else {
match start_block.parse::<u64>() {
Ok(_) => Ok(()),
Err(e) if e.kind() == &IntErrorKind::PosOverflow => Err(
format!("Unable to parse '{}' into a starting block number or provide 'none' or 'latest' for the latest block number: digits exceed {}.",
start_block, u64::MAX),
),
Err(e) => Err(format!("Unable to parse '{}' into a starting block number or provide 'none' or 'latest' for the latest block number: {}.", start_block, e))
}
}
}

Expand All @@ -59,7 +68,7 @@ impl Command for SetConfigurationCommand {
const SET_CONFIGURATION_ABOUT: &str =
"Sets Node configuration parameters being enabled for this operation when the Node is running.";
const START_BLOCK_HELP: &str =
"Ordinal number of the Ethereum block where scanning for transactions will start.";
"Ordinal number of the Ethereum block where scanning for transactions will start. Use 'latest' or 'none' for Latest block.";

pub fn set_configurationify<'a>(shared_schema_arg: Arg<'a, 'a>) -> Arg<'a, 'a> {
shared_schema_arg.takes_value(true).min_values(1)
Expand Down Expand Up @@ -103,7 +112,7 @@ mod tests {
);
assert_eq!(
START_BLOCK_HELP,
"Ordinal number of the Ethereum block where scanning for transactions will start."
"Ordinal number of the Ethereum block where scanning for transactions will start. Use 'latest' or 'none' for Latest block."
);
}

Expand All @@ -122,10 +131,28 @@ mod tests {
assert!(result.contains("cannot be used with one or more of the other specified arguments"));
}

#[test]
fn validate_start_block_catches_invalid_values() {
assert_eq!(validate_start_block("abc".to_string()), Err("Unable to parse 'abc' into a starting block number or provide 'none' or 'latest' for the latest block number: invalid digit found in string.".to_string()));
assert_eq!(validate_start_block("918446744073709551615".to_string()), Err("Unable to parse '918446744073709551615' into a starting block number or provide 'none' or 'latest' for the latest block number: digits exceed 18446744073709551615.".to_string()));
assert_eq!(validate_start_block("123,456,789".to_string()), Err("Unable to parse '123,456,789' into a starting block number or provide 'none' or 'latest' for the latest block number: invalid digit found in string.".to_string()));
assert_eq!(validate_start_block("123'456'789".to_string()), Err("Unable to parse '123'456'789' into a starting block number or provide 'none' or 'latest' for the latest block number: invalid digit found in string.".to_string()));
}
#[test]
fn validate_start_block_works() {
assert!(validate_start_block("abc".to_string()).is_err());
assert!(validate_start_block("1566".to_string()).is_ok());
assert_eq!(
validate_start_block("18446744073709551615".to_string()),
Ok(())
);
assert_eq!(validate_start_block("1566".to_string()), Ok(()));
assert_eq!(validate_start_block("none".to_string()), Ok(()));
assert_eq!(validate_start_block("None".to_string()), Ok(()));
assert_eq!(validate_start_block("NONE".to_string()), Ok(()));
assert_eq!(validate_start_block("nOnE".to_string()), Ok(()));
assert_eq!(validate_start_block("latest".to_string()), Ok(()));
assert_eq!(validate_start_block("LATEST".to_string()), Ok(()));
assert_eq!(validate_start_block("LaTeST".to_string()), Ok(()));
assert_eq!(validate_start_block("lATEst".to_string()), Ok(()));
}

#[test]
Expand Down
14 changes: 7 additions & 7 deletions masq/src/commands/setup_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ ip No sir, I don't like it.\n\
status_data_dir: UiSetupResponseValueStatus::Default,
},
SetupCommandData {
chain_str: Some("polygon-mumbai".to_owned()),
chain_str: Some("polygon-amoy".to_owned()),
data_directory: None,
chain_name_expected: Some("polygon-mumbai"),
data_directory_expected: Some("/home/cooga/.local/MASQ/polygon-mumbai"),
chain_name_expected: Some("polygon-amoy"),
data_directory_expected: Some("/home/cooga/.local/MASQ/polygon-amoy"),
note_expected: true,
status_chain: UiSetupResponseValueStatus::Set,
status_data_dir: UiSetupResponseValueStatus::Default,
Expand All @@ -409,10 +409,10 @@ ip No sir, I don't like it.\n\
status_data_dir: UiSetupResponseValueStatus::Set,
},
SetupCommandData {
chain_str: Some("polygon-mumbai".to_owned()),
data_directory: Some("booga/polygon-mumbai".to_owned()),
chain_name_expected: Some("polygon-mumbai"),
data_directory_expected: Some("booga/polygon-mumbai/polygon-mumbai"),
chain_str: Some("polygon-amoy".to_owned()),
data_directory: Some("booga/polygon-amoy".to_owned()),
chain_name_expected: Some("polygon-amoy"),
data_directory_expected: Some("booga/polygon-amoy/polygon-amoy"),
note_expected: true,
status_chain: UiSetupResponseValueStatus::Set,
status_data_dir: UiSetupResponseValueStatus::Set,
Expand Down
Loading
Loading