-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
21bc0f3
fix: Pass at least one coin to the faucet batch queue
samuel-rufi 0a520b8
fix: Clippy
samuel-rufi 5986ff9
fix: Rework split point
samuel-rufi e2b87af
fix: Enable `batch_enabled` flag for existing batch tests
samuel-rufi 723bb28
fix: Add test_faucet_batch_concurrent_requests test
samuel-rufi 0713c83
fix: Fix comment
samuel-rufi 9b19ab4
fix: Remove wrong comment
samuel-rufi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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.