Skip to content

refactor(nervous-system): Remove ic-sns-governance and ic-sns-init's test_feature configurations - #1606

Merged
anchpop merged 1 commit into
masterfrom
@anchpop/sns-gov-no-test-feature
Sep 25, 2024
Merged

anchpop merged 1 commit into
masterfrom
@anchpop/sns-gov-no-test-feature

Conversation

@anchpop

@anchpop anchpop commented Sep 20, 2024 •

Copy link
Copy Markdown
Contributor

← Previous PR

There are two reasons to have a --test_feature target:

  1. The crate itself has different functionality when cfg(feature = "test") is true
  2. The crate is a library that depends on crate that has a --test_feature target, and needs to give the choice to its consumer whether the dependency has --test_feature enabled.

The second rule is "viral" which has lead to a massive outbreak of crates with a --test_feature target. In fact most of our crates that had a --test_feature target were in the second category.

The root cause of most of these was that SNS Governance's library had a --test_feature target. This PR:

  1. Moves the logic for determining whether we are in "test mode" to the canister crate (from the library crate)
  2. Remove's SNS Governance's library's --test-feature target
  3. Remove's SNS Init's --test-feature target, which did nothing after refactor(sns): Remove different sns init behavior when cfg(feature = "test") #1609
  4. Reverses the viral outbreak of --test-feature now that these two crates no longer needed it. The following crates have had their --test-feature removed entirely:
    1. //rs/sns/init:init--test_feature
    2. //rs/sns/governance:governance--test_feature
    3. //rs/nns/governance/api:api--test_feature
    4. //rs/nns/sns-wasm:sns-wasm--test_feature
    5. //rs/sns/cli:cli--test_feature
    6. //rs/sns/swap:swap--test_feature
    7. //rs/nns/governance/init:init--test_feature
    8. //rs/nns/gtc:gtc--test_feature

And some others no longer depend on any --test_feature crates, which is useful for development

@anchpop
anchpop force-pushed the @anchpop/sns-gov-no-test-feature branch from 342ba0e to da13463 Compare September 20, 2024 22:45
@anchpop anchpop changed the title Start removing unnecessary test-feature deps refactor(nervous-system): Remove SNS Governance's test feature Sep 20, 2024
@anchpop
anchpop force-pushed the @anchpop/sns-gov-no-test-feature branch 5 times, most recently from 913145e to 7d2652b Compare September 21, 2024 01:05
@anchpop
anchpop marked this pull request as ready for review September 21, 2024 01:53
@anchpop
anchpop requested review from a team as code owners September 21, 2024 01:53
@anchpop anchpop changed the title refactor(nervous-system): Remove SNS Governance's test feature refactor(nervous-system): Remove ic-sns-governance and ic-sns-init's test_feature configurations Sep 21, 2024

@nmattia nmattia left a comment

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.

Rubber stamp

@anchpop
anchpop enabled auto-merge September 24, 2024 20:33
@anchpop
anchpop force-pushed the @anchpop/sns-gov-no-test-feature branch from 7d2652b to a07a9d3 Compare September 25, 2024 17:28
github-merge-queue Bot pushed a commit that referenced this pull request Sep 25, 2024
…"test") (#1609)

[Next PR →](#1606)

## Problem

ic-sns-init has :init and :init--test-feature targets, which makes our
dependency situation very hairy due to the viral nature of test
features. It should be removed, but first ic-sns-init needs to not have
any differential behavior between the test and normal configurations.

## Solution

Remove the code that ran when cfg(feature = "test") was true. This was
code that set up ledger with a principal with a ton of tokens.

This was probably needed at first, but is no longer, because the test
configuration of the SNS Gov canister has a `mint_tokens` API that can
be used instead. If this breaks anyone, I will help them switch over to
the new API. I think the `nns_dapp` has already switched to the new API.
@anchpop
anchpop force-pushed the @anchpop/sns-gov-no-test-feature branch from a07a9d3 to 25faf02 Compare September 25, 2024 18:27
@anchpop
anchpop added this pull request to the merge queue Sep 25, 2024
Merged via the queue into master with commit 09e7929 Sep 25, 2024
@anchpop
anchpop deleted the @anchpop/sns-gov-no-test-feature branch September 25, 2024 19:02
AleDema pushed a commit to AleDema/ic that referenced this pull request Nov 18, 2026
…#12159)

Upgrades `rules_foreign_cc` from 0.15.2 to
[0.17.0](https://github.com/bazel-contrib/rules_foreign_cc/releases/tag/0.17.0),
its latest release. 0.15.2 was never released: the `bazel_dep` only
resolved because an `archive_override` replaced it with the unreleased
commit
[f68b351c](bazel-contrib/rules_foreign_cc@f68b351)
(2026-06-27, between 0.15.1 and 0.16.0), pinned for its newer Meson.
0.17.0 contains that commit plus [28
more](bazel-contrib/rules_foreign_cc@f68b351...0.17.0),
so we're back on a BCR release.

The release artifacts don't change: the IC-OS images and the binary and
canister bundles are byte-identical to master's.

## Changes

- **`MODULE.bazel`**:
- `rules_foreign_cc` 0.15.2 → 0.17.0. The `archive_override` becomes a
`single_version_override` that applies our patch on top of BCR's source.
BCR's only patch for 0.17.0 sets the version in its `MODULE.bazel`. The
comment about using HEAD for a recent Meson is gone, since 0.17.0 ships
Meson 1.12.1 (f68b351c had 1.10.1). The new comment says what the patch
is for.
- 0.17.0 requires at least `bazel_skylib` 1.9.2 and `rules_shell` 0.8.0.
Master has `bazel_skylib` 1.9.2 and `rules_shell` 0.10.0 since dfinity#12150
and dfinity#12152. This PR carried the same two bumps, plus dfinity#12150's two
`allow_symlink = True` lines in `publish/canisters/BUILD.bazel`, which
skylib 1.9.2 needs; they dropped out of its diff when I merged master.
- The `register_toolchains` for the preinstalled `make` and `pkg-config`
are unchanged and still take precedence: the generated build scripts use
`MAKE=make` and `PKG_CONFIG=pkg-config`. Since 0.16.0, the make and
pkg-config that rules_foreign_cc builds by default come from the `make`
and `pkgconf` BCR modules, not from the bootstrap scripts
[dfinity#1313](bazel-contrib/rules_foreign_cc#1313)
is about. A new comment above them says why we register them, with a
TODO to drop the registrations if the module-built make and pkg-config
turn out to be reproducible. That check is left for a follow-up.
- **`bazel/rules_foreign_cc.patch`**: the content is unchanged. Only the
`index` line and the hunk position (715 → 748) are regenerated, so the
patch applies to 0.17.0 with no offset (the old patch applied with a
33-line offset). We still need it:
[dfinity#1313](bazel-contrib/rules_foreign_cc#1313)
is open, and 0.17.0's `wrap_outputs` still declares the build log as an
output and keeps it after a successful build. With the patch, the logs
of all seven foreign_cc targets are 1 byte (a newline).
- **`bazel/conf/.bazelrc.build`**: the comment on
`--incompatible_default_to_explicit_init_py` now names the `meson`
module's `py_binary` (`@@meson+//:meson`), which rules_foreign_cc 0.17.0
runs instead of a meson it builds itself. The flag still applies to it.
dfinity#12158 (rules_python 2.5.1), now in master, edited the same comment: it
dropped rules_python's `py_console_script_gen_py` from the list and
notes that rules_python opts out its own targets. The merge of master
keeps both edits.

## Module graph

Compared with master, `bazel mod graph` shows these changes besides
`rules_foreign_cc`:

- 0.17.0 adds six modules: `m4` 1.4.21.bcr.8, `make` 4.4.1.bcr.3,
`meson` 1.12.1, `ninja` 1.13.2, `pkgconf` 3.0.10, and
`rules_cc_autoconf` 0.32.0, which `m4`, `make` and `pkgconf` are built
with.
- `nlohmann_json` moves from 3.6.1 to 3.12.0.bcr.1, required by
`rules_cc_autoconf`. The only other module that depends on it is
`rules_swift`.
- `package_metadata` moves from 0.0.7 to 0.0.13, required by `m4` and
`make`.
- 0.17.0 requires at least `bazel_features` 1.47.1 and `bazel_lib`
3.2.0. We already resolve 1.50.0 and 3.2.2, so neither moves.

There are no new direct-dependency version warnings.

## Upstream changes that touch our setup

These are the relevant changes between f68b351c and 0.17.0.
[NEWS.md](https://github.com/bazel-contrib/rules_foreign_cc/blob/0.17.0/NEWS.md)
has the full list. All seven of our foreign_cc targets were built with
0.17.0, and I compared their generated build scripts with master's.

- **m4, make, ninja, meson and pkg-config now come from BCR modules by
default**
([dfinity#1582](bazel-contrib/rules_foreign_cc#1582),
[dfinity#1584](bazel-contrib/rules_foreign_cc#1584),
[dfinity#1596](bazel-contrib/rules_foreign_cc#1596)).
The build scripts differ from master's only in these tools:
- **m4**: previously the container's `m4`, found on `PATH`. Now it is m4
1.4.21, built from the `m4` module with our hermetic toolchain, exported
as `M4` and linked into `$EXT_BUILD_DEPS/bin` in every `configure_make`
action. Of our targets, only `@jemalloc//:jemalloc_private` runs
autoconf (`autoconf = True`). Its autoconf, still the container's, now
gets that m4 through `M4`. `libjemalloc.a` stays byte-identical.
- **meson** (libfuse only): previously 1.10.1, built by
rules_foreign_cc. Now it is the `py_binary` from the `meson` 1.12.1
module, wrapped in the new `meson_tool_toolchain`
([dfinity#1599](bazel-contrib/rules_foreign_cc#1599)).
That toolchain also exports `PYTHON3`, `MESON_REAL` and
`RULES_PYTHON_EXTRACT_ROOT`.
- **ninja** (libfuse only): previously the prebuilt 1.13.2 binary. Now
it is ninja 1.13.2, built from the `ninja` module.
- **make and pkg-config**: unchanged, because our preinstalled
registrations come first.
- **Build cost**: the first build of a `configure_make` target now also
builds m4, and `rules_cc_autoconf` runs m4's configure checks as
separate (cacheable) Bazel actions. In a fresh output base, building all
seven targets ran 1,463 actions locally; the other actions came from the
shared disk cache.
- **rules_foreign_cc no longer registers a Python toolchain for its
consumers**
([dfinity#1583](bazel-contrib/rules_foreign_cc#1583)).
Meson now runs on the Python 3.12 toolchain that our root module
registers (`PYTHON3` is `python_3_12_x86_64-unknown-linux-gnu`).
rules_foreign_cc's old registration was also for 3.12.
- **Foreign builds resolve their toolchains in a `foreign_cc` exec
group**
([dfinity#1604](bazel-contrib/rules_foreign_cc#1604)).
On Linux we have a single execution platform (`//:linux-glibc-2.31`),
and the tools still build in the same `linux-glibc-2.31-opt-exec`
configuration.
- **`PWD` is dropped from the C/C++ toolchain environment**
([dfinity#1606](bazel-contrib/rules_foreign_cc#1606)).
Our toolchain never put it there: no build script exports it, before or
after this change.

## Verification

All of these were run in the dev container. The module graph, analysis,
lint and release-artifact checks were run again on the latest commit,
along with the new canister and `py_binary` checks. The foreign_cc
builds and tests ran on the first commit; the later commits only change
`publish/canisters/BUILD.bazel` and comments. After dfinity#12150, dfinity#12152 and
dfinity#12158 landed, I merged master into this branch and re-ran `bazel mod
graph` (the changes above, and only the `rules_qemu` warning that master
also prints), `bazel build //... --nobuild` (all 3389 targets analyze)
and `bazel run //:buildifier` (no changes).

- `bazel mod graph`, master vs. this PR: the changes listed above. The
only warning is the existing `rules_qemu` `use_repo` one.
- `bazel build //... --nobuild`: all 3387 targets analyze, with no
`__init__.py` deprecation warnings.
- CI Linter parity: the eight `//pre-commit` checks pass, including
`buf-breaking-check`. The autofixes (`buildifier-fix`, `shfmt-fix`,
`ruff-fix`, `:rustfmt`, `:gazelle`) and `//:buildifier` leave the tree
clean.
- **Canister copies**: `bazel aquery
'mnemonic("Symlink|CopyFile|SymlinkFile", //publish/canisters:all)'`
finds 87 `Symlink` actions, and its output is identical to master's.
Without the two `allow_symlink` lines it finds 87 `CopyFile` actions.
The 20 `file_size_check` tests in `//publish/canisters` pass (cached
results).
- **Python executables of other modules**: `bazel cquery
'kind("py_binary", deps(//...))'` lists `@@meson+//:meson` and no
`py_binary` from a rules_foreign_cc repository.
- **Builds and tests**: all seven rules_foreign_cc targets in the repo
build, along with `//:mke2fs`, `//:fuse2fs` and `//:debugfs`. That is
five `configure_make` targets (e2fsprogs, dosfstools, mtools, openssl,
jemalloc), one `make` target (dnsmasq) and one `meson` target (libfuse).
These tests, which run the built `mkfs.fat` and `mcopy`, pass:
  - `//rs/ic_os/build_tools/partition_tools:partition_tools_test`
  - `//rs/ic_os/config/tool:config_lib_test`
  - `//rs/ic_os/config/tool:config_lib_test_dev`
  - `//rs/ic_os/os_tools/guest_vm_runner:guest_vm_runner_test`
- **Release artifacts**: these are byte-identical to master's (133
files), both on the first commit and on the latest one:
- the unstamped IC-OS bundles (GuestOS prod disk and update, GuestOS
recovery update, HostOS update, SetupOS)
  - `//publish/binaries:bundle`
  - `//publish/canisters:bundle`

e2fsprogs (with libfuse), dosfstools, mtools and jemalloc are in that
build graph and were built with 0.17.0 for this check.
- **The foreign_cc outputs themselves**: I hashed the outputs of all
seven targets (332 files) for master and for this PR, in one output
base. Master's outputs came from the caches; this PR's were built
locally. 331 files are identical, including `mke2fs`, `debugfs`,
`fuse2fs`, `libfuse3.a`, `libjemalloc.a`, `libssl.a`, `mkfs.fat`,
`mcopy` and `dnsmasq`.
- The one difference is openssl's `libcrypto.a`, which isn't
reproducible in the first place. Master's copy was built on a CI runner
and this PR's locally, at different times. Only four of its 961 objects
differ. `cversion.o` has the build time. All four (`cversion.o`,
`defaults.o`, `x509_def.o` and `ct_log.o`) have the absolute sandbox
path, which is compiled in through `OPENSSLDIR`, `ENGINESDIR` and
`MODULESDIR` (configure derives them from `--prefix`) and through the
clang path in the `compiler:` string. openssl isn't in the release
artifacts' build graph.

Not verified locally: macOS builds (openssl is built with
`configure_make` there too), the system tests (the only users of
dnsmasq), and the rest of the test suite. CI covers the full build and
test suite.

🤖 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants