Skip to content
Closed
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
23 changes: 22 additions & 1 deletion crates/node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ use eyre::OptionExt;
use signet_blobber::CacheHandle;
use signet_block_processor::AliasOracleFactory;
use signet_cold::BlockData;
use signet_hot::db::{HotDbRead, UnsafeDbWrite};
use signet_hot::{
db::{HotDbRead, UnsafeDbWrite},
model::HotKvWrite,
tables,
};
use signet_node_config::SignetNodeConfig;
use signet_node_types::HostNotifier;
use signet_rpc::{ServeConfig, StorageRpcConfig};
Expand Down Expand Up @@ -177,6 +181,23 @@ where
self.notifier.as_ref().ok_or_eyre("Notifier must be set")?;
let storage = self.storage.as_ref().ok_or_eyre("Storage must be set")?;

// Ensure all hot storage tables exist. On a fresh MDBX database,
// named tables must be created in a write transaction before
// read-only transactions can open them.
{
let writer = storage.hot().writer()?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should address this in the storage crate

writer.queue_create::<tables::Headers>()?;
writer.queue_create::<tables::HeaderNumbers>()?;
writer.queue_create::<tables::Bytecodes>()?;
writer.queue_create::<tables::PlainAccountState>()?;
writer.queue_create::<tables::PlainStorageState>()?;
writer.queue_create::<tables::AccountsHistory>()?;
writer.queue_create::<tables::AccountChangeSets>()?;
writer.queue_create::<tables::StorageHistory>()?;
writer.queue_create::<tables::StorageChangeSets>()?;
writer.raw_commit()?;
}

// Load genesis into hot storage if absent.
let reader = storage.reader()?;
let has_hot_genesis = reader.has_block(0)?;
Expand Down
12 changes: 10 additions & 2 deletions crates/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use signet_rpc::{
ChainNotifier, NewBlockNotification, RemovedBlock, ReorgNotification, RpcServerGuard,
ServeConfig, StorageRpcConfig,
};
use signet_storage::{DrainedBlock, HistoryRead, HotKv, HotKvRead, UnifiedStorage};
use signet_storage::{DrainedBlock, HistoryRead, HotKv, HotKvRead, StorageError, UnifiedStorage};
use signet_types::{PairedHeights, constants::SignetSystemConstants};
use std::{fmt, sync::Arc};
use tokio::sync::watch;
Expand Down Expand Up @@ -282,7 +282,15 @@ where
);
let executed = processor.process_block(block_extracts).await?;
self.notify_new_block(&executed);
self.storage.append_blocks(vec![executed])?;
// Cold backpressure is non-fatal: hot storage is authoritative
// and cold will catch up once the channel drains.
match self.storage.append_blocks(vec![executed]) {
Ok(()) => {}
Err(StorageError::Cold(e)) => {
tracing::debug!(%e, "cold storage backpressure, hot storage is ahead");
}
Err(e) => return Err(e.into()),
}
processed = true;
}
Ok(processed)
Expand Down