Skip to content

Commit 6404b77

Browse files
committed
Make Trin compilable on Windows
1 parent 6c7f801 commit 6404b77

File tree

10 files changed

+138
-118
lines changed

10 files changed

+138
-118
lines changed

Cargo.lock

+110-109
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ parking_lot = "0.11.2"
2424
portalnet = { path = "portalnet" }
2525
prometheus_exporter = "0.8.4"
2626
rand = "0.8.4"
27-
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
2827
rlp = "0.5.0"
2928
rocksdb = "0.18.0"
3029
rpc = { path = "rpc"}
@@ -44,6 +43,9 @@ trin-utils = { path = "trin-utils" }
4443
trin-validation = { path = "trin-validation" }
4544
utp-rs = "0.1.0-alpha.4"
4645

46+
[target.'cfg(not(windows))'.dependencies]
47+
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
48+
4749
[dev-dependencies]
4850
ethportal-peertest = { path = "ethportal-peertest" }
4951
ureq = { version = "2.5.0", features = ["json"] }

ethportal-peertest/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ hex = "0.4.3"
2323
hyper = { version = "0.14", features = ["full"] }
2424
jsonrpsee = {version="0.16.2", features = ["async-client", "client", "macros", "server"]}
2525
rand = "0.8.4"
26-
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
26+
2727
rocksdb = "0.18.0"
2828
serde_json = "1.0.89"
2929
structopt = "0.3.26"
@@ -39,5 +39,5 @@ trin-types = { path = "../trin-types" }
3939
trin-utils = { path = "../trin-utils" }
4040
ureq = { version = "2.5.0", features = ["json"] }
4141

42-
[target.'cfg(windows)'.dependencies]
43-
uds_windows = "1.0.1"
42+
[target.'cfg(not(windows))'.dependencies]
43+
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}

ethportal-peertest/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(unix)]
12
pub mod constants;
23
pub mod scenarios;
34

newsfragments/739.fixed.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### fix windows compilation
2+
3+
add cfg and add a few panics to clearly define what is not supported by windows so it can compile

portalnet/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ validator = { version = "0.13.0", features = ["derive"] }
5050
url = "2.3.1"
5151
utp-rs = "0.1.0-alpha.4"
5252

53-
[target.'cfg(windows)'.dependencies]
54-
uds_windows = "1.0.1"
55-
5653
[dev-dependencies]
5754
env_logger = "0.9.0"
5855
quickcheck = "1.0.3"

rpc/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ portalnet = { path = "../portalnet"}
1717
trin-types = { path = "../trin-types"}
1818
trin-utils = { path = "../trin-utils"}
1919
tokio = { version = "1.14.0", features = ["full"] }
20-
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
2120
url = "2.3.1"
2221
serde_json = "1.0.95"
22+
23+
[target.'cfg(not(windows))'.dependencies]
24+
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}

rpc/src/server_rpc.rs

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::jsonrpsee::server::{ServerBuilder as HttpServerBuilder, ServerHandle}
22
use crate::{Discv5Api, HistoryNetworkApi, Web3Api};
33
use ethportal_api::{Discv5ApiServer, HistoryNetworkApiServer, Web3ApiServer};
44
use portalnet::discovery::Discovery;
5+
#[cfg(unix)]
56
use reth_ipc::server::Builder as IpcServerBuilder;
67
use std::net::SocketAddr;
78
use std::path::Path;
@@ -31,6 +32,7 @@ impl JsonRpcServer {
3132
Ok(handle)
3233
}
3334

35+
#[cfg(unix)]
3436
pub async fn run_ipc(
3537
ipc_path: Box<dyn AsRef<Path>>,
3638
discv5: Arc<Discovery>,
@@ -46,4 +48,13 @@ impl JsonRpcServer {
4648
let handle = server.start(api).await?;
4749
Ok(handle)
4850
}
51+
52+
#[cfg(windows)]
53+
pub async fn run_ipc(
54+
_ipc_path: Box<dyn AsRef<Path>>,
55+
_discv5: Arc<Discovery>,
56+
_history_handler: mpsc::UnboundedSender<HistoryJsonRpcRequest>,
57+
) -> anyhow::Result<ServerHandle> {
58+
panic!("Windows doesn't support Unix Domain Sockets IPC, use --web3-transport http")
59+
}
4960
}

tests/self_peertest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(test)]
1+
#[cfg(all(unix, test))]
22
mod test {
33
use std::{
44
net::{IpAddr, Ipv4Addr},

trin-cli/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ trin-types = { path = "../trin-types" }
2626
trin-utils = { path = "../trin-utils" }
2727
ureq = { version = "2.5.0", features = ["json"] }
2828

29+
[target.'cfg(windows)'.dependencies]
30+
uds_windows = "1.0.1"
31+
2932
[[bin]]
3033
name="trin-cli"
3134
path="src/main.rs"

0 commit comments

Comments
 (0)