-
Notifications
You must be signed in to change notification settings - Fork 0
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
Faucet API #1
Faucet API #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @gianfra-t 👍 I left minor comments but it looks good overall
return reject(`Service Error: Invalid Mnemonic`); | ||
} | ||
|
||
const nonce = await api.api.rpc.system.accountNextIndex(sender.publicKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we actually able to support multiple incoming faucet requests by different users or would this nonce here be a dealbreaker? Maybe it works perfectly fine, just wondering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it by sending multiple requests at the "same time" (manually) and they all worked, or at least entered in the same block.
What is attempted to do here by fetching the nonce is exactly that, to allow multiple fund events simultaneously.
Now I wonder if the nonce is able to increase if the transactions arrive faster that what could manually be tested. I guess that to be on the safe side, we could implement a mutex similar to what we did here. The problem I see with something like that is that it could delay a lot the completion. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice, I was not fully aware how the accountNextIndex
works. But since this apparently is taking the pending transactions of the transaction pool of the node into account (see here), I think it's fine and should indeed work as expected.
I already noticed that the Spacewalk testing service was able to submit multiple extrinsics in the same block so I can confirm that this works. Let's not add a mutex as it's not necessary then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think it is also important for that to keep the await
in cases like in the example to ensure that the transaction reached the pool.
It is still not clear to me what would happen if 2 transactions were to be sent in which the first transaction does not reach the pool before the second one is sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and ready for merge 👍
This PR correspond to the first iteration of the faucet service API.
Please refer to the README for explanation about what the service does.