Skip to content

fix(gc): backfill new db records since snapshot epoch #5640

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 13 commits into from
May 23, 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
52 changes: 26 additions & 26 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion f3-sidecar/ffi_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ func init() {
logging.SetAllLoggers(logging.LevelInfo)
err := logging.SetLogLevel("dht", "error")
checkError(err)
err = logging.SetLogLevel("dht/RtRefreshManager", "warn")
err = logging.SetLogLevel("dht/RtRefreshManager", "error")
checkError(err)
err = logging.SetLogLevel("net/identify", "error")
checkError(err)
err = logging.SetLogLevel("pubsub", "warn")
checkError(err)
err = logging.SetLogLevel("swarm2", "error")
checkError(err)
err = logging.SetLogLevel("f3/sidecar", "debug")
checkError(err)
GoF3NodeImpl = &f3Impl{ctx: context.Background()}
Expand Down
10 changes: 5 additions & 5 deletions src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ use tokio::io::{AsyncWrite, AsyncWriteExt, BufWriter};
pub use self::{store::*, weight::*};

pub async fn export_from_head<D: Digest>(
db: Arc<impl Blockstore + SettingsStore + Send + Sync + 'static>,
db: &Arc<impl Blockstore + SettingsStore + Send + Sync + 'static>,
lookup_depth: ChainEpochDelta,
writer: impl AsyncWrite + Unpin,
seen: CidHashSet,
skip_checksum: bool,
) -> anyhow::Result<(Tipset, Option<digest::Output<D>>), Error> {
let head_key = SettingsStoreExt::read_obj::<TipsetKey>(&db, crate::db::setting_keys::HEAD_KEY)?
let head_key = SettingsStoreExt::read_obj::<TipsetKey>(db, crate::db::setting_keys::HEAD_KEY)?
.context("chain head key not found")?;
let head_ts = Tipset::load_required(&db, &head_key)?;
let digest = export::<D>(db, &head_ts, lookup_depth, writer, seen, skip_checksum).await?;
Ok((head_ts, digest))
}

pub async fn export<D: Digest>(
db: Arc<impl Blockstore + Send + Sync + 'static>,
db: &Arc<impl Blockstore + Send + Sync + 'static>,
tipset: &Tipset,
lookup_depth: ChainEpochDelta,
writer: impl AsyncWrite + Unpin,
Expand All @@ -53,8 +53,8 @@ pub async fn export<D: Digest>(
// block size is between 1kb and 2kb.
1024,
stream_chain(
Arc::clone(&db),
tipset.clone().chain_owned(Arc::clone(&db)),
Arc::clone(db),
tipset.clone().chain_owned(Arc::clone(db)),
stateroot_lookup_limit,
)
.with_seen(seen),
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async fn setup_db(opts: &CliOpts, config: &Config) -> anyhow::Result<(Arc<DbType
maybe_migrate_db(config);
let chain_data_path = chain_path(config);
let db_root_dir = db_root(&chain_data_path)?;
let db_writer = Arc::new(open_db(db_root_dir.clone(), config.db_config().clone())?);
let db_writer = Arc::new(open_db(db_root_dir.clone(), config.db_config())?);
let db = Arc::new(ManyCar::new(db_writer.clone()));
let forest_car_db_dir = db_root_dir.join(CAR_DB_DIR_NAME);
load_all_forest_cars(&db, &forest_car_db_dir)?;
Expand Down
13 changes: 12 additions & 1 deletion src/db/car/many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
use super::{AnyCar, ZstdFrameCache};
use crate::blocks::TipsetKey;
use crate::db::{
EthMappingsStore, IndicesStore, MemoryDB, PersistentStore, SettingsStore, SettingsStoreExt,
BlockstoreWriteOpsSubscribable, EthMappingsStore, IndicesStore, MemoryDB, PersistentStore,
SettingsStore, SettingsStoreExt,
};
use crate::libp2p_bitswap::BitswapStoreReadWrite;
use crate::rpc::eth::types::EthHash;
Expand Down Expand Up @@ -272,6 +273,16 @@ impl<T: Blockstore + SettingsStore> super::super::HeaviestTipsetKeyProvider for
}
}

impl<WriterT: BlockstoreWriteOpsSubscribable> BlockstoreWriteOpsSubscribable for ManyCar<WriterT> {
fn subscribe_write_ops(&self) -> tokio::sync::broadcast::Receiver<(Cid, Vec<u8>)> {
self.writer().subscribe_write_ops()
}

fn unsubscribe_write_ops(&self) {
self.writer().unsubscribe_write_ops()
}
}

#[cfg(test)]
mod tests {
use super::super::AnyCar;
Expand Down
Loading
Loading