Skip to content

Commit c5047d0

Browse files
authored
Make Trin compilable/(not crash) on Windows + Add check CI (#923)
1 parent 1ad0a74 commit c5047d0

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

.circleci/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ commands:
4242
command: sudo apt install clang
4343
orbs:
4444
rust: circleci/[email protected]
45+
win: circleci/[email protected]
4546
executors:
4647
docker-publisher:
4748
environment:
@@ -159,6 +160,31 @@ jobs:
159160
name: Build Trin workspace
160161
command: cargo build --workspace
161162
- save-sccache-cache
163+
check-windows:
164+
description: |
165+
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)).
166+
executor:
167+
name: win/default
168+
size: xlarge
169+
environment:
170+
RUSTFLAGS: '-D warnings'
171+
RUST_LOG: 'debug'
172+
steps:
173+
- checkout
174+
- run:
175+
name: Install rustup and clang
176+
# We are installing them at the same time because it is faster
177+
# todo: Remove --ignore-checksums flag
178+
command: choco install rustup.install llvm -y --ignore-checksums
179+
- run:
180+
name: Add target
181+
command: rustup target add x86_64-pc-windows-msvc
182+
- run:
183+
name: Install target toolchain
184+
command: rustup toolchain install stable-x86_64-pc-windows-msvc
185+
- run:
186+
name: Check Trin workspace
187+
command: cargo check --workspace
162188
test:
163189
description: |
164190
Run tests.
@@ -259,4 +285,5 @@ workflows:
259285
- lint
260286
- build
261287
- test
288+
- check-windows
262289
- utp-test

ethportal-peertest/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(unix)]
12
pub mod constants;
23
pub mod scenarios;
34
pub mod utils;

portalnet/src/overlay_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ where
15251525
Request::PopulatedOffer(offer) => Ok(response_clone
15261526
.content_keys
15271527
.iter()
1528-
.zip(offer.content_items.into_iter())
1528+
.zip(offer.content_items)
15291529
.filter(|(is_accepted, _item)| *is_accepted)
15301530
.map(|(_is_accepted, (_key, val))| val)
15311531
.collect()),

portalnet/src/storage.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,8 @@ pub mod test {
11401140
// The restarted store should have the same radius as the original
11411141
assert_eq!(radius, new_storage.radius);
11421142

1143+
drop(storage);
1144+
drop(new_storage);
11431145
temp_dir.close()?;
11441146
Ok(())
11451147
}

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use tokio::sync::RwLock;
88
use tracing::info;
99
use utp_rs::socket::UtpSocket;
1010

11+
#[cfg(windows)]
12+
use ethportal_api::types::cli::Web3TransportType;
1113
use ethportal_api::types::cli::{TrinConfig, BEACON_NETWORK, HISTORY_NETWORK, STATE_NETWORK};
1214
use portalnet::{
1315
discovery::{Discovery, Discv5UdpSocket},
@@ -25,6 +27,13 @@ use trin_validation::{accumulator::MasterAccumulator, oracle::HeaderOracle};
2527
pub async fn run_trin(
2628
trin_config: TrinConfig,
2729
) -> Result<RpcServerHandle, Box<dyn std::error::Error>> {
30+
// Panic early on a windows build that is trying to use IPC, which is unsupported for now
31+
// Make sure not to panic on non-windows configurations.
32+
#[cfg(windows)]
33+
if let Web3TransportType::IPC = trin_config.web3_transport {
34+
panic!("Tokio doesn't support Windows Unix Domain Sockets IPC, use --web3-transport http");
35+
}
36+
2837
let trin_version = get_trin_version();
2938
info!("Launching Trin: v{trin_version}");
3039
info!(config = %trin_config, "With:");

tests/rpc_server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(unix)]
12
/// Test that a 3rd-party web3 client can understand our JSON-RPC API
23
use std::net::{IpAddr, Ipv4Addr};
34

tests/self_peertest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(unix)]
12
use rpc::RpcServerHandle;
23
use std::env;
34
use std::net::{IpAddr, Ipv4Addr};

0 commit comments

Comments
 (0)