Skip to content

rep_weights part 3 - Add mininum weight to representative cache#4485

Merged
clemahieu merged 10 commits intonanocurrency:developfrom
rsnano-node:rep-cache-min-weight
Mar 22, 2024
Merged

rep_weights part 3 - Add mininum weight to representative cache#4485
clemahieu merged 10 commits intonanocurrency:developfrom
rsnano-node:rep-cache-min-weight

Conversation

@simpago
Copy link
Copy Markdown
Contributor

@simpago simpago commented Mar 12, 2024

This is the last part of multiple stacked and self-contained pull requests. The previous part is #4483.

Overall Goal

With the recent spam attack the number of representatives has increased significantly. All representatives and their vote weight are held in memory and this isn't a viable solution anymore. This series of pull requests moves the representatives out of memory and stores them in the database.

What this PR does

This PR introduces a minimum weight for the representatives cache (rep_weights). All votes from representatives below that minimum will be ignored. The minimum weight can be configured via the new option representative_vote_weight_minimum in the file config-node.toml

@simpago simpago force-pushed the rep-cache-min-weight branch 4 times, most recently from 3a6a8c3 to d916e14 Compare March 19, 2024 06:29
std::optional<nano::block_hash> successor (store::transaction const &, nano::qualified_root const &) const noexcept;
std::optional<nano::block_hash> successor (store::transaction const & transaction, nano::block_hash const & hash) const noexcept;
/* Returns the exact vote weight for the given representative by doing a database lookup */
nano::uint128_t weight_exact (store::transaction const &, nano::account const &);
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.

On the naming of "weight_exact" it seems like the other weight function isn't exact though they should always be in sync shouldn't they?

Copy link
Copy Markdown
Contributor Author

@simpago simpago Mar 22, 2024

Choose a reason for hiding this comment

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

Let's say a representative has a vote weight of Ӿ0.1. weight_exact would return Ӿ0.1, but weight would return 0, because it wasn't in the cache. I wanted to rename weight to weight_cached, but this would pollute this pull request with the renames. Or should I rename it now? Do you have better names in mind?
Maybe let's rename weight=>weight_cached and weight_exact => weight?

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.

Renaming is going to impact work in progress code, the current "non-exact" weight function is what node components should use 99% of the time.

@simpago simpago force-pushed the rep-cache-min-weight branch from d916e14 to b6ec773 Compare March 22, 2024 13:09
@clemahieu clemahieu merged commit 35da7e6 into nanocurrency:develop Mar 22, 2024
@simpago simpago deleted the rep-cache-min-weight branch March 29, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged / V27.0

Development

Successfully merging this pull request may close these issues.

5 participants