mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Ethereum relayer server
Causes send test to pass for the processor.
This commit is contained in:
39
orchestration/src/ethereum_relayer.rs
Normal file
39
orchestration/src/ethereum_relayer.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{Network, Os, mimalloc, os, build_serai_service, write_dockerfile};
|
||||
|
||||
pub fn ethereum_relayer(orchestration_path: &Path, network: Network) {
|
||||
let setup = mimalloc(Os::Debian).to_string() +
|
||||
&build_serai_service("", network.release(), network.db(), "serai-ethereum-relayer");
|
||||
|
||||
let env_vars = [
|
||||
("DB_PATH", "/volume/ethereum-relayer-db".to_string()),
|
||||
("RUST_LOG", "info,serai_ethereum_relayer=trace".to_string()),
|
||||
];
|
||||
let mut env_vars_str = String::new();
|
||||
for (env_var, value) in env_vars {
|
||||
env_vars_str += &format!(r#"{env_var}=${{{env_var}:="{value}"}} "#);
|
||||
}
|
||||
|
||||
let run_ethereum_relayer = format!(
|
||||
r#"
|
||||
# Copy the relayer server binary and relevant license
|
||||
COPY --from=builder --chown=ethereumrelayer /serai/bin/serai-ethereum-relayer /bin
|
||||
|
||||
# Run ethereum-relayer
|
||||
EXPOSE 20830
|
||||
EXPOSE 20831
|
||||
CMD {env_vars_str} serai-ethereum-relayer
|
||||
"#
|
||||
);
|
||||
|
||||
let run = os(Os::Debian, "", "ethereumrelayer") + &run_ethereum_relayer;
|
||||
let res = setup + &run;
|
||||
|
||||
let mut ethereum_relayer_path = orchestration_path.to_path_buf();
|
||||
ethereum_relayer_path.push("coins");
|
||||
ethereum_relayer_path.push("ethereum-relayer");
|
||||
ethereum_relayer_path.push("Dockerfile");
|
||||
|
||||
write_dockerfile(ethereum_relayer_path, &res);
|
||||
}
|
||||
@@ -32,6 +32,9 @@ use mimalloc::mimalloc;
|
||||
mod coins;
|
||||
use coins::*;
|
||||
|
||||
mod ethereum_relayer;
|
||||
use ethereum_relayer::ethereum_relayer;
|
||||
|
||||
mod message_queue;
|
||||
use message_queue::message_queue;
|
||||
|
||||
@@ -280,6 +283,8 @@ fn dockerfiles(network: Network) {
|
||||
let ethereum_key = infrastructure_keys.remove("ethereum").unwrap();
|
||||
let monero_key = infrastructure_keys.remove("monero").unwrap();
|
||||
|
||||
ethereum_relayer(&orchestration_path, network);
|
||||
|
||||
message_queue(
|
||||
&orchestration_path,
|
||||
network,
|
||||
@@ -363,6 +368,7 @@ fn start(network: Network, services: HashSet<String>) {
|
||||
let name = match service.as_ref() {
|
||||
"serai" => "serai",
|
||||
"coordinator" => "coordinator",
|
||||
"ethereum-relayer" => "ethereum-relayer",
|
||||
"message-queue" => "message-queue",
|
||||
"bitcoin-daemon" => "bitcoin",
|
||||
"bitcoin-processor" => "bitcoin-processor",
|
||||
@@ -495,6 +501,10 @@ fn start(network: Network, services: HashSet<String>) {
|
||||
command
|
||||
}
|
||||
}
|
||||
"ethereum-relayer" => {
|
||||
// Expose the router command fetch server
|
||||
command.arg("-p").arg("20831:20831")
|
||||
}
|
||||
"monero" => {
|
||||
// Expose the RPC for tests
|
||||
if network == Network::Dev {
|
||||
@@ -561,6 +571,9 @@ Commands:
|
||||
- `message-queue`
|
||||
- `bitcoin-daemon`
|
||||
- `bitcoin-processor`
|
||||
- `ethereum-daemon`
|
||||
- `ethereum-processor`
|
||||
- `ethereum-relayer`
|
||||
- `monero-daemon`
|
||||
- `monero-processor`
|
||||
- `monero-wallet-rpc` (if "dev")
|
||||
@@ -593,6 +606,9 @@ Commands:
|
||||
Some("start") => {
|
||||
let mut services = HashSet::new();
|
||||
for arg in args {
|
||||
if arg == "ethereum-processor" {
|
||||
services.insert("ethereum-relayer".to_string());
|
||||
}
|
||||
if let Some(ext_network) = arg.strip_suffix("-processor") {
|
||||
services.insert(ext_network.to_string() + "-daemon");
|
||||
}
|
||||
|
||||
@@ -41,24 +41,32 @@ RUN apt install -y ca-certificates
|
||||
const RPC_PASS: &str = "seraidex";
|
||||
// TODO: Isolate networks
|
||||
let hostname = format!("serai-{}-{coin}", network.label());
|
||||
let port = match coin {
|
||||
"bitcoin" => 8332,
|
||||
"ethereum" => 8545,
|
||||
"monero" => 18081,
|
||||
_ => panic!("unrecognized external network"),
|
||||
};
|
||||
let port = format!(
|
||||
"{}",
|
||||
match coin {
|
||||
"bitcoin" => 8332,
|
||||
"ethereum" => 8545,
|
||||
"monero" => 18081,
|
||||
_ => panic!("unrecognized external network"),
|
||||
}
|
||||
);
|
||||
|
||||
let env_vars = [
|
||||
let mut env_vars = vec![
|
||||
("MESSAGE_QUEUE_RPC", format!("serai-{}-message-queue", network.label())),
|
||||
("MESSAGE_QUEUE_KEY", hex::encode(coin_key.to_repr())),
|
||||
("ENTROPY", hex::encode(entropy.as_ref())),
|
||||
("NETWORK", coin.to_string()),
|
||||
("NETWORK_RPC_LOGIN", format!("{RPC_USER}:{RPC_PASS}")),
|
||||
("NETWORK_RPC_HOSTNAME", hostname),
|
||||
("NETWORK_RPC_PORT", format!("{port}")),
|
||||
("NETWORK_RPC_PORT", port),
|
||||
("DB_PATH", "/volume/processor-db".to_string()),
|
||||
("RUST_LOG", "info,serai_processor=debug".to_string()),
|
||||
];
|
||||
if coin == "ethereum" {
|
||||
env_vars
|
||||
.push(("ETHEREUM_RELAYER_HOSTNAME", format!("serai-{}-ethereum-relayer", network.label())));
|
||||
env_vars.push(("ETHEREUM_RELAYER_PORT", "20830".to_string()));
|
||||
}
|
||||
let mut env_vars_str = String::new();
|
||||
for (env_var, value) in env_vars {
|
||||
env_vars_str += &format!(r#"{env_var}=${{{env_var}:="{value}"}} "#);
|
||||
|
||||
Reference in New Issue
Block a user