Skip to content

Conversation

@maradini77
Copy link

Description

  • Replace calls to start(), end(), and duration() with direct reads of immutable fields _start and _duration inside VestingWallet._vestingSchedule.
  • Keeps public getters unchanged for external use/overrides; only optimizes internal logic.

@maradini77 maradini77 requested a review from a team as a code owner November 7, 2025 10:17
@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2025

⚠️ No Changeset found

Latest commit: e36cd3b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Walkthrough

The VestingWallet contract's internal _vestingSchedule function was refactored to use private immutable state variables (_start and _duration) directly instead of calling public getter functions. Three specific comparisons and calculations were updated: the timestamp comparison now references _start directly, the end condition uses _start + _duration instead of calling end(), and the vesting amount calculation performs arithmetic on the immutable variables rather than retrieving them through public methods. Public function signatures remain unchanged, and no alterations were made to exported or public entity declarations.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main optimization: replacing redundant getter calls with direct immutable field access in the _vestingSchedule function.
Description check ✅ Passed The description is directly related to the changeset, explaining the replacement of getter calls with immutable field reads and clarifying that public getters remain unchanged.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
contracts/finance/VestingWallet.sol (1)

76-78: Consider updating end() for consistency (with caution).

For consistency with the optimizations in _vestingSchedule, you could update end() to return _start + _duration directly. However, this has the same implications: if derived contracts override start() or duration(), those overrides would no longer be reflected in end().

Given that end() is a public function more likely to be called externally, and the gas savings are minimal for a simple getter, the current implementation may be the safer choice.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb97fd3 and e36cd3b.

📒 Files selected for processing (1)
  • contracts/finance/VestingWallet.sol (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Redirect rules - solidity-contracts
  • GitHub Check: Header rules - solidity-contracts
  • GitHub Check: slither
  • GitHub Check: tests-foundry
  • GitHub Check: coverage
  • GitHub Check: tests-upgradeable
  • GitHub Check: tests
  • GitHub Check: Pages changed - solidity-contracts
  • GitHub Check: halmos
🔇 Additional comments (1)
contracts/finance/VestingWallet.sol (1)

151-159: Gas optimization verified—no contracts in the codebase override the getters.

The change correctly reduces gas costs by accessing immutable state variables directly rather than through view function calls. Verification confirms no existing contracts in the OpenZeppelin repository override start(), duration(), or end(), and the only derived contract (VestingWalletCliff) properly handles inheritance by overriding _vestingSchedule and calling super._vestingSchedule().

@Amxx
Copy link
Collaborator

Amxx commented Nov 10, 2025

start(), end() and duration() are virtual. In case there is an override, we will want to consider the overriden value.

@Amxx Amxx closed this Nov 10, 2025
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