-
Notifications
You must be signed in to change notification settings - Fork 4
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
PoW Faucet #2
Merged
PoW Faucet #2
Conversation
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
nicolasochem
approved these changes
Aug 25, 2023
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 only read the PR description and the README and it looks like excellent work. Ship it!
nicolasochem
requested review from
nicolasochem
and removed request for
nicolasochem
August 25, 2023 21:13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces significant updates to the Tezos Faucet Backend aimed at enhancing its security, reliability, and configurability. The primary change is the implementation of a Proof of Work (PoW) challenge process to ensure that users expend computational resources, thereby preventing bots and malicious actors from spamming and draining the faucet.
Frontend changes for PoW code: oxheadalpha/tezos-faucet#16
The flow of the new process is as follows:
Other changes:
Redis
The backend now uses Redis to store PoW challenge data. This is optional and challenges can be disabled by setting the
DISABLE_CHALLENGES
environment variable to false.Express Server:
The Express server has been updated with new endpoints and middleware. The
/info
endpoint now returns more detailed information. The/challenge
endpoint has been added which starts a new challenge if no challenge exists or if the profile has changed. The/verify
endpoint is used to verify solutions and either responds with another challenge or sends the user Tez.CAPTCHA
CAPTCHA validation is performed for the
/challenge
endpoint. The/verify
endpoint does not perform CAPTCHA validation directly. Instead, when a solution is submitted to the/verify
endpoint, the backend checks the associated challenge to determine if a CAPTCHA was used during the initial challenge request via the/challenge
endpoint.Middleware:
New middleware functions have been added to validate, for example, the address and profile fields in the request body. If the fields are not valid, an error message is returned.
Error Handling:
Improved error handling has been implemented. If an error occurs during the challenge process or while sending Tezos, a detailed error message is returned.
Logging:
A new logging system has been implemented using Winston. This logs HTTP requests and responses, providing useful debugging information.
Profiles:
A new file
profiles.json
has been added which contains user and baker profiles with their respective amounts, challenges needed, difficulty levels, etc. The profiles are validated when the server starts. If a profile is not valid, an error is thrown.README:
The README has been significantly updated to provide a detailed overview of the Tezos Faucet Backend, prerequisites, configuration details, running instructions, Docker instructions, API endpoints, and programmatic faucet usage.
Code Refactoring:
The code has been refactored to improve readability and maintainability. This includes changes to environment variables and removal of unused code. Removed the
/dist
dir.Env Vars
The code changes also include the addition of a new
env.ts
file to handle environment variables and necessary type conversions. The file imports all environment variables from process.env and performs necessary type conversions. For some values, it's better to use the converted values from this file instead of process.env directly. Env vars have been added, removed, and renamed.Dockerfile:
The Dockerfile has been updated to use
node:18-alpine
instead ofnode:16-alpine
. TheWORKDIR
has been changed to/app
and the ownership of the directory has been changed to thenode
user. TheCOPY
commands have been updated to copy thepackage.json
andpackage-lock.json
files with the correct ownership. TheCMD
command has been updated to enable source maps.Package.json:
The
package.json
file has been updated with new dependencies, updated old ones, and removed unused ones. The scripts section has also been updated with new commands for building, starting, and testing the application.