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: IC-1680: Add NPR computation V1 in ic-registry-node-provider-rewards lib #2655

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

pietrodimarco-dfinity
Copy link
Contributor

@pietrodimarco-dfinity pietrodimarco-dfinity commented Nov 18, 2024

The PR adds to ic-registry-node-provider-rewards lib the v1 modules for computing Node Provider rewards with the following differences with respect to v0:

  • Rewards are computed evaluating reported subnet metrics in reward period.
  • Rewarded nodes are only the ones present in at least one registry version in the reward period.
  • Decimal precision numbers are used in the entire computation.
  • Each step of the entire computation is logged and logs are returned to the caller for debugging

@pietrodimarco-dfinity pietrodimarco-dfinity requested a review from a team as a code owner November 18, 2024 14:08
@pietrodimarco-dfinity pietrodimarco-dfinity changed the title Add compute rewards v1 feat: IC-1680: Add NPR computation V1 in lib Nov 18, 2024
@github-actions github-actions bot added the feat label Nov 18, 2024
@pietrodimarco-dfinity pietrodimarco-dfinity marked this pull request as draft November 18, 2024 14:11
@pietrodimarco-dfinity pietrodimarco-dfinity changed the title feat: IC-1680: Add NPR computation V1 in lib feat: IC-1680: Add NPR computation V1 in ic-registry-node-provider-rewards lib Nov 18, 2024
@pietrodimarco-dfinity pietrodimarco-dfinity marked this pull request as ready for review November 18, 2024 15:52
@pietrodimarco-dfinity pietrodimarco-dfinity requested a review from a team as a code owner November 18, 2024 15:52
Copy link
Contributor

@max-dfinity max-dfinity left a comment

Choose a reason for hiding this comment

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

Left some initial comments. I will need more time to review this, as there's a lot to understand here, and I'm a little backed up. Sorry for the dela.

rs/registry/node_provider_rewards/src/v1_rewards.rs Outdated Show resolved Hide resolved
rs/registry/node_provider_rewards/src/v1_rewards.rs Outdated Show resolved Hide resolved
rs/registry/node_provider_rewards/src/v1_rewards.rs Outdated Show resolved Hide resolved
@max-dfinity max-dfinity self-requested a review November 27, 2024 02:05
/// failure rate of the subnet from the node's failure rate for each day.
/// If the node's failure rate is less than the systematic failure rate, the idiosyncratic
/// failure rate is set to zero.
fn nodes_idiosyncratic_fr(
Copy link
Contributor

Choose a reason for hiding this comment

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

idiosyncratic has more of a connotation of "weird" or "peculiar", and maybe only serves to tell someone to read the function.

Maybe we could say "node_failure_rate_relative_to_subnet" or something more wordy, especially since it's only used locally. I'm not sure that's a great name either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a fairly good name...maybe "compute_relative_node_failure_rate" wdyt?

}

#[derive(Clone, Hash, Eq, PartialEq, Debug, Default)]
pub struct DailyNodeMetrics {
Copy link
Contributor

Choose a reason for hiding this comment

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

Because this is called daily_node_metrics, it makes it difficult to also use the variable name "daily_node_metrics" to refer to the vector of DailyNodeMetrics that spans a number of days.

I wonder if there's a clearer name for this... It's not actually multiple metrics, it seems to only be a single measurement, with some supporting data, and a timestamp that actually indicates a time period (i.e. a whole day).

As I've been reviewing, I've been having trouble tracking the logical flow of data as the shapes of each collection is transformed, and I think a large part of the difficulty is the naming of variables and concepts, and perhaps some type ambiguity.

Copy link
Contributor Author

@pietrodimarco-dfinity pietrodimarco-dfinity Jan 15, 2025

Choose a reason for hiding this comment

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

I see your point and I agree...I called it DailyNodeMetrics to stay consistent with "NodeMetrics" name from NodeMetricsHistoryResponse. One solution could be instead of using daily_node_metrics for the Vec use the concept of rewarding period as I did. wdyt?

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.

2 participants