Skip to content

chore: some db readme #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2025
Merged
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
19 changes: 19 additions & 0 deletions crates/db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Signet Database

Extensions and modifications to reth's Database system for use in the Signet
Node.

This library contains the following:

- Traits for reading and writing Signet events
- Table definitions for Signet Events, Headers, and JournalHashes
- Helpers for reading, writing, reverting, Signet EVM blocks and headers

## Significant Traits

- `RuWriter` - Encapsulates logic for reading and writing Signet events, state,
headers, etc.
- `DbProviderExt` - Extends the reth `DatabaseProviderRW` with a scope-guarded
`update` method.
- `DataCompat` - Provides methods for converting between Signet and reth data
structures, such as `ExecutionOutcome` and `Receipt`.
2 changes: 1 addition & 1 deletion crates/db/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct DbExtractionResults {
pub enter_tokens: Vec<Passage::EnterToken>,
}

/// Equivalent of [`Chain`] but also containing zenith headers.
/// Equivalent of [`Chain`] but also containing zenith events and information.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct RuChain {
/// Inner chain of RU blocks.
Expand Down
11 changes: 2 additions & 9 deletions crates/db/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
//! Database access for Signet Node.
//!
//! This library contains the following:
//!
//! - Traits for reading and writing Signet events
//! - Table definitions for Signet Events and Headers
//! - Helpers for reading and writing Signet EVM blocks and headers

#![doc = include_str!("../README.md")]
#![warn(
missing_copy_implementations,
missing_debug_implementations,
Expand Down Expand Up @@ -33,4 +26,4 @@ pub use tables::{
};

mod traits;
pub use traits::{DbProviderExt, RuEnterReader, RuWriter};
pub use traits::{DbProviderExt, RuWriter};
21 changes: 1 addition & 20 deletions crates/db/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,9 @@ use signet_evm::BlockResult;
use signet_node_types::{NodeTypesDbTrait, SignetNodeTypes};
use signet_types::primitives::RecoveredBlock;
use signet_zenith::{Passage, Transactor, Zenith};
use std::{
collections::BTreeMap,
ops::{RangeBounds, RangeInclusive},
};
use std::{collections::BTreeMap, ops::RangeInclusive};
use tracing::trace;

/// Reader for [`Passage::Enter`] events stored in the DB.
pub trait RuEnterReader {
/// Get an enter by height and index.
fn enter_by_height_and_index(
&self,
height: u64,
index: u64,
) -> ProviderResult<Option<Passage::Enter>>;

/// Get enters by height.
fn get_enters_by_height(
&self,
height: impl RangeBounds<u64> + Clone,
) -> ProviderResult<Vec<Passage::Enter>>;
}

/// Writer for [`Passage::Enter`] events.
pub trait RuWriter {
/// Get the last block number
Expand Down