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

1.3.0 libs.0 zksync #588

Merged
merged 79 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
1975a39
feat: zksync support draft
nick8319 May 5, 2023
e8f1095
config: update ts configuration to include hardhat types
ElvisKrop May 5, 2023
2d51799
fix: update deploy script for zksync
ElvisKrop May 5, 2023
93155c4
fix: deployment script for safe-contracts v1.3.0
nick8319 May 5, 2023
5668614
deps: use satisfying libs
ElvisKrop May 5, 2023
59e76c3
fix: add types for benchmarks
ElvisKrop May 5, 2023
0402cdc
fix: fix types definitions
ElvisKrop May 5, 2023
8ddd54f
fix: change proxyRuntimeCode in tests
nick8319 May 8, 2023
2578796
fix: linting
nick8319 May 8, 2023
2a69a16
feat: zksync non-deterministick deployment script
nick8319 May 10, 2023
118daf9
feat: add zksync local node rich wallets and singleton factory ABI
ElvisKrop May 10, 2023
55249a8
feat: add getDeployer zk util
ElvisKrop May 10, 2023
1fe0c6e
feat: change hardhat-deploy package
ElvisKrop May 10, 2023
c49783e
feat: zksync deployment using custom hardhat-deploy
ElvisKrop May 10, 2023
58de489
feat: update hardhat tasks to use custom hardhat-deploy
ElvisKrop May 10, 2023
fabcaf5
refactor: replace waffle getWallets for zkSync networks with custom util
ElvisKrop May 10, 2023
8f9e0ba
WIP: zksync compiler
nick8319 May 11, 2023
3a5d1da
tests: zk deploy mock contract
ElvisKrop May 11, 2023
5a64d0d
feat: accessor test zkSync
nick8319 May 11, 2023
de9e58c
fix: change revert message for requiredTxGas test
ElvisKrop May 12, 2023
649e3ab
fix: await safe setup txs in fallback manager tests
ElvisKrop May 12, 2023
e0098db
fix: zksync proxy tests
nick8319 May 12, 2023
96c99ca
fix: await safe call txs in owner manager tests
ElvisKrop May 12, 2023
e7557a3
fix: calculateProxyAddress for evm
nick8319 May 12, 2023
1d42104
fix: zkSync storage and signatures test
nick8319 May 12, 2023
f8135db
fix: remove import from tests folder
ElvisKrop May 12, 2023
ad1287c
fix: make guard tests work for zksync
ElvisKrop May 12, 2023
dcb7f78
fix: make module manager tests work for zksync
ElvisKrop May 12, 2023
070af1f
feat: general getContractFactoryByName util
ElvisKrop May 13, 2023
9ccdde4
feat: DelegateCallTransactionGuard tests
ElvisKrop May 13, 2023
b917aff
feat: ReentrancyTransactionGuard tests
ElvisKrop May 13, 2023
b5e7c3d
fix: integration tests zkSync
nick8319 May 13, 2023
aed40a0
feat: CompatibilityFallbackHandler tests
ElvisKrop May 13, 2023
66bcfa9
fix: refactor zkCompile
nick8319 May 13, 2023
92864a2
feat: HandlerContext tests for zk
ElvisKrop May 13, 2023
d9d63e4
fix: zkCompiler
nick8319 May 13, 2023
facf440
fix: zkCompile output
ElvisKrop May 13, 2023
91228ae
feat: skip tests that contains selfdestruct for zksync
ElvisKrop May 13, 2023
ab4023b
fix: skip migration tests for zkSync
nick8319 May 13, 2023
1f96287
fix: skip createCall tests for zkSync
nick8319 May 13, 2023
b398ab4
feat: update SignMessageLib tests for zksync
ElvisKrop May 13, 2023
0ae1f78
fix: improving comments
nick8319 May 13, 2023
cd8ebf8
fix: skip migration test for zkSync
nick8319 May 13, 2023
96ce1e9
feat: update MultiSendCallOnly tests for zksync
ElvisKrop May 13, 2023
81270b9
feat: update MultiSend tests for zksync
ElvisKrop May 13, 2023
e5954ad
feat: update some Setup tests for zksync
ElvisKrop May 13, 2023
7bd2703
fix: incoming test for zkSync
nick8319 May 14, 2023
9acd4c4
fix: add comment for 2 tests that will fail on zkSync
nick8319 May 14, 2023
fc6ee41
fix: L2 execution tests for zkSync
nick8319 May 14, 2023
d2a8af4
fix: adding zk versions of master contracts with send()=>call() fix t…
nick8319 May 14, 2023
9e9239a
fix: execution tests for zkSync
nick8319 May 14, 2023
320930f
fix: rollback L2 execution test
nick8319 May 14, 2023
6a5a05c
feat: add comments with explanation for potentialy failed tests
nick8319 May 14, 2023
a8207e5
fix: update .env.sample
nick8319 May 14, 2023
b3b63d8
fix: moduleManager tests for zkSync
nick8319 May 15, 2023
8f30f89
fix: setup tests for zkSync
nick8319 May 15, 2023
d819082
feat: update ModuleManager test for zksync
ElvisKrop May 15, 2023
87729c7
feat: update zk related hardhat tasks
ElvisKrop May 16, 2023
61c72eb
feat: update zk deployment process
ElvisKrop May 16, 2023
827714f
feat: update readme for zkSync
ElvisKrop May 16, 2023
73cd2ef
feat: add verification for deployed contracts (bytecode and source)
nick8319 May 17, 2023
1159ad6
feat: update deployment scripts for zksync
ElvisKrop May 17, 2023
3271cb9
feat: update hardhat-deploy dependency
ElvisKrop May 17, 2023
423351d
feat: add inline variable for zk tests command
ElvisKrop May 17, 2023
ffc5265
feat: improve zk verification tasks
ElvisKrop May 17, 2023
17d9fd5
feat: add colors for local verification statuses
ElvisKrop May 17, 2023
f4cee69
feat: adding comment for updated kilLib Test contract for zkSync
nick8319 Jun 13, 2023
b20943f
feat: remove zk version of master copies with send() workaround
nick8319 Jun 14, 2023
412dec1
feat: skip tests for zkSync which use send() function
nick8319 Jun 14, 2023
b492bce
refactor: replace `@elvis-krop/hardhat-deploy` with resolution for `@…
ElvisKrop Jun 15, 2023
4a7a658
refactor: remove GnosisSafeL2Zk from .env.sample
ElvisKrop Jun 15, 2023
f2bd874
fix: L2 test for zkSync
nick8319 Jun 15, 2023
683db6e
feat: support for refactored singleton factory for zkSync
nick8319 Jun 16, 2023
2ebf777
Use adjusted hardhat-deploy version to support existing deployment sc…
rmeissner Jun 27, 2023
089b5ef
fix: get deterministicDeployment info
nick8319 Jun 28, 2023
e87d983
fix: cleanup scripts
nick8319 Jun 28, 2023
c8d2744
Merge pull request #4 from protofire/zksync_deterministic_deployment
nick8319 Jun 28, 2023
81d9dd9
feat: add zkSyncSepolia network config
nick8319 Jul 19, 2024
5d0cd60
feat: fix dependencies
nick8319 Aug 5, 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
4 changes: 3 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ INFURA_KEY=""
NODE_URL=""
ETHERSCAN_API_KEY=""
# Use the Safe singleton factory for singleton deployment. This is required if EIP-155 is enforce on a chain.
# CUSTOM_DETERMINISTIC_DEPLOYMENT="true"
# CUSTOM_DETERMINISTIC_DEPLOYMENT="true"
# To run tests with a fixed version of GnosisSafeL2 contract for zkSync
SAFE_CONTRACT_UNDER_TEST="GnosisSafeL2Zk"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ bin/
solc
coverage/
coverage.json
yarn-error.log
yarn-error.log
/.idea
.vscode/launch.json
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ yarn hardhat --network <network> etherscan-verify
yarn hardhat --network <network> local-verify
```

#### zkSync Network

In order to test and deploy locally to zkSync, you need to run zkSync local-node:

Download the dockerized project with the following command:
```bash
git clone https://github.com/matter-labs/local-setup.git
```

To run zkSync Era locally, run the start.sh script
```bash
cd local-setup
./start.sh
```
> Note: Wait about 10 minutes for node to startup

To compile safe-contracts for zkSync run
```bash
yarn build:zk
```

To test safe-contracts with local zkSync node run
```bash
yarn test:zk
```

#### Custom Networks

It is possible to use the `NODE_URL` env var to connect to any EVM based network via an RPC endpoint. This connection then can be used with the `custom` network.
Expand Down
4 changes: 2 additions & 2 deletions benchmark/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const generateTarget = async (owners: Wallet[], threshold: number, guardAddress:
return safe
}

export const configs = [
export const configs: { name: string, signers: Wallet[], threshold: number, useGuard?: boolean }[] = [
{ name: "single owner", signers: [user1], threshold: 1 },
{ name: "single owner and guard", signers: [user1], threshold: 1, useGuard: true },
{ name: "2 out of 23", signers: [user1, user2], threshold: 2 },
Expand Down Expand Up @@ -85,4 +85,4 @@ export const benchmark = async (topic: string, benchmarks: Benchmark[]) => {
}
})
}
}
}
4 changes: 2 additions & 2 deletions contracts/proxies/GnosisSafeProxyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ contract GnosisSafeProxyFactory {
emit ProxyCreation(proxy, singleton);
}

/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
/* /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
} */

/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
Expand Down
234 changes: 129 additions & 105 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,142 +1,166 @@
import type { HardhatUserConfig, HttpNetworkUserConfig } from "hardhat/types";
import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-verify";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "solidity-coverage";
import "hardhat-deploy";
import "@elvis-krop/hardhat-deploy";
import dotenv from "dotenv";
import yargs from "yargs";
import { getSingletonFactoryInfo } from "@gnosis.pm/safe-singleton-factory";

const argv = yargs
.option("network", {
type: "string",
default: "hardhat",
})
.help(false)
.version(false).argv;
.option("network", {
type: "string",
default: "hardhat",
})
.help(false)
.version(false).argv;

// Load environment variables.
dotenv.config();
const { NODE_URL, INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY, PK, SOLIDITY_VERSION, SOLIDITY_SETTINGS, CUSTOM_DETERMINISTIC_DEPLOYMENT } = process.env;
const { NODE_URL, INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY, PK, SOLIDITY_VERSION, SOLIDITY_SETTINGS } = process.env;

const DEFAULT_MNEMONIC =
"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
const DEFAULT_MNEMONIC = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";

const sharedNetworkConfig: HttpNetworkUserConfig = {};
if (PK) {
sharedNetworkConfig.accounts = [PK];
sharedNetworkConfig.accounts = [PK];
} else {
sharedNetworkConfig.accounts = {
mnemonic: MNEMONIC || DEFAULT_MNEMONIC,
};
sharedNetworkConfig.accounts = {
mnemonic: MNEMONIC || DEFAULT_MNEMONIC,
};
}

if (["mainnet", "rinkeby", "kovan", "goerli"].includes(argv.network) && INFURA_KEY === undefined) {
throw new Error(
`Could not find Infura key in env, unable to connect to network ${argv.network}`,
);
if (["mainnet", "rinkeby", "kovan", "goerli", "ropsten", "mumbai", "polygon"].includes(argv.network) && INFURA_KEY === undefined) {
throw new Error(`Could not find Infura key in env, unable to connect to network ${argv.network}`);
}

import "./src/tasks/local_verify"
import "./src/tasks/deploy_contracts"
import "./src/tasks/show_codesize"
import "./src/tasks/local_verify";
import "./src/tasks/zk";
import "./src/tasks/deploy_contracts";
import "./src/tasks/show_codesize";
import { BigNumber } from "@ethersproject/bignumber";
import { LOCAL_NODE_RICH_WALLETS } from "./src/zk-utils/constants";

const primarySolidityVersion = SOLIDITY_VERSION || "0.7.6"
const soliditySettings = !!SOLIDITY_SETTINGS ? JSON.parse(SOLIDITY_SETTINGS) : undefined
const primarySolidityVersion = SOLIDITY_VERSION || "0.7.6";
const soliditySettings = !!SOLIDITY_SETTINGS ? JSON.parse(SOLIDITY_SETTINGS) : undefined;

const deterministicDeployment = CUSTOM_DETERMINISTIC_DEPLOYMENT == "true" ?
(network: string) => {
const info = getSingletonFactoryInfo(parseInt(network))
if (!info) return undefined
return {
factory: info.address,
deployer: info.signerAddress,
funding: BigNumber.from(info.gasLimit).mul(BigNumber.from(info.gasPrice)).toString(),
signedTx: info.transaction
const deterministicDeployment = (network: string) => {
const info = getSingletonFactoryInfo(parseInt(network));
if (!info) {
throw new Error(`
Safe factory not found for network ${network}. You can request a new deployment at https://github.com/safe-global/safe-singleton-factory.
For more information, see https://github.com/safe-global/safe-contracts#replay-protection-eip-155
`);
}
} : undefined
return {
factory: info.address,
deployer: info.signerAddress,
funding: BigNumber.from(info.gasLimit).mul(BigNumber.from(info.gasPrice)).toString(),
signedTx: info.transaction,
};
};

const userConfig: HardhatUserConfig = {
paths: {
artifacts: "build/artifacts",
cache: "build/cache",
deploy: "src/deploy",
sources: "contracts",
},
solidity: {
compilers: [
{ version: primarySolidityVersion, settings: soliditySettings },
{ version: "0.6.12" },
{ version: "0.5.17" },
]
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
blockGasLimit: 100000000,
gas: 100000000
},
mainnet: {
...sharedNetworkConfig,
url: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
paths: {
artifacts: "build/artifacts",
cache: "build/cache",
deploy: "src/deploy",
sources: "contracts",
},
xdai: {
...sharedNetworkConfig,
url: "https://xdai.poanetwork.dev",
solidity: {
compilers: [{ version: primarySolidityVersion, settings: soliditySettings }, { version: "0.6.12" }, { version: "0.5.17" }],
},
ewc: {
...sharedNetworkConfig,
url: `https://rpc.energyweb.org`,
zksolc: {
version: "1.3.8",
compilerSource: "binary",
settings: {
isSystem: true,
},
},
rinkeby: {
...sharedNetworkConfig,
url: `https://rinkeby.infura.io/v3/${INFURA_KEY}`,
networks: {
hardhat: {
allowUnlimitedContractSize: true,
blockGasLimit: 100000000,
gas: 100000000,
},
mainnet: {
...sharedNetworkConfig,
url: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
},
xdai: {
...sharedNetworkConfig,
url: "https://xdai.poanetwork.dev",
},
ewc: {
...sharedNetworkConfig,
url: `https://rpc.energyweb.org`,
},
goerli: {
...sharedNetworkConfig,
url: `https://goerli.infura.io/v3/${INFURA_KEY}`,
},
mumbai: {
...sharedNetworkConfig,
url: `https://polygon-mumbai.infura.io/v3/${INFURA_KEY}`,
},
polygon: {
...sharedNetworkConfig,
url: `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
},
volta: {
...sharedNetworkConfig,
url: `https://volta-rpc.energyweb.org`,
},
bsc: {
...sharedNetworkConfig,
url: `https://bsc-dataseed.binance.org/`,
},
arbitrum: {
...sharedNetworkConfig,
url: `https://arb1.arbitrum.io/rpc`,
},
fantomTestnet: {
...sharedNetworkConfig,
url: `https://rpc.testnet.fantom.network/`,
},
avalanche: {
...sharedNetworkConfig,
url: `https://api.avax.network/ext/bc/C/rpc`,
},
zkSyncTestnet: {
...sharedNetworkConfig,
url: "https://testnet.era.zksync.dev",
ethNetwork: "goerli",
zksync: true,
verifyURL: 'https://zksync2-testnet-explorer.zksync.dev/contract_verification'
},
zkSyncLocal: {
chainId: 270,
accounts: LOCAL_NODE_RICH_WALLETS.map((account) => account.privateKey),
url: "http://localhost:3050",
ethNetwork: "http://localhost:8545",
zksync: true,
saveDeployments: true,
},
},
goerli: {
...sharedNetworkConfig,
url: `https://goerli.infura.io/v3/${INFURA_KEY}`,
deterministicDeployment,
namedAccounts: {
deployer: 0,
},
kovan: {
...sharedNetworkConfig,
url: `https://kovan.infura.io/v3/${INFURA_KEY}`,
mocha: {
timeout: 2000000,
},
polygon: {
...sharedNetworkConfig,
url: `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
volta: {
...sharedNetworkConfig,
url: `https://volta-rpc.energyweb.org`,
},
bsc: {
...sharedNetworkConfig,
url: `https://bsc-dataseed.binance.org/`,
},
arbitrum: {
...sharedNetworkConfig,
url: `https://arb1.arbitrum.io/rpc`,
},
fantomTestnet: {
...sharedNetworkConfig,
url: `https://rpc.testnet.fantom.network/`,
}
},
deterministicDeployment,
namedAccounts: {
deployer: 0,
},
mocha: {
timeout: 2000000,
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
};
if (NODE_URL) {
userConfig.networks!!.custom = {
...sharedNetworkConfig,
url: NODE_URL,
}
userConfig.networks!!.custom = {
...sharedNetworkConfig,
url: NODE_URL,
};
}
export default userConfig
export default userConfig;
Loading