Skip to content

feat(dashmate): add state sync configuration - #2558

Merged
lklimek merged 6 commits into
feat/reduced+state_syncfrom
feat/reduced+state_sync+configuration
Apr 24, 2025
Merged

feat(dashmate): add state sync configuration#2558
lklimek merged 6 commits into
feat/reduced+state_syncfrom
feat/reduced+state_sync+configuration

Conversation

@shumkov

@shumkov shumkov commented Apr 18, 2025

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

We need to configure state sync with dashmate

What was done?

  • Added configuration for state sync
  • Added config migration

How Has This Been Tested?

None

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Introduced configurable state synchronization options, including snapshot and checkpoint management, for enhanced data consistency across environments.
    • Added new environment variables and configuration options to control snapshot frequency, enable/disable state sync, and set limits for snapshots.
  • Configuration

    • Updated configuration schemas and environment files to support the new state sync options.
    • Improved Docker and Docker Compose setups to manage new checkpoint directories and environment variables.
  • Migration

    • Added automated migration to apply state sync settings to existing configurations.

@coderabbitai

coderabbitai Bot commented Apr 18, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce and standardize state synchronization (state sync) configuration across the system, particularly for the Drive ABCI and Tenderdash components. New configuration schema properties, environment variables, and Docker volume mounts are added to support state sync features such as snapshots and checkpoints. The Rust configuration structs are refactored to centralize state sync settings within the AbciConfig, removing redundant or legacy fields. Migration logic is included to update existing configuration files to the new format, and Docker-related files are updated to mount and initialize the new checkpoint directories. These updates collectively enable more robust and configurable state synchronization.

Changes

File(s) Change Summary
Dockerfile, packages/dashmate/docker-compose.yml Added new volume and directory for /var/lib/dash/rs-drive-abci/db-checkpoints, removed legacy checkpoint path, updated environment variables for state sync and snapshots.
packages/dashmate/configs/defaults/getBaseConfigFactory.js,
packages/dashmate/configs/defaults/getLocalConfigFactory.js
Introduced new stateSync configuration blocks for Drive ABCI and Tenderdash, with mainnet/testnet defaults enabled and local config disabled.
packages/dashmate/configs/getConfigFileMigrationsFactory.js Added migration for version 2.1.0 to insert new stateSync properties into config files, with logic to enable or disable based on environment.
packages/dashmate/src/config/configJsonSchema.js Extended JSON schema to validate new stateSync objects under Drive ABCI and Tenderdash with nested snapshot and concurrency properties.
packages/rs-drive-abci/.env.local,
packages/rs-drive-abci/.env.mainnet,
packages/rs-drive-abci/.env.testnet
Added environment variables for checkpoints path, snapshots enabled, frequency, and max snapshots under a new "State Sync" section.
packages/rs-drive-abci/src/abci/config.rs Added state_sync field to AbciConfig, provided environment-specific default constructors, and centralized checkpoint path logic. Enabled snapshots by default for mainnet and testnet.
packages/rs-drive-abci/src/config.rs Removed state_sync_config from PlatformConfig, refactored to use new AbciConfig constructors for state sync settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Dashmate Config
    participant Docker Compose
    participant Drive ABCI
    participant Tenderdash

    User->>Dashmate Config: Runs config migration or setup
    Dashmate Config->>Dashmate Config: Adds stateSync settings for ABCI and Tenderdash
    Dashmate Config->>Docker Compose: Passes stateSync env vars and volume mounts
    Docker Compose->>Drive ABCI: Mounts checkpoints directory, sets env vars
    Docker Compose->>Tenderdash: Sets stateSync env vars
    Drive ABCI->>Drive ABCI: Initializes stateSync from config/env
    Tenderdash->>Tenderdash: Initializes stateSync from config/env
Loading

Poem

🐰
In the warren of configs, a new path appears,
For checkpoints and snapshots, to calm syncing fears.
With state sync enabled, the nodes leap ahead,
Old configs migrated, old paths put to bed.
Environment variables sprout, like carrots in rows—
Now Drive and Tenderdash sync as the rabbit well knows!
🥕✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@shumkov shumkov self-assigned this Apr 18, 2025
@shumkov shumkov linked an issue Apr 18, 2025 that may be closed by this pull request
@shumkov

shumkov commented Apr 18, 2025

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 18, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/dashmate/docker-compose.yml (1)

96-99: Optional: Parameterize CHECKPOINTS_PATH instead of hardcoding
Consider using a host-side variable (e.g. ${PLATFORM_DRIVE_ABCI_STATE_SYNC_CHECKPOINTS_PATH:-/var/lib/dash/rs-drive-abci/db-checkpoints}) for CHECKPOINTS_PATH to maintain consistency with the other snapshot-related variables.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4039657 and 7dd673a.

⛔ Files ignored due to path filters (1)
  • packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot is excluded by !**/*.dot
📒 Files selected for processing (11)
  • Dockerfile (2 hunks)
  • packages/dashmate/configs/defaults/getBaseConfigFactory.js (2 hunks)
  • packages/dashmate/configs/defaults/getLocalConfigFactory.js (1 hunks)
  • packages/dashmate/configs/getConfigFileMigrationsFactory.js (1 hunks)
  • packages/dashmate/docker-compose.yml (3 hunks)
  • packages/dashmate/src/config/configJsonSchema.js (2 hunks)
  • packages/rs-drive-abci/.env.local (1 hunks)
  • packages/rs-drive-abci/.env.mainnet (1 hunks)
  • packages/rs-drive-abci/.env.testnet (1 hunks)
  • packages/rs-drive-abci/src/abci/config.rs (4 hunks)
  • packages/rs-drive-abci/src/config.rs (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/rs-drive-abci/src/abci/config.rs (1)
packages/rs-drive-abci/src/config.rs (10)
  • default_mainnet (832-871)
  • default (87-92)
  • default (366-369)
  • default (450-459)
  • default (540-549)
  • default (676-683)
  • default (687-689)
  • default (906-914)
  • default_local (706-745)
  • default_testnet (790-829)
packages/rs-drive-abci/src/config.rs (1)
packages/rs-drive-abci/src/abci/config.rs (6)
  • default_local (68-78)
  • default_local (124-131)
  • default_testnet (80-90)
  • default_testnet (133-140)
  • default_mainnet (56-66)
  • default_mainnet (142-149)
🔇 Additional comments (21)
packages/rs-drive-abci/.env.testnet (1)

17-21: Env vars for State Sync added correctly
The new environment variables under the “State Sync” section—CHECKPOINTS_PATH, SNAPSHOTS_ENABLED, SNAPSHOTS_FREQUENCY, and MAX_NUM_SNAPSHOTS—align with the updated configuration schema and existing defaults. No conflicts detected.

packages/dashmate/configs/defaults/getLocalConfigFactory.js (1)

66-68: Disable stateSync in local configs
Adding stateSync.enabled: false here correctly overrides the base configuration for local development, preventing unnecessary state sync operations on a single-node setup.

packages/rs-drive-abci/.env.local (1)

16-20: Local .env: State Sync variables inserted
The “State Sync” header and its associated variables (CHECKPOINTS_PATH, SNAPSHOTS_ENABLED, SNAPSHOTS_FREQUENCY, MAX_NUM_SNAPSHOTS) are in the right place and consistent with other env files.

packages/rs-drive-abci/.env.mainnet (1)

17-21: Mainnet .env: State Sync section added
The checkpoint path and snapshot controls appear correct and mirror the testnet/local defaults. No regressions spotted.

packages/dashmate/docker-compose.yml (1)

85-85: Verify renaming of DB path var to GROVEDB_LATEST_FILE
You’ve replaced DB_PATH with GROVEDB_LATEST_FILE in the container’s environment. Ensure the Rust AbciConfig (and any related code) now reads GROVEDB_LATEST_FILE instead of DB_PATH.

packages/dashmate/configs/getConfigFileMigrationsFactory.js (1)

1079-1104: Well-structured migration for state sync configuration.

This new migration adds state synchronization configuration to all platforms with sensible defaults, and correctly disables it for local configurations. The implementation iterates over existing configs and applies the new properties appropriately.

packages/dashmate/configs/defaults/getBaseConfigFactory.js (2)

308-314: Appropriate default settings for ABCI state sync snapshots.

The new stateSync configuration for the ABCI component sets reasonable defaults with snapshots enabled, a moderate frequency (5), and a reasonable maximum limit (100).


422-429: Good defaults for Tenderdash state sync configuration.

The Tenderdash state sync configuration includes appropriate timeout settings, retry logic, and concurrency limits that should work well in production environments.

Dockerfile (2)

608-608: Added necessary volume for state sync checkpoints.

This change adds a dedicated volume for state sync checkpoints, which is required for the new state synchronization functionality.


628-628: Correct permissions for checkpoint directory.

The updated ownership settings ensure that the dash user has proper access to the new checkpoints directory.

packages/dashmate/src/config/configJsonSchema.js (3)

952-976: New state sync schema for drive.abci looks good.

The schema properly defines the structure for ABCI state sync configuration, with appropriate validation for enabling snapshot functionality, frequency of snapshots, and maximum snapshot limit. All properties are correctly set as required with appropriate data types and minimum values.


1236-1264: Well-structured schema for Tenderdash state sync.

The Tenderdash state sync configuration schema is comprehensive, including the necessary parameters for enabling state sync, retries, timeout handling, and concurrent operations management. All properties have appropriate minimum values and correct data types.


1266-1266: Good addition of stateSync to required properties.

Adding stateSync to the required properties list for drive.tenderdash ensures that this configuration will be present in all configurations, which is important for the feature to work consistently.

packages/rs-drive-abci/src/abci/config.rs (8)

42-44: Good integration of state sync into AbciConfig.

The flattening of the state_sync field is a clean approach that will simplify the configuration structure when serialized/deserialized.


56-66: Well-structured default_mainnet implementation.

The default_mainnet implementation correctly initializes all configuration properties and uses the specific state sync configuration for mainnet environments.


68-78: Good implementation of default_local method.

This method correctly configures ABCI for local development environments, particularly by using the appropriate state sync configuration where snapshots are disabled by default.


88-88: Proper state sync configuration for testnet.

Using the TestNet-specific state sync configuration is appropriate here.


93-97: Good Default trait implementation.

Setting the default implementation to use default_mainnet() ensures consistency with production environments when explicit environment isn't specified.


127-127: Good refactoring of default path initialization.

Using the centralized default_checkpoints_path() method across all environment configurations ensures consistency and follows the DRY principle.

Also applies to: 136-136, 145-145


144-144: Enabling snapshots for mainnet is appropriate.

Setting snapshots_enabled to true for mainnet aligns with the testnet configuration and is suitable for production environments where state synchronization is important.


42-97: Verify PR testing status before merging.

The PR description mentioned "no testing has been performed yet." Before merging, ensure that comprehensive testing of the state sync configuration is performed in all supported environments (mainnet, testnet, local) to verify correct functionality.

Comment thread packages/dashmate/docker-compose.yml
block_spacing_ms: 5000,
drive: Default::default(),
abci: Default::default(),
abci: AbciConfig::default_local(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improved configuration structure by removing redundant state sync config.

This change refactors the configuration to use environment-specific AbciConfig constructors instead of default initialization. The code now centralizes state sync configuration within the AbciConfig rather than having a separate state_sync_config field in PlatformConfig.

The refactoring makes the configuration structure cleaner and more maintainable by properly delegating state sync configuration responsibility to the AbciConfig struct.

Also applies to: 774-774, 816-816, 858-858

@lklimek lklimek assigned lklimek and unassigned shumkov Apr 24, 2025
@lklimek
lklimek force-pushed the feat/reduced+state_sync+configuration branch from 5b769c0 to 8cb7ad7 Compare April 24, 2025 11:59
@lklimek lklimek added this to the v2.1 milestone Apr 24, 2025
@lklimek
lklimek merged commit 3fdf661 into feat/reduced+state_sync Apr 24, 2025
@lklimek
lklimek deleted the feat/reduced+state_sync+configuration branch April 24, 2025 13:37
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.

dashmate statesync Tenderdash configuration

2 participants