-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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] Implement simple faucet service #1549
Conversation
Addressed @bmwill and @patrickkuo 's comments
|
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 making those changes to simplify this!
struct AppState<F = SimpleFaucet> { | ||
faucet: F, | ||
// TODO: add counter | ||
} |
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.
What's the reasoning for wanting this to be generic?
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.
In case I want to experiment with a different implementation of Faucet(e.g., using a queue of gas objects,etc) for some traffic and can quickly switch to another one in case the more complicated implementation is failing.
ServiceBuilder::new() | ||
.layer(HandleErrorLayer::new(handle_error)) | ||
.buffer(REQUEST_BUFFER_SIZE) | ||
.concurrency_limit(CONCURRENCY_LIMIT) |
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 don't have context on how the internal wallet handles concurrent access so we may just want to be careful and sure that this service still functions properly with parallel requests (although the concurrency_limit should act as that bottleneck)
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 the current implementation only work for CONCURRENCY_LIMIT = 1
but will relax this assumption in a subsequent PR
@666lcz thanks for handling this |
Overview
This PR implements a modularized and extensible Faucet service with a naive Coin selection/splitting/transferring algorithm. The goal is to have something simple deployed to the Devnet first while I will improve concurrency in subsequent PRs.
Algorithm
src/faucet/simple_faucet.rs
, which always uses two coins in the active address(one to split and sent to users, and the other to pay gas fee for operations such as splitting and transferring). It selects the two coin during initialization with highest balances.Architecture
src/faucet
contains logic for coin transferring/splittingNext steps
Testing
Added unit tests. I also did an end to end testing as below:
Response
Used the wallet CLI to verify that the address indeed received these coins