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

[Merged by Bors] - Enable Compatibility with Windows #2333

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8fb73f1
Made changes for Windows Compatibility
ethDreamer May 5, 2021
0a796db
Cleaned up command line args for windows
ethDreamer May 5, 2021
7b8748f
Merge branch 'unstable' into windows
ethDreamer May 5, 2021
c401368
Cleaned up formatting
ethDreamer May 5, 2021
6c4fda1
removed forgotten println
ethDreamer May 5, 2021
8f73443
fixed unused import issue
ethDreamer May 5, 2021
1cd6a6f
Fixed clippy complaints
ethDreamer May 5, 2021
138f34a
Fixed formatting again
ethDreamer May 5, 2021
82eed9e
fixed clippy complaints again
ethDreamer May 5, 2021
33b900f
fixed clippy complaints again again
ethDreamer May 5, 2021
669ae04
fixed platform-specific dependencies
ethDreamer May 5, 2021
5df34e3
Fixed Cargo.lock for clippy
ethDreamer May 6, 2021
c8ba601
Use cfg! macro for windows booleans
ethDreamer May 6, 2021
d725a09
use cfg! macro again
ethDreamer May 6, 2021
e39277f
fixed typo
ethDreamer May 6, 2021
749ea97
Tests *should* complete in windows now
ethDreamer May 7, 2021
ab775ee
Ran cargo fmt
ethDreamer May 7, 2021
4a1e251
cargo test --all --release now succeeds on windows
ethDreamer May 10, 2021
d7ffcda
forgot to run cargo fmt >.<
ethDreamer May 10, 2021
c6f9e79
clippy again..
ethDreamer May 10, 2021
7d7ffa1
Merge upstream/unstable into windows
ethDreamer May 12, 2021
b8b04b6
Made changes requested by msproul
ethDreamer May 12, 2021
c20a63d
Fix some compilation errors/quirks
michaelsproul May 13, 2021
f3d48b9
Fix typo, check for tempdir cleanup
michaelsproul May 13, 2021
4f3ef51
First go at Windows CI
michaelsproul May 13, 2021
2f41852
Cargo fmt
michaelsproul May 13, 2021
0ec467e
Smaller DB for slasher tests
michaelsproul May 13, 2021
c30b155
No sudo on Windows oops
michaelsproul May 13, 2021
18603c9
forgot one of the tests needs testing config
ethDreamer May 13, 2021
d23e695
Updated lighthouse book & fixed slasher cli tests
ethDreamer May 18, 2021
5124fa6
Windows shell is so weird.. works in both now
ethDreamer May 19, 2021
96d5c07
Update book/src/slasher.md
ethDreamer May 19, 2021
339c25b
made requested changes to lighthouse book
ethDreamer May 19, 2021
80360b8
Forgot to use const for OWNER_SID_STR
ethDreamer May 19, 2021
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
14 changes: 14 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ jobs:
run: sudo npm install -g ganache-cli
- name: Run tests in release
run: make test-release
release-tests-windows:
name: release-tests-windows
runs-on: windows-latest
needs: cargo-fmt
steps:
- uses: actions/checkout@v1
- name: Get latest version of stable Rust
run: rustup update stable
- name: Install ganache-cli
run: npm install -g ganache-cli
- name: Install make
run: choco install -y make
- name: Run tests in release
run: make test-release
debug-tests-ubuntu:
name: debug-tests-ubuntu
runs-on: ubuntu-latest
Expand Down
98 changes: 92 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions account_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ slashing_protection = { path = "../validator_client/slashing_protection" }
eth2 = {path = "../common/eth2"}
safe_arith = {path = "../consensus/safe_arith"}
slot_clock = { path = "../common/slot_clock" }
filesystem = { path = "../common/filesystem" }
sensitive_url = { path = "../common/sensitive_url" }

[dev-dependencies]
Expand Down
5 changes: 4 additions & 1 deletion account_manager/src/validator/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
Expand All @@ -118,7 +120,8 @@ pub fn cli_run<T: EthSpec>(
let spec = env.core_context().eth2_config.spec;

let name: Option<String> = clap_utils::parse_optional(matches, WALLET_NAME_FLAG)?;
let stdin_inputs = matches.is_present(STDIN_INPUTS_FLAG);
let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG);

let wallet_base_dir = if matches.value_of("datadir").is_some() {
let path: PathBuf = clap_utils::parse_required(matches, "datadir")?;
path.join(DEFAULT_WALLET_DIR)
Expand Down
5 changes: 4 additions & 1 deletion account_manager/src/validator/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
Expand All @@ -70,7 +72,8 @@ pub fn cli_run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<
let keystore_path: PathBuf = clap_utils::parse_required(matches, KEYSTORE_FLAG)?;
let password_file_path: Option<PathBuf> =
clap_utils::parse_optional(matches, PASSWORD_FILE_FLAG)?;
let stdin_inputs = matches.is_present(STDIN_INPUTS_FLAG);

let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG);
let no_wait = matches.is_present(NO_WAIT);

let spec = env.eth2_config().spec.clone();
Expand Down
4 changes: 3 additions & 1 deletion account_manager/src/validator/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
Expand All @@ -83,7 +85,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), String> {
let keystore: Option<PathBuf> = clap_utils::parse_optional(matches, KEYSTORE_FLAG)?;
let keystores_dir: Option<PathBuf> = clap_utils::parse_optional(matches, DIR_FLAG)?;
let stdin_inputs = matches.is_present(STDIN_INPUTS_FLAG);
let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG);
let reuse_password = matches.is_present(REUSE_PASSWORD_FLAG);
let keystore_password_path: Option<PathBuf> =
clap_utils::parse_optional(matches, PASSWORD_FLAG)?;
Expand Down
4 changes: 3 additions & 1 deletion account_manager/src/validator/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
Expand All @@ -86,7 +88,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
let first_index: u32 = clap_utils::parse_required(matches, FIRST_INDEX_FLAG)?;
let count: u32 = clap_utils::parse_required(matches, COUNT_FLAG)?;
let mnemonic_path: Option<PathBuf> = clap_utils::parse_optional(matches, MNEMONIC_FLAG)?;
let stdin_inputs = matches.is_present(STDIN_INPUTS_FLAG);
let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG);

eprintln!("secrets-dir path: {:?}", secrets_dir);

Expand Down
32 changes: 4 additions & 28 deletions account_manager/src/wallet/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ use eth2_wallet::{
PlainText,
};
use eth2_wallet_manager::{LockedWallet, WalletManager, WalletType};
use filesystem::create_with_600_perms;
use std::ffi::OsStr;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};

pub const CMD: &str = "create";
Expand Down Expand Up @@ -83,6 +81,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
Expand Down Expand Up @@ -153,8 +153,7 @@ pub fn create_wallet_from_mnemonic(
let name: Option<String> = clap_utils::parse_optional(matches, NAME_FLAG)?;
let wallet_password_path: Option<PathBuf> = clap_utils::parse_optional(matches, PASSWORD_FLAG)?;
let type_field: String = clap_utils::parse_required(matches, TYPE_FLAG)?;
let stdin_inputs = matches.is_present(STDIN_INPUTS_FLAG);

let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG);
let wallet_type = match type_field.as_ref() {
HD_TYPE => WalletType::Hd,
unknown => return Err(format!("--{} {} is not supported", TYPE_FLAG, unknown)),
Expand Down Expand Up @@ -237,26 +236,3 @@ pub fn read_new_wallet_password_from_cli(
},
}
}

/// Creates a file with `600 (-rw-------)` permissions.
pub fn create_with_600_perms<P: AsRef<Path>>(path: P, bytes: &[u8]) -> Result<(), String> {
let path = path.as_ref();

let mut file =
File::create(&path).map_err(|e| format!("Unable to create {:?}: {}", path, e))?;

let mut perm = file
.metadata()
.map_err(|e| format!("Unable to get {:?} metadata: {}", path, e))?
.permissions();

perm.set_mode(0o600);

file.set_permissions(perm)
.map_err(|e| format!("Unable to set {:?} permissions: {}", path, e))?;

file.write_all(bytes)
.map_err(|e| format!("Unable to write to {:?}: {}", path, e))?;

Ok(())
}
Loading