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

fix(wevmos): make WEVMOS deposit and withdraw functions real no-ops and fix tests #2329

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

Vvaradinov
Copy link
Contributor

@Vvaradinov Vvaradinov commented Feb 6, 2024

Description

This PR makes the WEVMOS precompiled contract functions withdraw and deposit real no-ops without emitting events or modifying the StateDB.

Closes: XAP-103


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the correct branch (see PR Targeting)

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

Summary by CodeRabbit

  • Refactor
    • Simplified the logic for deposit and withdrawal functions in the WERC20 transactions, enhancing efficiency.
  • Tests
    • Enhanced test cases for deposit and withdrawal, including adjustments to event handling, gas consumption checks, and balance verification.
  • Chores
    • Updated the werc20 package functionality by removing input parameters from the Deposit and Withdraw functions to streamline their operations.
  • Chores
    • Modified the Deposit and Withdraw methods in the Precompile struct of the werc20.go file to no longer accept certain arguments, impacting WERC20 transaction behavior.

@Vvaradinov Vvaradinov requested a review from a team as a code owner February 6, 2024 10:36
@Vvaradinov Vvaradinov requested review from MalteHerrmann and GAtom22 and removed request for a team February 6, 2024 10:36
Copy link

linear bot commented Feb 6, 2024

Copy link

coderabbitai bot commented Feb 6, 2024

Warning

Rate Limit Exceeded

@Vvaradinov has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 28 minutes and 12 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between af25b9f and 623d4d0.

Walkthrough

The recent updates focus on refining the handling of deposit and withdrawal events within the werc20 package. This includes the addition of specific constants for event types, a simplification of the logic in both the tx.go and werc20.go files by removing certain input parameters, and enhancements to test cases to better check gas consumption and balance verifications. Overall, these changes streamline the process and improve the reliability of deposit and withdrawal transactions in WERC20.

Changes

Files Change Summary
.../werc20/integration_test.go Added constants for event types; refactored event handling; updated gas and balance checks.
.../werc20/tx.go, .../werc20.go Simplified Deposit and Withdraw by removing parameters; modified logic for these operations.

🐰✨
In the realm of code, where the smart contracts dwell,
Changes come forth, casting a harmonious spell.
Deposits and withdrawals, now sleek and refined,
A testament to progress, by developers designed.
🌟🐾

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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 9d49591 and fe9aac5.
Files selected for processing (3)
  • precompiles/werc20/integration_test.go (14 hunks)
  • precompiles/werc20/tx.go (2 hunks)
  • precompiles/werc20/werc20.go (1 hunks)
Additional comments: 18
precompiles/werc20/tx.go (2)
  • 18-18: The Deposit function has been correctly updated to perform no operations, aligning with the PR objectives.
  • 25-25: The Withdraw function has been correctly updated to perform no operations, aligning with the PR objectives.
precompiles/werc20/werc20.go (1)
  • 117-120: The logic in the Run function correctly handles calls to the Deposit and Withdraw methods as no-ops, consistent with the PR objectives.
precompiles/werc20/integration_test.go (15)
  • 26-31: The introduction of EventTypeDeposit and EventTypeWithdrawal constants is appropriate for handling event types in tests, improving readability and maintainability.
  • 104-104: The gas consumption check for the Deposit method correctly reflects its new no-op nature.
  • 117-117: The gas consumption check for the Withdraw method correctly reflects its new no-op nature.
  • 136-136: The balance check logic in the test case for calling with incomplete data correctly reflects the expected behavior.
  • 152-152: The balance check logic in the test case for calling with short call data correctly reflects the expected behavior.
  • 168-168: The balance check logic in the test case for calling with non-existing function correctly reflects the expected behavior.
  • 182-182: The balance check logic in the test case for calling without call data and without amount correctly reflects the expected behavior.
  • 197-197: The balance check logic in the test case for calling with short call data and without amount correctly reflects the expected behavior.
  • 212-212: The balance check logic in the test case for calling with non-existing function and without amount correctly reflects the expected behavior.
  • 242-242: The gas consumption comparison between the precompile and the original contract for the Deposit method is correctly set up in the test.
  • 261-261: The error handling comparison between the precompile and the original contract for the Deposit method with insufficient balance is correctly set up in the test.
  • 282-282: The balance reflection test for the Deposit method correctly compares the precompile and the original contract.
  • 318-318: The setup for the Withdraw method test by depositing into the WEVMOS contract is correctly implemented.
  • 328-328: The gas consumption comparison between the precompile and the original contract for the Withdraw method is correctly set up in the test.
  • 344-344: The error handling comparison between the precompile and the original contract for the Withdraw method is correctly set up in the test.

precompiles/werc20/integration_test.go Outdated Show resolved Hide resolved
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 fe9aac5 and af25b9f.
Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • precompiles/werc20/integration_test.go (14 hunks)
Files skipped from review as they are similar to previous changes (1)
  • precompiles/werc20/integration_test.go
Additional comments: 1
CHANGELOG.md (1)
  • 73-73: The changelog entry correctly documents the change to the wevmos module, making the deposit and withdraw functions no-ops.

@Vvaradinov Vvaradinov merged commit c4c4730 into main Feb 8, 2024
49 of 50 checks passed
@Vvaradinov Vvaradinov deleted the Vvaradinov/wevmos-precompile-refactor branch February 8, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants