Skip to content

node/app/component: use []*component for relations storage#20585

Merged
AskAlexSharov merged 2 commits into
mainfrom
refactor/component-relations-typed-slice
Apr 16, 2026
Merged

node/app/component: use []*component for relations storage#20585
AskAlexSharov merged 2 commits into
mainfrom
refactor/component-relations-typed-slice

Conversation

@mh0lt

@mh0lt mh0lt commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up from #20583 — addresses the deferred "relations → []*component" suggestion from the #20450 review.

Changes the internal relations type from []relation (interface slice) to []*component. The relation interface is still used as the public parameter type for Add/Remove/Contains/WithDependencies/WithDependent — callers pass any relation and we unwrap to *component at the boundary via the existing asComponent helper.

Why

  • Pointer identity comparison becomes a direct *component == *component, eliminating the uintptr(unsafe.Pointer(...)) dance via the relationPtr helper.
  • Avoids the interface-header allocation that happens every time *component was converted to relation for storage.
  • cmp/samePtr now take *component directly, making the intent explicit.

Scope

Intentionally narrow: the relation interface itself is not changed, so there's no churn in method signatures that take relation as a parameter. Only the internal storage type changes.

Test plan

  • go test ./node/app/...
  • CI passes

🤖 Generated with Claude Code

Change the internal relations type from []relation (interface slice) to
[]*component. The relation interface is still used as the public
parameter type for Add/Remove/Contains/WithDependencies/WithDependent —
callers pass any relation and we unwrap to *component at the boundary
via asComponent.

Why:
- Pointer identity comparison becomes a direct *component == *component,
  eliminating the uintptr(unsafe.Pointer(...)) dance via the
  relationPtr helper.
- Avoids the interface-header allocation that happens when converting
  *component to relation for storage.
- cmp/samePtr now take *component directly, making the intent explicit.

Net: 32 insertions, 20 deletions. All node/app tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mh0lt added a commit that referenced this pull request Apr 15, 2026
… commit

The glamsterdam suite was tracking upstream
ethpandaops/ethereum-package@main unpinned, while other suites
(regular, pectra) pin to a specific version. Upstream commit 835dd9b
("feat: support gpu ere prover in zkboost", 2026-04-15) introduced an
undefined GpuConfig reference in zkboost_launcher.star:272, breaking
every Erigon PR that ran glamsterdam from that point on — regardless
of what the PR changed. Six unrelated PRs (#20471, #20472, #20526,
#20583, #20584, #20585) all failed identically.

Pin to e07503d16b (2026-04-13, the commit before the break) to stop
the bleeding. This was the last state under which our main successfully
ran glamsterdam. Revisit once upstream stabilises, or switch to a
tagged release that supports gloas_fork_epoch / fulu_fork_epoch which
our glamsterdam.io config requires.

Copilot AI 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.

Pull request overview

Updates the component framework’s internal dependency/dependent “relations” storage to use concrete []*component rather than an interface slice, reducing allocations and simplifying identity comparisons inside node/app/component.

Changes:

  • Change internal relations from []relation to []*component.
  • Update relation set operations (Add/Remove/Contains) to unwrap relation*component at the API boundary and compare pointers directly.
  • Update WithDependencies/WithDependent options to store unwrapped *component values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AskAlexSharov AskAlexSharov added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit 3456be6 Apr 16, 2026
36 checks passed
@AskAlexSharov AskAlexSharov deleted the refactor/component-relations-typed-slice branch April 16, 2026 08:29
github-merge-queue Bot pushed a commit that referenced this pull request Apr 16, 2026
## Summary

Follow-up PR addressing seven unresolved review comments from #20450
(componentization framework). All fixes are focused and localized.

### Fixes included

- **`event/eventbus.go`**: `HasCallback` now uses `RLock`/`RUnlock`
instead of `Lock`/`Unlock` — it only reads `handlerMap` and a full write
lock blocks concurrent `Publish`/`Subscribe` unnecessarily.

- **`component/componentdomain.go`**: Guard nil dereference of
`opts.execPoolSize` in the root-domain fallback path. Also return
`false` from the `WithDependentDomain` option callback when the passed
`ComponentDomain` is not a `*componentDomain`, instead of panicking on
the type assertion.

- **`event/managedeventbus.go`**: Reject non-pointer inputs to
`Register` and `UnregisterAll` with a descriptive error instead of
panicking inside `reflect.Value.Pointer()`.

- **`event/servicebus.go`**: Add `objectPointer` helper that validates
`reflect.Value` kind.
`Register`/`Unregister`/`UnregisterAll`/`Registrations` all use it.
`Registrations` now returns a copy of the internal slice so callers
cannot mutate shared state without the lock.

- **`util/compare.go`**: `Equal` guards against `==` on uncomparable
types (slices, maps, funcs). Falls back to `reflect.DeepEqual` when
either operand has a non-comparable type, preventing runtime panics.

- **`typeid.go`**: Initialize `LocalTypeDomain` to a real named domain
at package init instead of leaving it as a nil `TODO`. Previously
`TypeIdOf` / `newIdFor` would build IDs with a nil domain.

### Larger refactors split out

Two review suggestions warranted their own PRs because they touch many
call sites and benefit from independent review:

- **#20584**: `Publish` → `atomic.Pointer[handlerMap]` — lock-free
`Publish`/`HasCallback`, copy-on-write writers. Eliminates the `RWMutex`
and clone-on-publish entirely.
- **#20585**: `relations` → `[]*component` — removes interface-header
allocation and `unsafe.Pointer` indirection in relations storage.

## Test plan

- [x] `go build ./...`
- [x] `go test ./node/app/...`
- [ ] CI passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants