Skip to content

fix: use uuid4 for JSON-RPC request id to prevent response correlation - #101

Open
yasinlex wants to merge 1 commit into
genlayerlabs:v0.19-devfrom
yasinlex:fix/rpc-id-collision
Open

fix: use uuid4 for JSON-RPC request id to prevent response correlation#101
yasinlex wants to merge 1 commit into
genlayerlabs:v0.19-devfrom
yasinlex:fix/rpc-id-collision

Conversation

@yasinlex

@yasinlex yasinlex commented Aug 1, 2026

Copy link
Copy Markdown

Summary

The JSON-RPC id field in GenLayerProvider.make_request uses int(time.time() * 1000), a millisecond-resolution timestamp. Two requests sent within the same millisecond (common during sendTransaction + wait_for_receipt, or any concurrent calls) get the same id, violating the JSON-RPC spec requirement that id must uniquely correlate requests with responses.

The bug

# Before (provider.py line 19):
"id": int(time.time() * 1000),   # millisecond timestamp — collides frequently

When two responses arrive with the same id, a requests.post call that gets the wrong response will silently process data intended for a different request:

  • Return a receipt for a different transaction (accepting a revert as success)
  • Parse the wrong txId from events

Fix

# After:
"id": str(uuid.uuid4()),   # globally unique, collision-free

Checklist

  • Minimal change matching surrounding code style
  • No new dependencies (uuid is stdlib)

Summary by CodeRabbit

  • Bug Fixes
    • Improved JSON-RPC request ID uniqueness and reliability by switching to UUID-based identifiers.

The JSON-RPC id field used int(time.time() * 1000), a millisecond-resolution
timestamp. Two requests sent within the same millisecond (common during
sendTransaction + wait_for_receipt) share the same id. When responses arrive
with duplicate ids, a caller may silently process data intended for a different
request - accepting a reverted transaction as success or returning the wrong txId.
@github-actions
github-actions Bot changed the base branch from main to v0.19-dev August 1, 2026 17:36
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

This PR targeted main, which is only the default/static branch.

I retargeted it to v0.19-dev, the active development branch. Pushes to v0.19-dev automatically fast-forward main.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d32a060e-da07-4f2a-883e-18cb341f4054

📥 Commits

Reviewing files that changed from the base of the PR and between dd25ef7 and 77b3d02.

📒 Files selected for processing (1)
  • genlayer_py/provider/provider.py

📝 Walkthrough

Walkthrough

The provider replaces millisecond timestamp JSON-RPC request IDs with randomly generated UUID strings.

Changes

Provider request ID generation

Layer / File(s) Summary
Generate UUID request IDs
genlayer_py/provider/provider.py
The provider replaces the unused time import with uuid and uses UUID strings for JSON-RPC payload IDs.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the change from time-based IDs to UUID4 IDs for JSON-RPC request correlation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

1 participant