Skip to content

Conversation

golddydev
Copy link
Collaborator

@golddydev golddydev commented Sep 3, 2025

📋 Overview

This PR introduces improvements to the Epoch Activity Counter module, focusing on enhanced state management, rollback support, historical data storage capabilities.

🔧 Key Changes

1. Enhanced State Management with Rollback Support

  • Added StateHistory Integration: Implemented proper state history management using StateHistory<State> to handle blockchain rollbacks gracefully
  • Rollback Handling: Added logic to detect rolled back blocks and restore previous state accordingly
  • State Synchronization: Implemented message synchronization checks between header and fees processing

2. Historical Data Storage System

  • New EpochsHistoryState: Created a dedicated component for storing historical epoch activity data
  • Configurable Storage: Added store-history configuration option to enable/disable historical data storage
  • DashMap Integration: Used DashMap for thread-safe concurrent access to historical data

3. Improved Query System

  • Enhanced Epoch Queries: Added GetTotalBlocksMintedByPools query to retrieve cumulative block minting data
  • Query Restructuring: Moved pool-related queries from pools.rs to epochs.rs for better organization
  • Consistent Response Format: Standardized query response structures across the module

4. Architecture Improvements

  • Modular Design: Split functionality into focused modules:
    • epoch_activity_publisher.rs: Dedicated message publishing
    • epochs_history.rs: Historical data management
    • store_config.rs: Configuration handling
  • Better Separation of Concerns: Separated state management, publishing, and historical storage responsibilities

5. Dependency Updates

  • tracing-subscriber: Resolve tracing-subscriber dependabot alert.
  • imbl Version Upgrade: Updated to imbl 6.0.0 for the main module and 5.0.0 for other modules
  • New Dependencies: Added dashmap for concurrent hash map operations
  • Dependency Consistency: Ensured consistent imbl versions across the codebase

🧪 Testing

  • Rollback Testing: Included tests for state rollback scenarios
  • Historical Data Tests: Verified historical epoch storage and retrieval

…ory.

- Refactored state management to include  for tracking epoch activities.
- Introduced  for publishing epoch activity messages.
- Added  to manage historical epoch data.
- Updated REST handlers to support new state management structure.
- Improved handling of block information and epoch transitions.
@golddydev golddydev changed the base branch from main to golddydev/pool-delegators September 3, 2025 13:37
…vity_couter module

- Introduced  query to retrieve total blocks minted for specified VRF key hashes.
- Updated  to include  response type.
- Enhanced state management to support retrieval of total blocks minted by pools.
- Refactored REST handlers to utilize the new total blocks minted query, improving data aggregation for pool statistics.
@golddydev golddydev changed the base branch from golddydev/pool-delegators to main September 4, 2025 09:44
@golddydev golddydev marked this pull request as ready for review September 4, 2025 15:15
@golddydev golddydev requested review from whankinsiv and sandtreader and removed request for whankinsiv September 4, 2025 15:15
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the BlockfrostREST now covers this through the query, this might be a good time to kill this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I"ll remove rest.rs and move to blockfrost module.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

827462f
This is fixed


// History of epochs (disabled by default)
epoch_history: Option<BTreeMap<u64, EpochActivityMessage>>,
// Total blocks minted till epoch N
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment: ... for each SPO
Also is it the start of epoch N or the end?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • or actually, reading the code, the current state in this case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, that is actually till current block number.

So total_blocks_minted is updated for every block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me update the comments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

d745e43

Updated comment

@@ -173,12 +172,8 @@ impl SPOState {
{
let span =
info_span!("spo_state.handle_epoch_activity", block = block_info.number);
async {
span.in_scope(|| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting - if this is a direct replacement, this needs sharing!

…ounter module

- Implemented new REST handlers for fetching the latest epoch and specific epoch information.
- Removed obsolete REST handling code to streamline the module.
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