From 505909fcee23a642a17834d2c6a412988ef67f6f Mon Sep 17 00:00:00 2001 From: Kolby ML <31669092+KolbyML@users.noreply.github.com> Date: Sun, 17 Sep 2023 17:35:46 -0600 Subject: [PATCH 1/3] Make Trin compilable on Windows --- ethportal-peertest/src/lib.rs | 1 + portalnet/src/overlay_service.rs | 2 +- portalnet/src/storage.rs | 2 ++ src/lib.rs | 9 +++++++++ tests/rpc_server.rs | 1 + tests/self_peertest.rs | 1 + 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ethportal-peertest/src/lib.rs b/ethportal-peertest/src/lib.rs index 24b889251..053089b2f 100644 --- a/ethportal-peertest/src/lib.rs +++ b/ethportal-peertest/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg(unix)] pub mod constants; pub mod scenarios; pub mod utils; diff --git a/portalnet/src/overlay_service.rs b/portalnet/src/overlay_service.rs index ad4db50d7..9aff3b99c 100644 --- a/portalnet/src/overlay_service.rs +++ b/portalnet/src/overlay_service.rs @@ -1520,7 +1520,7 @@ where Request::PopulatedOffer(offer) => Ok(response_clone .content_keys .iter() - .zip(offer.content_items.into_iter()) + .zip(offer.content_items) .filter(|(is_accepted, _item)| *is_accepted) .map(|(_is_accepted, (_key, val))| val) .collect()), diff --git a/portalnet/src/storage.rs b/portalnet/src/storage.rs index 99911c2d3..e7dd38cc5 100644 --- a/portalnet/src/storage.rs +++ b/portalnet/src/storage.rs @@ -1140,6 +1140,8 @@ pub mod test { // The restarted store should have the same radius as the original assert_eq!(radius, new_storage.radius); + drop(storage); + drop(new_storage); temp_dir.close()?; Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index 50cd3cc56..ba8ac0ef0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,8 @@ use tokio::sync::RwLock; use tracing::info; use utp_rs::socket::UtpSocket; +#[cfg(windows)] +use ethportal_api::types::cli::Web3TransportType; use ethportal_api::types::cli::{TrinConfig, BEACON_NETWORK, HISTORY_NETWORK, STATE_NETWORK}; use portalnet::{ discovery::{Discovery, Discv5UdpSocket}, @@ -25,6 +27,13 @@ use trin_validation::{accumulator::MasterAccumulator, oracle::HeaderOracle}; pub async fn run_trin( trin_config: TrinConfig, ) -> Result> { + // Panic early on a windows build that is trying to use IPC, which is unsupported for now + // Make sure not to panic on non-windows configurations. + #[cfg(windows)] + if let Web3TransportType::IPC = trin_config.web3_transport { + panic!("Windows doesn't support Unix Domain Sockets IPC, use --web3-transport http"); + } + let trin_version = get_trin_version(); info!("Launching Trin: v{trin_version}"); info!(config = %trin_config, "With:"); diff --git a/tests/rpc_server.rs b/tests/rpc_server.rs index 2fb978c4e..d79baa460 100644 --- a/tests/rpc_server.rs +++ b/tests/rpc_server.rs @@ -1,3 +1,4 @@ +#![cfg(unix)] /// Test that a 3rd-party web3 client can understand our JSON-RPC API use std::net::{IpAddr, Ipv4Addr}; diff --git a/tests/self_peertest.rs b/tests/self_peertest.rs index af642b9ef..508aa3622 100644 --- a/tests/self_peertest.rs +++ b/tests/self_peertest.rs @@ -1,3 +1,4 @@ +#![cfg(unix)] use rpc::RpcServerHandle; use std::env; use std::net::{IpAddr, Ipv4Addr}; From 22564267d6d6ae56715537705561c8a422102f4e Mon Sep 17 00:00:00 2001 From: Kolby ML <31669092+KolbyML@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:20:48 -0600 Subject: [PATCH 2/3] Add a check CI for windows --- .circleci/config.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index d2cd0b775..4b281728e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,6 +42,7 @@ commands: command: sudo apt install clang orbs: rust: circleci/rust@1.6.0 + win: circleci/windows@2.2.0 executors: docker-publisher: environment: @@ -159,6 +160,31 @@ jobs: name: Build Trin workspace command: cargo build --workspace - save-sccache-cache + check-windows: + description: | + Check the crate on Windows (Check will tell us if we can build on Windows without the need to codegen (which is the time consuming part)). + executor: + name: win/default + size: xlarge + environment: + RUSTFLAGS: '-D warnings' + RUST_LOG: 'debug' + steps: + - checkout + - run: + name: Install rustup and clang + # We are installing them at the same time because it is faster + # todo: Remove --ignore-checksums flag + command: choco install rustup.install llvm -y --ignore-checksums + - run: + name: Add target + command: rustup target add x86_64-pc-windows-msvc + - run: + name: Install target toolchain + command: rustup toolchain install stable-x86_64-pc-windows-msvc + - run: + name: Check Trin workspace + command: cargo check --workspace test: description: | Run tests. @@ -259,4 +285,5 @@ workflows: - lint - build - test + - check-windows - utp-test From 40beb86d5ae2b7b520084e633ffa5bb17e9d7ee6 Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:32:01 -0600 Subject: [PATCH 3/3] Resolve PR comment --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ba8ac0ef0..7f5211127 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ pub async fn run_trin( // Make sure not to panic on non-windows configurations. #[cfg(windows)] if let Web3TransportType::IPC = trin_config.web3_transport { - panic!("Windows doesn't support Unix Domain Sockets IPC, use --web3-transport http"); + panic!("Tokio doesn't support Windows Unix Domain Sockets IPC, use --web3-transport http"); } let trin_version = get_trin_version();