Skip to content

Commit

Permalink
Make Trin compilable on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML committed May 16, 2023
1 parent 021e171 commit bb9fc39
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 129 deletions.
229 changes: 109 additions & 120 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ parking_lot = "0.11.2"
portalnet = { path = "portalnet" }
prometheus_exporter = "0.8.4"
rand = "0.8.4"
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
rlp = "0.5.0"
rocksdb = "0.18.0"
rpc = { path = "rpc"}
Expand All @@ -41,6 +40,9 @@ trin-utils = { path = "trin-utils" }
trin-validation = { path = "trin-validation" }
utp-rs = "0.1.0-alpha.4"

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

[dev-dependencies]
ethportal-peertest = { path = "ethportal-peertest" }
ureq = { version = "2.5.0", features = ["json"] }
Expand Down
6 changes: 3 additions & 3 deletions ethportal-peertest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ hex = "0.4.3"
hyper = { version = "0.14", features = ["full"] }
jsonrpsee = {version="0.16.2", features = ["async-client", "client", "macros", "server"]}
rand = "0.8.4"
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}

rocksdb = "0.18.0"
serde_json = "1.0.89"
tempfile = "3.3.0"
Expand All @@ -36,5 +36,5 @@ trin-state = { path = "../trin-state" }
trin-utils = { path = "../trin-utils" }
ureq = { version = "2.5.0", features = ["json"] }

[target.'cfg(windows)'.dependencies]
uds_windows = "1.0.1"
[target.'cfg(not(windows))'.dependencies]
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
1 change: 1 addition & 0 deletions ethportal-peertest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(unix)]
pub mod constants;
pub mod scenarios;

Expand Down
3 changes: 3 additions & 0 deletions newsfragments/739.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### fix windows compilation

add cfg and add a few panics to clearly define what is not supported by windows so it can compile
3 changes: 0 additions & 3 deletions portalnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ validator = { version = "0.13.0", features = ["derive"] }
url = "2.3.1"
utp-rs = "0.1.0-alpha.4"

[target.'cfg(windows)'.dependencies]
uds_windows = "1.0.1"

[dev-dependencies]
env_logger = "0.9.0"
quickcheck = "1.0.3"
Expand Down
4 changes: 3 additions & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ ethportal-api = { path = "../ethportal-api"}
portalnet = { path = "../portalnet"}
trin-utils = { path = "../trin-utils"}
tokio = { version = "1.14.0", features = ["full"] }
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
url = "2.3.1"
serde_json = "1.0.95"

[target.'cfg(not(windows))'.dependencies]
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
11 changes: 11 additions & 0 deletions rpc/src/server_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{Discv5Api, HistoryNetworkApi, Web3Api};
use ethportal_api::types::jsonrpc::request::HistoryJsonRpcRequest;
use ethportal_api::{Discv5ApiServer, HistoryNetworkApiServer, Web3ApiServer};
use portalnet::discovery::Discovery;
#[cfg(unix)]
use reth_ipc::server::Builder as IpcServerBuilder;
use std::net::SocketAddr;
use std::path::Path;
Expand Down Expand Up @@ -31,6 +32,7 @@ impl JsonRpcServer {
Ok(handle)
}

#[cfg(unix)]
pub async fn run_ipc(
ipc_path: Box<dyn AsRef<Path>>,
discv5: Arc<Discovery>,
Expand All @@ -46,4 +48,13 @@ impl JsonRpcServer {
let handle = server.start(api).await?;
Ok(handle)
}

#[cfg(windows)]
pub async fn run_ipc(
_ipc_path: Box<dyn AsRef<Path>>,
_discv5: Arc<Discovery>,
_history_handler: mpsc::UnboundedSender<HistoryJsonRpcRequest>,
) -> anyhow::Result<ServerHandle> {
panic!("Windows doesn't support Unix Domain Sockets IPC, use --web3-transport http")
}
}
2 changes: 1 addition & 1 deletion tests/self_peertest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
#[cfg(all(unix, test))]
mod test {
use std::{
net::{IpAddr, Ipv4Addr},
Expand Down

0 comments on commit bb9fc39

Please sign in to comment.