diff --git a/orchestration/dev/coins/ethereum/run.sh b/orchestration/dev/coins/ethereum/run.sh index 0b86ff69d..4fee3e461 100755 --- a/orchestration/dev/coins/ethereum/run.sh +++ b/orchestration/dev/coins/ethereum/run.sh @@ -1,6 +1,3 @@ #!/bin/sh -geth --dev --networkid 5208 --datadir "eth-devnet" \ - --http --http.api "web3,net,eth,miner" \ - --http.addr 0.0.0.0 --http.port 8545 \ - --http.vhosts="*" --http.corsdomain "*" +~/.foundry/bin/anvil --no-mining --slots-in-an-epoch 32 diff --git a/orchestration/src/coins/bitcoin.rs b/orchestration/src/coins/bitcoin.rs index 527b1062b..94686244b 100644 --- a/orchestration/src/coins/bitcoin.rs +++ b/orchestration/src/coins/bitcoin.rs @@ -1,4 +1,4 @@ -use std::{path::Path}; +use std::path::Path; use crate::{Network, Os, mimalloc, os, write_dockerfile}; diff --git a/orchestration/src/coins/ethereum.rs b/orchestration/src/coins/ethereum.rs deleted file mode 100644 index 2e15d3709..000000000 --- a/orchestration/src/coins/ethereum.rs +++ /dev/null @@ -1,5 +0,0 @@ -use std::path::Path; - -pub fn ethereum(_orchestration_path: &Path) { - // TODO -} diff --git a/orchestration/src/coins/ethereum/consensus/lighthouse.rs b/orchestration/src/coins/ethereum/consensus/lighthouse.rs new file mode 100644 index 000000000..add9728bb --- /dev/null +++ b/orchestration/src/coins/ethereum/consensus/lighthouse.rs @@ -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/{}/coins/ethereum/consensus/lighthouse/run.sh /consensus_layer.sh +"#, + network.label() + ); + + (DOWNLOAD_LIGHTHOUSE.to_string(), String::new(), run_lighthouse) +} diff --git a/orchestration/src/coins/ethereum/consensus/mod.rs b/orchestration/src/coins/ethereum/consensus/mod.rs new file mode 100644 index 000000000..4f64c0d89 --- /dev/null +++ b/orchestration/src/coins/ethereum/consensus/mod.rs @@ -0,0 +1,6 @@ +mod lighthouse; +#[allow(unused)] +pub use lighthouse::lighthouse; + +mod nimbus; +pub use nimbus::nimbus; diff --git a/orchestration/src/coins/ethereum/consensus/nimbus.rs b/orchestration/src/coins/ethereum/consensus/nimbus.rs new file mode 100644 index 000000000..07006aa94 --- /dev/null +++ b/orchestration/src/coins/ethereum/consensus/nimbus.rs @@ -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/{}/coins/ethereum/consensus/nimbus/run.sh /consensus_layer.sh +"#, + network.label() + ); + + (download_nimbus, String::new(), run_nimbus) +} diff --git a/orchestration/src/coins/ethereum/execution/anvil.rs b/orchestration/src/coins/ethereum/execution/anvil.rs new file mode 100644 index 000000000..53d894eca --- /dev/null +++ b/orchestration/src/coins/ethereum/execution/anvil.rs @@ -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()) +} diff --git a/orchestration/src/coins/ethereum/execution/mod.rs b/orchestration/src/coins/ethereum/execution/mod.rs new file mode 100644 index 000000000..3db59c844 --- /dev/null +++ b/orchestration/src/coins/ethereum/execution/mod.rs @@ -0,0 +1,5 @@ +mod reth; +pub use reth::reth; + +mod anvil; +pub use anvil::anvil; diff --git a/orchestration/src/coins/ethereum/execution/reth.rs b/orchestration/src/coins/ethereum/execution/reth.rs new file mode 100644 index 000000000..8c80a9faa --- /dev/null +++ b/orchestration/src/coins/ethereum/execution/reth.rs @@ -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/{}/coins/ethereum/execution/reth/run.sh /execution_layer.sh +"#, + network.label() + ); + + (DOWNLOAD_RETH.to_string(), String::new(), run_reth) +} diff --git a/orchestration/src/coins/ethereum/mod.rs b/orchestration/src/coins/ethereum/mod.rs new file mode 100644 index 000000000..a06318c07 --- /dev/null +++ b/orchestration/src/coins/ethereum/mod.rs @@ -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/{}/coins/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("coins"); + ethereum_path.push("ethereum"); + ethereum_path.push("Dockerfile"); + + write_dockerfile(ethereum_path, &res); +} diff --git a/orchestration/src/coins/monero.rs b/orchestration/src/coins/monero.rs index 873c64587..c21bc6107 100644 --- a/orchestration/src/coins/monero.rs +++ b/orchestration/src/coins/monero.rs @@ -1,4 +1,4 @@ -use std::{path::Path}; +use std::path::Path; use crate::{Network, Os, mimalloc, write_dockerfile}; diff --git a/orchestration/src/coordinator.rs b/orchestration/src/coordinator.rs index 67a245277..13fdff596 100644 --- a/orchestration/src/coordinator.rs +++ b/orchestration/src/coordinator.rs @@ -1,4 +1,4 @@ -use std::{path::Path}; +use std::path::Path; use zeroize::Zeroizing; diff --git a/orchestration/src/main.rs b/orchestration/src/main.rs index 4be84cd46..0e6c7cb00 100644 --- a/orchestration/src/main.rs +++ b/orchestration/src/main.rs @@ -266,7 +266,7 @@ fn dockerfiles(network: Network) { let orchestration_path = orchestration_path(network); bitcoin(&orchestration_path, network); - ethereum(&orchestration_path); + ethereum(&orchestration_path, network); monero(&orchestration_path, network); if network == Network::Dev { monero_wallet_rpc(&orchestration_path); diff --git a/orchestration/src/message_queue.rs b/orchestration/src/message_queue.rs index f16c6cbe9..eb662b671 100644 --- a/orchestration/src/message_queue.rs +++ b/orchestration/src/message_queue.rs @@ -1,4 +1,4 @@ -use std::{path::Path}; +use std::path::Path; use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto}; diff --git a/orchestration/src/processor.rs b/orchestration/src/processor.rs index 7ee69d117..8a2c8c776 100644 --- a/orchestration/src/processor.rs +++ b/orchestration/src/processor.rs @@ -1,4 +1,4 @@ -use std::{path::Path}; +use std::path::Path; use zeroize::Zeroizing; diff --git a/orchestration/src/serai.rs b/orchestration/src/serai.rs index 77d098b6e..2e1e915c0 100644 --- a/orchestration/src/serai.rs +++ b/orchestration/src/serai.rs @@ -1,4 +1,4 @@ -use std::{path::Path}; +use std::path::Path; use zeroize::Zeroizing; use ciphersuite::{group::ff::PrimeField, Ciphersuite, Ristretto}; diff --git a/orchestration/testnet/coins/ethereum/consensus/lighthouse/run.sh b/orchestration/testnet/coins/ethereum/consensus/lighthouse/run.sh new file mode 100755 index 000000000..1b3857bfe --- /dev/null +++ b/orchestration/testnet/coins/ethereum/consensus/lighthouse/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +RUST_LOG=info lighthouse bn --execution-endpoint http://localhost:8551 --execution-jwt /home/ethereum/.jwt diff --git a/orchestration/testnet/coins/ethereum/consensus/nimbus/run.sh b/orchestration/testnet/coins/ethereum/consensus/nimbus/run.sh new file mode 100755 index 000000000..2bb8d868b --- /dev/null +++ b/orchestration/testnet/coins/ethereum/consensus/nimbus/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exit 1 diff --git a/orchestration/testnet/coins/ethereum/execution/geth/run.sh b/orchestration/testnet/coins/ethereum/execution/geth/run.sh new file mode 100755 index 000000000..fee4a57c1 --- /dev/null +++ b/orchestration/testnet/coins/ethereum/execution/geth/run.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +#geth --dev --networkid 5208 \ +# --http --http.api "web3,net,eth,miner" \ +# --http.addr 0.0.0.0 --http.port 8545 \ +# --http.vhosts="*" --http.corsdomain "*" + +exit 1 diff --git a/orchestration/testnet/coins/ethereum/execution/reth/run.sh b/orchestration/testnet/coins/ethereum/execution/reth/run.sh new file mode 100755 index 000000000..5be8924a3 --- /dev/null +++ b/orchestration/testnet/coins/ethereum/execution/reth/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +RUST_LOG=info reth node --authrpc.jwtsecret /home/ethereum/.jwt diff --git a/orchestration/testnet/coins/ethereum/run.sh b/orchestration/testnet/coins/ethereum/run.sh index 2bb8d868b..82b8ff580 100755 --- a/orchestration/testnet/coins/ethereum/run.sh +++ b/orchestration/testnet/coins/ethereum/run.sh @@ -1,3 +1 @@ -#!/bin/sh - -exit 1 +/execution_layer.sh & /consensus_layer.sh