-
Notifications
You must be signed in to change notification settings - Fork 8
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
[iota-faucet] Enable the use of batched mode on faucet #4110
Conversation
// This is to handle the case where there is only 1 coin, we want it to go to | ||
// the normal queue | ||
let split_point = if coins.len() > 10 { | ||
coins.len() / 2 |
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.
@samuel-rufi could you elaborate on how the gas pool handles gas tokens? Why were there multiple gas coins put into it before and why do we only put one now? Is the faucet capable of issuing concurrent transactions with different gas coins?
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 question @lzpap !
So first of all each user request to the gas pool will be handled in a dedicated task spawn in
iota/crates/iota-faucet/src/server.rs
Line 205 in a403cf3
async fn request_gas( |
Each task, will try to get a free gas object from the queue (protected by an Mutex to make sure each request gets a different gas object). The gas pool can serve multiple requests using multiple gas objects basically at the same time.
So how does it work in more detail? For each TX, it will try to get an available coin from this queue. This coin will be locked and unlocked (also called "recycled") once the transaction was successful. If the transaction fails, the coin will stay locked and the queue with available objects shrinks.
So if batch is activated, only one gas object is allocated to the normal gas pool and all others are added to the batch pool. If batch is deactivated, all gas coins are added to the gas pool. Do you think we should change this splitting logic?
In case we don't want to use batch mode, but still want to be able to serve multiple faucet requests (basically at the same time) we can make use of the gas pool, but need to make sure that it was initialized with multiple gas coins. Also for the batch mode, multiple gas coins are needed in order to handle multiple batches at the same time.
--
In case a request comes in and there is no gas coin available (for both modes), it will wait some seconds and then return an error if the queue is still empty.
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.
Thanks for the answers!
So currently on the testnet we have the non-batch mode and 2 objects in the gas pool (obj 1) and (obj 2), right?
@junwei0117 next time the faucet gets topped up would be nice to send the coins in smaller batches to it, so it has 5-10 coins and can serve concurrent requests as well.
Description of change
Enables the use of batched mode on the faucet.
It appeared that if only 5 coins are provided to the faucet (which is the default for the wallet context) all coins will be added to the default gas queue available at
/gas
and not to the batch queue at/v1/gas
. This logic has been refactored.Links to any relevant issues
Fixes #4065
Type of change
How the change has been tested
Provided a test for batch send.
Change checklist