-
Notifications
You must be signed in to change notification settings - Fork 566
pkg/cosmosfaucet: fix race condition during transfer #1965
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
Comments
@ivanovpetr can you please debug to find the cause of this issue and check if adding a mutex to the Transfer function would solve it? We can add an integration test for this by sending concurrent requests (x50) to the faucet API. The configuration in the faucet:
name: bob
coins: ["5token", "100000stake"]
coins_max: ["11token", "100000stake"] So, in our integration test, we need to see only |
Hi, @ilgooz |
Hey @Shashank-In! There is no a PR yet, we will look into it this week. But if this is urgent for you please free feel create one with or without the integration test (we can add it later). 🙌 For your notice, integration tests go under the integration/ folder in the root. |
The maximum amount of coins is actually not overflown because a parallel faucet request fails |
Uh oh!
There was an error while loading. Please reload this page.
When sending concurrent requests to the faucet API, it seems that faucet can send more balance to an account, instead of respecting the limitation set inside
coin max
configuration.There is a high chance that when sending concurrent requests to the faucet, in the time of querying the balance, for some requests this check might happen at the same time and end up seeing less balance in the account because sending the tokens action has not been finalized for the previous requests.
To avoid this race condition we can add a lock to the Transfer function, to put the transfer requests to faucet into some sort of queue and they won't interfere with each other.
The text was updated successfully, but these errors were encountered: