Skip to content

Commit

Permalink
Add a dev ethereum Docker setup
Browse files Browse the repository at this point in the history
Also adds untested Dockerfiles for reth, lighthouse, and nimbus.
  • Loading branch information
kayabaNerve committed Apr 24, 2024
1 parent d57fef8 commit cef63a6
Show file tree
Hide file tree
Showing 21 changed files with 217 additions and 19 deletions.
5 changes: 1 addition & 4 deletions orchestration/dev/coins/ethereum/run.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion orchestration/src/coins/bitcoin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;

use crate::{Network, Os, mimalloc, os, write_dockerfile};

Expand Down
5 changes: 0 additions & 5 deletions orchestration/src/coins/ethereum.rs

This file was deleted.

36 changes: 36 additions & 0 deletions orchestration/src/coins/ethereum/consensus/lighthouse.rs
Original file line number Diff line number Diff line change
@@ -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)
}
6 changes: 6 additions & 0 deletions orchestration/src/coins/ethereum/consensus/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mod lighthouse;
#[allow(unused)]
pub use lighthouse::lighthouse;

mod nimbus;
pub use nimbus::nimbus;
49 changes: 49 additions & 0 deletions orchestration/src/coins/ethereum/consensus/nimbus.rs
Original file line number Diff line number Diff line change
@@ -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)
}
14 changes: 14 additions & 0 deletions orchestration/src/coins/ethereum/execution/anvil.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions orchestration/src/coins/ethereum/execution/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod reth;
pub use reth::reth;

mod anvil;
pub use anvil::anvil;
38 changes: 38 additions & 0 deletions orchestration/src/coins/ethereum/execution/reth.rs
Original file line number Diff line number Diff line change
@@ -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)
}
43 changes: 43 additions & 0 deletions orchestration/src/coins/ethereum/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion orchestration/src/coins/monero.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;

use crate::{Network, Os, mimalloc, write_dockerfile};

Expand Down
2 changes: 1 addition & 1 deletion orchestration/src/coordinator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;

use zeroize::Zeroizing;

Expand Down
2 changes: 1 addition & 1 deletion orchestration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion orchestration/src/message_queue.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;

use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto};

Expand Down
2 changes: 1 addition & 1 deletion orchestration/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;

use zeroize::Zeroizing;

Expand Down
2 changes: 1 addition & 1 deletion orchestration/src/serai.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;

use zeroize::Zeroizing;
use ciphersuite::{group::ff::PrimeField, Ciphersuite, Ristretto};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUST_LOG=info lighthouse bn --execution-endpoint http://localhost:8551 --execution-jwt /home/ethereum/.jwt
3 changes: 3 additions & 0 deletions orchestration/testnet/coins/ethereum/consensus/nimbus/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

exit 1
8 changes: 8 additions & 0 deletions orchestration/testnet/coins/ethereum/execution/geth/run.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions orchestration/testnet/coins/ethereum/execution/reth/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUST_LOG=info reth node --authrpc.jwtsecret /home/ethereum/.jwt
4 changes: 1 addition & 3 deletions orchestration/testnet/coins/ethereum/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#!/bin/sh

exit 1
/execution_layer.sh & /consensus_layer.sh

0 comments on commit cef63a6

Please sign in to comment.