Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dot/rpc: implement RPC state storage calls #835

Merged
merged 15 commits into from
May 6, 2020

Conversation

edwardmack
Copy link
Member

@edwardmack edwardmack commented May 2, 2020

Changes

Implement RPC calls for state storage functions.

  • state_getPairs
  • state_getStorage
  • state_getStorageHash
  • state_getStorageSize

Tests:

 go test ./dot/rpc/...

Checklist:

  • I have read CONTRIBUTING and CODE_OF_CONDUCT
  • I have provided as much information as possible and necessary
  • I have reviewed my own pull request before requesting a review
  • I have linked any relevant issues in my pull request comments
  • All integration tests and required coverage checks are passing

Issues:

Comment on lines +140 to +148
resI, err := sm.storageAPI.GetStorage(reqBytes)
if err != nil {
return err
}
if resI != nil {
*res = append(*res, []string{"0x" + hex.EncodeToString(reqBytes), "0x" + hex.EncodeToString(resI)})
} else {
*res = []interface{}{}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this only gets one value from a key, but it should get all keys with the the same prefix? this functionality will need to be implemented into the trie since it doesn't exist yet, I can make an issue for it

Copy link
Contributor

Choose a reason for hiding this comment

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

could you add a TODO for #837 somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}

// GetStorageHash isn't implemented properly yet.
func (sm *StateModule) GetStorageHash(r *http.Request, req *StateStorageQueryRequest, res *StateStorageHashResponse) {
func (sm *StateModule) GetStorageHash(r *http.Request, req *[]string, res *interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this supposed to do?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated comment

Copy link
Contributor

Choose a reason for hiding this comment

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

cool, could you add a TODO for this saying it can be finished when we have the storage changes trie?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}

// GetStorageSize isn't implemented properly yet.
func (sm *StateModule) GetStorageSize(r *http.Request, req *StateStorageQueryRequest, res *StateStorageSizeResponse) {
func (sm *StateModule) GetStorageSize(r *http.Request, req *[]string, res *interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

same with this?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated comment

Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

please add TODOs, otherwise looks good!

@edwardmack edwardmack merged commit 752b1ce into development May 6, 2020
@edwardmack edwardmack deleted the ed/310-rpc_state-storage branch May 6, 2020 16:12
ryanchristo pushed a commit that referenced this pull request Jun 24, 2020
* rpc getStorage

* implement basic rpc state_getStorage call

* added test for state_getStorage

* implement state_getPairs

* implement state_getStorageHash

* implement state_getStorageSize

* refactor tests

* cleanup comments

* added tests

* updated comments

* added TODOs
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.

4 participants