Skip to content

Commit

Permalink
[aptos-node/cli] Add windows compatibility
Browse files Browse the repository at this point in the history
LLVM needs to be installed, but otherwise remove pieces or have
build flags accordingly that are unix only
  • Loading branch information
gregnazario committed Sep 2, 2022
1 parent 4c67047 commit 8513ed8
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 51 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

45 changes: 37 additions & 8 deletions aptos-move/framework/cached-packages/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,49 @@
// SPDX-License-Identifier: Apache-2.0

use framework::ReleaseTarget;
use std::env::current_dir;
use std::path::PathBuf;

fn main() {
// Set the below variable to skip the building step. This might be useful if the build
// is broken so it can be debugged with the old outdated artifacts.
if std::env::var("SKIP_FRAMEWORK_BUILD").is_err() {
println!("cargo:rerun-if-changed=../aptos-token/sources");
println!("cargo:rerun-if-changed=../aptos-token/Move.toml");
println!("cargo:rerun-if-changed=../aptos-framework/sources");
println!("cargo:rerun-if-changed=../aptos-framework/Move.toml");
println!("cargo:rerun-if-changed=../aptos-stdlib/sources");
println!("cargo:rerun-if-changed=../aptos-stdlib/Move.toml");
println!("cargo:rerun-if-changed=../move-stdlib/sources");
println!("cargo:rerun-if-changed=../move-stdlib/Move.toml");
let current_dir = current_dir().expect("Should be able to get current dir");
// Get the previous directory
let mut prev_dir = current_dir;
prev_dir.pop();
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-token").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-token").join("Move.toml").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-framework").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-framework").join("Move.toml").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-stdlib").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-stdlib").join("Move.toml").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("move-stdlib").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("move-stdlib").join("Move.toml").display()
);
ReleaseTarget::Head
.create_release(Some(
PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR defined")).join("head.mrb"),
Expand Down
3 changes: 3 additions & 0 deletions aptos-move/framework/cached-packages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ pub mod aptos_framework_sdk_builder;
pub mod aptos_stdlib;
pub mod aptos_token_sdk_builder;

#[cfg(unix)]
const HEAD_RELEASE_BUNDLE_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/head.mrb"));
#[cfg(windows)]
const HEAD_RELEASE_BUNDLE_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "\\head.mrb"));

static HEAD_RELEASE_BUNDLE: Lazy<ReleaseBundle> = Lazy::new(|| {
bcs::from_bytes::<ReleaseBundle>(HEAD_RELEASE_BUNDLE_BYTES).expect("bcs succeeds")
Expand Down
21 changes: 20 additions & 1 deletion aptos-move/framework/src/aptos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,26 @@ impl ReleaseTarget {
PathBuf::from(self.file_name())
},
};
options.create_release()

#[cfg(unix)]
{
options.create_release()
}
#[cfg(windows)]
{
// Windows requires to set the stack because the package compiler puts too much on the
// stack for the default size. A quick internet search has shown the new thread with
// a custom stack size is the easiest course of action.
const STACK_SIZE: usize = 4 * 1024 * 1024;
let child_thread = std::thread::Builder::new()
.name("Framework-release".to_string())
.stack_size(STACK_SIZE)
.spawn(|| options.create_release())
.expect("Expected to spawn release thread");
child_thread
.join()
.expect("Expected to join release thread")
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion aptos-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ clap = "3.1.8"
fail = "0.5.0"
futures = "0.3.21"
hex = "0.4.3"
jemallocator = { version = "0.3.2", features = ["profiling", "unprefixed_malloc_on_supported_platforms"] }
rand = "0.7.3"
tokio = { version = "1.18.2", features = ["full"] }
tokio-stream = "0.1.8"
Expand Down Expand Up @@ -59,6 +58,9 @@ storage-interface = { path = "../storage/storage-interface" }
storage-service-client = { path = "../state-sync/storage-service/client" }
storage-service-server = { path = "../state-sync/storage-service/server" }

[target.'cfg(unix)'.dependencies]
jemallocator = { version = "0.3.2", features = ["profiling", "unprefixed_malloc_on_supported_platforms"] }

[features]
default = []
assert-private-keys-not-cloneable = ["aptos-crypto/assert-private-keys-not-cloneable"]
Expand Down
1 change: 1 addition & 0 deletions aptos-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use aptos_node::AptosNodeArgs;
use clap::Parser;

#[cfg(unix)]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down
1 change: 0 additions & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ once_cell = "1.10.0"
rand = { version = "0.7.3", default-features = false }
serde = { version = "1.0.137", default-features = false }
serde_json = "1.0.81"
termion = { version = "1.5.6", default-features = false }
thiserror = "1.0.31"
tokio = { version = "1.18.2", features = ["full"] }

Expand Down
20 changes: 4 additions & 16 deletions consensus/src/experimental/tests/phase_tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,12 @@ impl<T: StatelessPipeline> PhaseTester<T> {
} in self.cases
{
eprint!(
"{}Unit Test{} - {}:",
termion::color::Fg(termion::color::LightBlue),
termion::style::Reset,
"Unit Test - {}:",
prompt.unwrap_or(format!("Test {}", index))
);
let resp = processor.process(input).await;
judge(resp);
eprintln!(
" {}OK{}",
termion::color::Fg(termion::color::LightGreen),
termion::style::Reset
);
eprintln!(" OK",);
}
})
}
Expand All @@ -93,21 +87,15 @@ impl<T: StatelessPipeline> PhaseTester<T> {
} in self.cases
{
eprint!(
"{}E2E Test{} - {}:",
termion::color::Fg(termion::color::LightBlue),
termion::style::Reset,
"E2E Test - {}:",
prompt.unwrap_or(format!("Test {}", index))
);
tx.send(CountedRequest::new(input, Arc::new(AtomicU64::new(0))))
.await
.ok();
let resp = rx.next().await.unwrap();
judge(resp);
eprintln!(
" {}OK{}",
termion::color::Fg(termion::color::Green),
termion::style::Reset
);
eprintln!(" OK",);
}
})
}
Expand Down
5 changes: 1 addition & 4 deletions consensus/src/round_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ use safety_rules::ConsensusState;
use safety_rules::TSafetyRules;
use serde::Serialize;
use std::{mem::Discriminant, sync::Arc, time::Duration};
use termion::color::*;

#[derive(Serialize, Clone)]
pub enum UnverifiedEvent {
Expand Down Expand Up @@ -585,9 +584,7 @@ impl RoundManager {
self.block_store.highest_2chain_timeout_cert().as_deref(),
);
let vote = vote_result.context(format!(
"[RoundManager] SafetyRules {}Rejected{} {}",
Fg(Red),
Fg(Reset),
"[RoundManager] SafetyRules Rejected {}",
executed_block.block()
))?;
if !executed_block.block().is_nil_block() {
Expand Down
5 changes: 1 addition & 4 deletions consensus/src/test_utils/mock_state_computer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use consensus_types::{block::Block, common::Payload, executed_block::ExecutedBlo
use executor_types::{Error, StateComputeResult};
use futures::channel::mpsc;
use std::{collections::HashMap, sync::Arc};
use termion::color::*;

pub struct MockStateComputer {
state_sync_client: mpsc::UnboundedSender<Vec<SignedTransaction>>,
Expand Down Expand Up @@ -89,9 +88,7 @@ impl StateComputer for MockStateComputer {

async fn sync_to(&self, commit: LedgerInfoWithSignatures) -> Result<(), StateSyncError> {
debug!(
"{}Fake sync{} to block id {}",
Fg(Blue),
Fg(Reset),
"Fake sync to block id {}",
commit.ledger_info().consensus_block_id()
);
self.consensus_db
Expand Down
3 changes: 2 additions & 1 deletion crates/aptos/src/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ use itertools::Itertools;
use move_deps::move_core_types::account_address::AccountAddress;
use reqwest::Url;
use serde::Serialize;
#[cfg(unix)]
use std::os::unix::fs::OpenOptionsExt;
use std::{
collections::BTreeMap,
env,
fs::OpenOptions,
io::Write,
os::unix::fs::OpenOptionsExt,
path::{Path, PathBuf},
str::FromStr,
time::{Duration, Instant},
Expand Down
1 change: 0 additions & 1 deletion crates/transaction-emitter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ futures = "0.3.21"
itertools = "0.10.3"
rand = "0.7.3"
rand_core = "0.5.1"
termion = "1.5.6"
tokio = { version = "1.18.2", features = ["full"] }

aptos-logger = { path = "../../crates/aptos-logger" }
Expand Down
15 changes: 4 additions & 11 deletions crates/transaction-emitter/src/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
cmp::min,
time::{Duration, Instant},
};
use termion::color;
use transaction_emitter_lib::{query_sequence_numbers, Cluster, TxnEmitter};

pub async fn diag(cluster: &Cluster) -> Result<()> {
Expand Down Expand Up @@ -58,19 +57,13 @@ pub async fn diag(cluster: &Cluster) -> Result<()> {
format_err!("Failed to query sequence number from {}: {}", instance, e)
})?[0];
let host = instance.api_url().host().unwrap().to_string();
let color = if seq != faucet_account.sequence_number() {
let status = if seq != faucet_account.sequence_number() {
all_good = false;
color::Fg(color::Red).to_string()
"good"
} else {
color::Fg(color::Green).to_string()
"bad"
};
print!(
"[{}{}:{}{}] ",
color,
&host[..min(host.len(), 10)],
seq,
color::Fg(color::Reset)
);
print!("[{}:{}:{}] ", &host[..min(host.len(), 10)], seq, status);
}
println!();
if all_good {
Expand Down
4 changes: 3 additions & 1 deletion execution/executor-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ chrono = "0.4.19"
criterion = "0.3.5"
indicatif = "0.15.0"
itertools = "0.10.3"
jemallocator = { version = "0.3.2", features = ["profiling", "unprefixed_malloc_on_supported_platforms"] }
num_cpus = "1.13.1"
rand = "0.7.3"
rayon = "1.5.2"
Expand All @@ -41,6 +40,9 @@ schemadb = { path = "../../storage/schemadb" }
scratchpad = { path = "../../storage/scratchpad" }
storage-interface = { path = "../../storage/storage-interface" }

[target.'cfg(unix)'.dependencies]
jemallocator = { version = "0.3.2", features = ["profiling", "unprefixed_malloc_on_supported_platforms"] }

[dev-dependencies]
aptos-temppath = { path = "../../crates/aptos-temppath" }

Expand Down
1 change: 1 addition & 0 deletions execution/executor-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use aptos_vm::AptosVM;
use std::path::PathBuf;
use structopt::StructOpt;

#[cfg(unix)]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down

0 comments on commit 8513ed8

Please sign in to comment.