diff --git a/Cargo.lock b/Cargo.lock index d183c75d..47b4303e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3136,7 +3136,6 @@ dependencies = [ "futures", "getrandom", "gloo-timers 0.3.0", - "hex", "instant", "libp2p", "lumina-node", diff --git a/cli/src/native.rs b/cli/src/native.rs index 81f29b54..7fcf437e 100644 --- a/cli/src/native.rs +++ b/cli/src/native.rs @@ -10,7 +10,7 @@ use directories::ProjectDirs; use libp2p::{identity, multiaddr::Protocol, Multiaddr}; use lumina_node::blockstore::RedbBlockstore; use lumina_node::events::NodeEvent; -use lumina_node::network::{canonical_network_bootnodes, network_genesis, network_id, Network}; +use lumina_node::network::{canonical_network_bootnodes, network_id, Network}; use lumina_node::node::{Node, NodeConfig}; use lumina_node::store::{RedbStore, Store}; use tokio::task::spawn_blocking; @@ -54,7 +54,6 @@ pub(crate) async fn run(args: Params) -> Result<()> { }; let network_id = network_id(network).to_owned(); - let genesis_hash = network_genesis(network); info!("Initializing store"); let db = open_db(args.store, &network_id).await?; @@ -70,7 +69,6 @@ pub(crate) async fn run(args: Params) -> Result<()> { let (_node, mut events) = Node::new_subscribed(NodeConfig { network_id, - genesis_hash, p2p_local_keypair, p2p_bootnodes, p2p_listen_on: args.listen_addrs, diff --git a/cli/src/server.rs b/cli/src/server.rs index 40ce19f3..ab1fda43 100644 --- a/cli/src/server.rs +++ b/cli/src/server.rs @@ -7,11 +7,10 @@ use axum::http::{header, StatusCode}; use axum::response::Response; use axum::routing::get; use axum::{Json, Router}; -use celestia_types::hash::Hash; use clap::Args; use libp2p::multiaddr::Protocol; use libp2p::Multiaddr; -use lumina_node::network::{canonical_network_bootnodes, network_genesis}; +use lumina_node::network::canonical_network_bootnodes; use rust_embed::RustEmbed; use serde::Serialize; use tokio::net::TcpListener; @@ -25,7 +24,6 @@ const SERVER_DEFAULT_BIND_ADDR: &str = "127.0.0.1:9876"; struct WasmNodeArgs { pub network: ArgNetwork, pub bootnodes: Vec, - pub genesis_hash: Option, } #[derive(RustEmbed)] @@ -53,7 +51,6 @@ pub(crate) struct Params { pub(crate) async fn run(args: Params) -> Result<()> { let network = args.network.into(); - let genesis_hash = network_genesis(network); let bootnodes = if args.bootnodes.is_empty() { canonical_network_bootnodes(network) .filter(|addr| addr.iter().any(|proto| proto == Protocol::WebTransport)) @@ -65,7 +62,6 @@ pub(crate) async fn run(args: Params) -> Result<()> { let state = WasmNodeArgs { network: args.network, bootnodes, - genesis_hash, }; let app = Router::new() diff --git a/cli/static/index.html b/cli/static/index.html index bb14cb97..becc32ed 100644 --- a/cli/static/index.html +++ b/cli/static/index.html @@ -93,9 +93,6 @@

Network

-

Genesis Hash

- -

Bootnodes

diff --git a/cli/static/run_node.js b/cli/static/run_node.js index 67fa6f64..46f021be 100644 --- a/cli/static/run_node.js +++ b/cli/static/run_node.js @@ -12,9 +12,6 @@ async function fetch_config() { if (json.bootnodes.length !== 0) { config.bootnodes = json.bootnodes; } - if (json.genesis) { - config.genesis = json.genesis; - } return config; } @@ -53,12 +50,10 @@ async function show_stats(node) { function bind_config(data) { const network_div = document.getElementById("network-id"); - const genesis_div = document.getElementById("genesis-hash"); const bootnodes_div = document.getElementById("bootnodes"); const update_config_elements = () => { network_div.value = window.config.network; - genesis_div.value = window.config.genesis_hash || ""; bootnodes_div.value = window.config.bootnodes.join("\n"); } @@ -67,9 +62,8 @@ function bind_config(data) { if (prop == "network") { const config = NodeConfig.default(Number(value)); obj.network = config.network; - obj.genesis_hash = config.genesis_hash; obj.bootnodes = config.bootnodes; - } else if (prop == "genesis_hash" || prop == "bootnodes") { + } else if (prop == "bootnodes") { obj[prop] = value; } else { return Reflect.set(obj, prop, value); @@ -87,9 +81,6 @@ function bind_config(data) { network_div.addEventListener("change", event => { window.config.network = Number(event.target.value.trim()); }); - genesis_div.addEventListener("change", event => { - window.config.genesis_hash = event.target.value.trim(); - }); bootnodes_div.addEventListener("change", event => { window.config.bootnodes = event.target.value.trim().split("\n").map(multiaddr => multiaddr.trim()); }); diff --git a/node-wasm/src/node.rs b/node-wasm/src/node.rs index fa277a11..470580f8 100644 --- a/node-wasm/src/node.rs +++ b/node-wasm/src/node.rs @@ -9,7 +9,7 @@ use wasm_bindgen::prelude::*; use web_sys::BroadcastChannel; use lumina_node::blockstore::IndexedDbBlockstore; -use lumina_node::network::{canonical_network_bootnodes, network_genesis, network_id}; +use lumina_node::network::{canonical_network_bootnodes, network_id}; use lumina_node::node::NodeConfig; use lumina_node::store::IndexedDbStore; @@ -27,9 +27,6 @@ const LUMINA_WORKER_NAME: &str = "lumina"; pub struct WasmNodeConfig { /// A network to connect to. pub network: Network, - /// Hash of the genesis block in the network. - #[wasm_bindgen(getter_with_clone)] - pub genesis_hash: Option, /// A list of bootstrap peers to connect to. #[wasm_bindgen(getter_with_clone)] pub bootnodes: Vec, @@ -347,11 +344,10 @@ impl NodeDriver { #[wasm_bindgen(js_class = NodeConfig)] impl WasmNodeConfig { - /// Get the configuration with default bootnodes and genesis hash for provided network + /// Get the configuration with default bootnodes for provided network pub fn default(network: Network) -> WasmNodeConfig { WasmNodeConfig { network, - genesis_hash: network_genesis(network.into()).map(|h| h.to_string()), bootnodes: canonical_network_bootnodes(network.into()) .filter(|addr| addr.iter().any(|proto| proto == Protocol::WebTransport)) .map(|addr| addr.to_string()) @@ -372,12 +368,6 @@ impl WasmNodeConfig { let p2p_local_keypair = Keypair::generate_ed25519(); - let genesis_hash = self - .genesis_hash - .map(|h| h.parse()) - .transpose() - .context("genesis hash invalid")?; - let p2p_bootnodes = self .bootnodes .iter() @@ -387,7 +377,6 @@ impl WasmNodeConfig { Ok(NodeConfig { network_id: network_id.to_string(), - genesis_hash, p2p_bootnodes, p2p_local_keypair, p2p_listen_on: vec![], diff --git a/node/Cargo.toml b/node/Cargo.toml index 12c073ea..dad83eb0 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -38,7 +38,6 @@ beetswap = "0.1.1" cid = { version = "0.11.1", features = ["serde-codec"] } dashmap = "5.5.3" futures = "0.3.30" -hex = "0.4.3" instant = "0.1.13" prost = "0.12.6" rand = "0.8.5" diff --git a/node/README.md b/node/README.md index 981ebfeb..a897bf1e 100644 --- a/node/README.md +++ b/node/README.md @@ -7,7 +7,7 @@ use std::sync::Arc; use libp2p::{identity, multiaddr::Protocol, Multiaddr}; use lumina_node::blockstore::RedbBlockstore; use lumina_node::network::{ - canonical_network_bootnodes, network_genesis, network_id, Network, + canonical_network_bootnodes, network_id, Network, }; use lumina_node::node::{Node, NodeConfig}; use lumina_node::store::RedbStore; @@ -18,7 +18,6 @@ async fn main() { let p2p_local_keypair = identity::Keypair::generate_ed25519(); let network = Network::Mainnet; let network_id = network_id(network).to_owned(); - let genesis_hash = network_genesis(network); let p2p_bootnodes = canonical_network_bootnodes(network).collect(); let db = spawn_blocking(|| redb::Database::create("path/to/db")) @@ -34,7 +33,6 @@ async fn main() { let node = Node::new(NodeConfig { network_id, - genesis_hash, p2p_local_keypair, p2p_bootnodes, p2p_listen_on: vec!["/ip4/0.0.0.0/tcp/0".parse().unwrap()], diff --git a/node/src/network.rs b/node/src/network.rs index a0bddf82..f95a3306 100644 --- a/node/src/network.rs +++ b/node/src/network.rs @@ -2,7 +2,6 @@ use std::str::FromStr; -use celestia_types::hash::Hash; use libp2p::Multiaddr; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -49,21 +48,6 @@ pub fn network_id(network: Network) -> &'static str { } } -/// Get the hash of a genesis block for the given network. -pub fn network_genesis(network: Network) -> Option { - let hex = match network { - Network::Mainnet => "6BE39EFD10BA412A9DB5288488303F5DD32CF386707A5BEF33617F4C43301872", - Network::Arabica => "5904E55478BA4B3002EE885621E007A2A6A2399662841912219AECD5D5CBE393", - Network::Mocha => "B93BBE20A0FBFDF955811B6420F8433904664D45DB4BF51022BE4200C1A1680D", - Network::Private => return None, - }; - - let bytes = hex::decode(hex).expect("failed decoding genesis hash"); - let array = bytes.try_into().expect("invalid genesis hash lenght"); - - Some(Hash::Sha256(array)) -} - /// Get official Celestia and Lumina bootnodes for the given network. pub fn canonical_network_bootnodes(network: Network) -> impl Iterator { let peers: &[_] = match network { @@ -103,21 +87,6 @@ pub fn canonical_network_bootnodes(network: Network) -> impl Iterator, /// The keypair to be used as [`Node`]s identity. pub p2p_local_keypair: Keypair, /// List of bootstrap nodes to connect to and trust. diff --git a/node/src/test_utils.rs b/node/src/test_utils.rs index 506d8e96..c62e5256 100644 --- a/node/src/test_utils.rs +++ b/node/src/test_utils.rs @@ -46,7 +46,6 @@ pub fn test_node_config() -> NodeConfig { let node_keypair = identity::Keypair::generate_ed25519(); NodeConfig { network_id: "private".to_string(), - genesis_hash: None, p2p_local_keypair: node_keypair, p2p_bootnodes: vec![], p2p_listen_on: vec![],