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-4 #449

Open
wants to merge 14 commits into
base: GH-606-Review-4
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
15 changes: 14 additions & 1 deletion USER-INTERFACE-INTERFACE.md
Original file line number Diff line number Diff line change
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
13 changes: 8 additions & 5 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 @@ -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 @@ -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
2 changes: 1 addition & 1 deletion masq_lib/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ pub struct UiConfigurationResponse {
#[serde(rename = "portMappingProtocol")]
pub port_mapping_protocol_opt: Option<String>,
#[serde(rename = "startBlock")]
pub start_block: u64,
pub start_block_opt: Option<u64>,
#[serde(rename = "consumingWalletPrivateKeyOpt")]
pub consuming_wallet_private_key_opt: Option<String>,
// This item is calculated from the private key, not stored in the database, so that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::path::PathBuf;
use std::time::{Duration, SystemTime};

use log::Level;
use regex::escape;
use serde_derive::Serialize;

use masq_lib::messages::{FromMessageBody, ScanType, ToMessageBody, UiScanRequest, UiScanResponse};
Expand Down Expand Up @@ -157,19 +156,15 @@ fn blockchain_bridge_starts_properly_on_bootstrap() {
let mut cluster = MASQNodeCluster::start().unwrap();
let private_key = "0011223300112233001122330011223300112233001122330011223300112233";
let subject = cluster.start_real_node(
NodeStartupConfigBuilder::zero_hop()
NodeStartupConfigBuilder::standard()
.consuming_wallet_info(ConsumingWalletInfo::PrivateKey(private_key.to_string()))
.chain(cluster.chain)
.build(),
);

let escaped_pattern = escape(&format!(
"DEBUG: BlockchainBridge: Received BindMessage; consuming wallet address {}",
subject.consuming_wallet().unwrap()
));
MASQNodeUtils::wrote_log_containing(
subject.name(),
&escaped_pattern,
"DEBUG: BlockchainBridge: Received BindMessage",
Duration::from_millis(1000),
)
}
Expand Down
Loading
Loading