matter-labs / era-contracts

Smart Contract Submodule For zkSync Era
MIT License
482 stars 338 forks source link

feat(consensus): add L2 registry contract (BFT-434) #555

Closed moshababo closed 1 month ago

moshababo commented 3 months ago

What ❔

Adding consensus L2 registry contract, to manage attester & validator committees.

Why ❔

Support for PoA deployment.

Checklist

brunoffranca commented 3 months ago

Seems good to me, matches the design doc. I'm not the best person to review Solidity code though.

brunoffranca commented 3 months ago

@moshababo Let's do a couple of changes here to simplify the contract a bit:

  1. Remove the inactivity delay mechanism. (we don't really need it now while only governance can remove nodes)
  2. Remove epoch number. (we don't have a use for it now)
  3. Remove the nextCommittee field. setNextCommittee should now set current committee. (we will need to store future committees somehow but I think it will need to be more complete than this, for now we can make it work)
koloz193 commented 3 months ago

Also if possible please merge into dev, main is supposed to only contain mainnet deployed code

moshababo commented 2 months ago

Shouldn't you also emit the log with the commitment to the attesters list?

We plan to implement L2->L1 logs only at a later phase.

github-actions[bot] commented 1 month ago

Coverage after merging consensus_contracts into dev will be

89.25%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
contracts/bridge
   L1ERC20Bridge.sol81.82%80%75%84.62%62, 70, 70, 70–72
   L1SharedBridge.sol81.88%76.58%79.41%85.98%102, 111, 117, 117, 117, 129–133, 147, 154, 165–166, 176, 176, 176–180, 180, 180–181, 186–188, 188, 188–191, 191, 191–192, 204, 213, 213, 213, 346–347, 469, 484, 493, 510, 599, 827, 832, 96
contracts/bridgehub
   Bridgehub.sol98.36%97.37%100%98.46%297, 50
contracts/common
   ReentrancyGuard.sol100%100%100%100%
contracts/common/libraries
   L2ContractHelper.sol53.57%30%50%71.43%25, 28–29, 42–43, 43, 43, 45, 45, 45, 52
   SemVer.sol100%100%100%100%
   UncheckedMath.sol100%100%100%100%
   UnsafeBytes.sol100%100%100%100%
contracts/governance
   ChainAdmin.sol0%0%0%0%26, 26, 26–27, 29–30, 36–37, 44–45, 53, 53, 53–54, 56–57, 57, 60, 63, 72, 72, 72–73
   Governance.sol91.67%93.55%95%89.47%44, 44, 44, 46, 48–49, 51–52
contracts/state-transition
   StateTransitionManager.sol63.40%56%50%69.79%103–107, 113, 144–146, 150, 191, 193–194, 199–200, 200, 200, 202–204, 206–207, 242, 262, 276, 281, 286, 291, 296, 301, 306, 373, 373, 373, 375, 438, 91, 91, 91, 98
   TestnetVerifier.sol44.44%33.33%50%50%16, 16, 16, 32
   ValidatorTimelock.sol92.86%100%94.74%90.70%231, 60–62
   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.sol87.76%70%100%100%27–31, 54
   DiamondProxy.sol80.77%62.50%100%88.24%16, 16, 16–17, 27
contracts/state-transition/chain-deps/facets
   Admin.sol86.05%72.73%92.31%90.20%126, 153–154, 156, 76, 85, 97, 97, 97–99
   Executor.sol87.22%77.04%84.38%94.82%123, 168, 171, 174, 177, 180, 183, 186, 192, 198, 200–202, 214, 232, 246, 305, 363, 383–385, 405, 42, 446, 453, 472, 477, 538, 54, 56, 56, 56, 563–564, 57–58, 612, 614, 65–66, 675
   Getters.sol92.08%100%90.24%92.98%153, 204, 72, 77
   Mailbox.sol100%100%100%100%
   ZkSyncHyperchainBase.sol96.43%92.86%100%100%48
contracts/state-transition/libraries
   Diamond.sol94.81%86.49%100%97.73%110, 112, 114, 116, 119, 184, 294
   LibMap.sol100%100%100%100%
   Merkle.sol100%100%100%100%
   PriorityQueue.sol100%100%100%100%
   TransactionValidator.sol97.18%94.12%100%100%54–55
contracts/upgrades
   BaseZkSyncUpgrade.sol69.42%48.65%100%75%102, 102, 102, 104, 107, 110–111, 122, 122, 122, 124, 127, 130–131, 145–147, 165–167, 206, 208, 223, 241–242, 246, 246, 246, 259, 267, 272, 278–279, 283, 291–292, 75
   BaseZkSyncUpgradeGenesis.sol56.67%14.29%100%68.18%25, 25–26, 33–34, 40–41, 52–53, 62–63, 65–66
   DefaultUpgrade.sol100%100%100%100%
   GenesisUpgrade.sol100%100%100%100%
contracts/vendor
   AddressAliasHelper.sol100%100%100%100%