feat(internal/ethapi): add eth_getStorageValues method #32591#2116
feat(internal/ethapi): add eth_getStorageValues method #32591#2116gzliudan wants to merge 1 commit intoXinFinOrg:dev-upgradefrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
There was a problem hiding this comment.
Pull request overview
This PR adds a new eth_getStorageValues RPC method that allows batch retrieval of storage slot values from multiple addresses at a specified block, improving efficiency over making multiple individual eth_getStorageAt calls.
Changes:
- Added
GetStorageValuesAPI method with a 1024-slot limit to prevent abuse - Implemented comprehensive test coverage including happy path, edge cases, and error conditions
- Registered the method in web3 extension for JavaScript client access
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/ethapi/api.go | Implements GetStorageValues method with slot limit validation and batch state retrieval |
| internal/ethapi/api_test.go | Adds comprehensive test coverage including mock backend and multiple test scenarios |
| internal/web3ext/web3ext.go | Registers the new eth_getStorageValues method in web3 JavaScript extension |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if err := state.Error(); err != nil { | ||
| return nil, err | ||
| } | ||
| result[addr] = vals | ||
| } |
There was a problem hiding this comment.
The state.Error() check is inside the outer loop, which causes it to be called once per address. This is inefficient and inconsistent with similar methods like GetStorageAt which call state.Error() only once after all state accesses are complete. Consider moving this check outside the loop to check only once after all values have been retrieved.
| if err := state.Error(); err != nil { | |
| return nil, err | |
| } | |
| result[addr] = vals | |
| } | |
| result[addr] = vals | |
| } | |
| if err := state.Error(); err != nil { | |
| return nil, err | |
| } |
Proposed changes
Ref: ethereum#32591
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that