Skip to content

Commit 787826a

Browse files
committed
remove redundant comment and function
1 parent ab9f095 commit 787826a

24 files changed

Lines changed: 123 additions & 427 deletions

File tree

bin/ream/src/cli/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ mod tests {
211211

212212
#[test]
213213
fn test_cli_da_node_command() {
214-
// Explicit flags parse through to the config.
215214
let cli = Cli::parse_from([
216215
"program",
217216
"--verbosity",
@@ -234,7 +233,6 @@ mod tests {
234233
_ => unreachable!("This test should only validate the da node cli"),
235234
}
236235

237-
// Omitting --http-port falls back to DEFAULT_DATA_AVAILABILITY_HTTP_PORT.
238236
let cli = Cli::parse_from(["program", "da_node"]);
239237

240238
match cli.command {

bin/ream/src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,8 @@ pub async fn run_data_availability_node(
660660

661661
set_beacon_network_spec(config.network.clone());
662662

663-
// The DA RPC is a private, same-host channel to the local beacon, not a public
664-
// service. Refuse to start if bound anywhere reachable beyond this
665-
// machine, which would expose unauthenticated write/prune/read to the network.
663+
// The DA RPC is unauthenticated; it must never be reachable beyond
664+
// localhost.
666665
if !config.http_address.is_loopback() {
667666
error!(
668667
"refusing to start DA node: http address {} is not loopback; \
@@ -678,7 +677,6 @@ pub async fn run_data_availability_node(
678677
config.http_allow_origin,
679678
);
680679

681-
// Filesystem-backed store, rooted at the node's data directory.
682680
let store = Arc::new(DaFileStore::new(data_dir).expect("failed to open DA store"));
683681
let max_blobs_per_block =
684682
NonZeroUsize::new(beacon_network_spec().max_blobs_per_block_electra as usize)
@@ -693,9 +691,8 @@ pub async fn run_data_availability_node(
693691
ream_rpc_da::server::start(server_config, ingest_handle, store).await
694692
}));
695693

696-
// The KZG trusted setup is lazily loaded and expensive (seconds). Warm it up
697-
// now, off the async workers, so the first column to arrive doesn't pay that
698-
// cost mid-verification.
694+
// Warm the trusted setup (multi-second) off the async workers before the
695+
// first column arrives.
699696
if let Err(err) = executor
700697
.spawn_blocking(KzgVerifier::warm_up_trusted_setup)
701698
.await

crates/common/da/src/availability.rs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
use crate::id::{NUMBER_OF_COLUMNS, column_indices};
22

3-
/// Which of a block's columns this node holds, against the set it is responsible
4-
/// for.
5-
///
6-
/// Both fields are 128-bit presence bitmaps — bit `i` set ⇔ column index `i`:
7-
/// - `held`: columns actually stored here.
8-
/// - `expected`: columns this node is responsible for (its custody set). For the full-custody MVP
9-
/// the store stamps every value with `ALL_COLUMNS_MASK`; once custody groups land it stamps the
10-
/// node's actual custody set instead, and the query methods below keep working unchanged.
3+
/// Which of a block's columns this node holds (`held`) against the set it is
4+
/// responsible for (`expected`). Both are 128-bit presence bitmaps: bit `i`
5+
/// set ⇔ column `i`. The full-custody MVP stamps `expected` with
6+
/// `ALL_COLUMNS_MASK`.
117
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
128
pub struct DaAvailability {
139
held: u128,
@@ -29,26 +25,17 @@ impl DaAvailability {
2925
u64::from(self.held.count_ones())
3026
}
3127

32-
/// Whether column `index` is physically held, regardless of custody.
33-
///
34-
/// A pure bitmap probe — this is the cheap presence check for callers that
35-
/// would otherwise fetch a whole column just to see if it exists. An
36-
/// out-of-range index is never held.
28+
/// Whether column `index` is held; an out-of-range index is never held.
3729
pub fn holds(&self, index: u64) -> bool {
3830
index < NUMBER_OF_COLUMNS && self.held & (1u128 << index) != 0
3931
}
4032

41-
/// Column indices this node is responsible for but does not yet hold, in
42-
/// ascending order.
43-
///
44-
/// This is the list a fetcher turns into a request for the missing columns
33+
/// Column indices expected but not held, ascending.
4534
pub fn missing_indices(&self) -> Vec<u64> {
4635
column_indices(self.expected & !self.held)
4736
}
4837

49-
/// Column indices physically held, ascending — the list a serving node walks
50-
/// to return every column it has for a block. Includes any held outside the
51-
/// custody set.
38+
/// Column indices held (including any outside custody), ascending.
5239
pub fn held_indices(&self) -> Vec<u64> {
5340
column_indices(self.held)
5441
}
@@ -58,14 +45,10 @@ impl DaAvailability {
5845
mod tests {
5946
use super::DaAvailability;
6047

61-
/// A small custody set — columns {0, 1, 2, 3} — keeps the expectations
62-
/// readable while still exercising partial/complete logic.
6348
const EXPECTED_FOUR: u128 = 0b1111;
6449

6550
#[test]
6651
fn holds_probes_single_columns() {
67-
// Held {0, 2}: bit probes answer per column, and an out-of-range index
68-
// (>= NUMBER_OF_COLUMNS) is never held.
6952
let availability = DaAvailability::new(0b0101, EXPECTED_FOUR);
7053
assert!(availability.holds(0));
7154
assert!(!availability.holds(1));
@@ -92,7 +75,6 @@ mod tests {
9275

9376
#[test]
9477
fn partial_reports_only_the_gaps() {
95-
// Holds columns 0 and 2 of the four expected.
9678
let availability = DaAvailability::new(0b0101, EXPECTED_FOUR);
9779
assert!(!availability.is_complete());
9880
assert_eq!(availability.held_count(), 2);
@@ -101,8 +83,6 @@ mod tests {
10183

10284
#[test]
10385
fn extra_columns_beyond_custody_still_complete() {
104-
// Holds column 4 on top of the expected four: a superset, still complete,
105-
// and column 4 is never reported as missing.
10686
let availability = DaAvailability::new(0b11111, EXPECTED_FOUR);
10787
assert!(availability.is_complete());
10888
assert_eq!(availability.held_count(), 5);
@@ -111,8 +91,6 @@ mod tests {
11191

11292
#[test]
11393
fn sparse_custody_follows_the_bits_not_the_count() {
114-
// Custody indices {5, 70, 99}, plus a held column (9) that lies
115-
// OUTSIDE custody.
11694
let expected = (1u128 << 5) | (1u128 << 70) | (1u128 << 99);
11795
let held = (1u128 << 5) | (1u128 << 9);
11896
let availability = DaAvailability::new(held, expected);
@@ -124,10 +102,8 @@ mod tests {
124102

125103
#[test]
126104
fn held_indices_lists_every_stored_column_in_order() {
127-
// Held {0, 2} within custody plus {9} outside it — all count as held.
128105
let availability = DaAvailability::new((1 << 0) | (1 << 2) | (1 << 9), EXPECTED_FOUR);
129106
assert_eq!(availability.held_indices(), vec![0, 2, 9]);
130-
// Nothing held -> empty list.
131107
assert!(
132108
DaAvailability::new(0, EXPECTED_FOUR)
133109
.held_indices()

crates/common/da/src/column.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,22 @@ use serde::{Deserialize, Serialize};
33
use crate::id::DaColumnId;
44

55
/// Consensus-derived context attached to a candidate column.
6-
///
7-
/// Only plain data crosses this boundary; no beacon runtime handles.
86
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
97
pub struct DaContext {
10-
/// Slot of the block the column belongs to. Used for retention decisions,
11-
/// never for fork choice.
8+
/// Slot of the block the column belongs to; used for retention only.
129
pub slot: u64,
1310
}
1411

1512
/// A candidate column submitted for verification.
16-
///
17-
/// Candidates may come from a consensus data source, the dev-mode ingest API,
18-
/// or (in the future) peers. All of them pass through the same verification
19-
/// pipeline before they can be stored or served.
2013
#[derive(Debug, Clone, PartialEq, Eq)]
2114
pub struct CandidateColumn {
2215
pub id: DaColumnId,
2316
pub context: DaContext,
24-
/// Opaque, scheme-specific payload bytes carrying the column and its
25-
/// availability evidence. The DA core never interprets them: for the
26-
/// PeerDAS backend they are an SSZ-encoded `DataColumnSidecar` (cells, KZG
27-
/// commitments, KZG proofs, signed block header, and commitments inclusion
28-
/// proof); a future non-KZG backend can encode different evidence without
29-
/// changing storage, API, or serving logic.
3017
pub payload: Vec<u8>,
3118
}
3219

33-
/// A column that passed verification.
34-
///
35-
/// This is the only type accepted by `DaWriteStore`. It must only be
36-
/// constructed by `DaVerifier` implementations; everything downstream of the
37-
/// verifier relies on this to avoid re-verifying on the serving path.
20+
/// A column that passed verification — the only type accepted by
21+
/// `DaWriteStore`, and only constructed by `DaVerifier` implementations.
3822
#[derive(Debug, Clone, PartialEq, Eq)]
3923
pub struct VerifiedColumn {
4024
id: DaColumnId,
@@ -43,7 +27,6 @@ pub struct VerifiedColumn {
4327
}
4428

4529
impl VerifiedColumn {
46-
/// Construct a verified column without running verification.
4730
pub fn new_unchecked(id: DaColumnId, context: DaContext, payload: Vec<u8>) -> Self {
4831
Self {
4932
id,
@@ -63,8 +46,4 @@ impl VerifiedColumn {
6346
pub fn payload(&self) -> &[u8] {
6447
&self.payload
6548
}
66-
67-
pub fn into_payload(self) -> Vec<u8> {
68-
self.payload
69-
}
7049
}

crates/common/da/src/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ pub enum ValidationError {
4646

4747
#[derive(Debug, Error)]
4848
pub enum DaStoreError {
49-
/// Underlying storage failure: filesystem I/O, a missing backing file, or
50-
/// corruption. Not a normal "not found" answer — that is `Ok(None)`.
49+
/// Underlying storage failure; "not found" is `Ok(None)`, not an error.
5150
#[error("storage I/O failure: {0}")]
5251
Io(#[from] io::Error),
5352
}

crates/common/da/src/id.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ use serde::{Deserialize, Serialize};
33

44
use crate::error::ValidationError;
55

6-
/// Number of data columns per block in the PeerDAS MVP.
7-
///
8-
/// The MVP custodies and serves the full column set.
9-
///
10-
/// This MUST stay equal to the spec's `NUMBER_OF_COLUMNS`
6+
/// MUST stay equal to the spec's `NUMBER_OF_COLUMNS`
117
/// (<https://ethereum.github.io/consensus-specs/fulu/das-core/>).
128
pub const NUMBER_OF_COLUMNS: u64 = 128;
139

14-
/// Bitmask for full custody, serve the full column set.
10+
/// Bitmask for full custody.
1511
pub const ALL_COLUMNS_MASK: u128 = u128::MAX;
1612

1713
/// Ascending column indices set in a 128-bit presence bitmap (bit `i` ⇔ column
18-
/// `i`). Expands a bitmap into concrete indices for callers that need them — the
19-
/// missing-column set, or the columns to delete when pruning a block.
14+
/// `i`).
2015
pub fn column_indices(mut bitmap: u128) -> Vec<u64> {
2116
let mut indices = Vec::new();
2217
while bitmap != 0 {

crates/common/da/src/lib.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
//! DA core for `ream da-node`: the storage-and-verification half of a PeerDAS
2-
//! data-availability node.
3-
//!
4-
//! # Division of labor: beacon node vs. DA node
5-
//!
6-
//! A beacon node and a DA node run as two separate OS processes, and the split
7-
//! of responsibility is deliberate:
8-
//!
9-
//! - The **beacon node** owns the consensus business logic — gossip, peer scoring, fork choice,
10-
//! which blocks are canonical, which columns this node is custodian of. It drives the DA node
11-
//! over HTTP/RPC.
12-
//! - The **DA node** (this code) only *stores* data columns and *verifies* them in a self-contained
13-
//! way: SSZ structure, the commitments inclusion proof, and the KZG cell proofs. It has no P2P
14-
//! stack and no view of the chain — it cannot tell "canonical" from "orphaned". Everything it
15-
//! needs arrives as an opaque payload plus a small context across the RPC boundary.
16-
//!
17-
//! This crate is intentionally free of beacon, KZG, and execution
18-
//! dependencies. A concrete proof system enters only through an adapter (see
19-
//! `ream-da-verifier-kzg`) behind the [`verifier::DaVerifier`] trait, so the
20-
//! core stays reusable by a future non-KZG or post-quantum scheme.
211
pub mod availability;
222
pub mod column;
233
pub mod error;

crates/common/da/src/store.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,23 @@ use crate::{
77
/// Outcome of inserting a verified column.
88
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
99
pub enum InsertOutcome {
10-
/// The column was newly persisted.
1110
Inserted,
12-
/// A column was already stored for this identifier; the insert is a no-op
13-
/// idempotent success and the existing value is kept.
11+
/// A column was already stored for this id; the insert is an idempotent
12+
/// no-op and the existing column is kept.
1413
Duplicated,
1514
}
1615

17-
/// Read-only storage handle.
18-
///
19-
/// This is the only storage capability handed to the local API and to P2P
20-
/// serving. Serving does not re-verify on the output path because the store
21-
/// only ever contains verified data.
16+
/// Read-only storage handle. Serving never re-verifies on the output path
17+
/// because the store only ever contains verified data.
2218
pub trait DaReadStore: Send + Sync {
2319
fn get(&self, id: &DaColumnId) -> Result<Option<VerifiedColumn>, DaStoreError>;
2420
fn availability(&self, block_root: B256) -> Result<DaAvailability, DaStoreError>;
2521
}
2622

27-
/// Write-capable storage handle.
28-
///
29-
/// Handed to the verification service only. Accepting [`VerifiedColumn`] (not
30-
/// candidates) makes "unverified data is never stored" a type-level rule.
23+
/// Write-capable storage handle, handed to the verification service only.
24+
/// Accepting [`VerifiedColumn`] (not candidates) makes "unverified data is
25+
/// never stored" a type-level rule.
3126
pub trait DaWriteStore: DaReadStore {
32-
/// Store a verified column.
33-
///
34-
/// Columns are keyed by [`DaColumnId`]. If a column is already stored for
35-
/// this id, the call is an idempotent [`InsertOutcome::Duplicated`]: the
36-
/// incoming column is ignored and the stored one is kept, never
37-
/// overwritten. Otherwise the column is persisted and
38-
/// [`InsertOutcome::Inserted`] is returned.
3927
fn put(&self, column: VerifiedColumn) -> Result<InsertOutcome, DaStoreError>;
4028

4129
fn prune_below_slot(&self, slot: u64) -> Result<usize, DaStoreError>;
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
//! PeerDAS/KZG verifier adapter for the DA core.
2-
//!
3-
//! This is the scheme boundary made concrete: the only DA crate that depends on
4-
//! both beacon types (`DataColumnSidecar`) and a concrete commitment scheme
5-
//! (KZG over BLS12-381). Isolating those dependencies here lets `ream-da` stay
6-
//! free of beacon and KZG code while still getting real verification, plugged
7-
//! in through the [`ream_da::verifier::DaVerifier`] trait.
8-
91
pub mod verifier;
102

113
pub use verifier::KzgVerifier;

0 commit comments

Comments
 (0)