Skip to content

Commit

Permalink
Contract deploy, verify
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush committed Nov 24, 2020
1 parent 74eefdb commit 3087933
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# zkSync changelog

### Contracts v4 and protocol (24.11.2020)

- Timestamp is added to the block commitment. Rollup block timestamp validity is checked when block is committed onchain.
- Offchain ChangePubKey can be performed for smart contract wallets that can be deployed with CREATE2 when pubkey hash is encoded in the CREATE2 salt parameter.
- Governance contract can pause token deposits.
- ChangePubKey message signature is changed.
- Onchain operation processing changed on the contract.
- Recursive block verifier added.
- Onchain rollup block commitment changed, multiple blocks can be committed, verified at once.


### Contracts v3 and protocol (4.09.2020)

- Change pubkey operation requires fee for processing.
Expand Down
2 changes: 1 addition & 1 deletion contracts/contracts/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contract Config {
/// @dev Notice period before activation preparation status of upgrade mode (in seconds)
/// @dev NOTE: we must reserve for users enough time to send full exit operation, wait maximum time for processing this operation and withdraw funds from it.
uint256 constant UPGRADE_NOTICE_PERIOD =
MASS_FULL_EXIT_PERIOD + PRIORITY_EXPIRATION_PERIOD + TIME_TO_WITHDRAW_FUNDS_FROM_FULL_EXIT;
$(defined(UPGRADE_NOTICE_PERIOD) ? UPGRADE_NOTICE_PERIOD : MASS_FULL_EXIT_PERIOD + PRIORITY_EXPIRATION_PERIOD + TIME_TO_WITHDRAW_FUNDS_FROM_FULL_EXIT);

/// @dev Timestamp - seconds since unix epoch
uint256 constant COMMIT_TIMESTAMP_NOT_OLDER = 8 hours;
Expand Down
39 changes: 34 additions & 5 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@ import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-solpp';
import 'hardhat-typechain';
import 'hardhat-contract-sizer';
import "@nomiclabs/hardhat-etherscan";

const prodConfig = {
// UPGRADE_NOTICE_PERIOD: 0,
MAX_AMOUNT_OF_REGISTERED_TOKENS: 127,
// PRIORITY_EXPIRATION: 101,
DUMMY_VERIFIER: false
}
const testnetConfig = {
UPGRADE_NOTICE_PERIOD: 0,
MAX_AMOUNT_OF_REGISTERED_TOKENS: 127,
// PRIORITY_EXPIRATION: 101,
DUMMY_VERIFIER: false
}
const testConfig = {
UPGRADE_NOTICE_PERIOD: 0,
MAX_AMOUNT_OF_REGISTERED_TOKENS: 5,
PRIORITY_EXPIRATION: 101,
DUMMY_VERIFIER: true
}
const contractDefs = {
rinkeby: testnetConfig,
ropsten: testnetConfig,
mainnet: prodConfig,
test: testConfig,
};

export default {
solidity: {
Expand All @@ -20,11 +46,14 @@ export default {
sources: './contracts'
},
solpp: {
defs: {
UPGRADE_NOTICE_PERIOD: 0,
MAX_AMOUNT_OF_REGISTERED_TOKENS: 5,
PRIORITY_EXPIRATION: 101,
DUMMY_VERIFIER: false
defs: process.env.ETH_NETWORK ? contractDefs[process.env.ETH_NETWORK] : contractDefs["test"],
},
networks: {
env : {
url: process.env.WEB3_URL
}
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
}
};
3 changes: 2 additions & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"license": "MIT",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^2.0.1",
"@nomiclabs/hardhat-solpp": "^2.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.0",
"@openzeppelin/contracts": "3.2.1-solc-0.7",
Expand Down Expand Up @@ -44,7 +45,7 @@
"deploy-eip1271": "ts-node scripts/deploy-eip1271.ts",
"deploy-erc20": "ts-node scripts/deploy-erc20.ts",
"deploy-testkit": "ts-node scripts/deploy-testkit.ts",
"publish-sources": "ts-node scripts/publish.ts",
"publish-sources": "hardhat run --network env scripts/publish.ts",
"deploy-testnet-erc20": "ts-node scripts/deploy-testnet-token.ts"
}
}
9 changes: 5 additions & 4 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
process.exit(1);
}
console.log(`Using nonce: ${args.nonce}`);
args.nonce = parseInt(args.nonce);
}

const governorAddress = args.governor ? args.governor : wallet.address;
Expand All @@ -53,8 +54,8 @@ const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
if (args.contract === 'Governance' || args.contract == null) {
await deployer.deployGovernanceTarget({ gasPrice, nonce: args.nonce });
}

if (args.contract === 'Proxies' || args.contract == null) {
await deployer.deployProxiesAndGatekeeper({ gasPrice, nonce: args.nonce });
}
//
// if (args.contract === 'Proxies' || args.contract == null) {
// await deployer.deployProxiesAndGatekeeper({ gasPrice, nonce: args.nonce });
// }
})();
32 changes: 18 additions & 14 deletions contracts/scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { Wallet } from 'ethers';
import { Deployer } from '../src.ts/deploy';
import {deployedAddressesFromEnv} from "../src.ts/deploy";

(async () => {
try {
// Wallet is not needed for publishing
const deployer = new Deployer({ deployWallet: Wallet.createRandom() });
if (process.env.ETH_NETWORK === 'localhost') {
await deployer.publishSourcesToTesseracts();
} else {
await deployer.publishSourcesToEtherscan();
const hre = require("hardhat");

async function main() {
const addresses = deployedAddressesFromEnv();
for (const address of [addresses.ZkSyncTarget, addresses.VerifierTarget, addresses.GovernanceTarget]) {
try {
await hre.run('verify', {address});
} catch (e) {
console.log(e)
}
process.exit(0);
} catch (e) {
console.error('Failed to publish contracts code:', e.toString());
}
})();
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
2 changes: 1 addition & 1 deletion etc/env/dev.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ RUST_BACKTRACE=1
BELLMAN_VERBOSE=1

# key dir ending with latest version of circuit commit hash
KEY_DIR=keys/plonk-975ae851
KEY_DIR=keys/plonk-8c6e12e4c
# actual supported block chunks sizes by verifier contract (determined by circuit size on setup boundaries)
# and setup power needed to proof block of this size
SUPPORTED_BLOCK_CHUNKS_SIZES=6,30,74,150,320,630
Expand Down
60 changes: 60 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,21 @@
"@ethersproject/properties" "^5.0.3"
"@ethersproject/strings" "^5.0.4"

"@ethersproject/abi@^5.0.2":
version "5.0.9"
resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.0.9.tgz#738c1c557e56d8f395a5a27caef9b0449bc85a10"
integrity sha512-ily2OufA2DTrxkiHQw5GqbkMSnNKuwZBqKsajtT0ERhZy1r9w2CpW1bmtRMIGzaqQxCdn/GEoFogexk72cBBZQ==
dependencies:
"@ethersproject/address" "^5.0.4"
"@ethersproject/bignumber" "^5.0.7"
"@ethersproject/bytes" "^5.0.4"
"@ethersproject/constants" "^5.0.4"
"@ethersproject/hash" "^5.0.4"
"@ethersproject/keccak256" "^5.0.3"
"@ethersproject/logger" "^5.0.5"
"@ethersproject/properties" "^5.0.3"
"@ethersproject/strings" "^5.0.4"

"@ethersproject/[email protected]", "@ethersproject/abstract-provider@^5.0.4":
version "5.0.5"
resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.0.5.tgz#797a32a8707830af1ad8f833e9c228994d5572b9"
Expand Down Expand Up @@ -989,6 +1004,17 @@
"@ethersproject/rlp" "^5.0.3"
bn.js "^4.4.0"

"@ethersproject/address@^5.0.2":
version "5.0.8"
resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.0.8.tgz#0c551659144a5a7643c6bea337149d410825298f"
integrity sha512-V87DHiZMZR6hmFYmoGaHex0D53UEbZpW75uj8AqPbjYUmi65RB4N2LPRcJXuWuN2R0Y2CxkvW6ArijWychr5FA==
dependencies:
"@ethersproject/bignumber" "^5.0.10"
"@ethersproject/bytes" "^5.0.4"
"@ethersproject/keccak256" "^5.0.3"
"@ethersproject/logger" "^5.0.5"
"@ethersproject/rlp" "^5.0.3"

"@ethersproject/[email protected]", "@ethersproject/base64@^5.0.3":
version "5.0.4"
resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.0.4.tgz#b0d8fdbf3dda977cf546dcd35725a7b1d5256caa"
Expand All @@ -1013,6 +1039,15 @@
"@ethersproject/logger" "^5.0.5"
bn.js "^4.4.0"

"@ethersproject/bignumber@^5.0.10":
version "5.0.11"
resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.0.11.tgz#0d89c1c42439e04ab85013e6d437e428914fcbb2"
integrity sha512-6mS55WZDceEFZHaWKlRTKwOUmw8sU51Ar1Tbdt3qfk1HNf7i60d6MQVAWJswzCfKWx+E2gCBob8ywajgTZ7zMw==
dependencies:
"@ethersproject/bytes" "^5.0.4"
"@ethersproject/logger" "^5.0.5"
bn.js "^4.4.0"

"@ethersproject/[email protected]", "@ethersproject/bytes@>=5.0.0-beta.129", "@ethersproject/bytes@^5.0.4":
version "5.0.5"
resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.0.5.tgz#688b70000e550de0c97a151a21f15b87d7f97d7c"
Expand Down Expand Up @@ -1376,6 +1411,18 @@
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.0.0.tgz#ebab032b3aed03945ea560f56bb67aec56a30cbc"
integrity sha512-fIi6XP9PgKqwSNVcLDr6S5hvGlc21PendaLD5eGdXEXc9aYQ0OJX8Mk3evs+p78x7W9n9U3ZcKtTiGc1+YScDw==

"@nomiclabs/hardhat-etherscan@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.0.1.tgz#576c162b0c2b8f5913b3853f4591e98ccc1c2e4d"
integrity sha512-5xPh5xhLXO1tDO0VTc4qlqqgv2m1bL+pXLSFibUVJ2EzzXHKn1C4ioHmYgseIkoNC3iG19cSJ7gRcQz4u54pGQ==
dependencies:
"@ethersproject/abi" "^5.0.2"
"@ethersproject/address" "^5.0.2"
cbor "^5.0.2"
fs-extra "^7.0.1"
node-fetch "^2.6.0"
semver "^6.3.0"

"@nomiclabs/hardhat-solpp@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-solpp/-/hardhat-solpp-2.0.0.tgz#4660f1c9cdc9ef307a7864152f636f8daa74560a"
Expand Down Expand Up @@ -4030,6 +4077,14 @@ caseless@~0.12.0:
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=

cbor@^5.0.2:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cbor/-/cbor-5.1.0.tgz#c3be220dcbbd96a338d279a664237aed3f596904"
integrity sha512-qzEc7kUShdMbWTaUH7X+aHW8owvBU3FS0dfYR1lGYpoZr0mGJhhojLlZJH653x/DfeMZ56h315FRNBUIG1R7qg==
dependencies:
bignumber.js "^9.0.0"
nofilter "^1.0.4"

chai-as-promised@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-7.1.1.tgz#08645d825deb8696ee61725dbf590c012eb00ca0"
Expand Down Expand Up @@ -9903,6 +9958,11 @@ node-sass@^4.13.0:
stdout-stream "^1.4.0"
"true-case-path" "^1.0.2"

nofilter@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-1.0.4.tgz#78d6f4b6a613e7ced8b015cec534625f7667006e"
integrity sha512-N8lidFp+fCz+TD51+haYdbDGrcBWwuHX40F5+z0qkUjMJ5Tp+rdSuAkMJ9N9eoolDlEVTf6u5icM+cNKkKW2mA==

"nopt@2 || 3":
version "3.0.6"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
Expand Down

0 comments on commit 3087933

Please sign in to comment.