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

Migrate L2 contracts to use foundry testing #755

Merged
merged 22 commits into from
Aug 29, 2024

Conversation

StanislavBreadless
Copy link
Collaborator

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.

Copy link

github-actions bot commented Aug 29, 2024

Changes to gas cost

Generated at commit: aca7ab2846ae507f1efb3a56c384bca42ac41064, compared to commit: 10ec8ba28f3de36ab6d8f73d63496f59b37654e3

🧾 Summary (100% most significant diffs)

Contract Method Avg (+/-) %
DummyBridgehubSetter setHyperchain
setSTM
-1 ✅
-1 ✅
-0.00%
-0.00%
DiamondProxy finalizeEthWithdrawal
requestL2Transaction
+1 ❌
-4 ✅
+0.00%
-0.00%
MerkleTest calculateRoot(bytes32[],uint256,bytes32) -1 ✅ -0.03%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
DummyBridgehubSetter 3,964,042 (0) addStateTransitionManager
admin
proveL1ToL2TransactionStatus
proveL2LogInclusion
removeStateTransitionManager
setHyperchain
setPendingAdmin
setSTM
23,879 (0)
446 (0)
0 (0)
0 (0)
23,855 (0)
111,388 (0)
26,003 (0)
44,187 (0)
0.00%
0.00%
+∞%
+∞%
0.00%
0.00%
0.00%
0.00%
41,154 (-1)
1,446 (0)
1,403 (+9)
1,539 (+9)
25,482 (-1)
111,425 (-1)
41,668 (-5)
44,224 (-1)
-0.00%
0.00%
+0.65%
+0.59%
-0.00%
-0.00%
-0.01%
-0.00%
47,605 (0)
1,446 (-1,000)
991 (0)
1,139 (0)
25,855 (0)
111,436 (-12)
49,685 (0)
44,235 (-12)
0.00%
-40.88%
0.00%
0.00%
0.00%
-0.01%
0.00%
-0.03%
47,605 (0)
2,446 (0)
3,651 (+7)
3,951 (0)
26,267 (0)
111,448 (0)
49,901 (0)
44,247 (0)
0.00%
0.00%
+0.19%
0.00%
0.00%
0.00%
0.00%
0.00%
3,584 (0)
2,048 (+1)
512 (0)
512 (0)
2,048 (0)
768 (0)
1,280 (+1)
768 (0)
DiamondProxy 1,888,784 (-539,861) finalizeEthWithdrawal
requestL2Transaction
util_setChainId
37,779 (0)
33,295 (0)
29,011 (0)
0.00%
0.00%
0.00%
76,528 (+1)
130,198 (-4)
33,846 (-25)
+0.00%
-0.00%
-0.07%
76,979 (-12)
167,132 (-12)
33,823 (0)
-0.02%
-0.01%
0.00%
77,303 (0)
191,247 (0)
34,195 (0)
0.00%
0.00%
0.00%
257 (0)
771 (0)
519 (0)
MerkleTest 442,717 (0) calculateRoot(bytes32[],uint256,bytes32) 571 (0) 0.00% 2,929 (-1) -0.03% 2,982 (0) 0.00% 3,037 (+11) +0.36% 265 (0)
MerkleTreeNoSort 534,636 (0) getProof 2,594 (0) 0.00% 32,739 (-1) -0.00% 33,193 (0) 0.00% 33,215 (0) 0.00% 277 (0)
L1ERC20Bridge 1,109,516 (-12)
DummyStateTransitionManager 3,875,602 (-12)
TransactionFiltererFalse 145,799 (-24)
TransactionFiltererTrue 146,039 (+12)
VerifierTest 2,409,010 (-12)
RelayedSLDAValidator 631,088 (+12)
GenerateForceDeploymentsData 1,251,217 (+12)
TestBaseFacet 169,007 (-12)
GettersFacetWrapper 1,740,191 (+12)

Copy link

Coverage after merging kl/sync-layer-reorg-foundry into kl/sync-layer-reorg will be

87.50%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
../da-contracts/contracts
   RollupL1DAValidator.sol61.04%31.25%83.33%67.27%145, 148, 148, 148, 150, 183–184, 187–188, 27, 27–28, 30, 30–31, 34, 36–37, 41–42, 65, 67, 67, 67–68, 70, 80, 80–81
contracts/bridge
   BridgeHelper.sol100%100%100%100%
   L1AssetRouter.sol93.91%84.85%94.87%96.62%139–140, 155–156, 216, 236, 285, 338, 390, 550, 571, 613, 731–732, 753–754, 895
   L1ERC20Bridge.sol97.50%100%100%96.55%116
   L1NativeTokenVault.sol92.42%93.33%78.57%94.32%177–178, 258, 286, 291, 46–47
contracts/bridgehub
   Bridgehub.sol65.85%33.78%78.38%76.88%107, 107, 107, 112, 118, 123, 123, 152–153, 196, 196–197, 199–200, 200, 200–201, 207–208, 208, 208–209, 209, 209, 211–212, 212, 212–213, 221–222, 236–237, 284–285, 315–316, 318–319, 321–323, 325–326, 329–330, 336, 338–339, 341–342, 369–370, 380–381, 384, 412, 436–438, 441, 441–442, 486, 494–496, 500, 500–501, 503, 517–518, 530–531, 570, 594–595, 674, 677–678, 682–683, 712–713, 718–719, 748, 753
   MessageRoot.sol91.38%61.54%100%100%156, 162, 69, 76, 94
   STMDeploymentTracker.sol79.49%50%90%94.12%110, 114, 31, 38, 61, 88, 91
contracts/common
   ReentrancyGuard.sol90%66.67%100%92.86%78–79
contracts/common/libraries
   DataEncoding.sol80%100%100%66.67%72, 80
   DynamicIncrementalMerkle.sol74.42%100%80%72.22%67–70, 72–74, 76–78
   FullMerkle.sol100%100%100%100%
   L2ContractHelper.sol47.06%0%60%54.17%100, 104, 29–30, 35–36, 39–40, 54, 56, 56–57, 61, 61–62, 70
   Merkle.sol96.61%90.91%100%97.67%80–81
   MessageHashing.sol100%100%100%100%
   SemVer.sol100%100%100%100%
   UncheckedMath.sol100%100%100%100%
   UnsafeBytes.sol100%100%100%100%
contracts/governance
   ChainAdmin.sol17.86%0%20%21.05%27–28, 39–40, 47–48, 56, 56–57, 60, 62–63, 63, 66, 69, 78, 78–79, 81
   Governance.sol98.15%94.74%100%98.55%44–45
contracts/state-transition
   StateTransitionManager.sol66.25%33.33%55.88%77.45%108, 137–138, 140–141, 143–144, 146–147, 202–203, 247, 254, 272, 278, 285, 297, 304, 311, 319, 326, 334, 341, 359, 361, 426, 445, 445, 445, 448, 448, 448, 450, 463, 468, 493, 74, 87–88
   TestnetVerifier.sol77.78%66.67%100%75%16, 32
   ValidatorTimelock.sol95.38%83.33%100%95.45%210, 83–84
   Verifier.sol89.88%35.71%96.30%90.93%1673–1674, 287–302, 305–308, 311–318, 321–328, 331–332, 335–336, 339, 384–385, 395–396, 406–407, 417–418, 428–429, 444–445, 454, 454–455, 904–905
contracts/state-transition/chain-deps
   DiamondInit.sol78%45.45%100%86.49%39–40, 42–43, 45–46, 48–49, 51–52, 77
   DiamondProxy.sol92.31%75%100%100%16, 27
contracts/state-transition/chain-deps/facets
   Admin.sol81.50%48.57%86.36%90.52%104–105, 115–116, 130, 130–131, 133–134, 157, 157, 157–158, 158, 158, 160, 239, 241, 254–255, 261, 280–281, 286, 323, 333, 337, 40, 40
   Executor.sol78.32%64.94%92.86%81.37%119–120, 201, 207–208, 208–209, 211, 211–212, 224, 224, 228, 228, 228, 252–253, 270, 273, 319, 319–320, 324, 328, 330–331, 337–338, 357–360, 362, 37, 418, 418, 418–421, 423, 426, 429–430, 447, 450–451, 453–455, 468–470, 531–532, 540–541, 563–564, 574–575, 626–627, 653–654
   Getters.sol81.82%62.50%82.22%83.82%110, 113, 119, 122, 133, 136, 178, 231, 237, 241, 65, 70, 85, 90
   Mailbox.sol82.27%70.59%89.66%83.57%153, 188, 198, 207–208, 233, 237, 237, 237, 240, 242–243, 245, 250, 252, 255–257, 262–265, 267–268, 274, 274, 274, 276, 279–280, 374–375, 54
   ZkSyncHyperchainBase.sol71.43%71.43%71.43%71.43%55, 55–56, 62, 62–63
contracts/state-transition/data-availability
   CalldataDA.sol100%100%100%100%
   CalldataDAGateway.sol85.71%66.67%100%100%27–28
   RelayedSLDAValidator.sol96.67%83.33%100%100%94
contracts/state-transition/libraries
   Diamond.sol93.33%80.77%100%95.96%109–110, 113, 115, 117, 120, 198–199, 316
   LibMap.sol100%100%100%100%
   PriorityQueue.sol100%100%100%100%
   PriorityTree.sol97.62%80%100%100%80
   TransactionValidator.sol94.44%88.24%100%96%66–67, 69–70
contracts/upgrades
   BaseZkSyncUpgrade.sol58.20%27.27%100%60.23%104,

@@ -12,3 +12,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/@matterlabs/zksync-contracts"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this submodule? Looks good otherwise

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need this library for efficientcall in the l2-contracts.

We try to avoid importing stuff from node_modules inside foundry, so we have to import it via submodule like a normal foundry lib

@StanislavBreadless StanislavBreadless merged commit dfd969c into kl/sync-layer-reorg Aug 29, 2024
23 checks passed
@StanislavBreadless StanislavBreadless deleted the kl/sync-layer-reorg-foundry branch August 29, 2024 10:46
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.

3 participants