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

feat(contracts): add withdrawTo to ValidatorPool contract #274

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

0xHansLee
Copy link
Contributor

@0xHansLee 0xHansLee commented Mar 21, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new withdrawal functionality in the Validator Pool, enabling users to directly transfer a specified amount to a given address.
    • Added test functions to ensure the withdrawal process functions correctly, including testing withdrawals to specific addresses and handling balance adjustments accurately.
    • Implemented a test to check for reverting withdrawals to the zero address.

@0xHansLee 0xHansLee self-assigned this Mar 21, 2024
@0xHansLee 0xHansLee requested a review from a team as a code owner March 21, 2024 09:19
Copy link
Contributor

coderabbitai bot commented Mar 21, 2024

Walkthrough

The update introduces a new withdrawal feature in the ValidatorPool.sol contract, allowing users to withdraw a specified amount to a designated address. A corresponding test function test_withdraw_to_succeeds in the ValidatorPoolTest contract validates this functionality, ensuring accurate balance adjustments post-withdrawal.

Changes

File Change Summary
.../contracts/L1/ValidatorPool.sol Added withdrawTo function for withdrawing a specified amount to a given address.
.../contracts/test/ValidatorPool.t.sol Added test_withdraw_to_succeeds to test the new withdrawal functionality and balance adjustments. Added test_withdraw_to_zero_address_reverts to check for reverting withdrawals to the zero address.

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.
    • Open a follow-up GitHub issue for this discussion.
  • 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 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
Contributor

@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: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b5621b2 and 024c58a.
Files selected for processing (2)
  • packages/contracts/contracts/L1/ValidatorPool.sol (1 hunks)
  • packages/contracts/contracts/test/ValidatorPool.t.sol (1 hunks)

packages/contracts/contracts/L1/ValidatorPool.sol Outdated Show resolved Hide resolved
@0xHansLee 0xHansLee force-pushed the feat/add-withdraw-to-validator-pool branch from 024c58a to fb15fae Compare March 21, 2024 11:02
Copy link
Contributor

@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 b5621b2 and fb15fae.
Files selected for processing (2)
  • packages/contracts/contracts/L1/ValidatorPool.sol (1 hunks)
  • packages/contracts/contracts/test/ValidatorPool.t.sol (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/contracts/contracts/L1/ValidatorPool.sol
  • packages/contracts/contracts/test/ValidatorPool.t.sol

@0xHansLee 0xHansLee force-pushed the feat/add-withdraw-to-validator-pool branch from fb15fae to 42455c1 Compare March 21, 2024 13:57
Copy link
Contributor

@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 b5621b2 and 42455c1.
Files selected for processing (2)
  • packages/contracts/contracts/L1/ValidatorPool.sol (1 hunks)
  • packages/contracts/contracts/test/ValidatorPool.t.sol (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/contracts/contracts/L1/ValidatorPool.sol
  • packages/contracts/contracts/test/ValidatorPool.t.sol

@0xHansLee 0xHansLee force-pushed the feat/add-withdraw-to-validator-pool branch from 42455c1 to b1a61f8 Compare March 21, 2024 23:31
Copy link
Contributor

@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 b5621b2 and b1a61f8.
Files selected for processing (3)
  • packages/contracts/.gas-snapshot (6 hunks)
  • packages/contracts/contracts/L1/ValidatorPool.sol (1 hunks)
  • packages/contracts/contracts/test/ValidatorPool.t.sol (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/contracts/contracts/L1/ValidatorPool.sol
  • packages/contracts/contracts/test/ValidatorPool.t.sol
Additional comments: 2
packages/contracts/.gas-snapshot (2)
  • 382-382: The gas cost for test_withdraw_to_succeeds is 167576. This adjustment is crucial to understand the performance impact of the newly introduced withdrawTo function. Ensure that this gas cost is within acceptable limits and does not indicate a significant performance regression. It's also important to compare this cost with similar functions to ensure consistency.
  • 350-383: The gas cost adjustments across various functions in the ValidatorPoolTest class, including test_addPendingBond_succeeds, test_createBond_succeeds, test_increaseBond_succeeds, and others, indicate changes in the contract's performance characteristics. It's important to ensure that these adjustments are justified by the changes made to the ValidatorPool contract and do not introduce inefficiencies. Additionally, verify that the gas costs for new or modified functions, such as test_withdraw_to_succeeds, are in line with expectations and do not significantly impact the contract's usability due to high gas costs.

Copy link
Contributor

@kangsorang kangsorang 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
Contributor

@seolaoh seolaoh left a comment

Choose a reason for hiding this comment

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

LGTM except that the bindings need to be updated!

@0xHansLee
Copy link
Contributor Author

LGTM except that the bindings need to be updated!

Thank you for pointing out. I'll add it soon.

@0xHansLee 0xHansLee force-pushed the feat/add-withdraw-to-validator-pool branch from b1a61f8 to 6840f93 Compare March 22, 2024 03:23
Copy link
Contributor

@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 b5621b2 and 6840f93.
Files selected for processing (5)
  • kroma-bindings/bindings/validatorpool.go (2 hunks)
  • kroma-bindings/bindings/validatorpool_more.go (1 hunks)
  • packages/contracts/.gas-snapshot (6 hunks)
  • packages/contracts/contracts/L1/ValidatorPool.sol (1 hunks)
  • packages/contracts/contracts/test/ValidatorPool.t.sol (1 hunks)
Files not summarized due to errors (2)
  • kroma-bindings/bindings/validatorpool.go: Error: Message exceeds token limit
  • kroma-bindings/bindings/validatorpool_more.go: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (3)
  • packages/contracts/.gas-snapshot
  • packages/contracts/contracts/L1/ValidatorPool.sol
  • packages/contracts/contracts/test/ValidatorPool.t.sol
Additional comments: 8
kroma-bindings/bindings/validatorpool_more.go (3)
  • 16-16: The ValidatorPoolDeployedBin constant holds the deployed bytecode for the ValidatorPool contract. Ensure this bytecode matches the actual deployed bytecode of the contract.
  • 16-16: The ValidatorPoolStorageLayoutJSON constant defines the storage layout for the ValidatorPool contract. Verify that this JSON matches the actual storage layout defined in the Solidity contract.
  • 16-16: In the init function, the use of panic for error handling is appropriate for initialization code where failure is not an option. However, it might be helpful to add a comment explaining why panic is used here, for the sake of clarity and maintainability.
kroma-bindings/bindings/validatorpool.go (5)
  • 34-34: The metadata, ABI, and Bin variables are correctly defined and follow best practices by encouraging access through the ValidatorPoolMetaData struct.

Also applies to: 35-35

  • 34-34: The DeployValidatorPool function is correctly implemented, handling deployment and error scenarios appropriately.
  • 34-34: The contract, caller, transactor, and filterer structs, along with their methods, are correctly implemented and provide the necessary functionality to interact with the smart contract.
  • 34-34: The event handling logic, including iterators and filter functions for various contract events, is correctly implemented and follows best practices.
  • 900-920: The withdrawTo method is correctly implemented, aligning with the PR objectives to enhance user control over withdrawals.

@0xHansLee 0xHansLee merged commit dde2544 into dev Mar 22, 2024
2 checks passed
@0xHansLee 0xHansLee deleted the feat/add-withdraw-to-validator-pool branch March 22, 2024 07:40
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.

4 participants