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

Unmarshaling arrays items to struct for RPC #1216

Closed
3 tasks done
arijitAD opened this issue Dec 3, 2020 · 0 comments · Fixed by #1217
Closed
3 tasks done

Unmarshaling arrays items to struct for RPC #1216

arijitAD opened this issue Dec 3, 2020 · 0 comments · Fixed by #1217
Assignees

Comments

@arijitAD
Copy link
Contributor

arijitAD commented Dec 3, 2020

Expected Behavior

  1. API's like QueryStorage uses StateStorageQueryRangeRequest as request params but it should parse unstructured JSON to RPC request struct. The issue is with the Gorilla RPC library.
  2. commmon.Hash should have custom marshaling and unmarshalling.

Current Behavior

  • For 1: It fails to parse unstructured JSON RPC request params struct and an unmarshalling error is returned.
  • For 2: Any RPC returning commmon.Hash would convert the byte to string and return the underlying bytes instead of expected hash value.
    Example: It should format hash like this 0xe99c87d6efab57a98706c10fa4bc4d39feaf51ca62ac3bae7a67bf17c8c305ec but it returns the bytes directly(e99c87d6efab57a98706c10fa4bc4d39feaf51ca62ac3bae7a67bf17c8c305ec in bytes).

Possible Solution

  • Fix the CodecRequest implementation for JSON RPC v2 in the RPC gorilla library.
  • Add custom marshaling and unmarshalling for commmon.Hash.

Steps to Reproduce

  1. Make RPC call to QueryStorage.
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_queryStorage", "params":[["0xf2794c22e353e9a839f12faab03a911bf68967d635641a7087e53f2bff1ecad3c6756fee45ec79ead60347fffb770bcdf0ec74da701ab3d6495986fe1ecc3027"], "0xa32c60dee8647b07435ae7583eb35cee606209a595718562dd4a486a07b6de15", null]}' http://localhost:9933
  1. Make RPC call to any RPC returning common.Hash

Specification

  • go version:
  • gossamer version:
  • gossamer commit tag:
  • gossamer commit hash:
  • operating system:
  • additional links:

Checklist

  • I have read CODE_OF_CONDUCT and CONTRIBUTING
  • I have provided as much information as possible and necessary
  • I am planning to submit a pull request to fix this issue myself
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 a pull request may close this issue.

1 participant