-
Notifications
You must be signed in to change notification settings - Fork 5
Snapshot bootstrapper process outline with TODOs for the relevant messages #271
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
base: main
Are you sure you want to change the base?
Conversation
…ing for processing a snapshot file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a streaming snapshot parser for Cardano node snapshots, replacing the previous ledger state directory loading approach. The changes establish a callback-based architecture for processing snapshot data asynchronously and publishing completion messages to coordinate with downstream modules.
Key Changes:
- Replaced
LedgerState::from_directory()with a streaming parser using callback handlers for UTXOs, pools, stakes, DReps, and governance proposals - Introduced
SnapshotHandlerstruct to accumulate snapshot data and build blockchain state information - Added progress tracking with logging every million UTXOs and comprehensive statistics reporting
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| modules/snapshot_bootstrapper/src/snapshot_bootstrapper.rs | Core implementation of streaming snapshot parser with callback handlers and message publishing |
| common/src/messages.rs | Added BootupCompleteMessage type and clarified SnapshotComplete comment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| // Create a synthetic BlockInfo representing the snapshot state | ||
| // This represents the last block included in the snapshot | ||
| Ok(BlockInfo { | ||
| status: BlockStatus::Immutable, // Snapshot blocks are immutable | ||
| slot: 0, // TODO: Extract from snapshot metadata if available | ||
| number: 0, // TODO: Extract from snapshot metadata if available | ||
| hash: BlockHash::default(), // TODO: Extract from snapshot metadata if available | ||
| epoch: metadata.epoch, | ||
| epoch_slot: 0, // TODO: Extract from snapshot metadata if available | ||
| new_epoch: false, // Not necessarily a new epoch | ||
| timestamp: 0, // TODO: Extract from snapshot metadata if available |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using zero values and default hash for critical block identification fields (slot, number, hash, epoch_slot, timestamp) will cause issues with downstream consumers expecting valid block identifiers. These fields should either be extracted from the snapshot metadata or the code should validate that metadata contains these values before proceeding.
| // Create a synthetic BlockInfo representing the snapshot state | |
| // This represents the last block included in the snapshot | |
| Ok(BlockInfo { | |
| status: BlockStatus::Immutable, // Snapshot blocks are immutable | |
| slot: 0, // TODO: Extract from snapshot metadata if available | |
| number: 0, // TODO: Extract from snapshot metadata if available | |
| hash: BlockHash::default(), // TODO: Extract from snapshot metadata if available | |
| epoch: metadata.epoch, | |
| epoch_slot: 0, // TODO: Extract from snapshot metadata if available | |
| new_epoch: false, // Not necessarily a new epoch | |
| timestamp: 0, // TODO: Extract from snapshot metadata if available | |
| // Validate and extract critical block identification fields from metadata | |
| let slot = metadata.slot; | |
| let number = metadata.number; | |
| let hash = metadata.hash.clone(); | |
| let epoch_slot = metadata.epoch_slot; | |
| let timestamp = metadata.timestamp; | |
| if slot == 0 { | |
| return Err(anyhow::anyhow!("Invalid slot value in snapshot metadata")); | |
| } | |
| if number == 0 { | |
| return Err(anyhow::anyhow!("Invalid block number in snapshot metadata")); | |
| } | |
| if hash == BlockHash::default() { | |
| return Err(anyhow::anyhow!("Invalid block hash in snapshot metadata")); | |
| } | |
| if epoch_slot == 0 { | |
| return Err(anyhow::anyhow!("Invalid epoch_slot value in snapshot metadata")); | |
| } | |
| if timestamp == 0 { | |
| return Err(anyhow::anyhow!("Invalid timestamp value in snapshot metadata")); | |
| } | |
| // Create a BlockInfo representing the snapshot state | |
| Ok(BlockInfo { | |
| status: BlockStatus::Immutable, // Snapshot blocks are immutable | |
| slot, | |
| number, | |
| hash, | |
| epoch: metadata.epoch, | |
| epoch_slot, | |
| new_epoch: false, // Not necessarily a new epoch | |
| timestamp, |
| epoch_slot: 0, // TODO: Extract from snapshot metadata if available | ||
| new_epoch: false, // Not necessarily a new epoch | ||
| timestamp: 0, // TODO: Extract from snapshot metadata if available | ||
| era: Era::Conway, // TODO: Determine from snapshot or config |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding Era::Conway assumes all snapshots are from the Conway era, which may not be true for historical snapshots or other network configurations. The era should be determined from the snapshot metadata or configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
…nization with consumer modules
|
Looks a great start - @buddhisthead did you want this merged or is it still WIP? |
|
I don't have any good tests for it yet, which I'd like to add. I can probably hack on this a little tomorrow and try to wrap it up. I'd love to get some messages flowing to the DRepState before I call it good. |
This PR updates the snapshot_bootstrapper module to read and parse an Amaru/Haskell node snapshot file, providing the initial structure of the process. It includes the parser and placeholder callback implementation for the streaming snapshot parser and also the pub/sub top-level message sequence.
Some features:
TESTING
Nothing yet. But
cargo testshouldn't be broken.