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

[5.0.x] Fix panic when calling certain API endpoints #552

Merged
merged 2 commits into from
Dec 17, 2020

Conversation

jaspervdm
Copy link
Contributor

The HTTP client is currently used both outside and inside of a tokio runtime context. In the latter case we are not allowed to do a blocking call to our global runtime, which unfortunately means we have to spawn a new thread.

At the moment we are mixing asynchronous and synchronous contexts all over the place, which is not great. This means that we are blocking inside API calls, reducing the amount of concurrent request we could serve. In practice, this probably is not noticeable since the number of requests to a wallet API is usually not that huge. Additionally a lot of wallet operations require a write lock on the db, which means requests have to be handled in-part sequentially anyway.

Ideally, we'd move to fully asynchronous, but this would require a relatively large refactor of the wallet. Another thing we could look into is if we can wrap each api call in a spawn_blocking, although i suspect that is not really possible since we are using Hyper.

Thanks to @bladedoyle for reporting the issue.

@jaspervdm jaspervdm added this to the 5.0.0 milestone Dec 17, 2020
Copy link
Member

@antiochp antiochp left a comment

Choose a reason for hiding this comment

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

Its not pretty but it does the job. 😄
👍 once tests pass.

@jaspervdm jaspervdm merged commit 2160813 into mimblewimble:current/5.0.x Dec 17, 2020
quentinlesceller pushed a commit to quentinlesceller/grin-wallet that referenced this pull request Mar 5, 2021
* Detect if already in runtime context

* Add comment
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.

2 participants