Skip to content

Commit

Permalink
add a lot of logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-maron committed Feb 13, 2025
1 parent 822dfe2 commit b711251
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
13 changes: 11 additions & 2 deletions hotshot-query-service/src/data_source/storage/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use atomic_store::{AtomicStore, AtomicStoreLoader, PersistenceError};
use committable::Committable;
use futures::future::Future;
use hotshot_types::traits::{block_contents::BlockHeader, node_implementation::NodeType};
use log::info;
use serde::{de::DeserializeOwned, Serialize};
use snafu::OptionExt;
use std::collections::{
Expand Down Expand Up @@ -144,10 +145,15 @@ where
///
/// The [FileSystemStorage] will manage its own persistence synchronization.
pub async fn create(path: &Path) -> Result<Self, PersistenceError> {
info!("27 creating file system storage");
let mut loader = AtomicStoreLoader::create(path, "hotshot_data_source")?;
info!("created loader");
loader.retain_archives(1);
info!("retained archives");
let data_source = Self::create_with_store(&mut loader).await?;
info!("created data source, opening store");
data_source.inner.write().await.top_storage = Some(AtomicStore::open(loader)?);
info!("opened store");
Ok(data_source)
}

Expand Down Expand Up @@ -175,7 +181,8 @@ where
pub async fn create_with_store(
loader: &mut AtomicStoreLoader,
) -> Result<Self, PersistenceError> {
Ok(Self {
info!("creating with store");
let f = Ok(Self {
inner: RwLock::new(FileSystemStorageInner {
index_by_leaf_hash: Default::default(),
index_by_block_hash: Default::default(),
Expand All @@ -190,7 +197,9 @@ where
vid_storage: LedgerLog::create(loader, "vid_common", CACHED_VID_COMMON_COUNT)?,
}),
metrics: Default::default(),
})
});
info!("created with store");
f
}

/// Open an existing [FileSystemStorage] using a persistent storage loader.
Expand Down
12 changes: 10 additions & 2 deletions sequencer/src/api/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::Path;

use async_trait::async_trait;
use hotshot_query_service::data_source::FileSystemDataSource;
use tracing::info;

use super::data_source::{Provider, SequencerDataSource};
use crate::{catchup::CatchupStorage, persistence::fs::Options, SeqTypes};
Expand All @@ -13,12 +14,19 @@ impl SequencerDataSource for DataSource {
type Options = Options;

async fn create(opt: Self::Options, provider: Provider, reset: bool) -> anyhow::Result<Self> {
info!("creating file system data source");
let path = Path::new(opt.path());
let data_source = {
if reset {
FileSystemDataSource::create(path, provider).await?
info!("resetting file system data source");
let f = FileSystemDataSource::create(path, provider).await?;
info!("reset file system data source");
f
} else {
FileSystemDataSource::open(path, provider).await?
info!("opening file system data source");
let f = FileSystemDataSource::open(path, provider).await?;
info!("opened file system data source");
f
}
};

Expand Down
3 changes: 2 additions & 1 deletion sequencer/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use parking_lot::Mutex;
use std::fmt::Debug;
use std::{fmt::Display, sync::Arc};
use tokio::{spawn, task::JoinHandle};
use tracing::{Instrument, Level};
use tracing::{info, Instrument, Level};
use url::Url;

use crate::{
Expand Down Expand Up @@ -292,6 +292,7 @@ impl<N: ConnectedNetwork<PubKey>, P: SequencerPersistence, V: Versions> Sequence

/// Start participating in consensus.
pub async fn start_consensus(&self) {
info!("starting consensus");
if let Some(orchestrator_client) = &self.wait_for_orchestrator {
tracing::warn!("waiting for orchestrated start");
let peer_config = PeerConfig::to_bytes(&self.validator_config.public_config()).clone();
Expand Down
3 changes: 3 additions & 0 deletions sequencer/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl Genesis {

impl Genesis {
pub async fn validate_fee_contract(&self, l1_rpc_url: Url) -> anyhow::Result<()> {
tracing::info!("validating fee contract");
let l1 = L1Client::new(vec![l1_rpc_url]).with_context(|| "failed to create L1 client")?;

if let Some(fee_contract_address) = self.chain_config.fee_contract {
Expand Down Expand Up @@ -126,6 +127,8 @@ impl Genesis {
}
}
// TODO: it's optional for the fee contract to be included in a proxy in v1 so no need to panic but revisit this after v1 https://github.com/EspressoSystems/espresso-sequencer/pull/2000#discussion_r1765174702

tracing::info!("validated fee contract");
Ok(())
}
}
Expand Down
7 changes: 5 additions & 2 deletions sequencer/src/persistence/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,20 @@ impl PersistenceOptions for Options {
}

async fn create(&mut self) -> anyhow::Result<Self::Persistence> {
tracing::info!("creating file system persistence");
let path = self.path.clone();
let store_undecided_state = self.store_undecided_state;
let view_retention = self.consensus_view_retention;

Ok(Persistence {
let f = Persistence {
store_undecided_state,
inner: Arc::new(RwLock::new(Inner {
path,
view_retention,
})),
})
};
tracing::info!("created file system persistence");
Ok(f)
}

async fn reset(self) -> anyhow::Result<()> {
Expand Down
33 changes: 29 additions & 4 deletions sequencer/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ pub async fn main() -> anyhow::Result<()> {
let modules = opt.modules();
tracing::warn!(?modules, "sequencer starting up");

tracing::info!("loading genesis from file");
let genesis = Genesis::from_file(&opt.genesis_file)?;
tracing::info!("loaded genesis from file");

tracing::info!("validating fee contract");
// validate that the fee contract is a proxy and panic otherwise
genesis
.validate_fee_contract(opt.l1_provider_url[0].clone())
.await
.unwrap();
tracing::info!("validated fee contract");

tracing::info!(?genesis, "genesis");

Expand All @@ -41,6 +45,7 @@ pub async fn main() -> anyhow::Result<()> {
match (base, upgrade) {
#[cfg(all(feature = "fee", feature = "marketplace"))]
(FeeVersion::VERSION, MarketplaceVersion::VERSION) => {
tracing::info!("running fee and marketplace sequencer");
run(
genesis,
modules,
Expand All @@ -51,6 +56,7 @@ pub async fn main() -> anyhow::Result<()> {
}
#[cfg(feature = "fee")]
(FeeVersion::VERSION, _) => {
tracing::info!("running fee only sequencer");
run(
genesis,
modules,
Expand All @@ -61,6 +67,7 @@ pub async fn main() -> anyhow::Result<()> {
}
#[cfg(feature = "marketplace")]
(MarketplaceVersion::VERSION, _) => {
tracing::info!("running marketplace only sequencer");
run(
genesis,
modules,
Expand All @@ -85,11 +92,14 @@ where
V: Versions,
{
if let Some(storage) = modules.storage_fs.take() {
tracing::info!("running with local file system storage");
run_with_storage(genesis, modules, opt, storage, versions).await
} else if let Some(storage) = modules.storage_sql.take() {
tracing::info!("running with sql storage");
run_with_storage(genesis, modules, opt, storage, versions).await
} else {
// Persistence is required. If none is provided, just use the local file system.
tracing::info!("running with local file system storage 2");
run_with_storage(
genesis,
modules,
Expand All @@ -112,11 +122,18 @@ where
S: DataSourceOptions,
V: Versions,
{
tracing::info!("initializing with storage");
let ctx = init_with_storage(genesis, modules, opt, storage_opt, versions).await?;
tracing::info!("initialized with storage");

// Start doing consensus.
tracing::info!("starting consensus");
ctx.start_consensus().await;
tracing::info!("consensus started");

tracing::info!("joining consensus");
ctx.join().await;
tracing::info!("consensus joined");

Ok(())
}
Expand Down Expand Up @@ -184,7 +201,9 @@ where
};
let proposal_fetcher_config = opt.proposal_fetcher_config;

tracing::info!("creating persistence storage");
let persistence = storage_opt.create().await?;
tracing::info!("created persistence storage");

// Initialize HotShot. If the user requested the HTTP module, we must initialize the handle in
// a special way, in order to populate the API with consensus metrics. Otherwise, we initialize
Expand Down Expand Up @@ -213,7 +232,8 @@ where
http_opt
.serve(move |metrics, consumer| {
async move {
init_node(
tracing::info!("initializing node");
let f = init_node(
genesis,
network_params,
&*metrics,
Expand All @@ -226,14 +246,17 @@ where
marketplace_config,
proposal_fetcher_config,
)
.await
.await;
tracing::info!("initialized node");
f
}
.boxed()
})
.await?
}
None => {
init_node(
tracing::info!("initializing node 2");
let f = init_node(
genesis,
network_params,
&NoMetrics,
Expand All @@ -246,7 +269,9 @@ where
marketplace_config,
proposal_fetcher_config,
)
.await?
.await?;
tracing::info!("initialized node 2");
f
}
};

Expand Down

0 comments on commit b711251

Please sign in to comment.