Skip to content

Amend chip-testsink#21327

Open
thomaska wants to merge 2 commits intodevelopfrom
infoplat-3436-chipingress-publishBatch
Open

Amend chip-testsink#21327
thomaska wants to merge 2 commits intodevelopfrom
infoplat-3436-chipingress-publishBatch

Conversation

@thomaska
Copy link

@thomaska thomaska commented Feb 27, 2026

Ticket: https://smartcontract-it.atlassian.net/browse/INFOPLAT-3436

Summary

  • Implement PublishBatch on the chip-testsink gRPC server so it no longer
    returns UNIMPLEMENTED when nodes send batched events

The ChipIngressBatchEmitter in chainlink-common sends events via
PublishBatch. The chip-testsink only implemented Publish (single event),
inheriting UNIMPLEMENTED from the embedded UnimplementedChipIngressServer.
This means any CRE system test using chip-testsink would fail when the node's
beholder client uses batch mode.

The fix delegates each event in the batch to the existing Publish flow
(including the configured PublishFunc and optional upstream forwarding).

Why

9 CRE system tests depend on chip-testsink:
v2_http_action, v2_evm_capability, v2_consensus_capability,
v2_sharding, v2_dontime, v2_http_trigger_regression,
v2_http_action_regression, v2_evm_regression, v2_consensus_regression

Without this change, these tests receive gRPC UNIMPLEMENTED errors on the
beholder path once batch mode is the default.

Requires

smartcontractkit/chainlink-common#1862

@github-actions
Copy link
Contributor

👋 thomaska, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

✅ No conflicts with other open PRs targeting develop

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds PublishBatch support to the chip-testsink gRPC server so CRE/system tests don’t fail with UNIMPLEMENTED when nodes emit batched ChIP ingress events.

Changes:

  • Implement PublishBatch on the chip-testsink ChipIngressServer.
  • Delegate batch handling to the existing Publish flow (including configured PublishFunc and optional upstream forwarding).

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

}

for _, event := range batch.Events {
if _, err := s.Publish(ctx, event); err != nil {
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling s.Publish() inside the batch loop triggers the per-event async upstream forwarding goroutine in Publish(). For large batches this can create a burst of goroutines and N upstream RPCs. Consider handling upstream forwarding in PublishBatch with a single PublishBatch call (or at least a bounded worker/pool), and calling the configured PublishFunc directly for local handling to avoid unbounded goroutine/RPC fan-out per batch.

Suggested change
if _, err := s.Publish(ctx, event); err != nil {
// Forward upstream synchronously to avoid spawning a goroutine per event.
if s.cfg.UpstreamEndpoint != "" {
forwardCtx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second)
_, err := s.upstream.Publish(forwardCtx, event)
cancelFn()
if err != nil {
log.Printf("failed to forward to upstream: %v", err)
}
}
if _, err := s.cfg.PublishFunc(ctx, event); err != nil {

Copilot uses AI. Check for mistakes.
Comment on lines 124 to 125
// It delegates each event in the batch to the configured PublishFunc,
// mirroring how the real ChIP Ingress processes batches atomically.
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment claims this mirrors how the real ChIP ingress processes batches "atomically", but this implementation is not atomic: it publishes events one-by-one and can return an error after earlier events have already been accepted/forwarded. Please either adjust the comment to reflect best-effort sequential processing, or change the implementation to provide the atomicity guarantees being documented.

Suggested change
// It delegates each event in the batch to the configured PublishFunc,
// mirroring how the real ChIP Ingress processes batches atomically.
// It delegates each event in the batch to the configured PublishFunc
// sequentially, returning an error on the first failure. Earlier events
// in the batch may already have been published or forwarded when an error
// is returned, so processing is best-effort rather than atomic.

Copilot uses AI. Check for mistakes.
@trunk-io
Copy link

trunk-io bot commented Feb 27, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@cl-sonarqube-production
Copy link

@pkcll pkcll added the build-publish Build and Publish image to SDLC label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-publish Build and Publish image to SDLC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants