Add a dev ethereum Docker setup

Also adds untested Dockerfiles for reth, lighthouse, and nimbus.
This commit is contained in:
Luke Parker 2024-04-24 09:25:11 -04:00
parent d57fef8999
commit cef63a631a
No known key found for this signature in database
21 changed files with 217 additions and 19 deletions

View file

@ -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

View file

@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;
use crate::{Network, Os, mimalloc, os, write_dockerfile};

View file

@ -1,5 +0,0 @@
use std::path::Path;
pub fn ethereum(_orchestration_path: &Path) {
// TODO
}

View 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/{}/coins/ethereum/consensus/lighthouse/run.sh /consensus_layer.sh
"#,
network.label()
);
(DOWNLOAD_LIGHTHOUSE.to_string(), String::new(), run_lighthouse)
}

View file

@ -0,0 +1,6 @@
mod lighthouse;
#[allow(unused)]
pub use lighthouse::lighthouse;
mod nimbus;
pub use nimbus::nimbus;

View 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/{}/coins/ethereum/consensus/nimbus/run.sh /consensus_layer.sh
"#,
network.label()
);
(download_nimbus, String::new(), run_nimbus)
}

View 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())
}

View file

@ -0,0 +1,5 @@
mod reth;
pub use reth::reth;
mod anvil;
pub use anvil::anvil;

View 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/{}/coins/ethereum/execution/reth/run.sh /execution_layer.sh
"#,
network.label()
);
(DOWNLOAD_RETH.to_string(), String::new(), run_reth)
}

View 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/{}/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);
}

View file

@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;
use crate::{Network, Os, mimalloc, write_dockerfile};

View file

@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;
use zeroize::Zeroizing;

View file

@ -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);

View file

@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;
use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto};

View file

@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;
use zeroize::Zeroizing;

View file

@ -1,4 +1,4 @@
use std::{path::Path};
use std::path::Path;
use zeroize::Zeroizing;
use ciphersuite::{group::ff::PrimeField, Ciphersuite, Ristretto};

View file

@ -0,0 +1,3 @@
#!/bin/sh
RUST_LOG=info lighthouse bn --execution-endpoint http://localhost:8551 --execution-jwt /home/ethereum/.jwt

View file

@ -0,0 +1,3 @@
#!/bin/sh
exit 1

View file

@ -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

View file

@ -0,0 +1,3 @@
#!/bin/sh
RUST_LOG=info reth node --authrpc.jwtsecret /home/ethereum/.jwt

View file

@ -1,3 +1 @@
#!/bin/sh
exit 1
/execution_layer.sh & /consensus_layer.sh