11 releases (7 breaking)

0.8.0 Dec 2, 2024
0.7.0 Dec 2, 2024
0.6.0 Oct 29, 2024
0.5.1 Oct 11, 2024
0.1.1 Jan 15, 2024

#2 in #lumina

Download history 6/week @ 2024-08-29 13/week @ 2024-09-12 140/week @ 2024-09-19 52/week @ 2024-09-26 174/week @ 2024-10-03 200/week @ 2024-10-10 28/week @ 2024-10-17 101/week @ 2024-10-24 37/week @ 2024-10-31 11/week @ 2024-11-07 4/week @ 2024-11-14 5/week @ 2024-11-21 247/week @ 2024-11-28 69/week @ 2024-12-05 23/week @ 2024-12-12

345 downloads per month
Used in 2 crates

Apache-2.0

1MB
20K SLoC

Lumina node

A crate to configure, run and interact with Celestia's data availability nodes.

use std::sync::Arc;
use libp2p::{identity, multiaddr::Protocol, Multiaddr};
use lumina_node::blockstore::RedbBlockstore;
use lumina_node::network::{
    canonical_network_bootnodes, network_id, Network,
};
use lumina_node::node::{Node, NodeConfig};
use lumina_node::store::RedbStore;
use tokio::task::spawn_blocking;

#[tokio::main]
async fn main() {
    let p2p_local_keypair = identity::Keypair::generate_ed25519();
    let network = Network::Mainnet;
    let network_id = network_id(network).to_owned();
    let p2p_bootnodes = canonical_network_bootnodes(network).collect();

    let db = spawn_blocking(|| redb::Database::create("path/to/db"))
        .await
        .expect("Failed to join")
        .expect("Failed to open the database");
    let db = Arc::new(db);

    let store = RedbStore::new(db.clone())
        .await
        .expect("Failed to create a store");
    let blockstore = RedbBlockstore::new(db);

    let node = Node::new(NodeConfig {
        network_id,
        p2p_local_keypair,
        p2p_bootnodes,
        p2p_listen_on: vec!["/ip4/0.0.0.0/tcp/0".parse().unwrap()],
        sync_batch_size: 512,
        custom_syncing_window: None,
        blockstore,
        store,
    })
    .await
    .expect("Failed to start node");

    node.wait_connected().await.expect("Failed to connect");

    let header = node
        .request_header_by_height(15)
        .await
        .expect("Height not found");
}

Dependencies

~27–64MB
~1M SLoC