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

Return JSON RPC errors for personal_unlockAccount #171

Merged
merged 1 commit into from
Apr 15, 2022

Conversation

nguyer
Copy link
Contributor

@nguyer nguyer commented Apr 15, 2022

The geth JSON RPC client code in the FireFly CLI is wrapped in a retry / delay loop, but the function which unlocks an account wasn't returning errors properly. It would return an error if the HTTP request itself failed (for example if the server wasn't listening) or if the HTTP status code was something other than 200. However, when a JSON RPC server has a problem fulfilling a request, they usually return 200 OK and put the specific JSON RPC error code / message inside the JSON response body. For example:

> POST / HTTP/1.1
> Host: localhost:5100
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 168
>
} [168 bytes data]
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 15 Apr 2022 12:30:36 GMT
< Content-Length: 94
<
{ [94 bytes data]
100   262  100    94  100   168   5541   9904 --:--:-- --:--:-- --:--:-- 26200
* Connection #0 to host localhost left intact
{
  "jsonrpc": "2.0",
  "id": 0,
  "error": {
    "code": -32000,
    "message": "no key for given address or file"
  }
}

This small code change parses JSON RPC errors and returns them, allowing the retry logic to kick in when necessary.

Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

👍

@peterbroadhurst peterbroadhurst merged commit 020f491 into main Apr 15, 2022
@peterbroadhurst peterbroadhurst deleted the account-unlock-retry branch April 15, 2022 12:35
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.

None yet

2 participants