|
| 1 | +use serde::Deserialize; |
| 2 | +use spec::{Arg, Babel, ComputeResource, Deployment, DeploymentExtension, Manifest, Pod, Spec, Volume}; |
| 3 | + |
| 4 | +#[derive(Default, Clone)] |
| 5 | +pub enum Chains { |
| 6 | + #[default] |
| 7 | + Mainnet, |
| 8 | +} |
| 9 | + |
| 10 | +#[derive(Default, Deserialize)] |
| 11 | +pub struct TempoDeploymentInput { |
| 12 | + pub tempo: Tempo, |
| 13 | +} |
| 14 | + |
| 15 | +#[derive(Default, Deserialize)] |
| 16 | +pub struct TempoDeployment {} |
| 17 | + |
| 18 | +impl Deployment for TempoDeployment { |
| 19 | + type Input = TempoDeploymentInput; |
| 20 | + type Chains = Chains; |
| 21 | + |
| 22 | + fn manifest(&self, chain: Chains, input: TempoDeploymentInput) -> eyre::Result<Manifest> { |
| 23 | + let mut manifest = Manifest::new("tempo".to_string()); |
| 24 | + |
| 25 | + let tempo_pod = input.tempo.spec(chain)?; |
| 26 | + manifest.add_spec("tempo".to_string(), tempo_pod); |
| 27 | + |
| 28 | + Ok(manifest) |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +#[derive(Default, Deserialize)] |
| 33 | +pub struct Tempo {} |
| 34 | + |
| 35 | +impl ComputeResource for Tempo { |
| 36 | + type Chains = Chains; |
| 37 | + |
| 38 | + fn spec(&self, _chain: Chains) -> eyre::Result<Pod> { |
| 39 | + let node = Spec::builder() |
| 40 | + .image("ghcr.io/tempo-xyz/tempo") |
| 41 | + .tag("1.0.1") |
| 42 | + .volume(Volume { |
| 43 | + name: "data".to_string(), |
| 44 | + path: "/data".to_string(), |
| 45 | + }) |
| 46 | + .arg("node") |
| 47 | + .arg("-vvv") |
| 48 | + .arg("--follow") |
| 49 | + .arg2("--datadir", "/data") |
| 50 | + .arg2("--port", "30303") |
| 51 | + .arg2("--discovery.addr", "0.0.0.0") |
| 52 | + .arg2("--discovery.port", "30303") |
| 53 | + .arg("--http") |
| 54 | + .arg2("--http.addr", "0.0.0.0") |
| 55 | + .arg2( |
| 56 | + "--http.port", |
| 57 | + Arg::Port { |
| 58 | + name: "http".to_string(), |
| 59 | + preferred: 8545, |
| 60 | + }, |
| 61 | + ) |
| 62 | + .arg2("--http.api", "eth,net,web3,txpool,trace") |
| 63 | + .arg("--ws") |
| 64 | + .arg2("--ws.addr", "0.0.0.0") |
| 65 | + .arg2( |
| 66 | + "--ws.port", |
| 67 | + Arg::Port { |
| 68 | + name: "ws".to_string(), |
| 69 | + preferred: 8546, |
| 70 | + }, |
| 71 | + ) |
| 72 | + .arg2("--ws.api", "eth,net,web3,txpool,trace") |
| 73 | + .arg2( |
| 74 | + "--metrics", |
| 75 | + Arg::Port { |
| 76 | + name: "metrics".to_string(), |
| 77 | + preferred: 9000, |
| 78 | + }, |
| 79 | + ) |
| 80 | + .with_babel(Babel::new( |
| 81 | + "ethereum", |
| 82 | + Arg::Ref { |
| 83 | + name: "tempo-node".to_string(), |
| 84 | + port: "http".to_string(), |
| 85 | + }, |
| 86 | + )); |
| 87 | + |
| 88 | + Ok(Pod::default().with_spec("node", node)) |
| 89 | + } |
| 90 | +} |
0 commit comments