Skip to content
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

Further limit draining faucet before the hackathon weekend #164

Closed
ericnakagawa opened this issue Mar 27, 2024 · 28 comments
Closed

Further limit draining faucet before the hackathon weekend #164

ericnakagawa opened this issue Mar 27, 2024 · 28 comments
Assignees

Comments

@ericnakagawa
Copy link
Contributor

Describe the feature you would like

I’d like a way to further limit draining of testnet faucet.

One idea is to require GitHub auth via Social Connect to further limit abuse.

Additional context

No response

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 27, 2024

Thanks for raising this @ericnakagawa 👍 Convo started on Slack and moved over here.

I checked, the faucet address (0x22579CA45eE22E2E16dDF72D955D6cf4c767B0eF) is indeed low on tokens.

image

faucet.celo.org also display a message that the faucet is low on tokens:

image

@arthurgousset arthurgousset self-assigned this Mar 27, 2024
@arthurgousset
Copy link
Contributor

Eric is hosting a hackathon this weekend and needs the faucet to be accessible to devs.

@arthurgousset
Copy link
Contributor

It looks like the current faucet balance is:

  1. cREAL: ~0.8
  2. cUSD: ~1.2
  3. cEUR: ~824,264
  4. CELO: ~0.3

Source: https://alfajores.celoscan.io/address/0x22579ca45ee22e2e16ddf72d955d6cf4c767b0ef

@arthurgousset
Copy link
Contributor

Checking how much the faucet distributes at the moment.

From here

function getSendAmounts(
authLevel: AuthLevel,
config: NetworkConfig,
): { goldAmount: string; stableAmount: string } {
switch (authLevel) {
case undefined:
case AuthLevel.none:
return {
goldAmount: config.faucetGoldAmount,
stableAmount: config.faucetStableAmount,
}
case AuthLevel.authenticated:
return {
goldAmount: config.authenticatedGoldAmount,
stableAmount: config.authenticatedStableAmount,
}
}
}

we know it's the amounts set here

export interface NetworkConfig {
nodeUrl: string
faucetGoldAmount: string
faucetStableAmount: string
authenticatedGoldAmount: string
authenticatedStableAmount: string
bigFaucetSafeAddress: string
bigFaucetSafeAmount: string
bigFaucetSafeStablesAmount: string
}

Checking what the amounts are set to.

Following the setup instructions in readme.md:

$ cd apps/firebase
$ yarn dlx firebase-tools@latest logim
# ...
$ yarn install

From firebase/README.md, we get the config values with:

$ yarn cli config:get --net alfajores
{
  // ...
  "authenticated_stable_amount": "5000000000000000000",
  "authenticated_gold_amount": "5000000000000000000",
  "faucet_gold_amount": "500000000000000000",
  "faucet_stable_amount": "500000000000000000",
  // ...
}

Converting from wei to ethers

# authenticated
$ cast from-wei 5000000000000000000 ether
5.000000000000000000

# not authenticated
$ cast from-wei 500000000000000000 ether
0.500000000000000000

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 27, 2024

Ideas to avoid faucet being empty:

  1. lower unauthenticated amount even more. But that doesn't prevent abuse per se, it only makes the number of requests required to drain the faucet higher
  2. separate faucet balance available for authenticated and unauthenticated requests. If unauthenticated requests empty their allocation, authenticated users are not affected, because their available balance is not empty. But that doesn't protect from authenticated abusers.
  3. Limit authenticated requests per day. If authenticated users want to abuse the faucet, they have to use multiple Github accounts, which creates additional friction.

@arthurgousset
Copy link
Contributor

Ideas to fill the faucet by the weekend:

  1. wait for validator rewards to come in
  2. convert a portion of ~824,264 cEUR into CELO
  3. Eric to fill faucet with tokens he has

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 28, 2024

  • Confirm that faucet is getting replenished

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 28, 2024

Historical context: Aaron shared that the faucet is currently only getting replenished using carbon offsetting rewards.

$ celocli network:parameters --node alfajores
... 
EpochRewards:
  carbonOffsetting:
    factor: 0.25
    partner: 0x22579CA45eE22E2E16dDF72D955D6cf4c767B0eF
...

The faucet address is set as the carbon offset reward recipient: 0x22579CA45eE22E2E16dDF72D955D6cf4c767B0eF

In the past, the faucet was replenished by transferring funds from a larger funder account.

@arthurgousset
Copy link
Contributor

Asked for help to make a short-term transfer to the faucet for the weekend hackathon.

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

@arthurgousset
Copy link
Contributor

The faucet balance has been drained by 100,000 CELO in 10 days. From Mar 19 to Mar 29, the balance dropped from 100,460 to near 0.

image

Source: https://explorer.celo.org/alfajores/address/0x22579CA45eE22E2E16dDF72D955D6cf4c767B0eF/coin-balances?block_number=23258880&items_count=50#address-tabs

@arthurgousset
Copy link
Contributor

It might be necessary to limit the amount of CELO that can be sent out, whether the user is authenticated or not.

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

@arthurgousset
Copy link
Contributor

The funding amount fluctuates with use, because carbon offset rewards depend on network usage. In recent days it's around ~900-1,000 CELO per day, but not sure what it looks like before:

image

Source: https://explorer.celo.org/alfajores/block/23241600/epoch-transactions

image

Source: https://explorer.celo.org/alfajores/block/23224320/epoch-transactions

image

Source: https://explorer.celo.org/alfajores/block/23207040/epoch-transactions

@arthurgousset
Copy link
Contributor

Other ideas to limit abuse:

  1. Adjust the amount that is sent based on the recipient's balance (if CELO balance high, send less)
  2. Check reCaptcha is required when user is Github authenticated (seems like a bot is making 5 CELO requests repeatedly)

@arthurgousset
Copy link
Contributor

The faucet used be funded every hour:

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

This address 0xb8c3475d736ab7c587b3fcf6a4e2d55136d4968f seems to be running an automated process.

Eric briefly funded the faucet with 25 CELO and the address above automatically started making 5 CELO requests until the faucet was empty:

image

Source: https://explorer.celo.org/alfajores/address/0x22579CA45eE22E2E16dDF72D955D6cf4c767B0eF

image

Source: https://explorer.celo.org/alfajores/address/0x22579CA45eE22E2E16dDF72D955D6cf4c767B0eF/token-transfers#address-tabs

@jcortejoso
Copy link
Member

Hi @arthurgousset ! Thanks for the explanation.

Do we know what authentication method is the draining bot using?

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

Hi @arthurgousset ! Thanks for the explanation.

Do we know what authentication method is the draining bot using?

Yes, the bot is using a Github authenticated account to request 5 CELO instead of 0.5 for unauthenticated accounts.

But, more importantly, we have a mechanism in place that doesn't fund any address that has more than 20 CELO. But, there was a bug that prevented that from working.
It's fixed and deployed in production:

That means if the bot has a balance >= 20 CELO the faucet will not fund it.

image

Technically, the bot could be updated to always have a balance < 20 CELO and send it on to another address, but as a quick fix, this might prevent the bot from working over the weekend.

Depends how quickly they'll update the scripts.

I'll look into better long-term solutions to prevent abuse.

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

Unfortunately, it looks like the bot is still able to request 5 CELO repeatedly. because their balance is below 20. They are currently using this address: 0xbabe97E806Ae3a153A94F2ee564cD8cCeA1Dc913.

image

Source: https://explorer.celo.org/alfajores/address/0xbabe97E806Ae3a153A94F2ee564cD8cCeA1Dc913/coin-balances#address-tabs

@arthurgousset
Copy link
Contributor

One short-term fix could be to reduce the amount of CELO that are sent out to authenticated accounts.

Currently, it's 5 CELO. We could set it to 0.5 CELO, which is the unauthenticated amount.

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

Whenever the bot's balance is above 20, the faucet doesn't send tokens as expected 👍

Here 0xbabe97E806Ae3a153A94F2ee564cD8cCeA1Dc913 has 21.25 CELO. So requests stop until the bot sends CELO away and the balance drops below 20.

image

Source: https://explorer.celo.org/alfajores/address/0xbabe97E806Ae3a153A94F2ee564cD8cCeA1Dc913/coin-balances#address-tabs

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

We could consider limiting requests per Github user per day.
But, that's not a short-term fix, because I have to save state in Firebase and add some code that reads/write Github user data.

We could store a hash of the Github username, so it anonymizes users, but still uniquely identifies them.

We could also limit requests to 1x per day.
For additional requests, we could make it conditional on having CELO on mainnet.

@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

(for future reference)
Javi topped the faucet up with 50,000 CELO so Eric is unblocked for the weekend.

@arthurgousset
Copy link
Contributor

We also sent @ericnakagawa 50,000 CELO as a short-term fix for the weekend. That way he can top up the faucet independently, if he has a short-term need, and the faucet is still affected by the abuse.

@arthurgousset arthurgousset changed the title Further limit draining faucet Further limit draining faucet before the hackathon weekend Mar 29, 2024
@arthurgousset
Copy link
Contributor

arthurgousset commented Mar 29, 2024

I'm closing this issue as it pertains to the hackathon weekend, and opened a new issue for longer-term changes to prevent abuse:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants