Skip to content

Conversation

@madlabman
Copy link
Contributor

@madlabman madlabman commented Jan 15, 2026

Description

Extract function bodies to external libraries. Applying byte code saving tricks here and there.

Affected functions:

  • getNodeOperatorSummary
  • obtainDepositData (top-ups)
  • cleanDepositQueue
  • createNodeOperator
  • reportWithdrawnValidators
  • bunch of functions using _onOperatorDepositableChange
  • bunch of functions using _setTargetLimit
--- <unnamed>
+++ <unnamed>
@@ -186,17 +186,17 @@
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | changeNodeOperatorRewardAddress                                | 25947           | 32761  | 32747  | 40960   | 8       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| cleanDepositQueue                                              | 22412           | 74098  | 71792  | 111584  | 20      |
-|----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| compensateGeneralDelayedPenalty                                | 24510           | 59143  | 65548  | 90546   | 5       |
+| cleanDepositQueue                                              | 25784           | 68224  | 66146  | 107080  | 21      |
+|----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
+| compensateGeneralDelayedPenalty                                | 24510           | 56863  | 65506  | 84867   | 5       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | confirmNodeOperatorManagerAddressChange                        | 27694           | 30057  | 29840  | 33074   | 5       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | confirmNodeOperatorRewardAddressChange                         | 27281           | 30668  | 31026  | 32626   | 6       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| createNodeOperator                                             | 26454           | 116422 | 121932 | 144902  | 375     |
-|----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| decreaseVettedSigningKeysCount                                 | 26540           | 67686  | 79733  | 106702  | 27      |
+| createNodeOperator                                             | 26454           | 120200 | 125705 | 148827  | 376     |
+|----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
+| decreaseVettedSigningKeysCount                                 | 26540           | 63560  | 74051  | 99320   | 27      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | depositQueueItem                                               | 0               | 662    | 0      | 2934    | 217     |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
@@ -210,7 +210,7 @@
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | getKeysForTopUp                                                | 4169            | 27557  | 28698  | 48378   | 6       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| getNodeOperator                                                | 0               | 6995   | 13469  | 13469   | 953     |
+| getNodeOperator                                                | 0               | 7002   | 13469  | 13469   | 954     |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | getNodeOperatorIds                                             | 3082            | 3437   | 3412   | 3949    | 8       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
@@ -222,7 +222,7 @@
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | getNodeOperatorOwner                                           | 6245            | 6245   | 6245   | 6246    | 2       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| getNodeOperatorSummary                                         | 30983           | 31374  | 31500  | 31924   | 36      |
+| getNodeOperatorSummary                                         | 32684           | 33076  | 33201  | 33629   | 36      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | getNodeOperatorTotalDepositedKeys                              | 3866            | 3866   | 3866   | 3866    | 2       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
@@ -264,7 +264,7 @@
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | obtainDepositData(uint256,bytes)                               | 26220           | 116794 | 96728  | 274625  | 114     |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| obtainDepositData(uint256,bytes,uint256[],uint256[],uint256[]) | 26873           | 47207  | 47244  | 75161   | 16      |
+| obtainDepositData(uint256,bytes,uint256[],uint256[],uint256[]) | 26873           | 52558  | 53451  | 84438   | 16      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | onExitedAndStuckValidatorsCountsUpdated                        | 23095           | 23095  | 23095  | 23095   | 1       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
@@ -286,13 +286,13 @@
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | recoverEther                                                   | 24287           | 26544  | 26544  | 28802   | 2       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| removeKeys                                                     | 25154           | 94354  | 104065 | 181682  | 18      |
-|----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| reportGeneralDelayedPenalty                                    | 25439           | 99195  | 112623 | 112936  | 29      |
+| removeKeys                                                     | 25154           | 92455  | 100883 | 179136  | 18      |
+|----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
+| reportGeneralDelayedPenalty                                    | 25439           | 96779  | 109444 | 109757  | 29      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | reportValidatorExitDelay                                       | 28337           | 30179  | 30179  | 32022   | 2       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| reportWithdrawnValidators                                      | 25844           | 109084 | 113651 | 235932  | 44      |
+| reportWithdrawnValidators                                      | 25844           | 113459 | 120514 | 235720  | 44      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | resetNodeOperatorManagerAddress                                | 27633           | 32639  | 30911  | 39180   | 6       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
@@ -302,17 +302,17 @@
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | setTopUpQueueLimit                                             | 23806           | 39722  | 36580  | 53680   | 9       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| settleGeneralDelayedPenalty                                    | 25056           | 52592  | 45659  | 89158   | 15      |
+| settleGeneralDelayedPenalty                                    | 25056           | 55266  | 45659  | 97305   | 15      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | supportsInterface                                              | 363             | 480    | 480    | 598     | 2       |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | unsafeUpdateValidatorsCount                                    | 25443           | 36445  | 35872  | 45690   | 11      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| updateDepositableValidatorsCount                               | 44202           | 59542  | 58737  | 104912  | 38      |
+| updateDepositableValidatorsCount                               | 44160           | 56883  | 55789  | 107924  | 38      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
 | updateExitedValidatorsCount                                    | 26242           | 41270  | 47129  | 56792   | 11      |
 |----------------------------------------------------------------+-----------------+--------+--------+---------+---------|
-| updateTargetValidatorsLimits                                   | 24316           | 64824  | 59769  | 109351  | 54      |
+| updateTargetValidatorsLimits                                   | 24317           | 65500  | 62915  | 115676  | 54      |
 ╰----------------------------------------------------------------+-----------------+--------+--------+---------+---------╯
 
 ╭------------------------------------------------+-----------------+--------+--------+--------+---------╮

Checklist

  • Appropriate PR labels applied
  • Test coverage maintained (just coverage)
    • No need to add/update tests
    • Tests are added/updated
  • Documentation maintained
    • No need to update
    • Updated

@madlabman madlabman requested a review from Copilot January 15, 2026 20:54
@madlabman madlabman requested a review from a team as a code owner January 15, 2026 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extracts function bodies from the main contracts into dedicated external libraries to reduce bytecode size. The refactoring moves complex logic into reusable library functions while maintaining the same functionality.

Changes:

  • Extracted queue cleaning, operator management, and deposit data processing logic into separate libraries
  • Updated copyright year from 2025 to 2026 across modified files
  • Removed redundant test cases for queue operations that now return early instead of reverting
  • Moved constant definitions to interface files for better organization

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib/WithdrawnValidatorLib.sol Updated copyright year and added validation logic previously in BaseModule
src/lib/TopUpDepositDataLib.sol New library extracting top-up deposit data processing logic
src/lib/OperatorTracker.sol New library for tracking operator creators in transient storage
src/lib/OperatorDepositableChangeLib.sol New library handling operator depositable count changes
src/lib/NodeOperatorLib.sol New library containing node operator management functions
src/lib/DepositQueueLib.sol Removed clean function moved to dedicated library
src/lib/DepositQueueCleanLib.sol New library containing deposit queue cleaning logic
src/interfaces/IStakingModule.sol Added constant definition for forced target limit mode
src/abstract/BaseModule.sol Refactored to use new library functions, updated imports
src/CSModule.sol Refactored to use new library functions for queue operations
test/unit/lib/DepositQueueLib.t.sol Removed test for maxItems zero revert case
test/unit/CSModule.t.sol Added test verifying early return when maxItems is zero

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vgorkavenko
Copy link
Contributor

@codex Review, pls!

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants