Skip to content

fix: mirror node contract query - #1767

Merged
Dosik13 merged 2 commits into
hiero-ledger:mainfrom
radkomih:fix/1752-mirror-node-retry
Jul 10, 2026
Merged

fix: mirror node contract query#1767
Dosik13 merged 2 commits into
hiero-ledger:mainfrom
radkomih:fix/1752-mirror-node-retry

Conversation

@radkomih

@radkomih radkomih commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description:

Fix flaky mirror-node contract-query e2e tests that intermittently failed with an EOF transport error when the local JSON-RPC relay dropped connections under load. performContractCallToMirrorNode used a bare http.Post with no timeout or retry, so a transient connection drop surfaced as an unhandled transport error instead of being retried or returning the intended HTTP result.

Add a shared mirror-node POST helper with bounded retries, backoff, and an explicit timeout, and route the contract query and fee-estimate query through it.

  • Add mirrorNodePostWithRetry and mirrorNodeShouldRetry in sdk/mirror_node_rest_helpers.go — retries transport errors and 5xx/429 with exponential backoff (capped at 8s, default 3 attempts), uses an http.Client with an explicit timeout (30s default), and does not retry genuine 4xx responses
  • Route performContractCallToMirrorNode through the helper and return a clear error on a nil response
  • Refactor FeeEstimateQuery.callGetFeeEstimate to reuse the helper and remove its duplicated inline retry loop
  • Remove the now-unused FeeEstimateQuery.shouldRetry wrapper and repoint its unit test at mirrorNodeShouldRetry
  • Add unit tests covering transient 5xx retry, transport-error (EOF) retry, and no-retry on 4xx

Related issue(s):

Fixes #1752
Fixes #1753

Notes for reviewer:

Both issues share the same root cause (the bare http.Post in performContractCallToMirrorNode), so this single change closes both. 4xx responses are intentionally not retried, preserving the "received non-200 response from Mirror Node" assertion in TestMirrorNodeContractQueryFailWhenGasLimitIsLow (#1752), while transient EOF/5xx are now retried, fixing the TestUint8*/TestUint16* success-path flakiness (#1753).

Checklist

  • Unit tests
  • Integration tests

Signed-off-by: Rado M <radkomih@gmail.com>
@radkomih
radkomih requested review from a team as code owners July 10, 2026 09:08
@radkomih
radkomih requested review from Dosik13 and gsstoykov July 10, 2026 09:08
@lfdt-bot

lfdt-bot commented Jul 10, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@radkomih

Copy link
Copy Markdown
Contributor Author

need to perform the e2e tests

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sdk/mirror_node_rest_helpers.go 90.62% 2 Missing and 1 partial ⚠️
sdk/fee_estimate_query.go 80.00% 2 Missing ⚠️
sdk/mirror_node_contract_query.go 33.33% 1 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
sdk/fee_estimate_query.go 78.44% <80.00%> (-0.72%) ⬇️
sdk/mirror_node_contract_query.go 66.92% <33.33%> (-1.08%) ⬇️
sdk/mirror_node_rest_helpers.go 90.62% <90.62%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dosik13

Dosik13 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

can you add more test coverage?

Signed-off-by: Rado M <radkomih@gmail.com>
@Dosik13
Dosik13 merged commit eb02d21 into hiero-ledger:main Jul 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants