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: foundry refactor #313

Draft
wants to merge 44 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
56282f9
build: set up Forge project
ZeroEkkusu Jun 10, 2024
d49bc83
test: set up `PolygonRollupManager` & add test
ZeroEkkusu Jun 10, 2024
9b5d502
test: push latest
ZeroEkkusu Jun 11, 2024
3c94a04
test: add `updateRollup` tests 1/2
ZeroEkkusu Jun 11, 2024
6a278b4
test: add `updateRollup` tests 2/2
ZeroEkkusu Jun 13, 2024
e2b3a08
test: cover branches
ZeroEkkusu Jun 17, 2024
089f120
test: `verifyBatchesTrustedAggregator` reverts 1/2
ZeroEkkusu Jun 18, 2024
1171875
chore: relocate contract dirs and files
JDawg287 Jun 20, 2024
1aad202
chore: update hardcoded paths
JDawg287 Jun 20, 2024
70477f1
forge install: deployer-kit
JDawg287 Jun 21, 2024
3bf887e
chore: reinstate PolygonZkEVMDeployer
JDawg287 Jun 21, 2024
180b94d
forge install: solmate
JDawg287 Jun 24, 2024
91e2f85
feat: add deploy script & test for polygonZkEVMDeployer
JDawg287 Jun 25, 2024
f634e81
feat: add multiple deployers
JDawg287 Jun 27, 2024
c6d8764
feat: add PolygonZkEVMBridgeV2 test
JDawg287 Jul 1, 2024
1bb9e50
feat: changes to make the forge coverage work
JDawg287 Jul 2, 2024
b88cb60
fix: review changes
JDawg287 Jul 3, 2024
a93b6ff
chore: add tests PolygonZkEVMBridgeV2.sol
JDawg287 Jul 5, 2024
69ad7ad
feat: add more tests PolygonZkEVMBridgeV2.sol
JDawg287 Jul 8, 2024
4421d29
test: add test for PolygonZkEVMGlobalExitRootV2
JDawg287 Jul 18, 2024
bbb9338
chore: fix existing deployers to proxy deployment
JDawg287 Jul 22, 2024
4fdb440
feat: add more deployers
JDawg287 Jul 22, 2024
26cad75
feat: add PolygonZkEVMTimelock deployer
JDawg287 Jul 24, 2024
bbb02c1
feat: add grantRole script
JDawg287 Jul 24, 2024
9236a9b
chore: standardize deployer scripts
JDawg287 Jul 26, 2024
bfeb734
feat: add test for PolygonZkEVMEtrog.sol
JDawg287 Jul 26, 2024
4541776
fix: initialize operates on 0x
ethyla Jul 29, 2024
35632c5
feat: complete PolygonZkEVMEtrog tests
JDawg287 Aug 6, 2024
ee69f76
chore: add missing TestHelper
JDawg287 Aug 8, 2024
b281466
feat: add test for PolygonDataCommittee
JDawg287 Aug 8, 2024
d553a8d
feat: add entire deployment flow
JDawg287 Aug 19, 2024
5af1845
feat: add rollup manager verification
JDawg287 Aug 21, 2024
088a0f0
feat: Deploy keyless zkevm deployer script
JDawg287 Sep 12, 2024
8dc80b6
feat: create genesis script for CDKs
JDawg287 Sep 12, 2024
b461aa6
fix: proxify
JDawg287 Sep 12, 2024
034303d
fix: foundry.toml polygon rpc url and key
JDawg287 Sep 12, 2024
83c6f51
fix: sonarcloud warnings
JDawg287 Sep 12, 2024
72a79ad
fix: rebase fixes
JDawg287 Sep 13, 2024
7c9aeb6
fix: reinstate contract in pre-commit hook
JDawg287 Sep 13, 2024
123a986
fix: enable ci foundry checks
JDawg287 Sep 13, 2024
6c9f2e9
fix: ci failing
JDawg287 Sep 13, 2024
165b8fe
fix: shadowing variable name
JDawg287 Sep 13, 2024
885ae5b
chore: foundry ci workflow rename
JDawg287 Sep 13, 2024
565f45b
chore: Remove metadata_hash from foundry.toml
JDawg287 Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,38 @@ if npm run lint; then
npx hardhat compile --force
npm run docgen
git add docs
cp artifacts/contracts/PolygonZkEVMBridge.sol/PolygonZkEVMBridge.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVMGlobalExitRoot.sol/PolygonZkEVMGlobalExitRoot.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVMGlobalExitRootL2.sol/PolygonZkEVMGlobalExitRootL2.json compiled-contracts/
cp artifacts/contracts/outdated/PolygonZkEVMBridge.sol/PolygonZkEVMBridge.json compiled-contracts/
cp artifacts/contracts/outdated/PolygonZkEVMGlobalExitRoot.sol/PolygonZkEVMGlobalExitRoot.json compiled-contracts/
cp artifacts/contracts/outdated/PolygonZkEVMGlobalExitRootL2.sol/PolygonZkEVMGlobalExitRootL2.json compiled-contracts/
cp artifacts/contracts/lib/TokenWrapped.sol/TokenWrapped.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonZkEVMBridgeMock.sol/PolygonZkEVMBridgeMock.json compiled-contracts/
cp artifacts/contracts/outdated/mocks/PolygonZkEVMBridgeMock.sol/PolygonZkEVMBridgeMock.json compiled-contracts/
cp artifacts/contracts/mocks/ERC20PermitMock.sol/ERC20PermitMock.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonZkEVMGlobalExitRootL2Mock.sol/PolygonZkEVMGlobalExitRootL2Mock.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonZkEVMGlobalExitRootMock.sol/PolygonZkEVMGlobalExitRootMock.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonZkEVMMock.sol/PolygonZkEVMMock.json compiled-contracts/
cp artifacts/contracts/outdated/mocks/PolygonZkEVMGlobalExitRootL2Mock.sol/PolygonZkEVMGlobalExitRootL2Mock.json compiled-contracts/
cp artifacts/contracts/outdated/mocks/PolygonZkEVMGlobalExitRootMock.sol/PolygonZkEVMGlobalExitRootMock.json compiled-contracts/
cp artifacts/contracts/outdated/mocks/PolygonZkEVMMock.sol/PolygonZkEVMMock.json compiled-contracts/
cp artifacts/contracts/mocks/VerifierRollupHelperMock.sol/VerifierRollupHelperMock.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVM.sol/PolygonZkEVM.json compiled-contracts/
cp artifacts/contracts/outdated/PolygonZkEVM.sol/PolygonZkEVM.json compiled-contracts/
cp artifacts/contracts/verifiers/FflonkVerifier.sol/FflonkVerifier.json compiled-contracts/
cp artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json compiled-contracts/
cp artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json compiled-contracts/
cp artifacts/contracts/deployment/PolygonZkEVMDeployer.sol/PolygonZkEVMDeployer.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVMTimelock.sol/PolygonZkEVMTimelock.json compiled-contracts/

cp artifacts/contracts/v2/PolygonRollupManager.sol/PolygonRollupManager.json compiled-contracts/
cp artifacts/contracts/v2/mocks/PolygonRollupManagerMock.sol/PolygonRollupManagerMock.json compiled-contracts/
cp artifacts/contracts/v2/mocks/PolygonRollupManagerMockInternalTest.sol/PolygonRollupManagerMockInternalTest.json compiled-contracts/
cp artifacts/contracts/PolygonRollupManager.sol/PolygonRollupManager.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonRollupManagerMock.sol/PolygonRollupManagerMock.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonRollupManagerMockInternalTest.sol/PolygonRollupManagerMockInternalTest.json compiled-contracts/

cp artifacts/contracts/v2/PolygonZkEVMBridgeV2.sol/PolygonZkEVMBridgeV2.json compiled-contracts/
cp artifacts/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol/PolygonZkEVMGlobalExitRootV2.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVMBridgeV2.sol/PolygonZkEVMBridgeV2.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVMGlobalExitRootV2.sol/PolygonZkEVMGlobalExitRootV2.json compiled-contracts/

cp artifacts/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol/PolygonZkEVMGlobalExitRootV2.json compiled-contracts/
cp artifacts/contracts/v2/consensus/zkEVM/PolygonZkEVMEtrog.sol/PolygonZkEVMEtrog.json compiled-contracts/
cp artifacts/contracts/v2/consensus/zkEVM/PolygonZkEVMExistentEtrog.sol/PolygonZkEVMExistentEtrog.json compiled-contracts/
cp artifacts/contracts/v2/previousVersions/PolygonZkEVMEtrogPrevious.sol/PolygonZkEVMEtrogPrevious.json compiled-contracts/
cp artifacts/contracts/consensus/zkEVM/PolygonZkEVMEtrog.sol/PolygonZkEVMEtrog.json compiled-contracts/
cp artifacts/contracts/consensus/zkEVM/PolygonZkEVMExistentEtrog.sol/PolygonZkEVMExistentEtrog.json compiled-contracts/
cp artifacts/contracts/previousVersions/PolygonZkEVMEtrogPrevious.sol/PolygonZkEVMEtrogPrevious.json compiled-contracts/

cp artifacts/contracts/v2/consensus/validium/PolygonValidiumEtrog.sol/PolygonValidiumEtrog.json compiled-contracts/
cp artifacts/contracts/v2/consensus/validium/PolygonDataCommittee.sol/PolygonDataCommittee.json compiled-contracts/
cp artifacts/contracts/consensus/validium/PolygonValidiumEtrog.sol/PolygonValidiumEtrog.json compiled-contracts/
cp artifacts/contracts/consensus/validium/PolygonDataCommittee.sol/PolygonDataCommittee.json compiled-contracts/

cp artifacts/contracts/v2/utils/ClaimCompressor.sol/ClaimCompressor.json compiled-contracts/
cp artifacts/contracts/utils/ClaimCompressor.sol/ClaimCompressor.json compiled-contracts/

git add compiled-contracts
exit 0
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Foundry CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Build and Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install NPM dependencies
run: npm ci

- name: Run Forge build
run: |
forge --version
forge build
id: build

- name: Run Forge tests
run: |
forge test -vvv
id: test
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,22 @@ typechain-types/
create_rollup_parameters.json

docker/deploymentOutput

# From foundry-template:

/target
/out
/cache
/coverage
lcov.info
.DS_Store
.env
.vscode
.password

broadcast/*/31337
deployments/**/31337.*

# storage layout checker library
storage_check_cache
storage_check_report
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/deployer-kit"]
path = lib/deployer-kit
url = https://github.com/0xPolygon/deployer-kit
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

pragma solidity 0.8.20;

import "./lib/DepositContractV2.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "contracts/interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
import "contracts/interfaces/IBridgeMessageReceiver.sol";
import "contracts/interfaces/IPolygonZkEVMBridgeV2.sol";
import "contracts/lib/DepositContractV2.sol";
import "contracts/lib/EmergencyManager.sol";
import "contracts/lib/GlobalExitRootLib.sol";
import "contracts/lib/TokenWrapped.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import "../lib/TokenWrapped.sol";
import "../interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
import "../interfaces/IBridgeMessageReceiver.sol";
import "./interfaces/IPolygonZkEVMBridgeV2.sol";
import "../lib/EmergencyManager.sol";
import "../lib/GlobalExitRootLib.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

/**
* PolygonZkEVMBridge that will be deployed on Ethereum and all Polygon rollups
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ pragma solidity 0.8.20;

import "./interfaces/IPolygonRollupManager.sol";
import "./interfaces/IPolygonZkEVMGlobalExitRootV2.sol";
import "../interfaces/IPolygonZkEVMBridge.sol";
import "./interfaces/IPolygonZkEVMBridge.sol";
import "./interfaces/IPolygonRollupBase.sol";
import "../interfaces/IVerifierRollup.sol";
import "../lib/EmergencyManager.sol";
import "./interfaces/IVerifierRollup.sol";
import "./lib/EmergencyManager.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "./lib/PolygonTransparentProxy.sol";
import "./lib/PolygonAccessControlUpgradeable.sol";
Expand Down
1,160 changes: 1,160 additions & 0 deletions contracts/PolygonZkEVMBridgeV2.sol.ignored

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.20;

import "./interfaces/IPolygonZkEVMGlobalExitRootV2.sol";
import "./lib/PolygonZkEVMGlobalExitRootBaseStorage.sol";
import "../lib/GlobalExitRootLib.sol";
import "./lib/GlobalExitRootLib.sol";
import "./lib/DepositContractBase.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/PolygonZkEVMTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.20;

import "@openzeppelin/contracts/governance/TimelockController.sol";
import "./PolygonZkEVM.sol";
import "./outdated/PolygonZkEVM.sol";

/**
* @dev Contract module which acts as a timelocked controller.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.20;
import "../../interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
import "./IBasePolygonZkEVMGlobalExitRoot.sol";

interface IPolygonZkEVMBridgeV2 {
/**
Expand Down
Loading