Skip to content

move FinalizeLatest inside the tx sending loop#22614

Open
Tofel wants to merge 3 commits into
developfrom
fix-flaky-TestIntegration_Functions_MultipleV1Requests_Success
Open

move FinalizeLatest inside the tx sending loop#22614
Tofel wants to merge 3 commits into
developfrom
fix-flaky-TestIntegration_Functions_MultipleV1Requests_Success

Conversation

@Tofel
Copy link
Copy Markdown
Contributor

@Tofel Tofel commented May 22, 2026

commit after each tx to avoid nonce collisions like this one:

Error Trace:	/home/runner/_work/chainlink/chainlink/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go:619
        	            		/home/runner/_work/chainlink/chainlink/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go:50
Error:      	Received unexpected error:
         	    replacement transaction underpriced
Test:       	TestIntegration_Functions_MultipleV1Requests_Success

MQ failure: https://github.com/smartcontractkit/chainlink/actions/runs/26240637562/job/77225788271

@github-actions
Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

✅ No conflicts with other open PRs targeting develop

@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented May 22, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@Tofel Tofel marked this pull request as ready for review May 22, 2026 09:25
@Tofel Tofel requested a review from a team as a code owner May 22, 2026 09:25
Copilot AI review requested due to automatic review settings May 22, 2026 09:25
Copy link
Copy Markdown
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

Risk Rating: LOW (changes are confined to integration test utilities, but can impact CI stability/flakiness)

This PR updates the Functions OCR2 v1 integration test utilities to mine/finalize after each request transaction, reducing the likelihood of nonce collisions (e.g., “replacement transaction underpriced”) when sending multiple requests in quick succession.

Changes:

  • Move client.FinalizeLatest(t, b) inside the per-request send loop to commit/finalize after each SendRequest.
  • Rename the loop variable (clientcc) to avoid shadowing the imported client package.
  • Refactor the response-validation goroutine spawning to use wg.Go(...).

Scrupulous human review recommended (high impact on CI behavior):

  • ClientTestRequests request-sending loop (FinalizeLatest placement): verify FinalizeLatest is the correct mechanism to advance nonce state on the backend and doesn’t introduce excessive test runtime.

Comment thread core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go Outdated
Comment on lines +654 to +656
// require/gomega assertions call t.FailNow which must run on the test goroutine;
// calling them from spawned goroutines panics or behaves unpredictably, so we
// poll without assertions in the goroutines and fail here on the main goroutine.
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.

Typically assert can be used instead of require. Errors are fine off the main goroutine. Only fatal is a problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, but from what I see, when Eventually times out it calls t.Fatalf, which afaik should not be used in goroutines

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.

Yeah but that is just gomega. The require and assert packages have their own versions:
https://pkg.go.dev/github.com/stretchr/testify/assert#Eventually

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jmank88 wasn't aware assert also has such a function. Switched to it. Pls review again.

mchain0
mchain0 previously approved these changes May 22, 2026
@cl-sonarqube-production
Copy link
Copy Markdown

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.

4 participants