Skip to content

test: Add checks for Traps in the Random Traffic Canister Framework - #4689

Merged
stiegerc merged 22 commits into
masterfrom
stiegerc/add_check_for_canister_traps_to_messaging_integration_tests
Apr 9, 2025
Merged

stiegerc merged 22 commits into
masterfrom
stiegerc/add_check_for_canister_traps_to_messaging_integration_tests

Conversation

@stiegerc

@stiegerc stiegerc commented Apr 7, 2025 •

Copy link
Copy Markdown
Contributor
  • Adds a check for traps in the canister logs since there are asserts in the canister that would fire for misrouted or duplicate responses for example.
  • Improves the test about canister migration to really enforce what it is supposed to test rather than rely on randomness to occasionally produce this situation since I was unable to observe that during manual inspection.
  • The default number of instructions was bumped since making this lower does not speed up the test, but rather it can turn the heartbeat into an apparent no-op by turning aborting and resetting. This unfortunately does not show up in the logs; a comment warning about this was added instead and a counter for successful heartbeat invocations such that a no-op there can be distinguished from other problems.
  • Some refactoring.

@github-actions github-actions Bot added the test label Apr 7, 2025
@stiegerc stiegerc changed the title test: Adds checks for Traps in the Random Traffic Canister Framework test: Add checks for Traps in the Random Traffic Canister Framework Apr 7, 2025
@stiegerc
stiegerc marked this pull request as ready for review April 8, 2025 08:12
@stiegerc
stiegerc requested a review from a team as a code owner April 8, 2025 08:12

@alin-at-dfinity alin-at-dfinity 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.

LGTM, thanks.

Comment thread rs/messaging/tests/common/mod.rs Resolved
Comment thread rs/messaging/tests/common/mod.rs Resolved
Comment thread rs/messaging/tests/common/mod.rs Resolved
Comment thread rs/messaging/tests/common/mod.rs Resolved
Comment thread rs/messaging/tests/common/mod.rs Resolved
Comment thread rs/messaging/tests/common/mod.rs Resolved
Comment thread rs/messaging/tests/common/mod.rs Resolved
Comment thread rs/messaging/tests/memory_tests.rs Resolved
@stiegerc
stiegerc added this pull request to the merge queue Apr 9, 2025
Merged via the queue into master with commit b502cf3 Apr 9, 2025
@stiegerc
stiegerc deleted the stiegerc/add_check_for_canister_traps_to_messaging_integration_tests branch April 9, 2025 13:46
AleDema pushed a commit to AleDema/ic that referenced this pull request Nov 18, 2026
Upgrades `rules_go` from 0.62.0 to
[0.65.0](https://github.com/bazel-contrib/rules_go/releases/tag/v0.65.0),
its latest release.

The repository has no Go sources and no `go_*` targets of its own.
rules_go builds `//:gazelle` (which `//pre-commit:gazelle-check` and the
Linter job's autofix run) and `//:gazelle-update-repos`, and provides
the `go` tool behind `//:gobin`. `bazel query 'rdeps(//...,
@rules_go//:go_context_data)'` lists only those targets in the main
repository.

## Changes

- **`MODULE.bazel`**: version bump, and a rewritten comment above it.
The old comment said that 0.62.0 matched the resolved graph because the
llvm module pulled it in. The llvm module (0.8.16, and also the latest
0.8.27) declares `bazel_dep(name = "rules_go", version = "0.62.0",
repo_name = None)`, so it only sets a minimum version. gazelle 0.51.3
requires 0.59.0 and rules_buf 0.5.2 requires 0.42.0. The root module's
0.65.0 is now the highest requirement, so it's the version that
resolution selects. BCR's `rules_go/0.65.0` has only the usual
`module_dot_bazel_version.patch`, and we carry no patch or override for
rules_go.

In the module graph, only rules_go's version changes. It also gains an
edge to `package_metadata`: 0.65.0 requires 0.0.5, which already
resolves to 0.0.7. On a fresh Bazel server the warnings are the same as
on master (only the existing rules_qemu `use_repo` one). That includes
gazelle's `go_deps` extension, which prints no warnings.

## What changes for us

- **Default Go SDK 1.25.0 → 1.26.7.** We don't declare a `go_sdk`, and
no other module in our graph does outside its dev dependencies. `bazel
mod show_extension @rules_go//go:extensions.bzl%go_sdk` shows only
rules_go's own `go_sdk.from_file(name = "go_default_sdk", go_mod =
"//:go.mod")`; gazelle only imports `go_host_compatible_sdk_label`. That
SDK's version comes from the `toolchain` line of rules_go's own
`go.mod`, which
[bazel-contrib/rules_go#4697](bazel-contrib/rules_go#4697)
bumped from go1.25.0 to go1.26.7 (released in 0.64.0). So Gazelle is now
compiled with Go 1.26.7, and `bazel run //:gobin -- version` prints
`go1.26.7` instead of `go1.25.0`.
- **Go modules in the Gazelle build.** gazelle's `go_deps` extension
resolves the Go modules that all Bazel modules' `go.mod` files require,
and the highest version wins. rules_go's `go.mod` now raises the
following (from `bazel mod show_repo`, master → this PR):
- compiled into Gazelle: `golang.org/x/mod` v0.25.0 → v0.41.0,
`golang.org/x/sync` v0.15.0 → v0.23.0 and `golang.org/x/sys` v0.33.0 →
v0.48.0.
- `golang.org/x/tools` v0.34.0 → v0.51.0
([dfinity#4701](bazel-contrib/rules_go#4701),
[dfinity#4740](bazel-contrib/rules_go#4740)). Its
`goyacc` generates the BUILD-file parser of buildtools during the
Gazelle build.

Gazelle's other dependencies (buildtools, doublestar, go-difflib,
`x/tools/go/vcs`) don't change. rules_go's `go.mod` requires none of the
Go modules that our `go.mod` requires directly.

## Upstream changes that touch our setup

- [dfinity#4762](bazel-contrib/rules_go#4762) raises
the minimum Bazel version to 7.7.0 (`bazel_compatibility`). We use
9.3.2.
- [dfinity#4761](bazel-contrib/rules_go#4761) removes
the `//go/private:request_nogo` setting. We don't configure nogo, and
neither gazelle 0.51.3 nor 0.54.0 references that setting. Gazelle
0.51.3's `gazelle_binary` uses `go_context`, `new_go_info`, `GoArchive`
and `CGO_ATTRS`/`CGO_FRAGMENTS`/`CGO_TOOLCHAINS`, which all still exist.
Gazelle 0.54.0 (dfinity#12149) uses `go_binary`, `GoArchive`, `go_context` and
the same `CGO_*` symbols.
- cgo, which the hermetic LLVM toolchain compiles:
- [dfinity#4671](bazel-contrib/rules_go#4671) replaces
cgo's default `-fdebug-prefix-map` flags with `-ffile-prefix-map`, which
clang supports, so `__FILE__` no longer embeds absolute paths. This also
covers the cgo part of the standard library build.
- [dfinity#4739](bazel-contrib/rules_go#4739) also
makes `-internal-externc-isystem`/`-stdlib++-isystem` header paths
absolute. llvm 0.8.16 (and 0.8.27) passes neither and uses `-Xclang
-internal-isystem`, which rules_go already handled.
- [dfinity#4667](bazel-contrib/rules_go#4667) turns off
path mapping for cgo standard library builds. We don't enable path
mapping.
- [dfinity#4689](bazel-contrib/rules_go#4689) and
[dfinity#4704](bazel-contrib/rules_go#4704) change how
the `static`, `pure` and `linkmode` settings reach Go tool binaries.
[dfinity#4706](bazel-contrib/rules_go#4706) applies the
`static` attribute at link time instead of through a transition. We set
none of the `//go/config` flags or those attributes.
- [dfinity#4728](bazel-contrib/rules_go#4728) changes
the build IDs of the Go binaries that rules_go links. 0.62.0 linked them
with `-buildid=redacted`. 0.65.0 links with a placeholder, then
overwrites it with a SHA-256 of the linked binary:
  - ELF: the Go build ID, and the GNU build ID if the binary has one.
- Mach-O: the Go build ID and `LC_UUID`. If the binary is code-signed
(Go's linker signs darwin/arm64 binaries), rules_go's builder then
re-signs it ad hoc in Go, without Apple's `codesign`.

For us this affects Gazelle, the `go` tool runner behind `//:gobin`, and
`goyacc`, which the Gazelle build runs. I checked the first two on Linux
and cross-compiled for macOS (see Verification).

## Verification (dev container)

- `bazel mod graph`, `bazel mod explain
rules_go`/`gazelle`/`package_metadata` and `bazel mod
show_extension`/`show_repo` give the resolution described above,
compared with the same commands on master.
- `bazel build //... --nobuild`: all 3387 targets analyze.
- Linter-job parity: `shfmt-check`, `ruff-check`, `buf-check`,
`DFINITY-capitalization-check`, `do-not-merge-check`,
`buildifier-check`, `gazelle-check` and `buf-breaking-check` pass. After
them, `buildifier-fix`, `shfmt-fix`, `ruff-fix` and `bazel run
//:gazelle` leave the tree unchanged.
- `//:gazelle`, `//:gazelle-update-repos` and `//:gobin` build, with
Gazelle and the Go standard library rebuilt with Go 1.26.7.
- With no Go code to test, I exercised rules_go's rules and cgo through
the "Hello World" workflow in `bazel/README.md`. I used a temporary
package that isn't committed: a `main.go` with a C function and
`os/user`, plus a `main_test.go`.
- `bazel run //:gazelle` generated a `go_library` (`cgo = True`), a
`go_binary` and a `go_test`.
- The binary printed `hello world from go1.26.7: 1+2=3`, and the test
passed.
- Its build compiled the standard library with `CGO_ENABLED=1` and the
hermetic clang 22.1.8 as `CC`.
- After dfinity#12149 (gazelle 0.54.0) landed, I merged master into this
branch. Its gazelle line sits next to this PR's rules_go line; the
resolution keeps both. Against master, `bazel mod graph` changes only
`rules_go` (0.62.0 → 0.65.0) with no new warnings, `bazel build //...
--nobuild` analyzes all 3389 targets, and `bazel run //:buildifier`
changes nothing.
- Before that, I repeated this with gazelle temporarily bumped to
0.54.0, as in dfinity#12149. It resolves to gazelle 0.54.0 and rules_go 0.65.0
without new warnings, Gazelle builds, `gazelle-check` leaves the tree
clean, and the temporary package builds, runs and passes its test.
- Release artifacts: I didn't run the byte-identity rebuild. I ran
`bazel cquery 'deps(...)'` over the seven release targets: the IC-OS
bundles that `ci/container/build-ic.sh --icos` builds,
`//publish/binaries:bundle` and `//publish/canisters:bundle`. None of
the 110,935 configured targets it lists references rules_go, gazelle or
a Go SDK or toolchain repo. No other module's resolved version changes
either, so this upgrade can't change what we ship.
- Build IDs
([dfinity#4728](bazel-contrib/rules_go#4728)), which I
read from the binaries with a small Python script:
- Linux: the Go build IDs of Gazelle and the `go` tool runner are now
content hashes in `go build`'s format (four 20-character chunks), not
`redacted`. The runner's GNU build ID matches its Go build ID. Gazelle's
binary has no GNU build ID note, so only its Go build ID is rewritten.
- macOS, cross-compiled on Linux: I built `@gazelle//cmd/gazelle` and
`@rules_go//go/tools/go_bin_runner` with
`--platforms=@rules_go//go/toolchain:darwin_arm64`, and again with
`darwin_amd64`. These platforms turn cgo off, so Go's internal linker
links the binaries. In all four binaries, the Go build ID and `LC_UUID`
come from the same content hash. The two arm64 binaries have a valid ad
hoc signature: every CodeDirectory page hash (2,861 and 945 of them)
matches the file. The amd64 binaries have no signature, because Go's
linker signs only darwin/arm64 binaries.
- Not verified on a Mac, either locally or in CI. CI's `Bazel Test
arm64-darwin` job builds three `//publish/binaries` targets
(`pocket-ic.gz` also for x86_64), `//rs/...` and `//packages/...`. Of
those, it tests the targets tagged `test_all_platforms` or
`test_all_platforms_slow`.
- `bazel query 'deps(...)'` over these targets follows every `select()`
branch. It lists 79,392 labels, and none comes from rules_go, gazelle, a
Go SDK or a Go module repository.
- Across the whole workspace, a `bazel query` for main-repository
targets that depend on such a label finds only the targets named at the
top and their two `-runner` targets.
- On a Mac, those targets now build with Go 1.26.7. On Apple silicon,
the Go binaries involved (Gazelle, the `go` tool runner and `goyacc`)
are re-signed after linking, as described above. The cross-compiled
binaries don't show that they build and run on a Mac.
- Before merging, could someone on a Mac run `bazel run //:gazelle` and
`bazel run //:gobin -- version` on this branch? The second should print
`go1.26.7`.
- On Linux, CI covers the rest. Because this PR changes `MODULE.bazel`,
CI builds and tests all of `//...`, not just the affected targets (PR
runs still skip `long_test`s). The Linter job also runs `gazelle-check`.

🤖 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.

2 participants