Skip to content

feat: Add epoch activity REST endpoints with optional historical storage #89

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

whankinsiv
Copy link
Collaborator

This PR:

  • Adds current_epoch and optional epoch_history fields to the epoch_activity_counter state.
  • Introduces a store-history config option in omnibus.toml to enable historical epoch activity storage.
  • Implements /epoch and /epochs/{epoch_number} REST endpoints mentioned in Add REST endpoint to EpochActivityCounter #84.
  • Updates openapi.yaml to document new endpoints

API/openapi.yaml Outdated
content:
application/json:
schema:
type: object
Copy link
Collaborator

@sandtreader sandtreader Jul 17, 2025

Choose a reason for hiding this comment

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

To avoid duplication you can reference common structures with $ref - e.g.

       content:
          application/json:
              schema:
                $ref: '#/components/schemas/EpochData'

Then later (at top level)

components:
  schemas:
    EpochData:
        type: object
        properties:
            ...
            

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 made all 200 return types into components with shared subcomponents to clean up the top level paths in the latest commit.

@@ -53,21 +65,48 @@ impl State {
"End of epoch"
);

let epoch_activity = EpochActivityMessage {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could just be self.get_current_epoch() now, right? Although you'd have to clear the vrf_key_hashes separately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

use tokio::sync::Mutex;

#[derive(Serialize)]
pub struct EpochActivityRest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels like this could be the more natural thing to store (without the Rest suffix), and derive the EpochActivityMessage from that? Would save (duplicated) conversions below.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That was dumb - VRF keys are encoded strings in the REST version. Please ignore!

@sandtreader sandtreader merged commit bd85e49 into input-output-hk:main Jul 21, 2025
2 checks passed
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.

2 participants