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

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

Merged
merged 10 commits into from
Mar 22, 2024

Conversation

simpago
Copy link
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

nano/node/nodeconfig.hpp Outdated Show resolved Hide resolved
@simpago simpago force-pushed the rep-cache-min-weight branch 3 times, most recently from 3a6a8c3 to d916e14 Compare March 19, 2024 06:29
nano/core_test/ledger.cpp Outdated Show resolved Hide resolved
nano::uint128_t weight (nano::account const &);
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
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
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
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.

@clemahieu clemahieu merged commit 35da7e6 into nanocurrency:develop Mar 22, 2024
25 of 27 checks passed
@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.

4 participants