Skip to content

feat: disable default dht discovery forwarding#7128

Merged
SWvheerden merged 5 commits intotari-project:developmentfrom
hansieodendaal:ho_disable_default_forwarding
Jun 3, 2025
Merged

feat: disable default dht discovery forwarding#7128
SWvheerden merged 5 commits intotari-project:developmentfrom
hansieodendaal:ho_disable_default_forwarding

Conversation

@hansieodendaal
Copy link
Copy Markdown
Contributor

@hansieodendaal hansieodendaal commented May 29, 2025

Description

  • Disabled default forwarding of DHT discovery messages as this is not required for the proper operation of the network. A config option has been added to enable or disable this, but the default is false.
  • Adjusted the DHT dedup cache default config to be a lot more conservative before starting new dedup cycle - the amount of time an identical inbound message will be ignored before being processed again.

Motivation and Context

Mainnet is being flooded with messages that do not contribute to the blockchain.

How Has This Been Tested?

System-level testing shows markedly reduced overheads, inbound pipeline finish times and overall memory usage. The dedup cache also does its job much better now so the base node does not can ignore the endless round robbin of the messages.

What process can a PR reviewer use to test or verify this change?

Code review.
System-level testing.

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option to enable or disable message forwarding in the network's DHT. This option is disabled by default and can be enabled for communication nodes.
  • Improvements

    • Increased the default cache capacity for deduplication and extended the default cache trim interval, enhancing overall message handling efficiency.
  • Documentation

    • Updated configuration files and documentation comments to reflect the new forwarding option and revised cache settings.

- Disabled default forwarding of DHT discovery messages as this is not required for the
  proper operation of the network.
- Adjusted the DHT dedup cache default config to be a lot more conservative before
  starting new dedup cycle - the amount of time an identical inbound message will be
  ignored before being processed again.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 29, 2025

Walkthrough

A new configuration option, enable_forwarding, has been introduced to control whether the DHT forwards messages to other nodes. This option is added to configuration files as a commented-out line and implemented in the DhtConfig struct with a default of false. Related cache parameters were also updated for higher capacity and longer intervals.

Changes

File(s) Change Summary
common/config/presets/c_base_node_c.toml,
common/config/presets/d_console_wallet.toml
Added commented-out enable_forwarding option with description under DHT config sections.
comms/dht/src/config.rs Added enable_forwarding field to DhtConfig, updated default cache capacity and trim interval, updated documentation.
comms/dht/src/dht.rs Modified logic to require both PeerFeatures::DHT_STORE_FORWARD and enable_forwarding to activate message forwarding.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Configuration
    participant Dht as Dht Node
    participant ForwardLayer as Forward Layer

    Config->>Dht: Load DhtConfig (enable_forwarding, dedup_cache_capacity, etc.)
    Dht->>Dht: Check PeerFeatures::DHT_STORE_FORWARD
    Dht->>Dht: Check config.enable_forwarding
    alt Both conditions true
        Dht->>ForwardLayer: Activate
    else
        Dht->>ForwardLayer: Do not activate
    end
Loading

Suggested reviewers

  • SWvheerden

Poem

In the warren, messages hop and bound,
Now a toggle controls if they're passed around.
With caches grown vast and intervals long,
Forwarding's a feature—enabled if you belong!
So here’s to the network, swift and neat,
Configured by rabbits, never missing a beat. 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a8d282c and c640518.

📒 Files selected for processing (2)
  • common/config/presets/c_base_node_c.toml (1 hunks)
  • common/config/presets/d_console_wallet.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • common/config/presets/d_console_wallet.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • common/config/presets/c_base_node_c.toml
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: cargo check with stable
  • GitHub Check: ci
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: Cucumber tests / FFI

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

Copy link
Copy Markdown
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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7867d12 and 6ec1758.

📒 Files selected for processing (4)
  • common/config/presets/c_base_node_c.toml (1 hunks)
  • common/config/presets/d_console_wallet.toml (1 hunks)
  • comms/dht/src/config.rs (4 hunks)
  • comms/dht/src/dht.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: cargo check with stable
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: ci
🔇 Additional comments (5)
comms/dht/src/config.rs (4)

114-116: LGTM! New configuration option properly implemented.

The enable_forwarding field is well-documented and appropriately defaults to false, aligning with the PR objective to disable default forwarding.


55-55: Documentation comments correctly updated for new cache defaults.

The updated comments accurately reflect the significantly increased default values.

Also applies to: 58-58


174-175: Cache parameter defaults appropriately increased.

The more conservative cache settings (20x capacity increase and 144x longer trim interval) should help reduce redundant message processing as intended.


191-191: Correct default value for forwarding control.

Setting enable_forwarding to false by default properly implements the objective to disable default DHT discovery forwarding.

comms/dht/src/dht.rs (1)

275-276: Forwarding logic correctly implemented.

The condition properly requires both the node's DHT_STORE_FORWARD capability and the new enable_forwarding configuration flag to be true before enabling message forwarding. This provides the intended control over DHT message forwarding behavior.

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 29, 2025

Test Results (CI)

    2 files     62 suites   20m 33s ⏱️
1 330 tests 1 329 ✅ 0 💤 1 ❌
1 699 runs  1 698 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 30816e5.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 29, 2025

Test Results (Integration tests)

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
2 files   +2   0 ❌ ±0 
2 errors

For more details on these parsing errors, see this check.

Results for commit fe30606. ± Comparison against base commit 41add9f.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

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

I am slightly weary that this might cause some unintended breakage down the line

@SWvheerden SWvheerden merged commit b6894ff into tari-project:development Jun 3, 2025
11 of 16 checks passed
@hansieodendaal hansieodendaal deleted the ho_disable_default_forwarding branch June 3, 2025 09:50
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