Skip to content

feat: support custom code size limit#1965

Open
AntonD3 wants to merge 3 commits intozksync-os-stablefrom
ad-add-code-size-limit-stable
Open

feat: support custom code size limit#1965
AntonD3 wants to merge 3 commits intozksync-os-stablefrom
ad-add-code-size-limit-stable

Conversation

@AntonD3
Copy link
Contributor

@AntonD3 AntonD3 commented Jan 16, 2026

What ❔

Why ❔

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.

@AntonD3 AntonD3 marked this pull request as ready for review January 16, 2026 14:00
@AntonD3 AntonD3 changed the title feat: support custom code size limit(no tests) feat: support custom code size limit Jan 16, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8203a2951e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +196 to +197
if (_newBatch.codeSizeLimit != s.codeSizeLimit) {
revert IncorrectBatchCodeSizeLimit(_newBatch.codeSizeLimit, s.codeSizeLimit);

Choose a reason for hiding this comment

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

P1 Badge Initialize codeSizeLimit on upgrade

For existing ZKsync OS chains that upgrade to this code, s.codeSizeLimit will default to zero because the new storage slot is appended and DiamondInit only runs on fresh deployments. The new equality check in Executor._commitOneBatchZKsyncOS (_newBatch.codeSizeLimit != s.codeSizeLimit) will therefore revert for any commit that uses the normal EIP‑170 limit (0x6000), effectively halting batch commits until an admin explicitly calls setCodeSizeLimit. If upgrades are expected to be seamless, this needs an initialization/migration path or a safe fallback when s.codeSizeLimit == 0.

Useful? React with 👍 / 👎.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@AntonD3 the comment is correct

@github-actions
Copy link
Contributor

Coverage after merging ad-add-code-size-limit-stable into zksync-os-stable will be

80.00%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
contracts/bridge
   BridgeHelper.sol85.71%100%100%85%31, 36, 41
   BridgedStandardERC20.sol82.14%100%92.31%80.28%120–121, 126–127, 139–140, 164, 205, 212, 219, 229–230, 63, 91
   L1ERC20Bridge.sol94%100%100%93.02%189, 208, 270
   L1Nullifier.sol83.33%100%86.21%82.89%115, 129–131, 161, 222, 225, 235, 238, 248, 251, 419–421, 425–426, 453, 519, 603, 615, 653, 655, 699, 711, 714, 716, 729, 742–743, 747–748, 768
contracts/bridge/asset-router
   AssetRouterBase.sol97.14%100%100%96.55%67
   L1AssetRouter.sol88.17%100%89.29%87.97%106, 232, 270, 286, 373, 384, 415, 454–455, 469, 500, 572, 661, 672, 686, 691, 74, 90, 98
contracts/bridge/interfaces
   AssetHandlerModifiers.sol75%100%100%66.67%13
contracts/bridge/ntv
   L1NativeTokenVault.sol86.72%100%90.48%85.98%172–178, 180, 248–249, 251, 262, 264, 270, 94
   NativeTokenVaultBase.sol89.08%100%91.67%88.67%222, 227, 244, 262, 267, 283, 302, 310, 479, 494, 522, 555–556, 560–561, 74, 90
   UpgradeableBeaconDeployer.sol0%100%0%0%15–16, 18, 20–21
contracts/bridgehub
   BridgehubBase.sol79.41%100%80.56%79.17%128, 133, 135–136, 141–143, 150, 168, 208–209, 218, 233, 272, 275, 294, 310, 341, 459, 463, 467–468, 487, 490, 546, 550, 553, 588–589, 593–594, 602–603, 607–608
   CTMDeploymentTracker.sol73.47%100%81.82%71.05%107, 111, 115, 140, 144–145, 33, 41, 66, 79–80
   ChainAssetHandlerBase.sol69.39%100%66.67%69.77%116, 133, 136, 148–149, 194, 211–212, 216–217, 76, 83–84
   L1Bridgehub.sol88.14%100%92.31%87.62%101, 111, 123, 240, 313, 317–318, 321, 63–64, 87, 91–92
   L1ChainAssetHandler.sol81.82%100%75%84%39–40, 48–49
   L1MessageRoot.sol78.57%100%75%80%36–37
   L2Bridgehub.sol80.56%100%75%82.14%106, 63, 79–80, 91
   L2ChainAssetHandler.sol80.65%100%75%82.61%47–48, 70, 94
   L2MessageRoot.sol34.38%100%50%30.77%39–40, 43–44, 50, 68, 74–75, 79, 81, 83, 86–87, 89, 93–96
   L2MessageVerification.sol100%100%100%100%
   MessageRootBase.sol58.18%100%70%55.56%100–102, 108–110, 119, 131, 141, 146–151, 153–157
contracts/common
   ReentrancyGuard.sol95%100%100%94.12%79
contracts/common/l2-helpers
   L2ContractHelper.sol84.91%100%100%82.22%102, 108, 112, 129, 134, 73, 79, 83
   SystemContractsCaller.sol0%100%0%0%102, 114, 122–125, 128, 135–139, 141–142, 32–34, 37, 44–45, 47, 49, 51, 53, 66, 69, 72, 75, 78, 83, 89, 91, 93, 96, 98
contracts/common/libraries
   DataEncoding.sol85.11%100%100%81.58%109–110, 117–118, 163, 177, 45
   DynamicIncrementalMerkle.sol73.91%100%80%73.17%66–70, 72–74, 76–78
   FullMerkle.sol100%100%100%100%
   Merkle.sol98.15%100%100%97.96%83
   MessageHashing.sol95.16%100%100%94.64%113, 77, 94
   SemVer.sol100%100%100%100%
   UncheckedMath.sol100%100%100%100%
   UnsafeBytes.sol100%100%100%100%
   ZKSyncOSBytecodeInfo.sol50%100%50%50%30, 33
contracts/governance
   AccessControlRestriction.sol100%100%100%100%
   ChainAdmin.sol97.87%100%100%97.30%39
   ChainAdminOwnable.sol44.83%100%40%45.83%28, 38–40, 46–48, 57, 66, 77–79, 81
   Governance.sol100%100%100%100%
   L2ProxyAdminDeployer.sol0%100%0%0%16–18, 20
   PermanentRestriction.sol88.80%100%100%87.39%104, 111–112, 200–201, 204–205, 208, 210–211, 240, 288, 310, 341
   ServerNotifier.sol93.10%100%100%90.91%55, 65
   TransitionaryOwner.sol0%100%0%0%16–17, 21–23
contracts/governance/restriction
   Restriction.sol100%100%100%100%
   RestrictionValidator.sol100%100%100%100%
contracts/l2-upgrades
   L2ComplexUpgrader.sol0%100%0%0%23–25, 39, 44, 46, 56, 62–63, 70, 79–81, 84, 86–87
   L2GenesisForceDeploymentsHelper.sol0%100%0%0%100, 102–103, 108–110, 114, 124, 129–134, 136, 148, 156, 160, 165, 174–175, 178, 185–186, 189, 194–195, 201, 209, 213, 218, 220, 230, 239, 242, 247, 257, 263–264, 267, 270, 276, 280, 284, 295, 304, 309, 311, 319, 330, 344, 350, 370, 378–379, 38, 382–383, 385, 39, 392, 399, 40–41, 49, 52–53, 58, 64–66, 70–72, 78–79, 82–83, 85, 87–88, 94, 96
   L2GenesisUpgrade.sol0%100%0%0%24, 31–32, 37–38, 42, 50
   

if (_codeSizeLimit > MAX_CODE_SIZE_LIMIT) {
revert CodeSizeLimitTooBig(_codeSizeLimit, MAX_CODE_SIZE_LIMIT);
}
s.codeSizeLimit = _codeSizeLimit;
Copy link
Member

Choose a reason for hiding this comment

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

Please always add events for functions that change the config on smart contract. It is the easiest way to monitor the smart contract.

Copy link
Collaborator

@nikitastupin-matterlabs nikitastupin-matterlabs left a comment

Choose a reason for hiding this comment

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

Please add tests. The code looks good to me 👍

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