-
Notifications
You must be signed in to change notification settings - Fork 15
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
Basic Discord Bot #53
Conversation
90088fb
to
475f1d2
Compare
Not really working at the moment beyond a few transfers. Suspect there's some kind of deadlock and may have to change the design a bit.
Popping from two Vecs is a bad idea.
The zkevm websocket server runs on a different port than the http server. Other than that there are no surprises.
475f1d2
to
b676ba5
Compare
faucet/src/lib.rs
Outdated
inflight_clients: HashMap<Address, Arc<Middleware>>, | ||
// Funding wallets has priority, these transfer requests must be pushed to | ||
// the front. | ||
transfer_queue: VecDeque<Transfer>, |
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 may be somewhat simpler to use a channel for this transfer queue as well or just get rid of it completely. Currently for internal funding transfers the faucet will add to this queue directly and the external faucet transfer get added to this queue via the faucet_receiver
.
- Fix docker compose demo. - Include change of zkevm-node to panic on startup. - Make it possible to run without discord faucet for local testing.
The CI currently fails because it needs the container that is only available from |
This reverts commit 17d38ac. This doesn't work: The workflow is not valid. .github/workflows/build.yml (Line: 19, Col: 3): The workflow must contain at least one job with no dependencies.
For the CI I suggest we just merge it and then if necessary make new PRs to fix it. It's quite involved to change the CI workflows so that it can use the docker containers built from this repo directly so I don't think it's worth it at this stage. |
faucet/src/faucet.rs
Outdated
let required = match transfer { | ||
// Double the faucet amount to be on the safe side regarding gas. | ||
TransferRequest::Faucet { amount, .. } => amount * 2, | ||
TransferRequest::Funding { .. } => self.total_balance / self.clients.len(), |
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.
This is wrong. The balance here should be looking at the total balance and not the balance that is currently in the pool of available clients. Maybe it's better to keep all the clients in the pool but mark them as available or not, instead of moving the in and out of the pool.
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.
Fix in 8d82f76
let intents = GatewayIntents::GUILD_MESSAGES | ||
| GatewayIntents::DIRECT_MESSAGES | ||
| GatewayIntents::MESSAGE_CONTENT; |
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 think to avoid spam we should restrict the bot to listen only to messages in a specific channel (and maybe DMs). We don't want it responding to every message in any channel that happens to include a valid address (e.g. someone asks for help in a support channel and happens to include their address). Not sure how or where to do that.
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 thought we can tell discord to only have the bot get messages from the faucet channel but it turns out that is way more involved than I thought and one has to remove the bot from each channel that it shouldn't respond to. Some discussion here: https://support.discord.com/hc/en-us/community/posts/360045778711-Restrict-bots-to-certain-channels-
The easiest for us would be to filter by channel ID in rust but this is a bit tedious to configure: we need to add an env var with the channel ID.
I think a more idiomatic discord way of doing it may be to
- add a command to the bot, so users would have to write for example
/faucet 0x123...
instead of just posting the address - only allow that command in the faucet channel.
Unfortunately after half an hour I'm still not sure how to create these commands with serenity.
Another solution that might be okay, but still tedious. We can remove the bots permissions to read messages for all channel categories except for a channel category that only contains the faucet channel.
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.
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.
This change is in 4d54dd9
Require a wallet to have more than the average initiial balance of all the faucet wallets. - Log an error when we retry for a transaction receipt of a transactions that's already in a block.
Avoid holding guards longer than necessary.
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
Will merge to get docker image built. Then fix what's necessary. |
Limitations
TODO
Close EspressoSystems/espresso-sequencer#373