mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
Rename the coins folder to networks (#583)
* Rename the coins folder to networks Ethereum isn't a coin. It's a network. Resolves #357. * More renames of coins -> networks in orchestration * Correct paths in tests/ * cargo fmt
This commit is contained in:
55
orchestration/src/networks/bitcoin.rs
Normal file
55
orchestration/src/networks/bitcoin.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{Network, Os, mimalloc, os, write_dockerfile};
|
||||
|
||||
pub fn bitcoin(orchestration_path: &Path, network: Network) {
|
||||
#[rustfmt::skip]
|
||||
const DOWNLOAD_BITCOIN: &str = r#"
|
||||
FROM alpine:latest as bitcoin
|
||||
|
||||
ENV BITCOIN_VERSION=27.1
|
||||
|
||||
RUN apk --no-cache add git gnupg
|
||||
|
||||
# Download Bitcoin
|
||||
RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-$(uname -m)-linux-gnu.tar.gz \
|
||||
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS \
|
||||
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc
|
||||
|
||||
# Verify all sigs and check for a valid signature from laanwj -- 71A3
|
||||
RUN git clone https://github.com/bitcoin-core/guix.sigs && \
|
||||
cd guix.sigs/builder-keys && \
|
||||
find . -iname '*.gpg' -exec gpg --import {} \; && \
|
||||
gpg --verify --status-fd 1 --verify ../../SHA256SUMS.asc ../../SHA256SUMS | grep "^\[GNUPG:\] VALIDSIG.*71A3B16735405025D447E8F274810B012346C9A6"
|
||||
|
||||
RUN grep bitcoin-${BITCOIN_VERSION}-$(uname -m)-linux-gnu.tar.gz SHA256SUMS | sha256sum -c
|
||||
|
||||
# Prepare Image
|
||||
RUN tar xzvf bitcoin-${BITCOIN_VERSION}-$(uname -m)-linux-gnu.tar.gz
|
||||
RUN mv bitcoin-${BITCOIN_VERSION}/bin/bitcoind .
|
||||
"#;
|
||||
|
||||
let setup = mimalloc(Os::Debian).to_string() + DOWNLOAD_BITCOIN;
|
||||
|
||||
let run_bitcoin = format!(
|
||||
r#"
|
||||
COPY --from=bitcoin --chown=bitcoin bitcoind /bin
|
||||
|
||||
EXPOSE 8332 8333
|
||||
|
||||
ADD /orchestration/{}/networks/bitcoin/run.sh /
|
||||
CMD ["/run.sh"]
|
||||
"#,
|
||||
network.label()
|
||||
);
|
||||
|
||||
let run = os(Os::Debian, "", "bitcoin") + &run_bitcoin;
|
||||
let res = setup + &run;
|
||||
|
||||
let mut bitcoin_path = orchestration_path.to_path_buf();
|
||||
bitcoin_path.push("networks");
|
||||
bitcoin_path.push("bitcoin");
|
||||
bitcoin_path.push("Dockerfile");
|
||||
|
||||
write_dockerfile(bitcoin_path, &res);
|
||||
}
|
||||
36
orchestration/src/networks/ethereum/consensus/lighthouse.rs
Normal file
36
orchestration/src/networks/ethereum/consensus/lighthouse.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use crate::Network;
|
||||
|
||||
pub fn lighthouse(network: Network) -> (String, String, String) {
|
||||
assert_ne!(network, Network::Dev);
|
||||
|
||||
#[rustfmt::skip]
|
||||
const DOWNLOAD_LIGHTHOUSE: &str = r#"
|
||||
FROM alpine:latest as lighthouse
|
||||
|
||||
ENV LIGHTHOUSE_VERSION=5.1.3
|
||||
|
||||
RUN apk --no-cache add git gnupg
|
||||
|
||||
# Download lighthouse
|
||||
RUN wget https://github.com/sigp/lighthouse/releases/download/v${LIGHTHOUSE_VERSION}/lighthouse-v${LIGHTHOUSE_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz
|
||||
RUN wget https://github.com/sigp/lighthouse/releases/download/v${LIGHTHOUSE_VERSION}/lighthouse-v${LIGHTHOUSE_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz.asc
|
||||
|
||||
# Verify the signature
|
||||
gpg --keyserver keyserver.ubuntu.com --recv-keys 15E66D941F697E28F49381F426416DC3F30674B0
|
||||
gpg --verify lighthouse-v${LIGHTHOUSE_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz.asc lighthouse-v${LIGHTHOUSE_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz
|
||||
|
||||
# Extract lighthouse
|
||||
RUN tar xvf lighthouse-v${LIGHTHOUSE_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz
|
||||
"#;
|
||||
|
||||
let run_lighthouse = format!(
|
||||
r#"
|
||||
COPY --from=lighthouse --chown=ethereum lighthouse /bin
|
||||
|
||||
ADD /orchestration/{}/networks/ethereum/consensus/lighthouse/run.sh /consensus_layer.sh
|
||||
"#,
|
||||
network.label()
|
||||
);
|
||||
|
||||
(DOWNLOAD_LIGHTHOUSE.to_string(), String::new(), run_lighthouse)
|
||||
}
|
||||
6
orchestration/src/networks/ethereum/consensus/mod.rs
Normal file
6
orchestration/src/networks/ethereum/consensus/mod.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
mod lighthouse;
|
||||
#[allow(unused)]
|
||||
pub use lighthouse::lighthouse;
|
||||
|
||||
mod nimbus;
|
||||
pub use nimbus::nimbus;
|
||||
49
orchestration/src/networks/ethereum/consensus/nimbus.rs
Normal file
49
orchestration/src/networks/ethereum/consensus/nimbus.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use crate::Network;
|
||||
|
||||
pub fn nimbus(network: Network) -> (String, String, String) {
|
||||
assert_ne!(network, Network::Dev);
|
||||
|
||||
let platform = match std::env::consts::ARCH {
|
||||
"x86_64" => "amd64",
|
||||
"arm" => "arm32v7",
|
||||
"aarch64" => "arm64v8",
|
||||
_ => panic!("unsupported platform"),
|
||||
};
|
||||
|
||||
#[rustfmt::skip]
|
||||
let checksum = match platform {
|
||||
"amd64" => "5da10222cfb555ce2e3820ece12e8e30318945e3ed4b2b88d295963c879daeee071623c47926f880f3db89ce537fd47c6b26fe37e47aafbae3222b58bcec2fba",
|
||||
"arm32v7" => "7055da77bfa1186ee2e7ce2a48b923d45ccb039592f529c58d93d55a62bca46566ada451bd7497c3ae691260544f0faf303602afd85ccc18388fdfdac0bb2b45",
|
||||
"arm64v8" => "1a68f44598462abfade0dbeb6adf10b52614ba03605a8bf487b99493deb41468317926ef2d657479fcc26fce640aeebdbd880956beec3fb110b5abc97bd83556",
|
||||
_ => panic!("unsupported platform"),
|
||||
};
|
||||
|
||||
#[rustfmt::skip]
|
||||
let download_nimbus = format!(r#"
|
||||
FROM alpine:latest as nimbus
|
||||
|
||||
ENV NIMBUS_VERSION=24.3.0
|
||||
ENV NIMBUS_COMMIT=dc19b082
|
||||
|
||||
# Download nimbus
|
||||
RUN wget https://github.com/status-im/nimbus-eth2/releases/download/v${{NIMBUS_VERSION}}/nimbus-eth2_Linux_{platform}_${{NIMBUS_VERSION}}_${{NIMBUS_COMMIT}}.tar.gz
|
||||
|
||||
# Extract nimbus
|
||||
RUN tar xvf nimbus-eth2_Linux_{platform}_${{NIMBUS_VERSION}}_${{NIMBUS_COMMIT}}.tar.gz
|
||||
RUN mv nimbus-eth2_Linux_{platform}_${{NIMBUS_VERSION}}_${{NIMBUS_COMMIT}}/build/nimbus_beacon_node ./nimbus
|
||||
|
||||
# Verify the checksum
|
||||
RUN sha512sum nimbus | grep {checksum}
|
||||
"#);
|
||||
|
||||
let run_nimbus = format!(
|
||||
r#"
|
||||
COPY --from=nimbus --chown=ethereum nimbus /bin
|
||||
|
||||
ADD /orchestration/{}/networks/ethereum/consensus/nimbus/run.sh /consensus_layer.sh
|
||||
"#,
|
||||
network.label()
|
||||
);
|
||||
|
||||
(download_nimbus, String::new(), run_nimbus)
|
||||
}
|
||||
14
orchestration/src/networks/ethereum/execution/anvil.rs
Normal file
14
orchestration/src/networks/ethereum/execution/anvil.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use crate::Network;
|
||||
|
||||
pub fn anvil(network: Network) -> (String, String, String) {
|
||||
assert_eq!(network, Network::Dev);
|
||||
|
||||
const ANVIL_SETUP: &str = r#"
|
||||
RUN curl -L https://foundry.paradigm.xyz | bash || exit 0
|
||||
RUN ~/.foundry/bin/foundryup
|
||||
|
||||
EXPOSE 8545
|
||||
"#;
|
||||
|
||||
(String::new(), "RUN apt install git curl -y".to_string(), ANVIL_SETUP.to_string())
|
||||
}
|
||||
5
orchestration/src/networks/ethereum/execution/mod.rs
Normal file
5
orchestration/src/networks/ethereum/execution/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
mod reth;
|
||||
pub use reth::reth;
|
||||
|
||||
mod anvil;
|
||||
pub use anvil::anvil;
|
||||
38
orchestration/src/networks/ethereum/execution/reth.rs
Normal file
38
orchestration/src/networks/ethereum/execution/reth.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use crate::Network;
|
||||
|
||||
pub fn reth(network: Network) -> (String, String, String) {
|
||||
assert_ne!(network, Network::Dev);
|
||||
|
||||
#[rustfmt::skip]
|
||||
const DOWNLOAD_RETH: &str = r#"
|
||||
FROM alpine:latest as reth
|
||||
|
||||
ENV RETH_VERSION=0.2.0-beta.6
|
||||
|
||||
RUN apk --no-cache add git gnupg
|
||||
|
||||
# Download reth
|
||||
RUN wget https://github.com/paradigmxyz/reth/releases/download/v${RETH_VERSION}/reth-v${RETH_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz
|
||||
RUN wget https://github.com/paradigmxyz/reth/releases/download/v${RETH_VERSION}/reth-v${RETH_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz.asc
|
||||
|
||||
# Verify the signature
|
||||
gpg --keyserver keyserver.ubuntu.com --recv-keys A3AE097C89093A124049DF1F5391A3C4100530B4
|
||||
gpg --verify reth-v${RETH_VERSION}-$(uname -m).tar.gz.asc reth-v${RETH_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz
|
||||
|
||||
# Extract reth
|
||||
RUN tar xvf reth-v${RETH_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz
|
||||
"#;
|
||||
|
||||
let run_reth = format!(
|
||||
r#"
|
||||
COPY --from=reth --chown=ethereum reth /bin
|
||||
|
||||
EXPOSE 30303 9001 8545
|
||||
|
||||
ADD /orchestration/{}/networks/ethereum/execution/reth/run.sh /execution_layer.sh
|
||||
"#,
|
||||
network.label()
|
||||
);
|
||||
|
||||
(DOWNLOAD_RETH.to_string(), String::new(), run_reth)
|
||||
}
|
||||
43
orchestration/src/networks/ethereum/mod.rs
Normal file
43
orchestration/src/networks/ethereum/mod.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{Network, Os, mimalloc, os, write_dockerfile};
|
||||
|
||||
mod execution;
|
||||
use execution::*;
|
||||
|
||||
mod consensus;
|
||||
use consensus::*;
|
||||
|
||||
pub fn ethereum(orchestration_path: &Path, network: Network) {
|
||||
let ((el_download, el_run_as_root, el_run), (cl_download, cl_run_as_root, cl_run)) =
|
||||
if network == Network::Dev {
|
||||
(anvil(network), (String::new(), String::new(), String::new()))
|
||||
} else {
|
||||
// TODO: Select an EL/CL based off a RNG seeded from the public key
|
||||
(reth(network), nimbus(network))
|
||||
};
|
||||
|
||||
let download = mimalloc(Os::Alpine).to_string() + &el_download + &cl_download;
|
||||
|
||||
let run = format!(
|
||||
r#"
|
||||
ADD /orchestration/{}/networks/ethereum/run.sh /run.sh
|
||||
CMD ["/run.sh"]
|
||||
"#,
|
||||
network.label()
|
||||
);
|
||||
let run = mimalloc(Os::Debian).to_string() +
|
||||
&os(Os::Debian, &(el_run_as_root + "\r\n" + &cl_run_as_root), "ethereum") +
|
||||
&el_run +
|
||||
&cl_run +
|
||||
&run;
|
||||
|
||||
let res = download + &run;
|
||||
|
||||
let mut ethereum_path = orchestration_path.to_path_buf();
|
||||
ethereum_path.push("networks");
|
||||
ethereum_path.push("ethereum");
|
||||
ethereum_path.push("Dockerfile");
|
||||
|
||||
write_dockerfile(ethereum_path, &res);
|
||||
}
|
||||
8
orchestration/src/networks/mod.rs
Normal file
8
orchestration/src/networks/mod.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
mod bitcoin;
|
||||
pub use bitcoin::*;
|
||||
|
||||
mod ethereum;
|
||||
pub use ethereum::*;
|
||||
|
||||
mod monero;
|
||||
pub use monero::*;
|
||||
84
orchestration/src/networks/monero.rs
Normal file
84
orchestration/src/networks/monero.rs
Normal file
@@ -0,0 +1,84 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{Network, Os, mimalloc, write_dockerfile};
|
||||
|
||||
fn monero_internal(
|
||||
network: Network,
|
||||
os: Os,
|
||||
orchestration_path: &Path,
|
||||
folder: &str,
|
||||
monero_binary: &str,
|
||||
ports: &str,
|
||||
) {
|
||||
const MONERO_VERSION: &str = "0.18.3.1";
|
||||
|
||||
let arch = match std::env::consts::ARCH {
|
||||
// We probably would run this without issues yet it's not worth needing to provide support for
|
||||
"x86" | "arm" => panic!("unsupported architecture, please download a 64-bit OS"),
|
||||
"x86_64" => "x64",
|
||||
"aarch64" => "armv8",
|
||||
_ => panic!("unsupported architecture"),
|
||||
};
|
||||
|
||||
#[rustfmt::skip]
|
||||
let download_monero = format!(r#"
|
||||
FROM alpine:latest as monero
|
||||
|
||||
RUN apk --no-cache add gnupg
|
||||
|
||||
# Download Monero
|
||||
RUN wget https://downloads.getmonero.org/cli/monero-linux-{arch}-v{MONERO_VERSION}.tar.bz2
|
||||
|
||||
# Verify Binary -- fingerprint from https://github.com/monero-project/monero-site/issues/1949
|
||||
ADD orchestration/{}/networks/monero/hashes-v{MONERO_VERSION}.txt .
|
||||
RUN gpg --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options no-self-sigs-only --receive-keys 81AC591FE9C4B65C5806AFC3F0AF4D462A0BDF92 && \
|
||||
gpg --verify hashes-v{MONERO_VERSION}.txt && \
|
||||
grep "$(sha256sum monero-linux-{arch}-v{MONERO_VERSION}.tar.bz2 | cut -c 1-64)" hashes-v{MONERO_VERSION}.txt
|
||||
|
||||
# Extract it
|
||||
RUN tar -xvjf monero-linux-{arch}-v{MONERO_VERSION}.tar.bz2 --strip-components=1
|
||||
"#,
|
||||
network.label(),
|
||||
);
|
||||
|
||||
let setup = mimalloc(os).to_string() + &download_monero;
|
||||
|
||||
let run_monero = format!(
|
||||
r#"
|
||||
COPY --from=monero --chown=monero:nogroup {monero_binary} /bin
|
||||
|
||||
EXPOSE {ports}
|
||||
|
||||
ADD /orchestration/{}/networks/{folder}/run.sh /
|
||||
CMD ["/run.sh"]
|
||||
"#,
|
||||
network.label(),
|
||||
);
|
||||
|
||||
let run =
|
||||
crate::os(os, if os == Os::Alpine { "RUN apk --no-cache add gcompat" } else { "" }, "monero") +
|
||||
&run_monero;
|
||||
let res = setup + &run;
|
||||
|
||||
let mut monero_path = orchestration_path.to_path_buf();
|
||||
monero_path.push("networks");
|
||||
monero_path.push(folder);
|
||||
monero_path.push("Dockerfile");
|
||||
|
||||
write_dockerfile(monero_path, &res);
|
||||
}
|
||||
|
||||
pub fn monero(orchestration_path: &Path, network: Network) {
|
||||
monero_internal(network, Os::Debian, orchestration_path, "monero", "monerod", "18080 18081")
|
||||
}
|
||||
|
||||
pub fn monero_wallet_rpc(orchestration_path: &Path) {
|
||||
monero_internal(
|
||||
Network::Dev,
|
||||
Os::Debian,
|
||||
orchestration_path,
|
||||
"monero-wallet-rpc",
|
||||
"monero-wallet-rpc",
|
||||
"18082",
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user