fix: use uuid4 for JSON-RPC request id to prevent response correlation - #101
Open
yasinlex wants to merge 1 commit into
Open
fix: use uuid4 for JSON-RPC request id to prevent response correlation#101yasinlex wants to merge 1 commit into
yasinlex wants to merge 1 commit into
Conversation
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.
|
This PR targeted I retargeted it to |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe provider replaces millisecond timestamp JSON-RPC request IDs with randomly generated UUID strings. ChangesProvider request ID generation
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The JSON-RPC
idfield inGenLayerProvider.make_requestusesint(time.time() * 1000), a millisecond-resolution timestamp. Two requests sent within the same millisecond (common duringsendTransaction+wait_for_receipt, or any concurrent calls) get the sameid, violating the JSON-RPC spec requirement thatidmust uniquely correlate requests with responses.The bug
When two responses arrive with the same
id, arequests.postcall that gets the wrong response will silently process data intended for a different request:txIdfrom eventsFix
Checklist
Summary by CodeRabbit