Repository navigation
feat(nns): Voting rewards are now in proportion to total *potential* voting power. - #2385
Merged
daniel-wong-dfinity-org merged 11 commits intoNov 15, 2024
Conversation
daniel-wong-dfinity-org
changed the base branch from
master
to
total_potential_voting_power-daniel-wong
November 1, 2024 15:12
daniel-wong-dfinity-org
marked this pull request as ready for review
November 1, 2024 16:11
daniel-wong-dfinity-org
force-pushed
the
total_potential_voting_power-daniel-wong
branch
from
November 6, 2024 09:45
e0fba01 to
76d8d90
Compare
daniel-wong-dfinity-org
force-pushed
the
distribute-voting-rewards-based-on-potential-voting-power-daniel-wong
branch
from
November 6, 2024 09:46
4094330 to
48fa879
Compare
daniel-wong-dfinity-org
force-pushed
the
total_potential_voting_power-daniel-wong
branch
from
November 6, 2024 09:52
76d8d90 to
8936d4a
Compare
daniel-wong-dfinity-org
force-pushed
the
distribute-voting-rewards-based-on-potential-voting-power-daniel-wong
branch
from
November 6, 2024 09:52
48fa879 to
200cc5b
Compare
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Nov 7, 2024
# Background This is part of the "periodic confirmation" feature that was recently approved in proposal [132411][prop]. [prop]: https://dashboard.internetcomputer.org/proposal/132411 # Future Work This will be used in the calculation of voting rewards. Whereas, before, the total voting power in ballots (i.e. "deciding" voting power) was used as the baseline to determine each neuron's share of the reward purse. With the distinction between potential voting power vs. deciding voting power (implemented in an earlier PR in this series), if we continued to do it the old way, the pie would be sliced into a smaller number of pieces. When this new field is used, the pie will continue to be sliced into the same number of pieces today. This way, neurons that stay refreshed will keep getting the same amount of rewards (not more), while those who do not stay refreshed will get less. # References Closes https://dfinity.atlassian.net/browse/NNS1-3411. [👈 Previous PR][prev] | [Next PR 👉][next] [prev]: #2339 [next]: #2385
Base automatically changed from
total_potential_voting_power-daniel-wong
to
master
November 7, 2024 01:42
daniel-wong-dfinity-org
force-pushed
the
distribute-voting-rewards-based-on-potential-voting-power-daniel-wong
branch
from
November 7, 2024 07:51
200cc5b to
7a97685
Compare
daniel-wong-dfinity-org
enabled auto-merge
November 8, 2024 13:59
daniel-wong-dfinity-org
left a comment
Contributor
Author
There was a problem hiding this comment.
Hints for reviewers.
max-dfinity
reviewed
Nov 12, 2024
max-dfinity
reviewed
Nov 12, 2024
aterga
reviewed
Nov 13, 2024
aterga
reviewed
Nov 13, 2024
aterga
reviewed
Nov 13, 2024
aterga
reviewed
Nov 13, 2024
aterga
reviewed
Nov 13, 2024
aterga
reviewed
Nov 13, 2024
aterga
reviewed
Nov 13, 2024
aterga
reviewed
Nov 13, 2024
aterga
approved these changes
Nov 13, 2024
aterga
left a comment
Contributor
There was a problem hiding this comment.
Approving modulo comments
…de effect of making distribute_rewards a little longer, which is unfortunate, because distribute_rewards is super long.
daniel-wong-dfinity-org
force-pushed
the
distribute-voting-rewards-based-on-potential-voting-power-daniel-wong
branch
from
November 14, 2024 13:21
0ca5eb8 to
4f89235
Compare
daniel-wong-dfinity-org
removed this pull request from the merge queue due to a manual request
Nov 14, 2024
max-dfinity
reviewed
Nov 14, 2024
max-dfinity
approved these changes
Nov 14, 2024
max-dfinity
left a comment
Contributor
There was a problem hiding this comment.
Pre-approving, but if possible, please improve the test.
If that's not possible, I see it's covered in the next PR.
daniel-wong-dfinity-org
enabled auto-merge
November 15, 2024 15:44
daniel-wong-dfinity-org
deleted the
distribute-voting-rewards-based-on-potential-voting-power-daniel-wong
branch
November 15, 2024 16:16
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Nov 15, 2024
This used to be part of #2385, but I was asked to not spin out sum_weighted_voting_power from distribute_rewards.
DFINITYManu
pushed a commit
that referenced
this pull request
Nov 19, 2024
…voting power. (#2385) Whereas, before, we did not have a distinction between **potential** voting power vs. **deciding** voting power. When neurons refresh themselves, there is no difference between these. Whereas, when a neuron does not refresh itself recently enough, the amount of voting power in its ballots (its "deciding" voting power) is less than its potential voting power. # Example Suppose there are two neurons: * A has 100 potential voting power, and refreshed recently, and as a result, its deciding voting power is also 100. * B has 1000 potential voting power, but has not refreshed in a long time, and as a result, it's deciding voting power is just 500. Then, the total potential voting power is 1100. If both neurons vote, then A gets 100 / 1100 of the reward purse, while B gets only 500 / 1100 of the reward purse, not 1000 / 1100. You might also intuitively guess that the neurons get 100 / 600 and 500 / 600 of the reward purse, but this is (also) incorrect. The reason for this design is to keep the amount of rewards to refreshed neurons the same as before, not more. In other words, it should not be that some other neuron goes to sleep, and as a result, you get more rewards. It should only be that the sleeper neuron gets less. # References This is part of the "periodic confirmation" feature that was recently approved in proposal [132411][prop]. [prop]: https://dashboard.internetcomputer.org/proposal/132411 Closes https://dfinity.atlassian.net/browse/NNS1-3411. [👈 Previous PR][prev] | [Next PR (tangent) 👉][next] [prev]: #2375 [next]: #2470
DFINITYManu
pushed a commit
that referenced
this pull request
Nov 19, 2024
This used to be part of #2385, but I was asked to not spin out sum_weighted_voting_power from distribute_rewards.
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Nov 26, 2024
…2470) Instead, callers should use either NeruonSections::ALL or NeuronSections::NONE. It is very easy for a caller to think NeuronSections::default() is equivalent to ALL, when **_actually_**, it's equivalent to NONE. Whereas, it is basically impossible to misunderstand what ALL and NONE do. # History of This Pull Request Earlier, this PR tried to add support for sections to neuron range. But Max developed that independently/concurrently, and he was able to merge first. Therefore, the main change that I was originally trying to do has been removed from this PR. What remains is 1. Additional tests 2. `NeuronSections::ALL`, a constant that replaces `NeuronsSections::all` (an `fn`). 3. Added `NeuronSections::NONE`. In terms of interface, the difference between what I did vs. what Max merged is that I figured that there should be one range_neurons method, which should additionally take NeuronSections; whereas, he created range_neurons_sections. His interface also seems reasonable. I think my "1 range_neurons to rule them all" approach has various advantages, the main one being that it minimizes API surface area. # References [👈 Previous PR][prev] | [Next PR 👉][next] [prev]: #2385 [next]: #2471
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Nov 18, 2026
Upgrades `gazelle` from 0.51.3 to [0.54.0](https://github.com/bazel-contrib/bazel-gazelle/releases/tag/v0.54.0), its latest release. The BCR's `1.0.0-beta.1` and `2.0.0-beta.*` are pre-releases. The repository has no Go sources. We use gazelle in two places: - `//:gazelle`, which CI's Linter job runs as `//pre-commit:gazelle-check` and again as an autofix. This PR moves its definition to `//bazel/gazelle` and keeps `//:gazelle` as an alias (see Changes). - The `go_deps` extension, which creates the `go.mod` repos (`@com_github_fatih_color`, ...). It also writes the config that `@rules_go//go` (our `//:gobin`) reads. Nothing gazelle builds ends up in what we ship. ## Changes - **`MODULE.bazel`**: version bump. The [BCR entry](https://bcr.bazel.build/modules/gazelle/0.54.0/MODULE.bazel) of 0.54.0 adds two dependencies. One is `platforms` 1.1.0, which we already resolve; the other, `rules_testing`, is dev-only. Its only BCR patch sets the module version. gazelle is also required by `rules_go` 0.62.0 (0.51.3) and `rules_buf` 0.5.2 (0.34.0), so the root module's requirement decides the version. No other module's resolved version changes. - **`BUILD.bazel` and the new `bazel/gazelle/BUILD.bazel`**: the `gazelle` and `gazelle-update-repos` targets move from the root package to `//bazel/gazelle`. With 0.54.0, loading `@gazelle//:def.bzl` fetches the Go SDK, and every build on Linux loads the root package (see the `go_deps` item below). The root package keeps `//:gazelle` and `//:gazelle-update-repos` as aliases, so `bazel run //:gazelle`, `//pre-commit:gazelle-check`, CI's Autofix step and `bazel/README.md` work unchanged. It also keeps the `# gazelle:prefix` and `# gazelle:proto disable` directives, which apply to the whole repository. Gazelle takes its working directory from `BUILD_WORKSPACE_DIRECTORY`, so the package that defines the target doesn't change what it processes. dfinity#12151 (rules_buf 0.6.1, which requires gazelle 0.54.0) is stacked on this PR. dfinity#12148 (rules_go 0.65.0) rewrites the comment and the `rules_go` line right above the gazelle `bazel_dep` in `MODULE.bazel`, so git reports a merge conflict between the two: whichever lands second needs master merged in, keeping both new lines. ## Upstream changes that touch our setup - **The Gazelle binary is now a plain `go_binary`** ([bazel-contrib/bazel-gazelle#2386](bazel-contrib/bazel-gazelle#2386)). Its update command now drives the built-in (v1) language extensions through v2 compatibility wrappers ([dfinity#2423](bazel-contrib/bazel-gazelle#2423)), and the directory walk moved to the v2 packages ([dfinity#2330](bazel-contrib/bazel-gazelle#2330)). CI's `gazelle-check` and Autofix steps run this binary. With 0.54.0, `bazel run //:gazelle` builds and leaves the tree unchanged, as it did with 0.51.3, so the upgrade causes no Autofix commit. - **`go_deps` now computes the Go environment itself** ([dfinity#2392](bazel-contrib/bazel-gazelle#2392)), and records `GOROOT` as a label ([dfinity#2374](bazel-contrib/bazel-gazelle#2374), [dfinity#2385](bazel-contrib/bazel-gazelle#2385)). This has two effects for us: - The `go_env.bzl` and `config.json` of `@bazel_gazelle_go_repository_config` used to hold an empty environment. They now hold `GOROOT = "@@rules_go++go_sdk+go_default_sdk//:ROOT"` and `GOTOOLCHAIN = "local"`. Both places where we use them replace that `GOROOT` with the SDK's path. The `//:gazelle` runner script does it in its `set_goroot`. rules_go's `go_bin_runner`, behind `//:gobin`, appends `GOROOT=<sdk path>` after the config values. `bazel run //:gobin -- env GOROOT GOTOOLCHAIN GOMOD` prints the SDK path, `local` and our `go.mod`. - Evaluating `go_deps` now fetches rules_go's Go SDK: go1.25.0, a 57 MiB archive that takes 242 MiB on disk once extracted. Its `compute_env` resolves the SDK's `ROOT` file, and `go_deps.bzl` now loads `@bazel_gazelle_go_repository_cache//:def.bzl`. `@gazelle//:def.bzl` loads the `go_env.bzl` that `go_deps` generates, so loading `def.bzl` evaluates `go_deps`. The root `BUILD.bazel` loaded it, and on Linux every `bazel build`, `test`, `run`, `cquery` and `aquery` loads the root package, because `bazel/conf/.bazelrc.build` points `--platforms` and `--host_platform` at `//:linux-glibc-2.31`. So with the version bump alone (the first commit), every build on Linux fetched the SDK, also for targets without Go, which don't fetch it with 0.51.3. On a cold cache, that means downloading and extracting it. That's why this PR moves the gazelle targets out of the root package; the measurements are under Verification. Builds that include the gazelle targets or `//:gobin`, such as `//...`, still fetch the SDK, as they did with 0.51.3. - **`go_repository` moves its generated package metadata targets to a `_gazelle_generated` package** ([dfinity#2407](bazel-contrib/bazel-gazelle#2407)). Their PURLs now include the `go.sum` checksum ([dfinity#2409](bazel-contrib/bazel-gazelle#2409)). For our five `go_deps` repos, this is the only difference in the generated `BUILD.bazel` and `REPO.bazel` files (compared file by file), and the generated Go rules are identical. Nothing in this repository reads that metadata. - **Module downloads**: `fetch_repo` now checks module sums against the JSON output of `go mod download` ([dfinity#2366](bazel-contrib/bazel-gazelle#2366)). All our `go_deps` repos fetch, and their sums verify. - `rules_buf` 0.5.2 imports `bazel_gazelle_go_repository_tools` from gazelle's internal `non_module_deps` extension. 0.54.0 still provides that repo under the same name. We only use rules_buf's prebuilt `buf`, and `buf-check` and `buf-breaking-check` pass. ## Verification All of the following except the CI results ran in the dev container. The module graph, `go_deps` repos and `//:gobin` checks ran on the first commit; the second commit doesn't change `MODULE.bazel` or anything those checks use. The other checks ran on the final state. - **Module graph**: `bazel mod explain gazelle` shows 0.54.0, required by the root module, `rules_go` 0.62.0 and `rules_buf` 0.5.2. Compared with the base commit, the full `bazel mod graph` differs only in gazelle's version and its new `platforms` edge. There are no new warnings; the only one is the existing `rules_qemu` `use_repo` warning. - **Analysis**: `bazel build //... --nobuild` analyzes all 3389 targets. That's 2 more than on the first commit (3387): the `//...` pattern matches the new aliases `//:gazelle` and `//:gazelle-update-repos`, while the `gazelle` macro tags the `sh_binary` targets it creates `manual`. - **Linter job**: `//pre-commit:{shfmt-check,ruff-check,buf-check,DFINITY-capitalization-check,do-not-merge-check,buildifier-check,gazelle-check,buf-breaking-check}` all pass. The autofixes (`buildifier-fix`, `shfmt-fix`, `ruff-fix` and `bazel run //:gazelle`) leave `git status` clean. - **Gazelle**: `bazel run //:gazelle` (through the alias), `bazel run //bazel/gazelle` and `bazel run //:gazelle -- -mode=diff` exit 0 and change no files. `bazel run //:gazelle-update-repos`, which `bazel/README.md` documents, fails with `loading WORKSPACE file: ... no such file or directory`, as it does with 0.51.3 at the base commit. The repository has no `WORKSPACE` file. - **Repos fetched by builds without Go**: `bazel build --nobuild` of two targets, each in a fresh output base, then the repos under `external/`: | | `//.github:CODEOWNERS` | `//rs/types/base_types:base_types` | |---|---|---| | Base commit (0.51.3) | 27 repos, no Go SDK | 304 repos, no Go SDK | | First commit (0.54.0, gazelle targets in the root package) | 29: adds `rules_go++go_sdk+go_default_sdk` and `gazelle++non_module_deps+bazel_gazelle_go_repository_cache` | 306: adds the same two | | This PR (0.54.0, gazelle targets in `//bazel/gazelle`) | 19: none from gazelle, rules_go or rules_buf | 300: no Go SDK and no gazelle repos; the Go-related ones left (`rules_go+`, `go_toolchains`, `io_bazel_rules_nogo`) are in the base commit's list too | - **`go_deps` repos**: I ran `bazel test --keep_going` over `//...` of the five repos we import (`@com_github_fatih_color`, `@com_github_google_go_cmp`, `@com_github_schollz_closestmatch`, `@com_github_spf13_cobra`, `@com_github_stretchr_testify`). I ran it with 0.54.0 first, then with 0.51.3, in the same output base. - 10 of the 14 tests pass with both versions. - The other four fail the same way with both versions, for reasons unrelated to gazelle. For example, `closestmatch` reads `test/books.list`, which the generated `go_test` doesn't list as data, and testify's `suite` test runs `go` from the `PATH`. - `@com_github_spf13_cobra//doc` doesn't analyze with either version, because our `go.mod` doesn't include `go-md2man`. - In the 0.51.3 run, every compile and link action and the 10 passing tests were cache hits from the 0.54.0 run. So the Go rules that gazelle generates produce identical actions. - **`//:gobin`**: `version`, `env` and `mod verify` work ("all modules verified"). - **Release artifacts**: I didn't run the byte-identity build, because gazelle isn't in the release artifacts' build graph. I ran `bazel cquery 'deps(...)'` over the GuestOS (prod disk and update, recovery update), HostOS and SetupOS bundles plus `//publish/binaries:bundle` and `//publish/canisters:bundle`. Of its 110,935 labels, none comes from gazelle, its repos, rules_go or the Go SDK. On the final state, intersected with the root package and `//bazel/gazelle`, the same query returns only `//:linux-glibc-2.31`, `//:mainnet-routing-table.json`, `//:mke2fs`, `//:debugfs`, `//:e2fsdroid` and `//:ovmfsev_code`, none of which this PR changes. - **CI on the first commit** passed, including the darwin job. Its `Build pocket-ic-server x86_64-darwin` step builds with `--platforms=//:macos-intel`, a platform in the root package, so that run evaluated 0.54.0's `go_deps` on macOS. The job log doesn't list repository fetches, so it doesn't show the SDK download itself. With the gazelle targets moved, builds on macOS that don't involve them no longer evaluate `go_deps`. - **Not verified**: running `//:gazelle` on macOS. CI covers the full build and tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Whereas, before, we did not have a distinction between potential voting power vs. deciding voting power. When neurons refresh themselves, there is no difference between these. Whereas, when a neuron does not refresh itself recently enough, the amount of voting power in its ballots (its "deciding" voting power) is less than its potential voting power.
Example
Suppose there are two neurons:
Then, the total potential voting power is 1100. If both neurons vote, then A gets 100 / 1100 of the reward purse, while B gets only 500 / 1100 of the reward purse, not 1000 / 1100.
You might also intuitively guess that the neurons get 100 / 600 and 500 / 600 of the reward purse, but this is (also) incorrect. The reason for this design is to keep the amount of rewards to refreshed neurons the same as before, not more. In other words, it should not be that some other neuron goes to sleep, and as a result, you get more rewards. It should only be that the sleeper neuron gets less.
References
This is part of the "periodic confirmation" feature that was recently approved in proposal 132411.
Closes https://dfinity.atlassian.net/browse/NNS1-3411.
👈 Previous PR | Next PR (tangent) 👉