Skip to content

feat(nns): Prune following when a neuron has not refreshed in 7 months. - #2392

Merged
daniel-wong-dfinity-org merged 15 commits into
masterfrom
clear-following-daniel-wong
Dec 3, 2024
Merged

daniel-wong-dfinity-org merged 15 commits into
masterfrom
clear-following-daniel-wong

Conversation

@daniel-wong-dfinity-org

@daniel-wong-dfinity-org daniel-wong-dfinity-org commented Nov 1, 2024 •

Copy link
Copy Markdown
Contributor

This is something that happens in the background, and is low priority.

Background

This is part of the "periodic confirmation" feature that was recently approved in proposal 132411.

References

Closes https://dfinity.atlassian.net/browse/NNS1-3409.

👈 Previous PR

@github-actions github-actions Bot added the feat label Nov 1, 2024
@daniel-wong-dfinity-org
daniel-wong-dfinity-org changed the base branch from master to prune_some_following-daniel-wong November 6, 2024 18:42
@daniel-wong-dfinity-org
daniel-wong-dfinity-org force-pushed the prune_some_following-daniel-wong branch from 3865b4a to fda9f6c Compare November 7, 2024 08:10
@daniel-wong-dfinity-org
daniel-wong-dfinity-org force-pushed the clear-following-daniel-wong branch 3 times, most recently from 536b9f0 to 1b3aedf Compare November 7, 2024 17:40
@daniel-wong-dfinity-org
daniel-wong-dfinity-org marked this pull request as ready for review November 7, 2024 18:00
@daniel-wong-dfinity-org
daniel-wong-dfinity-org requested a review from a team as a code owner November 7, 2024 18:00
Comment thread rs/nns/governance/src/lib.rs Resolved
Comment thread rs/nns/governance/canister/canister.rs Resolved
@daniel-wong-dfinity-org
daniel-wong-dfinity-org force-pushed the prune_some_following-daniel-wong branch 2 times, most recently from c0e4bea to c418d39 Compare November 26, 2024 16:15
@daniel-wong-dfinity-org
daniel-wong-dfinity-org force-pushed the clear-following-daniel-wong branch 2 times, most recently from f6b0511 to 0046470 Compare November 26, 2024 16:50
@daniel-wong-dfinity-org
daniel-wong-dfinity-org force-pushed the prune_some_following-daniel-wong branch from 7ba6744 to e8bb0ec Compare December 2, 2024 18:04
@daniel-wong-dfinity-org
daniel-wong-dfinity-org force-pushed the clear-following-daniel-wong branch 5 times, most recently from 2e3d973 to 326dcb1 Compare December 2, 2024 19:09
github-merge-queue Bot pushed a commit that referenced this pull request Dec 2, 2024
Remove following when a neuron has not refreshed in more than 7 months.

The one exception is ManageNeuron; following on that topic is retained
forever.

In a later change (soon), this will be called periodically in the
background of the NNS governance canister. For now, this does not result
in any externally visible behavior changes to any canisters.

# References

[👈 Previous PR][prev] | [Next PR 👉][next]

[prev]: #2470
[next]: #2392
Base automatically changed from prune_some_following-daniel-wong to master December 2, 2024 21:28
Comment thread rs/nns/governance/canister/canister.rs Resolved
Comment thread rs/nns/governance/canister/canister.rs Resolved
@daniel-wong-dfinity-org
daniel-wong-dfinity-org added this pull request to the merge queue Dec 3, 2024
Merged via the queue into master with commit 3c714ea Dec 3, 2024
@daniel-wong-dfinity-org
daniel-wong-dfinity-org deleted the clear-following-daniel-wong branch December 3, 2024 10:45
Comment thread rs/nns/governance/canister/canister.rs Resolved
github-merge-queue Bot pushed a commit that referenced this pull request Feb 7, 2025
This addresses follow up issues from [PR 2392].

[PR 2392]: #2392

All changes here are comments.
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants