Skip to content

Fix backward-compatiblity of GraphQL queries for pre-0.48.0 versions#3258

Merged
Voxelot merged 8 commits intomasterfrom
dento/fix-client-backcompat
Apr 16, 2026
Merged

Fix backward-compatiblity of GraphQL queries for pre-0.48.0 versions#3258
Voxelot merged 8 commits intomasterfrom
dento/fix-client-backcompat

Conversation

@Dentosal
Copy link
Copy Markdown
Member

@Dentosal Dentosal commented Apr 9, 2026

Description

Connecting FuelClient to a node running v0.47.x causes an error since the GraphQL query parameters mismatch. Again I'd like to mention that this is caused by the way we abuse GraphQL: it really should be only used to query the fields we actually need and FuelClient is an abomination.

This PR adds a mechanism to query node version first and then performs old versions of queries when needed. We cache node_version in ChainStateInfo.

Note that this PR only does this for pre-0.48.0 versions, calling them Legacy versions. A more generic naming schema might be needed in the future if new breaking changes are done. The current one shall suffice for now. It also adds snapshot tests for the fields to prevent this issue in the future.

Trade-offs

An extra round-trip is required on the first call to chain_info() or consensus_parameters() against a node of either version, since the node version must be fetched before we know which query to send. Subsequent calls within the same FuelClient instance pay no extra cost.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

@Dentosal Dentosal self-assigned this Apr 9, 2026
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 9, 2026

PR Summary

Medium Risk
Touches core client query paths and adds conditional behavior plus an extra initial network round-trip, which could surface version-parsing or query-selection bugs across node versions.

Overview
Fixes FuelClient GraphQL breakage against pre-0.48.0 nodes by fetching and caching the node version and conditionally using legacy query shapes.

Introduces legacy GraphQL fragments/queries for chain_info() and consensus_parameters() that omit fields added in 0.48.0 (e.g. maxStorageSlotLength and storage gas-cost fields), plus snapshot/tests to prevent regressions and a changelog entry.

Reviewed by Cursor Bugbot for commit df92d81. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread crates/client/src/client/schema/chain.rs
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7c2136c. Configure here.

*lock = Some(version.clone());
}
Ok(version)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale cached node version after failover breaks compatibility

Medium Severity

The node_version cache in ensure_node_version is written once and never refreshed, unlike current_stf_version and current_consensus_parameters_version which are updated on every response via update_chain_state_info. If FailoverTransport switches to a node with a different version, the stale cached version causes the wrong query variant to be sent. Failing over from a 0.48.0+ node to a pre-0.48.0 node would reproduce the exact "Unknown field" error this PR intends to fix.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7c2136c. Configure here.

.into(),
)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Legacy ScriptParameters conversion skips version validation

Low Severity

TryFrom<ScriptParametersLegacy> unconditionally creates ScriptParametersV1 without checking params.version, unlike every other TryFrom in this file (TxParameters, PredicateParameters, ContractParameters, FeeParameters, ConsensusParametersLegacy, GasCostsLegacy) which all validate the version and return ConversionError::UnknownVariant on mismatch. This inconsistency means an unexpected version value is silently accepted instead of producing a clear error.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7c2136c. Configure here.

@Dentosal Dentosal marked this pull request as ready for review April 9, 2026 21:30
@Dentosal Dentosal requested review from a team, MitchTurner and xgreenx as code owners April 9, 2026 21:30
@Voxelot Voxelot merged commit c30e093 into master Apr 16, 2026
40 checks passed
@Voxelot Voxelot deleted the dento/fix-client-backcompat branch April 16, 2026 22:46
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