Merge pull request #2322 from 0xProject/feat/3.0-mainnet-migrations

Mainnet migrations
This commit is contained in:
Amir Bandeali
2019-11-12 14:50:36 -08:00
committed by GitHub
14 changed files with 501 additions and 286 deletions

View File

@@ -28,21 +28,24 @@ contract MixinDeploymentConstants {
// @TODO SET THESE VALUES FOR DEPLOYMENT
// Mainnet WETH9 Address
// address constant private WETH_ADDRESS = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address constant private WETH_ADDRESS = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
// Kovan WETH9 Address
// address constant private WETH_ADDRESS = address(0xd0A1E359811322d97991E03f863a0C30C2cF029C);
// Ropsten & Rinkeby WETH9 Address
address constant private WETH_ADDRESS = address(0xc778417E063141139Fce010982780140Aa0cD5Ab);
// address constant private WETH_ADDRESS = address(0xc778417E063141139Fce010982780140Aa0cD5Ab);
// @TODO SET THESE VALUES FOR DEPLOYMENT
// Mainnet ZrxVault address
address constant private ZRX_VAULT_ADDRESS = address(0xcE2a4B118813cBfa27Ee11cf8E67B101867fa85E);
// Kovan ZrxVault address
// address constant private ZRX_VAULT_ADDRESS = address(0xf36eabdFE986B35b62c8FD5a98A7f2aEBB79B291);
// Ropsten ZrxVault address
address constant private ZRX_VAULT_ADDRESS = address(0xffD161026865Ad8B4aB28a76840474935eEc4DfA);
// address constant private ZRX_VAULT_ADDRESS = address(0xffD161026865Ad8B4aB28a76840474935eEc4DfA);
// Rinkeby ZrxVault address
// address constant private ZRX_VAULT_ADDRESS = address(0xA5Bf6aC73bC40790FC6Ffc9DBbbCE76c9176e224);

View File

@@ -1,4 +1,17 @@
[
{
"version": "3.3.0-beta.3",
"changes": [
{
"note": "Update all v3 mainnet addresses",
"pr": 2322
},
{
"note": "Update ZeroExGovernor address on all testnets",
"pr": 2322
}
]
},
{
"version": "3.3.0-beta.2",
"changes": [

View File

@@ -1,26 +1,26 @@
{
"1": {
"exchangeV2": "0x080bf510fcbf18b91105470639e9561022937712",
"exchange": "0x0000000000000000000000000000000000000000",
"exchange": "0xb27f1db0a7e473304a5a06e54bdf035f671400c0",
"erc20Proxy": "0x95e6f48254609a6ee006f7d493c8e5fb97094cef",
"erc721Proxy": "0xefc70a1b18c432bdc64b596838b4d138f6bc6cad",
"forwarder": "0x0000000000000000000000000000000000000000",
"forwarder": "0x132a04f3f6196b499a7ed512c15e002d5dcefa9a",
"orderValidator": "0x0000000000000000000000000000000000000000",
"zrxToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"etherToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"assetProxyOwner": "0xdffe798c7172dd6deb32baee68af322e8f495ce0",
"zeroExGovernor": "0x0000000000000000000000000000000000000000",
"zeroExGovernor": "0x7d3455421bbc5ed534a83c88fd80387dc8271392",
"dutchAuction": "0x0000000000000000000000000000000000000000",
"coordinatorRegistry": "0x45797531b873fd5e519477a070a955764c1a5b07",
"coordinator": "0x0000000000000000000000000000000000000000",
"coordinator": "0x9401f3915c387da331b9b6af5e2a57e580f6a201",
"multiAssetProxy": "0xef701d5389ae74503d633396c4d654eabedc9d78",
"staticCallProxy": "0x3517b88c19508c08650616019062b898ab65ed29",
"erc1155Proxy": "0x7eefbd48fd63d441ec7435d024ec7c5131019add",
"zrxVault": "0x0000000000000000000000000000000000000000",
"staking": "0x0000000000000000000000000000000000000000",
"stakingProxy": "0x0000000000000000000000000000000000000000",
"devUtils": "0x0000000000000000000000000000000000000000",
"erc20BridgeProxy": "0x0000000000000000000000000000000000000000"
"zrxVault": "0xce2a4b118813cbfa27ee11cf8e67b101867fa85e",
"staking": "0xe533d7eb513bc90230ec9069a92eac25e1356beb",
"stakingProxy": "0x5fc73bf8c6158fbe205a5e14126b363ab915b8b1",
"devUtils": "0xf15fbafc74e10a9761b6aefd5d2239f098f8fb1e",
"erc20BridgeProxy": "0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0"
},
"3": {
"erc20Proxy": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
@@ -30,7 +30,7 @@
"exchangeV2": "0xbff9493f92a3df4b0429b6d00743b3cfb4c85831",
"exchange": "0xc56388332ddfc98701fefed94535100c6166956c",
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
"zeroExGovernor": "0xdcf20f7b447d51f2b3e5499b7f6cbbf7295a5d26",
"zeroExGovernor": "0x53993733d41a88ae86f77a18a024e5548ee26579",
"forwarder": "0xe66ae6162b3e9067d6ce9e5b9799cca1ba0d09f8",
"orderValidator": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
@@ -39,7 +39,7 @@
"multiAssetProxy": "0xab8fbd189c569ccdee3a4d929bb7f557be4028f6",
"staticCallProxy": "0xe1b97e47aa3796276033a5341e884d2ba46b6ac1",
"erc1155Proxy": "0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d",
"devUtils": "0x1f7a9c2e2c25ab1a894af1fd816599860ee2276c",
"devUtils": "0x6bb2fc91a82b55c02b88873958a19e04fbd02090",
"zrxVault": "0xffd161026865ad8b4ab28a76840474935eec4dfa",
"staking": "0x3f46b98061a3e1e1f41dff296ec19402c298f8a9",
"stakingProxy": "0xfaabcee42ab6b9c649794ac6c133711071897ee9",
@@ -53,7 +53,7 @@
"zrxToken": "0x8080c7e4b81ecf23aa6f877cfbfd9b0c228c6ffa",
"etherToken": "0xc778417e063141139fce010982780140aa0cd5ab",
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
"zeroExGovernor": "0x5d751aa855a1aee5fe44cf5350ed25b5727b66ae",
"zeroExGovernor": "0x3f46b98061a3e1e1f41dff296ec19402c298f8a9",
"forwarder": "0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291",
"orderValidator": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
@@ -62,7 +62,7 @@
"multiAssetProxy": "0xb34cde0ad3a83d04abebc0b66e75196f22216621",
"staticCallProxy": "0xe1b97e47aa3796276033a5341e884d2ba46b6ac1",
"erc1155Proxy": "0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d",
"devUtils": "0xfd21088fb008349839c2209ecbde97a7a4d2e397",
"devUtils": "0x326a303dc0fe20f43acb8e5dec99154e47f32d01",
"zrxVault": "0xa5bf6ac73bc40790fc6ffc9dbbbce76c9176e224",
"staking": "0x344d4f661a82afdd84d31456c291822d90d5dc3a",
"stakingProxy": "0xc6ad5277ea225ac05e271eb14a7ebb480cd9dd9f",
@@ -76,7 +76,7 @@
"exchangeV2": "0x30589010550762d2f0d06f650d8e8b6ade6dbf4b",
"exchange": "0xca8b1626b3b7a0da722ca9f264c4630c7d34d3b8",
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
"zeroExGovernor": "0x3654e5363cd75c8974c76208137df9691e820e97",
"zeroExGovernor": "0x6ff734d96104965c9c1b0108f83abc46e6e501df",
"forwarder": "0xd6330f9d2073e1889a295dd1dd2e28d42dec4bff",
"orderValidator": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
@@ -85,7 +85,7 @@
"multiAssetProxy": "0xf6313a772c222f51c28f2304c0703b8cf5428fd8",
"staticCallProxy": "0x48e94bdb9033640d45ea7c721e25f380f8bffa43",
"erc1155Proxy": "0x64517fa2b480ba3678a2a3c0cf08ef7fd4fad36f",
"devUtils": "0xa3858baf73430c2fa2339c731e3ffb04ea5e359c",
"devUtils": "0x5078321eec0fd8db5d61d25cce3ea2d6379bb5df",
"zrxVault": "0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291",
"staking": "0x89150f5eed50b3528f79bfb539f29d727f92821c",
"stakingProxy": "0xbab9145f1d57cd4bb0c9aa2d1ece0a5b6e734d34",

View File

@@ -1,4 +1,13 @@
[
{
"version": "2.3.0-beta.3",
"changes": [
{
"note": "Replace Staking artifact with TestStaking",
"pr": 2322
}
]
},
{
"version": "2.3.0-beta.2",
"changes": [

File diff suppressed because one or more lines are too long

View File

@@ -725,6 +725,7 @@ export interface Source {
* isOfflineMode: If set to true - sol-compiler will not fetch the list of solc releases from github. It will use the hardcoded list. Defaults to false.
* solcVersion: If you don't want to compile each contract with the Solidity version specified in-file, you can force all
* contracts to compile with the the version specified here.
* shouldSaveStandardInput: Write the standard JSON input in ${contractsDir}/${contractName}.input.json
*/
export interface CompilerOptions {
contractsDir?: string;
@@ -734,6 +735,7 @@ export interface CompilerOptions {
useDockerisedSolc?: boolean;
isOfflineMode?: boolean;
solcVersion?: string;
shouldSaveStandardInput?: boolean;
}
export interface BlockRange {

View File

@@ -15,6 +15,9 @@ import { logUtils, providerUtils } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { SupportedProvider } from 'ethereum-types';
import { getConfigsByChainId } from './utils/configs_by_chain';
import { getTimelockRegistrationsAsync } from './utils/timelocks';
// NOTE: add your own Infura Project ID to RPC urls before running
const INFURA_PROJECT_ID = '';
@@ -30,6 +33,7 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise<vo
const web3Wrapper = new Web3Wrapper(provider);
const chainId = await web3Wrapper.getChainIdAsync();
const addresses = getContractAddressesForChainOrThrow(chainId);
const configs = getConfigsByChainId(chainId);
function warnIfMismatch(actual: any, expected: any, message: string): void {
if (actual !== expected) {
@@ -108,6 +112,13 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise<vo
'Unexpected StaticCallProxy registered in Exchange',
);
const registeredERC20BridgeProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC20Bridge);
warnIfMismatch(
registeredERC20BridgeProxy,
addresses.erc20BridgeProxy,
'Unexpected ERC20BridgeProxy registered in Exchange',
);
const protocolFeeCollector = await exchange.protocolFeeCollector.callAsync();
warnIfMismatch(protocolFeeCollector, addresses.stakingProxy, 'Unexpected StakingProxy attached to Exchange');
@@ -246,10 +257,10 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise<vo
warnIfMismatch(stakingLogicAddress, addresses.staking, 'Unexpected Staking contract attached to StakingProxy');
const zrxVaultAddress = await stakingContract.getZrxVault.callAsync();
warnIfMismatch(zrxVaultAddress, addresses.zrxVault, 'Unexpected ZrxVault set in Staking contract');
warnIfMismatch(zrxVaultAddress, addresses.zrxVault, 'Unexpected ZrxVault set in StakingProxy');
const wethAddress = await stakingContract.getWethContract.callAsync();
warnIfMismatch(wethAddress, addresses.etherToken, 'Unexpected WETH contract set in Staking contract');
warnIfMismatch(wethAddress, addresses.etherToken, 'Unexpected WETH contract set in StakingProxy');
const stakingProxyOwner = await stakingProxy.owner.callAsync();
warnIfMismatch(stakingProxyOwner, addresses.zeroExGovernor, 'Unexpected StakingProxy owner');
@@ -270,15 +281,92 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise<vo
warnIfMismatch(zrxVaultAuthorizedAddresses.length, 1, 'Unexpected number of authorized addresses in ZrxVault');
const isGovernorAuthorizedInZrxVault = await zrxVault.authorized.callAsync(addresses.zeroExGovernor);
warnIfMismatch(isGovernorAuthorizedInZrxVault, true, 'ZeroExGovernor not authorized in ZrxVault');
const params = await stakingContract.getParams.callAsync();
warnIfMismatch(
params[0].toNumber(),
configs.staking.epochDurationInSeconds.toNumber(),
'Unexpected epoch duration in StakingProxy',
);
warnIfMismatch(
params[1].toString(),
configs.staking.rewardDelegatedStakeWeight.toString(),
'Unexpected delegated stake weight in StakingProxy',
);
warnIfMismatch(
params[2].toNumber(),
configs.staking.minimumPoolStake.toNumber(),
'Unexpected minimum pool stake in StakingProxy',
);
warnIfMismatch(
params[3].toString(),
configs.staking.cobbDouglasAlphaNumerator.toString(),
'Unexpected alpha numerator in StakingProxy',
);
warnIfMismatch(
params[4].toString(),
configs.staking.cobbDouglasAlphaDenominator.toString(),
'Unexpected alpha denominator in StakingProxy',
);
}
// TODO: implement ZeroExGovernor config tests
// async function verifyAssetProxyOwnerConfigsAsync(): Promise<void> {}
async function verifyZeroExGovernorConfigsAsync(): Promise<void> {
const timelockRegistrations = await getTimelockRegistrationsAsync(provider);
for (const timelockRegistration of timelockRegistrations) {
const actualRegistration = await governor.functionCallTimeLocks.callAsync(
timelockRegistration.functionSelector,
timelockRegistration.destination,
);
warnIfMismatch(
actualRegistration[0],
true,
`Function ${timelockRegistration.functionSelector} at address ${
timelockRegistration.destination
} not registered in ZeroExGovernor`,
);
warnIfMismatch(
actualRegistration[1].toNumber(),
timelockRegistration.secondsTimeLocked.toNumber(),
`Timelock for function ${timelockRegistration.functionSelector} at address ${
timelockRegistration.destination
} in ZeroExGovernor`,
);
}
const owners = await governor.getOwners.callAsync();
warnIfMismatch(
owners.length,
configs.zeroExGovernor.owners.length,
'Unexpected number of owners in ZeroExGovernor',
);
owners.forEach((owner, i) => {
warnIfMismatch(
owners[i],
configs.zeroExGovernor.owners[i],
`Unexpected owner in ZeroExGovernor at index ${i}`,
);
});
const secondsTimeLocked = await governor.secondsTimeLocked.callAsync();
warnIfMismatch(
secondsTimeLocked.toNumber(),
configs.zeroExGovernor.secondsTimeLocked.toNumber(),
'Unexpected secondsTimeLocked in ZeroExGovernor',
);
const confirmationsRequired = await governor.required.callAsync();
warnIfMismatch(
confirmationsRequired.toNumber(),
configs.zeroExGovernor.required.toNumber(),
'Unexpected number of confirmations required in ZeroExGovernor',
);
}
await verifyExchangeV2ConfigsAsync();
await verifyExchangeV3ConfigsAsync();
await verifyStakingConfigsAsync();
await verifyAssetProxyConfigsAsync();
await verifyZeroExGovernorConfigsAsync();
}
(async () => {

View File

@@ -19,8 +19,10 @@ import { IAuthorizableContract, IOwnableContract } from '@0x/contracts-utils';
import { AbiEncoder, BigNumber, logUtils, providerUtils } from '@0x/utils';
import { LogWithDecodedArgs, SupportedProvider, TxData } from 'ethereum-types';
import { getConfigsByChainId } from './utils/configs_by_chain';
import { constants } from './utils/constants';
import { providerFactory } from './utils/provider_factory';
import { getTimelockRegistrationsAsync } from './utils/timelocks';
async function submitAndExecuteTransactionAsync(
governor: ZeroExGovernorContract,
@@ -48,6 +50,7 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const chainId = new BigNumber(await providerUtils.getChainIdAsync(provider));
const deployedAddresses = getContractAddressesForChainOrThrow(chainId.toNumber());
const configs = getConfigsByChainId(chainId.toNumber());
// NOTE: This must be deployed before running these migrations, since its address is hard coded in the
// staking logic contract.
@@ -83,187 +86,10 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
assetProxyArtifacts,
);
const devUtils = await DevUtilsContract.deployFrom0xArtifactAsync(
devUtilsArtifacts.DevUtils,
provider,
txDefaults,
devUtilsArtifacts,
exchange.address,
);
await CoordinatorContract.deployFrom0xArtifactAsync(
coordinatorArtifacts.Coordinator,
provider,
txDefaults,
coordinatorArtifacts,
exchange.address,
chainId,
);
const wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployedAddresses.etherToken);
await ForwarderContract.deployFrom0xArtifactAsync(
forwarderArtifacts.Forwarder,
provider,
txDefaults,
forwarderArtifacts,
exchange.address,
wethAssetData,
);
const authorizableInterface = new IAuthorizableContract(constants.NULL_ADDRESS, provider, txDefaults);
const ownableInterface = new IOwnableContract(constants.NULL_ADDRESS, provider, txDefaults);
const customTimeLocks = [
// AssetProxy timelocks
{
destination: deployedAddresses.erc20Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc20Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc721Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc721Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc1155Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc1155Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.multiAssetProxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.multiAssetProxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: erc20BridgeProxy.address,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: erc20BridgeProxy.address,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
// ZrxVault timelocks
{
destination: deployedAddresses.zrxVault,
functionSelector: zrxVault.enterCatastrophicFailure.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.zrxVault,
functionSelector: zrxVault.setStakingProxy.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.zrxVault,
functionSelector: zrxVault.setZrxProxy.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.zrxVault,
functionSelector: ownableInterface.transferOwnership.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.zrxVault,
functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.zrxVault,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.zrxVault,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
// StakingProxy timelocks
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingProxy.attachStakingContract.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingProxy.detachStakingContract.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingLogic.setParams.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 10 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingLogic.addExchangeAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingLogic.removeExchangeAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: ownableInterface.transferOwnership.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
// Exchange timelocks
{
destination: exchange.address,
functionSelector: exchange.setProtocolFeeMultiplier.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 10 days on mainnet
},
{
destination: exchange.address,
functionSelector: exchange.setProtocolFeeCollectorAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT, // 20 days on mainnet
},
{
destination: exchange.address,
functionSelector: exchange.detachProtocolFeeCollector.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
];
const customTimeLocks = await getTimelockRegistrationsAsync(provider);
const governor = await ZeroExGovernorContract.deployFrom0xArtifactAsync(
multisigArtifacts.ZeroExGovernor,
@@ -273,24 +99,43 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
customTimeLocks.map(timeLockInfo => timeLockInfo.functionSelector),
customTimeLocks.map(timeLockInfo => timeLockInfo.destination),
customTimeLocks.map(timeLockInfo => timeLockInfo.secondsTimeLocked),
constants.ASSET_PROXY_OWNER_OWNERS,
constants.ASSET_PROXY_OWNER_CONFIRMATIONS,
constants.ASSET_PROXY_OWNER_TIMELOCK,
configs.zeroExGovernor.owners,
configs.zeroExGovernor.required,
configs.zeroExGovernor.secondsTimeLocked,
);
logUtils.log('Configuring Exchange...');
await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync(stakingProxy.address);
await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync(new BigNumber(150000));
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.erc20Proxy);
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.erc721Proxy);
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.erc1155Proxy);
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.multiAssetProxy);
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.staticCallProxy);
await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20BridgeProxy.address);
await exchange.transferOwnership.awaitTransactionSuccessAsync(governor.address);
logUtils.log('Exchange configured!');
logUtils.log('Configuring ERC20BridgeProxy...');
await erc20BridgeProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address);
await erc20BridgeProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(deployedAddresses.multiAssetProxy);
await erc20BridgeProxy.transferOwnership.awaitTransactionSuccessAsync(governor.address);
logUtils.log('ERC20BridgeProxy configured!');
logUtils.log('Configuring ZrxVault...');
await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(txDefaults.from);
await zrxVault.setStakingProxy.awaitTransactionSuccessAsync(stakingProxy.address);
await zrxVault.removeAuthorizedAddress.awaitTransactionSuccessAsync(txDefaults.from);
await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address);
await zrxVault.transferOwnership.awaitTransactionSuccessAsync(governor.address);
logUtils.log('ZrxVault configured!');
logUtils.log('Configuring StakingProxy...');
await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(txDefaults.from);
const staking = new StakingContract(stakingProxy.address, provider, txDefaults);
await staking.addExchangeAddress.awaitTransactionSuccessAsync(exchange.address);
await stakingProxy.removeAuthorizedAddress.awaitTransactionSuccessAsync(txDefaults.from);
await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(governor.address);
await stakingProxy.transferOwnership.awaitTransactionSuccessAsync(governor.address);
logUtils.log('StakingProxy configured!');
@@ -324,58 +169,6 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
logUtils.log('Ownership transferred!');
const functionCalls = [
// Exchange staking configs
{
destination: exchange.address,
data: exchange.setProtocolFeeCollectorAddress.getABIEncodedTransactionData(stakingProxy.address),
},
{
destination: exchange.address,
data: exchange.setProtocolFeeMultiplier.getABIEncodedTransactionData(new BigNumber(150000)),
},
// Exchange AssetProxy registrations
{
destination: exchange.address,
data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc20Proxy),
},
{
destination: exchange.address,
data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc721Proxy),
},
{
destination: exchange.address,
data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.erc1155Proxy),
},
{
destination: exchange.address,
data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.multiAssetProxy),
},
{
destination: exchange.address,
data: exchange.registerAssetProxy.getABIEncodedTransactionData(deployedAddresses.staticCallProxy),
},
{
destination: exchange.address,
data: exchange.registerAssetProxy.getABIEncodedTransactionData(erc20BridgeProxy.address),
},
// ZrxVault configs
{
destination: zrxVault.address,
data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(governor.address),
},
{
destination: zrxVault.address,
data: zrxVault.setStakingProxy.getABIEncodedTransactionData(stakingProxy.address),
},
// StakingProxy configs
{
destination: stakingProxy.address,
data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(governor.address),
},
{
destination: stakingProxy.address,
data: stakingLogic.addExchangeAddress.getABIEncodedTransactionData(exchange.address),
},
// AssetProxy configs
{
destination: deployedAddresses.erc20Proxy,
@@ -401,16 +194,6 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
destination: deployedAddresses.multiAssetProxy,
data: exchange.registerAssetProxy.getABIEncodedTransactionData(erc20BridgeProxy.address),
},
{
destination: erc20BridgeProxy.address,
data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address),
},
{
destination: erc20BridgeProxy.address,
data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(
deployedAddresses.multiAssetProxy,
),
},
];
const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])');
@@ -420,13 +203,41 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
functionCalls.map(() => constants.ZERO_AMOUNT),
]);
await submitAndExecuteTransactionAsync(governor, governor.address, batchTransactionData);
const devUtils = await DevUtilsContract.deployFrom0xArtifactAsync(
devUtilsArtifacts.DevUtils,
provider,
txDefaults,
devUtilsArtifacts,
exchange.address,
);
await CoordinatorContract.deployFrom0xArtifactAsync(
coordinatorArtifacts.Coordinator,
provider,
txDefaults,
coordinatorArtifacts,
exchange.address,
chainId,
);
const wethAssetData = await devUtils.encodeERC20AssetData.callAsync(deployedAddresses.etherToken);
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
forwarderArtifacts.Forwarder,
provider,
txDefaults,
forwarderArtifacts,
exchange.address,
wethAssetData,
);
await forwarder.approveMakerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.etherToken);
}
(async () => {
const networkId = 4;
const rpcUrl = 'https://rinkeby.infura.io/v3/';
const networkId = 1;
const rpcUrl = 'https://mainnet.infura.io/v3/';
const provider = await providerFactory.getLedgerProviderAsync(networkId, rpcUrl);
await runMigrationsAsync(provider, { from: constants.ASSET_PROXY_OWNER_OWNERS[0], gasPrice: 60000000000 });
await runMigrationsAsync(provider, { from: '0x3b39078f2a3e1512eecc8d6792fdc7f33e1cd2cf', gasPrice: 10000000000 });
})().catch(err => {
logUtils.log(err);
process.exit(1);

View File

@@ -0,0 +1,59 @@
import { BigNumber } from '@0x/utils';
import { constants } from './constants';
export interface ConfigsByChain {
zeroExGovernor: { owners: string[]; secondsTimeLocked: BigNumber; required: BigNumber };
staking: {
epochDurationInSeconds: BigNumber;
rewardDelegatedStakeWeight: number;
minimumPoolStake: BigNumber;
cobbDouglasAlphaNumerator: number;
cobbDouglasAlphaDenominator: number;
};
}
// tslint:disable custom-no-magic-numbers
/**
* Gets configs that correspond to the given chainId.
* @param chainId Id of the netowrk.
*/
export function getConfigsByChainId(chainId: number): ConfigsByChain {
const mainnetConfigs = {
zeroExGovernor: {
owners: [
'0x257619b7155d247e43c8b6d90c8c17278ae481f0',
'0x5ee2a00f8f01d099451844af7f894f26a57fcbf2',
'0x894d623e0e0e8ed12c4a73dada999e275684a37d',
],
secondsTimeLocked: constants.TWO_WEEKS_IN_SEC,
required: new BigNumber(2),
},
staking: {
epochDurationInSeconds: constants.TEN_DAYS_IN_SEC,
rewardDelegatedStakeWeight: 10 ** 6 * 0.9,
minimumPoolStake: new BigNumber(10).pow(18).times(100),
cobbDouglasAlphaNumerator: 2,
cobbDouglasAlphaDenominator: 3,
},
};
const testnetConfigs = {
zeroExGovernor: {
owners: [
'0x9df8137872ac09a8fee71d0da5c7539923fb9bf0',
'0xcf34d44db312d188789f43a63d11cf2bebb4da15',
'0x73fd50f2a6beac9cdac9fe87ef68a18edc415831',
],
secondsTimeLocked: constants.ZERO_AMOUNT,
required: new BigNumber(1),
},
staking: {
epochDurationInSeconds: constants.TEN_DAYS_IN_SEC.dividedToIntegerBy(2),
rewardDelegatedStakeWeight: 10 ** 6 * 0.9,
minimumPoolStake: new BigNumber(10).pow(18).times(100),
cobbDouglasAlphaNumerator: 2,
cobbDouglasAlphaDenominator: 3,
},
};
return chainId === constants.MAINNET_CHAIN_ID ? mainnetConfigs : testnetConfigs;
}

View File

@@ -1,19 +1,20 @@
import { BigNumber } from '@0x/utils';
// tslint:disable custom-no-magic-numbers
export const constants = {
ASSET_PROXY_OWNER_OWNERS: [
'0x9df8137872ac09a8fee71d0da5c7539923fb9bf0',
'0xcf34d44db312d188789f43a63d11cf2bebb4da15',
'0x73fd50f2a6beac9cdac9fe87ef68a18edc415831',
],
ASSET_PROXY_OWNER_TIMELOCK: new BigNumber(0),
ASSET_PROXY_OWNER_CONFIRMATIONS: new BigNumber(1),
ERC20_PROXY_ID: '0xf47261b0',
ERC721_PROXY_ID: '0x02571792',
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
KOVAN_RPC_URL: 'https://kovan.infura.io/',
KOVAN_CHAIN_ID: 42,
MAINNET_RPC_URL: 'https://mainnet.infura.io/',
MAINNET_CHAIN_ID: 1,
ZERO_AMOUNT: new BigNumber(0),
TWO_WEEKS_IN_SEC: new BigNumber(14)
.times(24)
.times(60)
.times(60),
TEN_DAYS_IN_SEC: new BigNumber(10)
.times(24)
.times(60)
.times(60),
TWENTY_DAYS_IN_SEC: new BigNumber(20)
.times(24)
.times(60)
.times(60),
};

View File

@@ -0,0 +1,209 @@
import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { ExchangeContract } from '@0x/contracts-exchange';
import { StakingContract, StakingProxyContract, ZrxVaultContract } from '@0x/contracts-staking';
import { IAuthorizableContract, IOwnableContract } from '@0x/contracts-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { SupportedProvider } from 'ethereum-types';
import { constants } from './constants';
export interface TimelockRegistration {
functionSelector: string;
destination: string;
secondsTimeLocked: BigNumber;
}
/**
* Gets the custom timelock configs that correspond the the network of the given provider.
* @param provider Web3 provider instance.
*/
export async function getTimelockRegistrationsAsync(provider: SupportedProvider): Promise<TimelockRegistration[]> {
const web3Wrapper = new Web3Wrapper(provider);
const chainId = await web3Wrapper.getChainIdAsync();
const deployedAddresses = getContractAddressesForChainOrThrow(chainId);
const authorizableInterface = new IAuthorizableContract(constants.NULL_ADDRESS, provider);
const ownableInterface = new IOwnableContract(constants.NULL_ADDRESS, provider);
const zrxVault = new ZrxVaultContract(constants.NULL_ADDRESS, provider);
const stakingProxy = new StakingProxyContract(constants.NULL_ADDRESS, provider);
const exchange = new ExchangeContract(constants.NULL_ADDRESS, provider);
const stakingLogic = new StakingContract(constants.NULL_ADDRESS, provider);
const noTimelockRegistrations = [
// AssetProxy timelocks
{
destination: deployedAddresses.erc20Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc20Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc721Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc721Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc1155Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc1155Proxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.multiAssetProxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.multiAssetProxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc20BridgeProxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.erc20BridgeProxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
// ZrxVault timelocks
{
destination: deployedAddresses.zrxVault,
functionSelector: zrxVault.enterCatastrophicFailure.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
// Exchange timelocks
{
destination: exchange.address,
functionSelector: exchange.detachProtocolFeeCollector.getSelector(),
secondsTimeLocked: constants.ZERO_AMOUNT,
},
];
const customTimelockRegistrations = [
// ZrxVault timelocks
{
destination: deployedAddresses.zrxVault,
functionSelector: zrxVault.setStakingProxy.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.zrxVault,
functionSelector: zrxVault.setZrxProxy.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.zrxVault,
functionSelector: ownableInterface.transferOwnership.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.zrxVault,
functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.zrxVault,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.zrxVault,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
// StakingProxy timelocks
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingProxy.attachStakingContract.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingProxy.detachStakingContract.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingLogic.setParams.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TEN_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingLogic.addExchangeAddress.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: stakingLogic.removeExchangeAddress.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: ownableInterface.transferOwnership.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: authorizableInterface.addAuthorizedAddress.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: deployedAddresses.stakingProxy,
functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
// Exchange timelocks
{
destination: exchange.address,
functionSelector: exchange.setProtocolFeeMultiplier.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TEN_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
{
destination: exchange.address,
functionSelector: exchange.setProtocolFeeCollectorAddress.getSelector(),
secondsTimeLocked:
chainId === constants.MAINNET_CHAIN_ID ? constants.TWENTY_DAYS_IN_SEC : constants.ZERO_AMOUNT,
},
];
return [...noTimelockRegistrations, ...customTimelockRegistrations];
}

View File

@@ -1,4 +1,13 @@
[
{
"version": "3.2.0-beta.2",
"changes": [
{
"note": "Add `shouldSaveStandardInput` config",
"pr": 2322
}
]
},
{
"version": "3.2.0-beta.1",
"changes": [

View File

@@ -49,6 +49,8 @@ const DEFAULT_CONTRACTS_DIR = path.resolve('contracts');
const DEFAULT_ARTIFACTS_DIR = path.resolve('artifacts');
const DEFAULT_USE_DOCKERISED_SOLC = false;
const DEFAULT_IS_OFFLINE_MODE = false;
const DEFAULT_SHOULD_SAVE_STANDARD_INPUT = false;
// Solc compiler settings cannot be configured from the commandline.
// If you need this configured, please create a `compiler.json` config file
// with your desired configurations.
@@ -95,6 +97,7 @@ export class Compiler {
private readonly _specifiedContracts: string[] | TYPE_ALL_FILES_IDENTIFIER;
private readonly _useDockerisedSolc: boolean;
private readonly _isOfflineMode: boolean;
private readonly _shouldSaveStandardInput: boolean;
/**
* Instantiates a new instance of the Compiler class.
* @param opts Optional compiler options
@@ -123,6 +126,8 @@ export class Compiler {
this._useDockerisedSolc =
passedOpts.useDockerisedSolc || config.useDockerisedSolc || DEFAULT_USE_DOCKERISED_SOLC;
this._isOfflineMode = passedOpts.isOfflineMode || config.isOfflineMode || DEFAULT_IS_OFFLINE_MODE;
this._shouldSaveStandardInput =
passedOpts.shouldSaveStandardInput || config.shouldSaveStandardInput || DEFAULT_SHOULD_SAVE_STANDARD_INPUT;
this._nameResolver = new NameResolver(this._contractsDir);
const resolver = new FallthroughResolver();
resolver.appendResolver(new URLResolver());
@@ -327,7 +332,12 @@ export class Compiler {
`Contract ${contractName} not found in ${contractPath}. Please make sure your contract has the same name as it's file name`,
);
}
if (this._shouldSaveStandardInput) {
await fsWrapper.writeFileAsync(
`${this._artifactsDir}/${contractName}.input.json`,
utils.stringifyWithFormatting(input.standardInput),
);
}
addHexPrefixToContractBytecode(compiledContract);
if (shouldPersist) {

View File

@@ -21,6 +21,7 @@ export const compilerOptionsSchema = {
},
useDockerisedSolc: { type: 'boolean' },
isOfflineMode: { type: 'boolean' },
shouldSaveStandardInput: { type: 'boolean' },
},
type: 'object',
required: [],