Skip to content

fix(move): clone stargate query proto buffers#529

Merged
beer-1 merged 1 commit into
mainfrom
fix/move-vm-query-proto-race
Jun 16, 2026
Merged

fix(move): clone stargate query proto buffers#529
beer-1 merged 1 commit into
mainfrom
fix/move-vm-query-proto-race

Conversation

@beer-1

@beer-1 beer-1 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Description

Closes: N/A

This fixes a data race in Move VM stargate queries by treating whitelist protobuf messages as prototypes only. queryStargate now clones the request and response messages before JSON/protobuf conversion so concurrent VM queries do not mutate shared decode buffers.

The PR also adds concurrent regression coverage for:

  • direct HandleVMQuery stargate queries
  • the VM view-function path through 0x1::query::get_proposal

Both tests assert zero errors and zero mismatched query results.


Validation

  • go test ./x/move/keeper -run 'TestQueryStargateDataRace|TestQueryStargateVMSessionRace' -count=1 -v
  • go test -race ./x/move/keeper -run 'TestQueryStargateDataRace|TestQueryStargateVMSessionRace' -count=1 -v
  • go test ./x/move/keeper -count=1

Author Checklist

I have...

  • included the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2905a9cf-7fb8-4010-bee3-957fb0799862

📥 Commits

Reviewing files that changed from the base of the PR and between 99a0fcc and d4ba343.

📒 Files selected for processing (2)
  • x/move/keeper/vm_query.go
  • x/move/keeper/vm_query_test.go

📝 Walkthrough

Walkthrough

queryStargate now calls proto.Clone on the shared protoSet.Request and protoSet.Response template instances from vmQueryWhiteList before using them for JSON/proto conversion, preventing mutation of shared state under concurrent access. Two new race tests exercise HandleVMQuery and ExecuteViewFunctionJSON concurrently to validate correctness.

Changes

Stargate query data-race fix and tests

Layer / File(s) Summary
Clone request/response templates in queryStargate
x/move/keeper/vm_query.go
Imports github.com/cosmos/gogoproto/proto and wraps protoSet.Request and protoSet.Response with proto.Clone before proto↔JSON conversion, ensuring concurrent callers operate on independent copies of the shared whitelist template instances.
Concurrent race tests
x/move/keeper/vm_query_test.go
Adds TestQueryStargateDataRace (many goroutines calling HandleVMQuery, asserting proposal id round-trip) and TestQueryStargateVMSessionRace (many goroutines calling ExecuteViewFunctionJSON with per-goroutine cached contexts, asserting proposal title correctness), plus their supporting imports.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Two clones hop into the goroutine race,
No shared proto template left out of place.
A spin of proposals, a flurry of calls,
Zero panics bounce off these newly safe walls.
The whitelist sleeps sound—no mutation, no fright—
The rabbit says "clone it!" and everything's right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: cloning stargate query protobuf messages to fix a data race.
Description check ✅ Passed The description is directly related to the changeset, explaining the data race fix and providing context for the concurrent test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/move-vm-query-proto-race

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@beer-1 beer-1 marked this pull request as ready for review June 16, 2026 01:39
@beer-1 beer-1 requested a review from a team as a code owner June 16, 2026 01:39
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.52%. Comparing base (99a0fcc) to head (d4ba343).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #529      +/-   ##
==========================================
- Coverage   38.53%   38.52%   -0.01%     
==========================================
  Files         327      327              
  Lines       30697    30697              
==========================================
- Hits        11829    11826       -3     
- Misses      16967    16969       +2     
- Partials     1901     1902       +1     
Files with missing lines Coverage Δ
x/move/keeper/vm_query.go 73.91% <100.00%> (ø)

... and 1 file with indirect coverage changes

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

@traviolus traviolus 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.

LGTM

@beer-1 beer-1 merged commit 924e5a5 into main Jun 16, 2026
14 checks passed
@beer-1 beer-1 deleted the fix/move-vm-query-proto-race branch June 16, 2026 06:31
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.

2 participants