Skip to content

Comments

Add topic score params#394

Merged
mergify[bot] merged 8 commits intosigp:unstablefrom
diegomrsantos:topic-score-consts
Jun 27, 2025
Merged

Add topic score params#394
mergify[bot] merged 8 commits intosigp:unstablefrom
diegomrsantos:topic-score-consts

Conversation

@diegomrsantos
Copy link
Member

@diegomrsantos diegomrsantos commented Jun 26, 2025

Issue Addressed

#371

Proposed Changes

Adds a new topic scoring configuration module and integrates decay functions into the scoring submodule

  • Defines network and topic config structs with default values and computes Gossipsub TopicScoreParams
  • Exposes calculate_score_decay_factor and decay_convergence as pub(crate) in peer_score_config.rs
  • Introduces a decay_threshold helper and wires in the new topic_score_config module

Additional Info

For reference, that's the go code https://github.com/ssvlabs/ssv/blob/main/network/topics/params/topic_score.go#L229

This comment was marked as outdated.

@diegomrsantos diegomrsantos requested a review from Copilot June 26, 2025 17:18

This comment was marked as outdated.

topic_weight: network.total_topics_weight / subnets as f64, /* Set topic weight with
* equal weights across
* all subnets */
expected_msg_rate: 0.0, // calculate_message_rate_for_topic(committees),
Copy link
Member Author

Choose a reason for hiding this comment

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

This will be added in the next PR cause it's a big file

@dknopik
Copy link
Member

dknopik commented Jun 27, 2025

The Go code does a sanitization at the end to avoid NaN and Inf values. Do you think we need that? Or can we guarantee that we do not reach such values? I am worried about edge cases like subnets without committees, which we may subscribe to when in --subscribe-all-subnets mode.

@diegomrsantos
Copy link
Member Author

The Go code does a sanitization at the end to avoid NaN and Inf values. Do you think we need that? Or can we guarantee that we do not reach such values? I am worried about edge cases like subnets without committees, which we may subscribe to when in --subscribe-all-subnets mode.

I was planning to add in a new PR, I'll push it here

@diegomrsantos diegomrsantos requested review from Copilot and dknopik June 27, 2025 10:25

This comment was marked as outdated.

@diegomrsantos diegomrsantos changed the title Add topic score consts and default function Add topic score params Jun 27, 2025
@diegomrsantos diegomrsantos requested a review from Copilot June 27, 2025 14:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new module for computing dynamic topic scoring parameters, exposes shared decay utilities, and integrates them into the scoring subsystem.

  • Introduces topic_score_config with NetworkConfig, TopicConfig, and TopicScoringOptions to calculate TopicScoreParams.
  • Makes calculate_score_decay_factor and decay_convergence pub(crate), and adds a new decay_threshold helper.
  • Updates scoring/mod.rs to wire in topic_score_config and include decay_threshold.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
anchor/network/src/scoring/topic_score_config.rs New topic scoring config module, default impls, and param conversion
anchor/network/src/scoring/peer_score_config.rs Changed decay utilities to pub(crate) for reuse
anchor/network/src/scoring/mod.rs Added topic_score_config module and decay_threshold function
Comments suppressed due to low confidence (3)

anchor/network/src/scoring/mod.rs:5

  • Public helper decay_threshold lacks doc comments. Please add ///-style documentation describing its parameters, return value, and error conditions.
pub(crate) fn decay_threshold(decay_factor: f64, target_value: f64) -> Result<f64, String> {

anchor/network/src/scoring/mod.rs:5

  • The new decay_threshold function is not covered by unit tests. Consider adding tests for both valid inputs and error branches to ensure correct behavior.
pub(crate) fn decay_threshold(decay_factor: f64, target_value: f64) -> Result<f64, String> {

anchor/network/src/scoring/topic_score_config.rs:310

  • topic_score_params_for_subnet isn't exercised by any tests. Add unit tests to validate its output in both success and fallback scenarios.
pub fn topic_score_params_for_subnet(

@diegomrsantos
Copy link
Member Author

topic_score_params_for_subnet isn't exercised by any tests. Add unit tests to validate its output in both success and fallback scenarios.

Tests will be added in a new PR

Copy link
Member

@dknopik dknopik left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@mergify mergify bot merged commit 5627fcb into sigp:unstable Jun 27, 2025
14 checks passed
diegomrsantos added a commit to diegomrsantos/anchor that referenced this pull request Sep 17, 2025
sigp#371


  Adds a new topic scoring configuration module and integrates decay functions into the scoring submodule
- Defines network and topic config structs with default values and computes Gossipsub `TopicScoreParams`
- Exposes `calculate_score_decay_factor` and `decay_convergence` as `pub(crate)` in `peer_score_config.rs`
- Introduces a `decay_threshold` helper and wires in the new `topic_score_config` module
jking-aus pushed a commit to jking-aus/anchor that referenced this pull request Oct 8, 2025
sigp#371


  Adds a new topic scoring configuration module and integrates decay functions into the scoring submodule
- Defines network and topic config structs with default values and computes Gossipsub `TopicScoreParams`
- Exposes `calculate_score_decay_factor` and `decay_convergence` as `pub(crate)` in `peer_score_config.rs`
- Introduces a `decay_threshold` helper and wires in the new `topic_score_config` module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants