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

Adding Tx Hash to the faucet funding #1660

Merged
merged 2 commits into from
Nov 22, 2023
Merged

Conversation

otherview
Copy link
Contributor

Why this change is needed

Adds the tx hash to the reply from the faucet.
Updates test to use the Authenticated path .

What changes were made as part of this PR

Please provide a high level list of the changes made

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

Copy link

coderabbitai bot commented Nov 22, 2023

Walkthrough

The changes across the codebase involve enhancing the Fund method in the Faucet type to return a transaction hash along with an error, and updating the HTTP request in fundWallet to include an authorization header. The fundingHandler function in the web server has been updated to return the transaction hash in the response. These updates suggest an added layer of security with the authorization requirement and improved transparency by providing transaction hashes for funding operations.

Changes

File Path Change Summary
integration/faucet/faucet_test.go Updated the fundWallet function to include an "Authorization" header in the HTTP request.
tools/faucet/faucet/faucet.go Modified the Fund method to return a transaction hash and an error, updated logging to include the transaction hash, and enhanced error messages to include the transaction hash.
tools/faucet/webserver/web_server.go Updated the fundingHandler function to return a transaction hash in the JSON response.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e0e082d and b945b10.
Files selected for processing (3)
  • integration/faucet/faucet_test.go (2 hunks)
  • tools/faucet/faucet/faucet.go (1 hunks)
  • tools/faucet/webserver/web_server.go (1 hunks)
Additional comments: 2
integration/faucet/faucet_test.go (2)
  • 111-117: The URL in the fundWallet function has been updated to include /auth in the path, indicating that the endpoint now requires authentication. Ensure that the corresponding endpoint in the server has been updated to handle this new authenticated route.

  • 125-125: An "Authorization" header with a mock JWT token has been added to the HTTP request in the fundWallet function. This change implies that the faucet service is now using JWT for authentication. Verify that the JWT token used here aligns with the authentication mechanism and that the token is valid for the test environment.

tools/faucet/webserver/web_server.go Show resolved Hide resolved
tools/faucet/faucet/faucet.go Outdated Show resolved Hide resolved
tools/faucet/faucet/faucet.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b945b10 and c5f9cdf.
Files selected for processing (1)
  • tools/faucet/faucet/faucet.go (1 hunks)
Additional comments: 2
tools/faucet/faucet/faucet.go (2)
  • 54-80: - The Fund method has been correctly updated to return a transaction hash as a string along with an error. This aligns with the change summary.
  • Ensure that all callers of the Fund method are updated to handle the new return type (string, error).
  • The error message in line 77 includes the transaction hash, which is a good practice for debugging purposes.
  • The logging statement in line 73 is informative, but consider if sensitive information is being logged.
  • The validateTx method is called after the transaction is sent, which is a good practice to ensure the transaction was successful. However, there is a todo comment on line 74 regarding handling the transaction receipt which should be addressed before finalizing the code.
  • The fundNativeToken method is called within a mutex lock, which is good for preventing race conditions when multiple funding operations occur.
  • 83-83: - The validateTx method is not part of the hunk, but it's important to ensure that the validation logic is robust and handles all possible cases.
  • The method waits for the transaction receipt with a timeout, which is a good practice to avoid indefinite waiting. However, the error message "tx status is not 0x1" could be more descriptive, indicating that the transaction failed.

@otherview otherview merged commit 29cae5d into main Nov 22, 2023
2 checks passed
@otherview otherview deleted the pedro/faucet_tx_feedback branch November 22, 2023 18:15
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

Successfully merging this pull request may close these issues.

2 participants