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

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

Merged
merged 72 commits into from
Aug 19, 2024
Merged

Conversation

moshababo
Copy link
Contributor

@moshababo moshababo commented Jun 27, 2024

What ❔

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

Why ❔

Support for PoA deployment.

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.

moshababo and others added 2 commits June 27, 2024 16:08
Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
@brunoffranca
Copy link
Member

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

@brunoffranca
Copy link
Member

@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)

l2-contracts/contracts/AttesterRegistry.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/AttesterRegistry.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/AttesterRegistry.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/AttesterRegistry.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/AttesterRegistry.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/ConsensusAuthority.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/ConsensusAuthority.sol Outdated Show resolved Hide resolved
@koloz193
Copy link
Contributor

koloz193 commented Jul 2, 2024

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

@moshababo moshababo changed the base branch from main to dev July 3, 2024 05:50
@moshababo moshababo changed the title [WIP] Add consensus L2 contracts (BFT-434) Add consensus L2 contracts (BFT-434) Jul 3, 2024
# Conflicts:
#	l1-contracts/deploy-scripts/AcceptAdmin.s.sol
#	l1-contracts/deploy-scripts/DeployErc20.s.sol
#	system-contracts/package.json
#	system-contracts/scripts/utils.ts
#	yarn.lock
l2-contracts/contracts/ConsensusRegistry.sol Outdated Show resolved Hide resolved
@@ -28,7 +28,8 @@
"ts-node": "^10.1.0",
"typechain": "^4.0.0",
"typescript": "^5.2.2",
"zksync-ethers": "^5.9.0"
"zksync-ethers": "^5.9.0",
"zksync-web3": "^0.15.4"
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need old SDK?

l2-contracts/contracts/ConsensusRegistry.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/ConsensusRegistry.sol Outdated Show resolved Hide resolved
l2-contracts/contracts/ConsensusRegistry.sol Outdated Show resolved Hide resolved
RomanBrodetski and others added 7 commits August 19, 2024 12:52
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Copy link

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%

@pompon0 pompon0 merged commit 80e8234 into dev Aug 19, 2024
20 checks passed
@pompon0 pompon0 deleted the consensus_contracts branch August 19, 2024 15:30
@vladbochok vladbochok restored the consensus_contracts branch August 19, 2024 17:36
pompon0 added a commit that referenced this pull request Aug 20, 2024
pompon0 pushed a commit that referenced this pull request Aug 20, 2024
Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Co-authored-by: Bruno França <bruno@franca.xyz>
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Co-authored-by: Roman Brodetski <Roman.Brodetski@gmail.com>
Co-authored-by: vladbochok <vladbochok1@gmail.com>
vladbochok added a commit that referenced this pull request Aug 20, 2024
Co-authored-by: Moshe Shababo <17073733+moshababo@users.noreply.github.com>
Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Co-authored-by: Bruno França <bruno@franca.xyz>
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Co-authored-by: Roman Brodetski <Roman.Brodetski@gmail.com>
Co-authored-by: vladbochok <vladbochok1@gmail.com>
Yberjon pushed a commit to neotheprogramist/era-contracts that referenced this pull request Aug 22, 2024
Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Co-authored-by: Bruno França <bruno@franca.xyz>
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Co-authored-by: Roman Brodetski <Roman.Brodetski@gmail.com>
Co-authored-by: vladbochok <vladbochok1@gmail.com>
aakoshh added a commit that referenced this pull request Sep 2, 2024
Co-authored-by: Moshe Shababo <17073733+moshababo@users.noreply.github.com>
Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Co-authored-by: Bruno França <bruno@franca.xyz>
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
Co-authored-by: Roman Brodetski <Roman.Brodetski@gmail.com>
Co-authored-by: vladbochok <vladbochok1@gmail.com>
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.

7 participants