mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 21:49:26 +00:00
update to develop latest
This commit is contained in:
@@ -63,15 +63,7 @@ pub fn serai_composition(name: &str) -> TestBodySpecification {
|
||||
TestBodySpecification::with_image(
|
||||
Image::with_repository("serai-dev-serai").pull_policy(PullPolicy::Never),
|
||||
)
|
||||
.replace_cmd(vec![
|
||||
"serai-node".to_string(),
|
||||
"--unsafe-rpc-external".to_string(),
|
||||
"--rpc-cors".to_string(),
|
||||
"all".to_string(),
|
||||
"--chain".to_string(),
|
||||
"local".to_string(),
|
||||
format!("--{}", name.to_lowercase()),
|
||||
])
|
||||
.replace_env([("SERAI_NAME".to_string(), name.to_lowercase())].into())
|
||||
.set_publish_all_ports(true)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ pub fn fresh_logs_folder(first: bool, label: &str) -> String {
|
||||
logs_path.to_str().unwrap().to_string()
|
||||
}
|
||||
|
||||
// TODO: Merge this with what's in serai-orchestrator/have serai-orchestrator perform building
|
||||
static BUILT: OnceLock<Mutex<HashMap<String, bool>>> = OnceLock::new();
|
||||
pub fn build(name: String) {
|
||||
let built = BUILT.get_or_init(|| Mutex::new(HashMap::new()));
|
||||
@@ -42,8 +43,59 @@ pub fn build(name: String) {
|
||||
assert!(repo_path.as_path().ends_with("target"));
|
||||
repo_path.pop();
|
||||
|
||||
// Run the orchestrator to ensure the most recent files exist
|
||||
if !Command::new("cargo")
|
||||
.current_dir(&repo_path)
|
||||
.arg("run")
|
||||
.arg("-p")
|
||||
.arg("serai-orchestrator")
|
||||
.arg("--")
|
||||
.arg("key_gen")
|
||||
.arg("dev")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap()
|
||||
.success()
|
||||
{
|
||||
panic!("failed to run the orchestrator");
|
||||
}
|
||||
|
||||
if !Command::new("cargo")
|
||||
.current_dir(&repo_path)
|
||||
.arg("run")
|
||||
.arg("-p")
|
||||
.arg("serai-orchestrator")
|
||||
.arg("--")
|
||||
.arg("setup")
|
||||
.arg("dev")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap()
|
||||
.success()
|
||||
{
|
||||
panic!("failed to run the orchestrator");
|
||||
}
|
||||
|
||||
let mut orchestration_path = repo_path.clone();
|
||||
orchestration_path.push("orchestration");
|
||||
if name != "runtime" {
|
||||
orchestration_path.push("dev");
|
||||
}
|
||||
|
||||
let mut dockerfile_path = orchestration_path.clone();
|
||||
if HashSet::from(["bitcoin", "ethereum", "monero"]).contains(name.as_str()) {
|
||||
dockerfile_path = dockerfile_path.join("coins");
|
||||
}
|
||||
if name.contains("-processor") {
|
||||
dockerfile_path =
|
||||
dockerfile_path.join("processor").join(name.split('-').next().unwrap()).join("Dockerfile");
|
||||
} else if name == "serai-fast-epoch" {
|
||||
dockerfile_path = dockerfile_path.join("serai").join("Dockerfile.fast-epoch");
|
||||
} else {
|
||||
dockerfile_path = dockerfile_path.join(&name).join("Dockerfile");
|
||||
}
|
||||
|
||||
// If this Docker image was created after this repo was last edited, return here
|
||||
// This should have better performance than Docker and allows running while offline
|
||||
@@ -65,24 +117,9 @@ pub fn build(name: String) {
|
||||
.0,
|
||||
);
|
||||
|
||||
let mut dockerfile_path = orchestration_path.clone();
|
||||
if HashSet::from(["bitcoin", "ethereum", "monero"]).contains(name.as_str()) {
|
||||
dockerfile_path = dockerfile_path.join("coins");
|
||||
}
|
||||
if name.contains("-processor") {
|
||||
dockerfile_path = dockerfile_path
|
||||
.join("processor")
|
||||
.join(name.split('-').next().unwrap())
|
||||
.join("Dockerfile");
|
||||
} else if name == "serai-fast-epoch" {
|
||||
dockerfile_path = dockerfile_path.join("serai").join("Dockerfile.fast-epoch");
|
||||
} else {
|
||||
dockerfile_path = dockerfile_path.join(&name).join("Dockerfile");
|
||||
}
|
||||
|
||||
// For all services, if the Dockerfile was edited after the image was built we should rebuild
|
||||
let mut last_modified =
|
||||
fs::metadata(dockerfile_path).ok().and_then(|meta| meta.modified().ok());
|
||||
fs::metadata(&dockerfile_path).ok().and_then(|meta| meta.modified().ok());
|
||||
|
||||
// Check any additionally specified paths
|
||||
let meta = |path: PathBuf| (path.clone(), fs::metadata(path));
|
||||
@@ -155,10 +192,13 @@ pub fn build(name: String) {
|
||||
|
||||
// Version which always prints
|
||||
if !Command::new("docker")
|
||||
.current_dir(orchestration_path)
|
||||
.arg("compose")
|
||||
.current_dir(&repo_path)
|
||||
.arg("build")
|
||||
.arg(&name)
|
||||
.arg("-f")
|
||||
.arg(dockerfile_path)
|
||||
.arg(".")
|
||||
.arg("-t")
|
||||
.arg(format!("serai-dev-{name}"))
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
@@ -171,10 +211,11 @@ pub fn build(name: String) {
|
||||
// Version which only prints on error
|
||||
/*
|
||||
let res = Command::new("docker")
|
||||
.current_dir(orchestration_path)
|
||||
.arg("compose")
|
||||
.current_dir(dockerfile_path)
|
||||
.arg("build")
|
||||
.arg(&name)
|
||||
.arg(".")
|
||||
.arg("-t")
|
||||
.arg(format!("serai-dev-{name}"))
|
||||
.output()
|
||||
.unwrap();
|
||||
if !res.status.success() {
|
||||
|
||||
@@ -27,16 +27,6 @@ pub fn bitcoin_instance() -> (TestBodySpecification, u32) {
|
||||
let composition = TestBodySpecification::with_image(
|
||||
Image::with_repository("serai-dev-bitcoin").pull_policy(PullPolicy::Never),
|
||||
)
|
||||
.replace_cmd(vec![
|
||||
"bitcoind".to_string(),
|
||||
"-txindex".to_string(),
|
||||
"-regtest".to_string(),
|
||||
format!("-rpcuser={RPC_USER}"),
|
||||
format!("-rpcpassword={RPC_PASS}"),
|
||||
"-rpcbind=0.0.0.0".to_string(),
|
||||
"-rpcallowip=0.0.0.0/0".to_string(),
|
||||
"-rpcport=8332".to_string(),
|
||||
])
|
||||
.set_publish_all_ports(true);
|
||||
(composition, BTC_PORT)
|
||||
}
|
||||
@@ -47,17 +37,6 @@ pub fn monero_instance() -> (TestBodySpecification, u32) {
|
||||
let composition = TestBodySpecification::with_image(
|
||||
Image::with_repository("serai-dev-monero").pull_policy(PullPolicy::Never),
|
||||
)
|
||||
.replace_cmd(vec![
|
||||
"monerod".to_string(),
|
||||
"--regtest".to_string(),
|
||||
"--offline".to_string(),
|
||||
"--fixed-difficulty=1".to_string(),
|
||||
"--rpc-bind-ip=0.0.0.0".to_string(),
|
||||
format!("--rpc-login={RPC_USER}:{RPC_PASS}"),
|
||||
"--rpc-access-control-origins=*".to_string(),
|
||||
"--confirm-external-bind".to_string(),
|
||||
"--non-interactive".to_string(),
|
||||
])
|
||||
.set_start_policy(StartPolicy::Strict)
|
||||
.set_publish_all_ports(true);
|
||||
(composition, XMR_PORT)
|
||||
|
||||
Reference in New Issue
Block a user