Skip to content

feat: Add SPDD and DRDD modules with optional historical storage #110

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

whankinsiv
Copy link
Collaborator

This PR:

  • Adds the spdd_state module to optionally store stake pool delegation distributions by epoch.
  • Moves the /spdd REST endpoint from accounts_state to spdd_state.
  • Updates caryatid_module_rest_server to v0.14.0 across applicable modules.
  • Enhances the /spdd endpoint to accept an optional epoch query parameter (Ex: /spdd?epoch=209).

In this implementation, the /spdd endpoint is always registered, while state creation and population are determined by the store-spdd config flag in omnibus.toml. When store-spdd is set to false, the handler receives a None state and returns a 503 error: "SPDD storage is disabled by configuration."

@whankinsiv whankinsiv changed the title feat: Add SPDD module with optional historical storage feat: Add SPDD and DRDD modules with optional historical storage Jul 31, 2025
@whankinsiv
Copy link
Collaborator Author

I've also included the drdd_state implementation in this PR, as it aligns closely with the logic in spdd_state. The /drdd endpoint now supports an optional epoch query parameter, enabling retrieval of historical DRep delegation distributions.

Signed-off-by: William Hankins <[email protected]>
@whankinsiv whankinsiv requested review from shd and alexwoods August 4, 2025 19:14
Copy link
Collaborator

@alexwoods alexwoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, probably only the incorrect label in the info_span of drdd_state really needs addressing.

@whankinsiv whankinsiv requested a review from alexwoods August 6, 2025 23:10
Copy link
Collaborator

@alexwoods alexwoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but check the comment on OrdMap

@whankinsiv whankinsiv requested a review from alexwoods August 12, 2025 18:33
{
let mut next = self.get_latest().cloned().unwrap_or_else(OrdMap::new);

// Update new or changed entries
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very similar to what's going on in drdd, just a slightly different contains check. For handling rollback state we currently have StateHistory in the common lib that works if your top level per-block state is a an imbl container. It might be nice to add a helper function alongside it for things like this where you have a new state to compare differences with the current one, to apply to an imbl::OrdMap clone of the current state. I can't help but feel that StateHistory might be extendable to work for epochs and retain all snapshots too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll expand StateHistory to handle epoch-based states and add a helper function to compare differences between imbl:OrdMaps when inserting.

@sandtreader
Copy link
Collaborator

@whankinsiv There are unresolved conflicts now which I can't directly fix - I suspect this has to do with 'cargo fmt' changes in AccountsState. I hope once we have 'cargo fmt' on CI this kind of thing will stop!

@whankinsiv whankinsiv marked this pull request as draft August 21, 2025 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants