-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Implement DRepState bootstrapping - 264 #488
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
Conversation
* Move DRep types into their own file * Remove the history part for PR, we can add it back in a future commit
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 DRepState bootstrapping from CBOR snapshot files, enabling the system to initialize DRep state directly from snapshot data rather than replaying the entire chain. The implementation refactors DRep-related types into a dedicated module to resolve circular dependencies and adds the necessary message passing infrastructure to communicate bootstrap data between the snapshot parser and DRepState module.
Key changes:
- Creates new
common/src/drep.rsmodule consolidating all DRep types (DRepCredential, DRepRecord, Anchor, DRepChoice, etc.) - Implements DRepState bootstrap handler to receive and process DRep data from snapshots
- Adds DRepBootstrapMessage and updates snapshot callback signatures to pass HashMap-based DRep data
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| processes/omnibus/omnibus.toml | Changes startup method from "mithril" to "snapshot" (appears to be test configuration that should be reverted) |
| modules/snapshot_bootstrapper/src/publisher.rs | Implements DRep bootstrap message publishing, updates callback to new signature, adds fields for tracking DRep count |
| modules/drep_state/src/state.rs | Adds bootstrap method to insert DRep records from snapshot data into state |
| modules/drep_state/src/drep_state.rs | Adds snapshot message subscription and handler to receive bootstrap messages |
| common/src/types.rs | Removes DRep types that were moved to dedicated module, updates imports |
| common/src/snapshot/streaming_snapshot.rs | Changes DRep parsing to return HashMap instead of Vec, updates internal types, converts from DRepInfo to DRepRecord |
| common/src/messages.rs | Adds DRepBootstrapMessage struct and DRepState variant to SnapshotStateMessage enum |
| common/src/lib.rs | Adds drep module and re-exports drep types |
| common/src/drep.rs | New file containing all DRep-related types: Anchor, DRepRecord, DRepChoice, DRepRegistration, DRepDeregistration, DRepUpdate, DRepVotingThresholds |
| common/examples/test_streaming_parser.rs | Updates example to work with new HashMap-based DRep callback signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub fn bootstrap(&mut self, drep_msg: &DRepBootstrapMessage) { | ||
| for (cred, record) in &drep_msg.dreps { | ||
| self.dreps.insert(cred.clone(), record.clone()); | ||
| // update historical state if enabled | ||
| /* | ||
| This will be needed once we want historical drep data from snapshots | ||
| if let Some(hist_map) = self.historical_dreps.as_mut() { | ||
| let cfg = self.config; | ||
| let entry = hist_map | ||
| .entry(cred.clone()) | ||
| .or_insert_with(|| HistoricalDRepState::from_config(&cfg)); | ||
| if let Some(info) = entry.info.as_mut() { | ||
| info.deposit = record.deposit; | ||
| info.expired = false; | ||
| info.retired = false; | ||
| info.active_epoch = None; | ||
| info.last_active_epoch = 0; // unknown from snapshot | ||
| info!( | ||
| "Bootstrapped Historical DRepState: DRep {:?} => {:?}", | ||
| cred, record | ||
| ); | ||
| } | ||
| } | ||
| */ | ||
| // info!("Bootstrapped DRepState: DRep {:?} => {:?}", cred, record); | ||
| } | ||
| } |
Copilot
AI
Dec 12, 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.
The new bootstrap method lacks test coverage. Consider adding unit tests to verify that DReps are correctly inserted from the bootstrap message, especially since this file already has comprehensive test coverage for other state operations (e.g., test_drep_process_one_certificate, test_drep_update_certificate). Tests should verify that the DRep records are properly stored and can be queried after bootstrap.
|
When I try to query dreps with the following configuration, I get empty responses. [module.drep-state]
# Enables /governance/dreps/{drep_id} endpoint (Requires store-delegators to be enabled)
store-info = true
# Enables /governance/dreps/{drep_id}/delegators endpoint
store-delegators = false
# Enables /governance/dreps/{drep_id}/metadata endpoint
store-metadata = false
# Enables /governance/dreps/{drep_id}/updates endpoint
store-updates = false
# Enables /governance/dreps/{drep_id}/votes endpoint
store-votes = false
[module.drdd-state]
store-drdd = trueWith the following: |
|
I would have expected these warnings to have disappeared as a result of this bootstrap work. Perhaps we can track this down together? The accounts bootstrap does already include the dreps so there must be something amiss with the credential decoding. |
| pub deposit: Lovelace, | ||
| } | ||
|
|
||
| /// Anchor |
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.
+100 for splitting this out!
sandtreader
left a comment
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.
Noted the Copilot suggestion about committing state and publish race condition - maybe needs snapshot callbacks to be async?
lowhung
left a comment
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.
Nice work @buddhisthead!
Description
Implement DRepState bootstrapping (without history)
Related Issue(s)
#264
How was this tested?
Modify your config file (omnibus.toml) to use the snapshot startup mode like this:
Run
make run | egrep "DRepState|Received 400 DReps"to see that we're receiving the bootstrapping messages.Checklist
Impact / Side effects
Moved all of the DRep types into their own file because adding more to "types.rs" seemed like generating more technical debt. The DRep types need to be shared across some modules and there was a circular dependency.
Reviewer notes / Areas to focus
Nothing special.