Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ members = [
edition = "2024"

[workspace.dependencies]
beetswap = "0.5"
blockstore = "0.8"
leopard-codec = "0.2"
lumina-node = { version = "0.18.2", path = "node" }
Expand Down Expand Up @@ -94,7 +93,6 @@ web-sys = "0.3.70"

[patch.crates-io]
# Uncomment to apply local changes
# beetswap = { path = "../beetswap" }
# blockstore = { path = "../blockstore" }
# nmt-rs = { path = "../nmt-rs" }
# libp2p = { path = "../../rust-libp2p/libp2p" }
Expand Down
4 changes: 2 additions & 2 deletions ci/Dockerfile.node
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ FROM docker.io/alpine:3.20
RUN apk update && apk add --no-cache bash jq dasel

# Copy in the binary
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.28.2 /bin/celestia /bin/celestia
COPY --from=ghcr.io/celestiaorg/celestia-node:v0.28.2 /bin/cel-key /bin/cel-key
COPY --from=celestia-node /bin/celestia /bin/celestia
COPY --from=celestia-node /bin/cel-key /bin/cel-key

COPY ./run-node.sh /opt/entrypoint.sh

Expand Down
6 changes: 3 additions & 3 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:

node-0:
image: node
platform: "linux/amd64"
# platform: "linux/amd64"
build:
context: .
dockerfile: Dockerfile.node
Expand All @@ -63,7 +63,7 @@ services:

node-1:
image: node
platform: "linux/amd64"
# platform: "linux/amd64"
build:
context: .
dockerfile: Dockerfile.node
Expand All @@ -76,7 +76,7 @@ services:

node-2:
image: node
platform: "linux/amd64"
# platform: "linux/amd64"
build:
context: .
dockerfile: Dockerfile.node
Expand Down
12 changes: 6 additions & 6 deletions node-uniffi/src/types/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ pub enum NodeEvent {
/// The column of the share.
column: u16,
/// Share sampling timed out.
timed_out: bool,
failed: bool,
},
/// Sampling result.
SamplingResult {
/// The block height that was sampled.
height: u64,
/// Sampling timed out.
timed_out: bool,
failed: bool,
/// How much time sampling took in milliseconds.
took_ms: u64,
},
Expand Down Expand Up @@ -187,21 +187,21 @@ impl From<LuminaNodeEvent> for NodeEvent {
square_width,
row,
column,
timed_out,
failed,
} => NodeEvent::ShareSamplingResult {
height,
square_width,
row,
column,
timed_out,
failed,
},
LuminaNodeEvent::SamplingResult {
height,
timed_out,
failed,
took,
} => NodeEvent::SamplingResult {
height,
timed_out,
failed,
took_ms: took.as_millis() as u64,
},
LuminaNodeEvent::FatalDaserError { error } => NodeEvent::FatalDaserError { error },
Expand Down
2 changes: 0 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ categories = [
crate-type = ["lib", "staticlib", "cdylib"]

[dependencies]
beetswap.workspace = true
celestia-proto.workspace = true
celestia-types.workspace = true
lumina-utils = { workspace = true, features = ["executor", "token", "time"] }
Expand Down Expand Up @@ -84,7 +83,6 @@ rustls-pki-types = "1.11"

[target.'cfg(target_arch = "wasm32")'.dependencies]
backoff = { version = "0.4", features = ["wasm-bindgen"] }
beetswap = { workspace = true, features = ["wasm-bindgen"] }
blockstore = { workspace = true, features = ["indexeddb"] }
celestia-types = { workspace = true, features = ["wasm-bindgen"] }
getrandom_03.workspace = true
Expand Down
99 changes: 0 additions & 99 deletions node/src/blockstore.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
//! Blockstore types aliases with lumina specific constants.

use blockstore::{Blockstore, Result};
use celestia_types::sample::SAMPLE_ID_CODEC;
use cid::CidGeneric;

use crate::p2p::MAX_MH_SIZE;

/// An [`InMemoryBlockstore`] with maximum multihash size used by lumina.
Expand All @@ -22,98 +18,3 @@ pub type RedbBlockstore = blockstore::RedbBlockstore;
///
/// [`IndexedDbBlockstore`]: blockstore::IndexedDbBlockstore
pub type IndexedDbBlockstore = blockstore::IndexedDbBlockstore;

/// A blockstore which only stores samples and discards other CIDs.
pub(crate) struct SampleBlockstore<B> {
blockstore: B,
}

impl<B> SampleBlockstore<B> {
/// Wrap another blockstore with sample blockstore.
pub(crate) fn new(blockstore: B) -> Self {
Self { blockstore }
}
}

impl<B> Blockstore for SampleBlockstore<B>
where
B: Blockstore,
{
async fn get<const S: usize>(&self, cid: &CidGeneric<S>) -> Result<Option<Vec<u8>>> {
self.blockstore.get(cid).await
}

async fn put_keyed<const S: usize>(&self, cid: &CidGeneric<S>, data: &[u8]) -> Result<()> {
if cid.codec() == SAMPLE_ID_CODEC {
self.blockstore.put_keyed(cid, data).await
} else {
Ok(())
}
}

async fn remove<const S: usize>(&self, cid: &CidGeneric<S>) -> Result<()> {
self.blockstore.remove(cid).await
}

async fn has<const S: usize>(&self, cid: &CidGeneric<S>) -> Result<bool> {
self.blockstore.has(cid).await
}

async fn close(self) -> Result<()> {
self.blockstore.close().await
}
}

#[cfg(test)]
mod tests {
use blockstore::Blockstore;
use celestia_types::{
nmt::Namespace, row::RowId, row_namespace_data::RowNamespaceDataId, sample::SampleId,
};
use lumina_utils::test_utils::async_test;

use super::{InMemoryBlockstore, SampleBlockstore};

#[async_test]
async fn should_only_store_samples() {
macro_rules! cid {
($bytes:expr) => {
::cid::CidGeneric::try_from($bytes).unwrap()
};
($id:ty, $($args:expr),+ $(,)?) => {
$crate::p2p::shwap::convert_cid(
&<$id>::new($($args),+).unwrap().into()
)
.unwrap()
};
}

let blockstore = SampleBlockstore::new(InMemoryBlockstore::new());

let sample_cids = [
cid!(SampleId, 1, 2, 3),
cid!(SampleId, 1111, 232, 33),
cid!(SampleId, 123, 1, 888888888),
];

let non_sample_cids = [
cid!(RowId, 1, 1737),
cid!(RowId, 8812, 193139),
cid!(RowNamespaceDataId, Namespace::new_v0(b"a").unwrap(), 15, 12),
cid!(RowNamespaceDataId, Namespace::new_v0(b"z").unwrap(), 1, 1),
cid!([1; 64].as_ref()),
cid!([[1].as_ref(), &[18; 63]].concat()),
];

for cid in sample_cids.iter().chain(non_sample_cids.iter()) {
blockstore.put_keyed(cid, &[10; 150]).await.unwrap();
}

for cid in &sample_cids {
assert!(blockstore.has(cid).await.unwrap());
}
for cid in &non_sample_cids {
assert!(!blockstore.has(cid).await.unwrap());
}
}
}
Loading
Loading