Skip to content
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

feat: single-node quorum type 111 #1008

Open
wants to merge 5 commits into
base: v1.5-dev
Choose a base branch
from
Open

Conversation

lklimek
Copy link
Collaborator

@lklimek lklimek commented Dec 17, 2024

Issue being fixed or feature implemented

We need support for quorum type 111, which is single-node quorum.

What was done?

  1. Updated dashd-go to v0.26.0 to include feat: add llmq_single_node quorum type (111) dashd-go#24
  2. Added a field sync-timeout to config file,
# Timeout for the initial sync process, before switching to consensus.
# If zero or empty, the default value is used.
#
# Default: 60s
sync-timeout = "{{ .BaseConfig.SyncTimeout }}"

How Has This Been Tested?

Tested as part of dash platform development, dashpay/platform#2392

Breaking Changes

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 made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Introduced a new configuration option for synchronization timeout, allowing users to define a specific duration.
    • Enhanced the configurability of synchronization timeout within the reactor and synchronizer components.
  • Bug Fixes
    • Improved validation logic for configuration settings to prevent negative timeout values.
  • Documentation
    • Added comments to clarify the purpose and default behavior of the new synchronization timeout option.

Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Walkthrough

The pull request introduces several updates across multiple files, primarily focusing on dependency version upgrades in the go.mod file and enhancements to configuration management. A new SyncTimeout field is added to the BaseConfig struct, along with corresponding updates in configuration tests and templates. The Reactor and Synchronizer structs are modified to incorporate this timeout, allowing for more flexible synchronization behavior. Additionally, the makeNode function is updated to utilize the new timeout configuration when creating a blockchain reactor.

Changes

File Change Summary
go.mod - Upgraded github.com/dashpay/dashd-go from v0.25.0 to v0.26.0
- Upgraded github.com/dashpay/dashd-go/btcec/v2 from v2.1.0 to v2.2.0
- Updated golang.org/x/crypto from v0.30.0 to v0.31.0
- Updated github.com/btcsuite/btclog from v0.0.0 to v1.0.0
- Upgraded github.com/dashpay/dashd-go/btcutil from v1.2.0 to v1.3.0
config/config.go - Added field SyncTimeout time.Duration in BaseConfig
- Set default value SyncTimeout: 60 * time.Second in DefaultBaseConfig()
- Updated validation for SyncTimeout in ValidateBasic()
config/config_test.go - Added assertion for SyncTimeout in TestDefaultConfig
- Updated validation tests for timeout configurations
config/toml.go - Added sync-timeout option to defaultConfigTemplate
internal/blocksync/reactor.go - Added field syncTimeout time.Duration in Reactor
- Added method WithSyncTimeout(timeout time.Duration)
- Renamed constant syncTimeout to defaultSyncTimeout
internal/blocksync/synchronizer.go - Added field syncTimeout time.Duration in Synchronizer
- Added method WithSyncTimeout(timeout time.Duration)
node/node.go - Updated makeNode to call WithSyncTimeout(cfg.SyncTimeout) on NewReactor

Suggested reviewers

  • QuantumExplorer
  • shumkov

Poem

🐰 Hop, hop, dependencies dance!
Versions leap with each new chance
Dashd and crypto take a stride
Upgrades flowing, smooth and wide
Code evolves with rabbit's glee 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

@lklimek lklimek self-assigned this Dec 17, 2024
@lklimek lklimek marked this pull request as ready for review December 18, 2024 11:43
@lklimek lklimek changed the title feat: support single-node quorums build(deps): bump dashd-go to 0.26.0 to support single-node quorums Dec 18, 2024
@lklimek lklimek changed the title build(deps): bump dashd-go to 0.26.0 to support single-node quorums build(deps): bump dashd-go to 0.26.0 to support 1-node quorums Dec 18, 2024
@lklimek lklimek enabled auto-merge (squash) December 18, 2024 11:49
@lklimek lklimek added this to the v1.5.x milestone Dec 18, 2024
@lklimek lklimek changed the title build(deps): bump dashd-go to 0.26.0 to support 1-node quorums feat: single-node quorum type 111 Dec 18, 2024
@lklimek lklimek disabled auto-merge December 18, 2024 11:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
internal/blocksync/synchronizer.go (1)

117-121: Consider adding validation for negative timeout values.

The WithSyncTimeout function should validate that the timeout value is positive to prevent potential issues.

 func WithSyncTimeout(timeout time.Duration) OptionFunc {
 	return func(v *Synchronizer) {
+		if timeout <= 0 {
+			timeout = defaultSyncTimeout
+		}
 		v.syncTimeout = timeout
 	}
 }
node/node.go (1)

Line range hint 1-1000: Consider breaking down the makeNode function

The makeNode function is quite large (>500 lines) and handles multiple responsibilities. Consider breaking it down into smaller, more focused functions for better maintainability.

Some suggestions:

  • Extract reactor creation into separate functions
  • Group related initialization logic
  • Consider using the builder pattern for node creation

Example refactor:

func makeNode(ctx context.Context, cfg *config.Config, ...) (service.Service, error) {
    node := &nodeImpl{}
    
    if err := node.initializeBasicServices(ctx, cfg); err != nil {
        return nil, err
    }
    
    if err := node.initializeReactors(ctx, cfg); err != nil {
        return nil, err
    }
    
    if err := node.initializeValidatorServices(ctx, cfg); err != nil {
        return nil, err
    }
    
    return node, nil
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8f428b and 6118718.

📒 Files selected for processing (6)
  • config/config.go (2 hunks)
  • config/config_test.go (1 hunks)
  • config/toml.go (1 hunks)
  • internal/blocksync/reactor.go (5 hunks)
  • internal/blocksync/synchronizer.go (4 hunks)
  • node/node.go (1 hunks)
🔇 Additional comments (7)
config/config_test.go (1)

27-28: LGTM: Test coverage added for SyncTimeout default value.

The test correctly verifies that the default sync timeout is set to 60 seconds, matching the defaultSyncTimeout constant.

internal/blocksync/reactor.go (2)

33-33: LGTM: Good refactoring of sync timeout configuration.

The constant rename to defaultSyncTimeout better reflects its purpose, and the new syncTimeout field in the Reactor struct enables runtime configuration of the timeout value.

Also applies to: 65-66


112-116: LGTM: Clean implementation of the builder pattern.

The WithSyncTimeout method follows the builder pattern correctly, allowing for fluent configuration of the sync timeout.

internal/blocksync/synchronizer.go (2)

73-74: LGTM: Clean implementation of configurable sync timeout.

The syncTimeout field is well-documented, and the WithSyncTimeout option function follows the established pattern for configuration.

Also applies to: 117-121


251-251: LGTM: Good use of configurable timeout in sync logic.

The WaitForSync method correctly uses the configured timeout, and the log message helpfully shows the remaining time until timeout.

Also applies to: 258-258

config/toml.go (1)

140-144: LGTM: Well-documented configuration option

The sync-timeout configuration is properly documented with clear default value and purpose.

node/node.go (1)

370-370: ⚠️ Potential issue

Implementation for quorum type 111 is missing

The PR objectives mention implementing support for single-node quorum type 111, but there are no changes related to this in the codebase. Please ensure the quorum type implementation is included.

config/config.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
config/config.go (1)

237-241: Enhance the documentation for SyncTimeout field.

The documentation could be more descriptive about what happens after the timeout expires. Consider adding details about the behavior when switching to consensus.

   // SyncTimeout is the timeout for the initial sync process, before switching to consensus.
+  // After this timeout expires, the node will proceed with consensus regardless of the sync state.
   //
   // Default: 60s
   SyncTimeout time.Duration `mapstructure:"sync-timeout"`
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6118718 and 86f286e.

📒 Files selected for processing (2)
  • config/config.go (3 hunks)
  • config/toml.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/toml.go
🔇 Additional comments (3)
config/config.go (3)

259-259: LGTM!

The default value initialization is correct and consistent with the documentation.


363-366: LGTM! Validation logic properly implemented.

The validation logic correctly checks for negative values and includes a descriptive error message.


237-241: Verify the usage of SyncTimeout configuration.

Let's verify how this configuration field is used in the codebase.

✅ Verification successful

Based on the search results, I can now generate a final response as the usage of SyncTimeout is well documented in the codebase.

SyncTimeout configuration is properly integrated and used

The configuration field is correctly integrated across the codebase:

  • Used in internal/blocksync/reactor.go with a default value of 60 seconds
  • Properly passed from node configuration to the block sync reactor via WithSyncTimeout
  • Utilized in the Synchronizer component through dependency injection
  • Has validation in config.ValidateBasic() to ensure non-negative values
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check where and how SyncTimeout is used in the codebase

# Search for SyncTimeout usage in the codebase
echo "Searching for SyncTimeout usage..."
rg -A 5 "SyncTimeout"

# Search for specific sync timeout related function calls
echo "Searching for sync timeout related function calls..."
rg -A 5 "NewReactor.*SyncTimeout|NewSynchronizer.*timeout"

Length of output: 4199

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant