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: zksync #301

Closed
wants to merge 13 commits into from
44 changes: 39 additions & 5 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,42 @@ on:

jobs:
test:
uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main
secrets: inherit
release:
needs: [test]
uses: bgd-labs/github-workflows/.github/workflows/release.yml@main
name: zkSync Foundry build and test
runs-on: ubuntu-latest
env:
FOUNDRY_PROFILE: ci
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
ref: ${{ inputs.ref }}
fetch-depth: 0
- name: Setup env
uses: bgd-labs/github-workflows/.github/actions/env@main
with:
RPC_MAINNET: ${{secrets.RPC_MAINNET}}
RPC_POLYGON: ${{secrets.RPC_POLYGON}}
RPC_AVALANCHE: ${{secrets.RPC_AVALANCHE}}
RPC_OPTIMISM: ${{secrets.RPC_OPTIMISM}}
RPC_ARBITRUM: ${{secrets.RPC_ARBITRUM}}
RPC_METIS: ${{secrets.RPC_METIS}}
RPC_BASE: ${{secrets.RPC_BASE}}
RPC_GNOSIS: ${{secrets.RPC_GNOSIS}}
RPC_BNB: ${{secrets.RPC_BNB}}
RPC_ZKEVM: ${{secrets.RPC_ZKEVM}}
RPC_SCROLL: ${{secrets.RPC_SCROLL}}
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly-2024-02-06
- name: Clone Foundry ZkSync
run: git clone https://github.com/matter-labs/foundry-zksync --depth=1 -b dev
- name: Build forge binary
run: |
cd foundry-zksync
cargo build --release --bin forge
- name: Run tests using built binary
run: |
cd ..
forge test --zksync

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package-lock.json
.DS_Store

yarn-error.log
zkout/

# snapshot artifacts
reports/
7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/solidity-utils"]
path = lib/solidity-utils
url = https://github.com/bgd-labs/solidity-utils
[submodule "lib/aave-address-book"]
path = lib/aave-address-book
url = https://github.com/bgd-labs/aave-address-book
branch = feat/zksync-lib
[submodule "lib/solidity-utils"]
path = lib/solidity-utils
url = https://github.com/bgd-labs/solidity-utils
6 changes: 5 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ remappings = []
fs_permissions = [{ access = "read-write", path = "./reports" }]
ffi = true
solc = '0.8.18'
evm_version = 'shanghai'

[profile.default.zksync]
compile = true
fallback_oz = true
mode = '3'

[rpc_endpoints]
mainnet = "${RPC_MAINNET}"
Expand Down
6 changes: 3 additions & 3 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aave-address-book/=lib/aave-address-book/src/
aave-v3-origin/=lib/aave-address-book/lib/aave-v3-origin/src/
aave-v3-core/=lib/aave-address-book/lib/aave-v3-origin/src/core
aave-v3-periphery/=lib/aave-address-book/lib/aave-v3-origin/src/periphery
aave-v3-origin/=lib/aave-address-book/lib/aave-v3-origin-private/src/
aave-v3-core/=lib/aave-address-book/lib/aave-v3-origin-private/src/core
aave-v3-periphery/=lib/aave-address-book/lib/aave-v3-origin-private/src/periphery
forge-std/=lib/forge-std/src/
solidity-utils/=lib/solidity-utils/src/
2 changes: 1 addition & 1 deletion src/AaveHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
pragma solidity >=0.7.5 <0.9.0;

import {GovHelpers, AaveGovernanceV2} from './GovHelpers.sol';
import {ProxyHelpers} from './ProxyHelpers.sol';
import {ProxyHelpers} from 'aave-v3-origin/../tests/utils/ProxyHelpers.sol';
import {ProtocolV3TestBase} from './ProtocolV3TestBase.sol';
7 changes: 7 additions & 0 deletions src/ChainIds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ library TestNetChainIds {
uint256 internal constant CELO_ALFAJORES = 44787;
uint256 internal constant OPTIMISM_SEPOLIA = 11155420;
uint256 internal constant ARBITRUM_SEPOLIA = 421614;
uint256 internal constant ZK_SYNC_SEPOLIA = 300;
}

library ChainHelpers {
Expand Down Expand Up @@ -76,6 +77,8 @@ library ChainHelpers {
newFork = vm.createSelectFork(vm.rpcUrl('sepolia'));
} else if (chainId == ChainIds.HARMONY) {
newFork = vm.createSelectFork(vm.rpcUrl('harmony'));
} else if (chainId == ChainIds.ZK_SYNC) {
newFork = vm.createSelectFork(vm.rpcUrl('zksync'));
} else {
revert UnknownChainId();
}
Expand Down Expand Up @@ -108,6 +111,8 @@ library ChainHelpers {
networkName = 'scroll';
} else if (chainId == ChainIds.CELO) {
networkName = 'celo';
} else if (chainId == ChainIds.ZK_SYNC) {
networkName = 'zksync';
}
// testnets
else if (chainId == TestNetChainIds.ETHEREUM_SEPOLIA) {
Expand All @@ -132,6 +137,8 @@ library ChainHelpers {
networkName = 'scroll_sepolia';
} else if (chainId == TestNetChainIds.CELO_ALFAJORES) {
networkName = 'celo_alfajores';
} else if (chainId == TestNetChainIds.ZK_SYNC_SEPOLIA) {
networkName = 'zksync_sepolia';
} else {
revert('chain id is not supported');
}
Expand Down
2 changes: 1 addition & 1 deletion src/GovHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';
import {AaveV3Harmony} from 'aave-address-book/AaveV3Harmony.sol';
import {AaveV3Fantom} from 'aave-address-book/AaveV3Fantom.sol';
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol';
import {ProxyHelpers} from './ProxyHelpers.sol';
import {ProxyHelpers} from 'aave-v3-origin/../tests/utils/ProxyHelpers.sol';
import {ChainIds} from './ChainIds.sol';
import {StorageHelpers} from './StorageHelpers.sol';

Expand Down
4 changes: 2 additions & 2 deletions src/GovV3Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {GovernanceV3PolygonZkEvm} from 'aave-address-book/GovernanceV3PolygonZkE
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol';
import {Address} from 'solidity-utils/contracts/oz-common/Address.sol';
import {StorageHelpers} from './StorageHelpers.sol';
import {ProxyHelpers} from './ProxyHelpers.sol';
import {ProxyHelpers} from 'aave-v3-origin/../tests/utils/ProxyHelpers.sol';
import {Create2Utils} from './ScriptUtils.sol';

interface IGovernance_V2_5 {
Expand Down Expand Up @@ -695,7 +695,7 @@ library GovV3Helpers {
PayloadsControllerUtils.Payload[] memory payloads,
bytes32 ipfsHash,
address votingPortal
) public pure {
) internal pure {
string memory payloadsStr;
for (uint256 i = 0; i < payloads.length; i++) {
string memory payloadBase = string.concat('&payload[', vm.toString(i), '].');
Expand Down
Loading
Loading