-
Notifications
You must be signed in to change notification settings - Fork 40
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
Remove client dependency from faucet #368
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.
Looking good! Left some comments
I didn't see where in the code we are currently using |
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.
Not a final review, In general looks good though. I'll continue with testing these changes locally.
One thing I noticed while reviewing this is that we never store the faucet state. This means that if by any reason the server crashes I lost the faucet forever. It might be worth considering storing it somewhere, but it's a separate issue than this one.
|
||
#[derive(Clone)] | ||
pub struct FaucetDataStore { | ||
faucet_account: Rc<RefCell<Account>>, |
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.
If we changed Rc<RefCell<Account>>
for Arc<<Mutex<Account>>
(maybe even Arc<RwLock<Account>>
) would we still need the unsafe impl Send
and unsafe impl Sync
from above?
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 because the TransactionExecutor
still wouldn't be Send+Sync
bin/faucet/src/client.rs
Outdated
|
||
struct FaucetAuthenticator { | ||
secret_key: AuthSecretKey, | ||
rng: RefCell<ChaCha20Rng>, |
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.
as for what was said above, what happens if we wrap this with a Mutex
/ RwLock
instead of a RefCell
?
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.
It was suggested to remove this struct in favor of the BasicAuthenticator
which currently also uses a RefCell
. In the future this may change and we could remove the unsafe impl Send+Sync
.
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.
Tested locally with the dockerized node, worked like a charm. In fact, it feels faster than before (it's still restricted by block time since we can only do one tx per block.
Again unrelated to the PR, but could it be possible to do a mint for multiple accounts at a time by "aggregating" many mint requests into a single Tx that generates all mint notes? It would probably change the flow a bit since we'd need to switch to a polling scheme or similar, but it would allow the faucet to mint for several accounts per block.
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! Thank you! I left a couple of small comments inline.
Also, I think as a part of this PR we should get rid of the miden-client
dependency entirely. So, before merging this, we should probably address 0xPolygonMiden/miden-base#715 and propagate the changes here and to miden-client
.
2dc9fc9
to
cb9e735
Compare
Creted a PR adding the new We will also need to update the client to use the new serialized file but it's not a blocking change for the faucet. |
0a2aff6
to
b0e9116
Compare
b0e9116
to
0a2aff6
Compare
0a2aff6
to
a176307
Compare
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.
Thank you! Not a very in-depth review - but overall everything looks good (only a couple of inline comments from my end).
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.
LGTM! Left a couple of comments but nothing blocking.
This reverts commit b103d38.
I see that this was merged into |
it will change the miden-base dependencies to point to the next branch since it was merged into |
Yes - I think it is fine to have |
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! Thank you! I left one comment inline.
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.
LGTM! (tested locally with a dockerized node + faucet and an account from a local client. Created multiple public notes and was able to consume them). We'd still need 0xPolygonMiden/miden-client#375 for private ones to import private notes into the client
closes #343
This PR removes almost all of the functionality implemented by the
miden-client
and replaces it with it's own implementation that doesn't depend on the crate. The newFaucetClient
is stored in the state and wrapped with a mutex to allow concurrency (a feature that was removed in the previous version).Some caveats:
InputNoteRecord
type is needed in order to be serialized and imported by the user. We could change themiden-client
to accept theNote
type as it's import or move theInputNoteRecord
tomiden-base
.