Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion modules/snapshot_bootstrapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ acropolis_common = { path = "../../common" }
caryatid_sdk = { workspace = true }

anyhow = { workspace = true }
pallas-primitives = { workspace = true }
pallas-traverse = { workspace = true }
config = { workspace = true }
minicbor = { version = "0.25.1", features = ["std", "half", "derive"] }
tokio = { workspace = true }
Expand Down
31 changes: 19 additions & 12 deletions modules/snapshot_bootstrapper/src/bootstrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,36 +91,43 @@ impl SnapshotBootstrapper {
) -> Result<(), BootstrapError> {
Self::wait_for_genesis(bootstrapped_sub).await?;

let data = BootstrapContext::load(&cfg)?;
info!("Loaded bootstrap data for epoch {}", data.block_info.epoch);
info!(" Snapshot: {}", data.snapshot.url);
let bootstrap_ctx = BootstrapContext::load(&cfg)?;
info!(
" Block: slot={}, height={}",
data.block_info.slot, data.block_info.number
"Loaded bootstrap data for epoch {}",
bootstrap_ctx.block_info.epoch
);
info!(" Snapshot: {}", bootstrap_ctx.snapshot.url);
info!(
" Block: slot={}, number={}",
bootstrap_ctx.block_info.slot, bootstrap_ctx.block_info.number
);

// Download
let downloader = SnapshotDownloader::new(data.network_dir(), &cfg.download)?;
downloader.download(&data.snapshot).await?;
let downloader = SnapshotDownloader::new(bootstrap_ctx.network_dir(), &cfg.download)?;
downloader.download(&bootstrap_ctx.snapshot).await.map_err(BootstrapError::Download)?;

// Publish
let mut publisher = SnapshotPublisher::new(
context,
cfg.completion_topic.clone(),
cfg.snapshot_topic.clone(),
data.context(),
bootstrap_ctx.context(),
);

publisher.publish_start().await?;

info!("Parsing snapshot: {}", data.snapshot_path().display());
info!(
"Parsing snapshot: {}",
bootstrap_ctx.snapshot_path().display()
);
let start = Instant::now();
let parser =
StreamingSnapshotParser::new(data.snapshot_path().to_string_lossy().into_owned());
let parser = StreamingSnapshotParser::new(
bootstrap_ctx.snapshot_path().to_string_lossy().into_owned(),
);
parser.parse(&mut publisher).map_err(|e| BootstrapError::Parse(e.to_string()))?;
info!("Parsed snapshot in {:.2?}", start.elapsed());

publisher.publish_completion(data.block_info).await?;
publisher.publish_completion(bootstrap_ctx.block_info).await?;

info!("Snapshot bootstrap completed");
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion modules/snapshot_bootstrapper/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl BootstrapContext {
hash: *hash,
epoch: target_epoch,
epoch_slot,
new_epoch: true,
new_epoch: false,
timestamp: genesis.slot_to_timestamp(slot),
era: Era::Conway, // TODO: Make dynamic with era history
};
Expand Down
10 changes: 4 additions & 6 deletions modules/snapshot_bootstrapper/src/header.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![allow(dead_code, unused)]
use acropolis_common::hash::Hash;
use acropolis_common::Point;
use pallas_primitives::babbage::MintedHeader;
use pallas_primitives::conway::Header as ConwayHeader;
use pallas_traverse::Era::Conway;
use pallas_traverse::MultiEraHeader;
use std::fs;
use std::path::{Path, PathBuf};
use thiserror::Error;
Expand Down Expand Up @@ -48,13 +48,11 @@ impl HeaderContext {
pub fn load(network_dir: &Path, point: &Point) -> Result<Self, HeaderContextError> {
let path = Self::path(network_dir, point)?;
let cbor = fs::read(&path).map_err(|e| HeaderContextError::ReadFile(path, e))?;

let minted: MintedHeader<'_> = minicbor::decode(&cbor)
let header = MultiEraHeader::decode(Conway as u8, None, &cbor)
.map_err(|e| HeaderContextError::Decode(point.slot(), e.to_string()))?;
let header = ConwayHeader::from(minted);
Ok(Self {
point: point.clone(),
block_number: header.header_body.block_number,
block_number: header.number(),
})
}
}
Expand Down