From 4be4217ab22ba8cf7c1a81eedbf2c08b96a9069c Mon Sep 17 00:00:00 2001 From: Simon Dosch Date: Thu, 28 Dec 2023 17:22:39 +0100 Subject: [PATCH 1/9] delete old migrations and scripts --- .babelrc | 3 - .editorconfig | 14 - .eslintrc.js | 17 - debug.sh | 5 - deploy-migrations/1_initial_migration.js | 5 - deploy-migrations/2_deploy_root_contracts.js | 245 -------------- deploy-migrations/3_initialize_state.js | 120 ------- deploy-migrations/4_deploy_child_contracts.js | 64 ---- .../5_sync_child_state_to_root.js | 73 ----- deploy-migrations/README.md | 76 ----- deploy-migrations/utils.js | 12 - migrations/1_initial_migration.js | 5 - migrations/2_deploy_root_contracts.js | 308 ------------------ migrations/3_drain_stake_manager.js | 7 - migrations/4_initialize_state.js | 130 -------- migrations/5_deploy_child_contracts.js | 70 ---- migrations/6_sync_child_state_to_root.js | 69 ---- migrations/utils.js | 12 - moonwalker-migrations/1_queueJobs.js | 73 ----- moonwalker-migrations/2_queueJobs.js | 221 ------------- moonwalker-migrations/3_queueJobs.js | 60 ---- moonwalker-migrations/4_queueJobs.js | 150 --------- moonwalker-migrations/README.md | 58 ---- moonwalker-migrations/addressClipper.js | 22 -- moonwalker-migrations/deployWorker.js | 27 -- scripts/deploy-erc20.js | 249 -------------- scripts/deposit.js | 99 ------ scripts/eventSignatures.js | 10 - scripts/run-blockchain.sh | 19 -- scripts/run-coverage.sh | 3 - scripts/run-migration.sh | 4 - scripts/run-test.sh | 45 --- scripts/stake.js | 169 ---------- scripts/stakeManagerTest.js | 77 ----- scripts/update-slots.js | 59 ---- scripts/update-validatorshare.js | 58 ---- scripts/updateDepositManager.js | 34 -- scripts/updateWithdrawManager.js | 26 -- scripts/wallet.js | 5 - truffle-config.js | 107 ------ 40 files changed, 2810 deletions(-) delete mode 100644 .babelrc delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 debug.sh delete mode 100644 deploy-migrations/1_initial_migration.js delete mode 100644 deploy-migrations/2_deploy_root_contracts.js delete mode 100644 deploy-migrations/3_initialize_state.js delete mode 100644 deploy-migrations/4_deploy_child_contracts.js delete mode 100644 deploy-migrations/5_sync_child_state_to_root.js delete mode 100644 deploy-migrations/README.md delete mode 100644 deploy-migrations/utils.js delete mode 100644 migrations/1_initial_migration.js delete mode 100644 migrations/2_deploy_root_contracts.js delete mode 100644 migrations/3_drain_stake_manager.js delete mode 100644 migrations/4_initialize_state.js delete mode 100644 migrations/5_deploy_child_contracts.js delete mode 100644 migrations/6_sync_child_state_to_root.js delete mode 100644 migrations/utils.js delete mode 100644 moonwalker-migrations/1_queueJobs.js delete mode 100644 moonwalker-migrations/2_queueJobs.js delete mode 100644 moonwalker-migrations/3_queueJobs.js delete mode 100644 moonwalker-migrations/4_queueJobs.js delete mode 100644 moonwalker-migrations/README.md delete mode 100644 moonwalker-migrations/addressClipper.js delete mode 100644 moonwalker-migrations/deployWorker.js delete mode 100644 scripts/deploy-erc20.js delete mode 100644 scripts/deposit.js delete mode 100644 scripts/eventSignatures.js delete mode 100755 scripts/run-blockchain.sh delete mode 100755 scripts/run-coverage.sh delete mode 100755 scripts/run-migration.sh delete mode 100755 scripts/run-test.sh delete mode 100644 scripts/stake.js delete mode 100644 scripts/stakeManagerTest.js delete mode 100644 scripts/update-slots.js delete mode 100644 scripts/update-validatorshare.js delete mode 100644 scripts/updateDepositManager.js delete mode 100644 scripts/updateWithdrawManager.js delete mode 100644 scripts/wallet.js delete mode 100644 truffle-config.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 002b4aa0d..000000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["env"] -} diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 5b8c7643d..000000000 --- a/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -max_line_length = 80 - -[*.md] -trim_trailing_whitespace = false -max_line_length = 80 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 11a03cb0a..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - parser: 'babel-eslint', - extends: 'standard', - env: { - node: true, - es6: true, - mocha: true - }, - rules: { - 'space-before-function-paren': ['error', 'never'] - }, - globals: { - contract: true, - web3: true, - assert: true - } -} diff --git a/debug.sh b/debug.sh deleted file mode 100644 index ecb3edf1d..000000000 --- a/debug.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh - -cd test-blockchain -bash clean.sh -bash start.sh diff --git a/deploy-migrations/1_initial_migration.js b/deploy-migrations/1_initial_migration.js deleted file mode 100644 index 1eb6f9daf..000000000 --- a/deploy-migrations/1_initial_migration.js +++ /dev/null @@ -1,5 +0,0 @@ -var Migrations = artifacts.require('./Migrations.sol') - -module.exports = function(deployer) { - deployer.deploy(Migrations) -} diff --git a/deploy-migrations/2_deploy_root_contracts.js b/deploy-migrations/2_deploy_root_contracts.js deleted file mode 100644 index 52f15d801..000000000 --- a/deploy-migrations/2_deploy_root_contracts.js +++ /dev/null @@ -1,245 +0,0 @@ -const bluebird = require('bluebird') - -const utils = require('./utils') - -const SafeMath = artifacts.require( - 'SafeMath' -) -const RLPReader = artifacts.require('solidity-rlp/contracts/RLPReader.sol') - -const BytesLib = artifacts.require('BytesLib') -const Common = artifacts.require('Common') -const ECVerify = artifacts.require('ECVerify') -const Merkle = artifacts.require('Merkle') -const MerklePatriciaProof = artifacts.require('MerklePatriciaProof') -const PriorityQueue = artifacts.require('PriorityQueue') -const RLPEncode = artifacts.require('RLPEncode') -const TransferWithSigUtils = artifacts.require('TransferWithSigUtils') - -const Registry = artifacts.require('Registry') -const RootChain = artifacts.require('RootChain') -const Governance = artifacts.require('Governance') -const GovernanceProxy = artifacts.require('GovernanceProxy') -const RootChainProxy = artifacts.require('RootChainProxy') -const DepositManager = artifacts.require('DepositManager') -const DepositManagerProxy = artifacts.require('DepositManagerProxy') -const WithdrawManager = artifacts.require('WithdrawManager') -const WithdrawManagerProxy = artifacts.require('WithdrawManagerProxy') -const StateSender = artifacts.require('StateSender') -const StakeManager = artifacts.require('StakeManager') -const ValidatorShare = artifacts.require('ValidatorShare') -const SlashingManager = artifacts.require('SlashingManager') -const StakeManagerProxy = artifacts.require('StakeManagerProxy') -const StakingInfo = artifacts.require('StakingInfo') -const StakingNFT = artifacts.require('StakingNFT') -const ValidatorShareFactory = artifacts.require('ValidatorShareFactory') -const ERC20Predicate = artifacts.require('ERC20Predicate') -const ERC721Predicate = artifacts.require('ERC721Predicate') -const MintableERC721Predicate = artifacts.require('MintableERC721Predicate') -const MarketplacePredicate = artifacts.require('MarketplacePredicate') -const TransferWithSigPredicate = artifacts.require('TransferWithSigPredicate') -const ExitNFT = artifacts.require('ExitNFT') - -// tokens -const MaticWeth = artifacts.require('MaticWETH') -const TestToken = artifacts.require('TestToken') -const RootERC721 = artifacts.require('RootERC721') - -const libDeps = [ - { - lib: BytesLib, - contracts: [ - WithdrawManager, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate - ] - }, - { - lib: Common, - contracts: [ - WithdrawManager, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate, - MarketplacePredicate, - TransferWithSigPredicate - ] - }, - { - lib: ECVerify, - contracts: [ - StakeManager, - SlashingManager, - MarketplacePredicate, - TransferWithSigPredicate - ] - }, - { - lib: Merkle, - contracts: [WithdrawManager, ERC20Predicate, ERC721Predicate, StakeManager, MintableERC721Predicate] - }, - { - lib: MerklePatriciaProof, - contracts: [WithdrawManager, ERC20Predicate, ERC721Predicate, MintableERC721Predicate] - }, - { - lib: PriorityQueue, - contracts: [WithdrawManager] - }, - { - lib: RLPEncode, - contracts: [ - WithdrawManager, - ERC20Predicate, - ERC721Predicate, - MarketplacePredicate - ] - }, - { - lib: RLPReader, - contracts: [ - RootChain, - StakeManager, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate, - MarketplacePredicate, - TransferWithSigPredicate - ] - }, - { - lib: SafeMath, - contracts: [ - RootChain, - ERC20Predicate, - StakeManager, - SlashingManager, - StateSender, - StakingInfo - ] - }, - { - lib: TransferWithSigUtils, - contracts: [MarketplacePredicate, TransferWithSigPredicate] - } -] - -module.exports = async function(deployer) { - if (!process.env.HEIMDALL_ID) { - throw new Error('Please export HEIMDALL_ID environment variable') - } - - deployer.then(async () => { - console.log('linking libs...') - await bluebird.map(libDeps, async e => { - await deployer.deploy(e.lib) - deployer.link(e.lib, e.contracts) - }) - - console.log('deploying contracts...') - await deployer.deploy(Governance) - await deployer.deploy(GovernanceProxy, Governance.address) - await deployer.deploy(Registry, GovernanceProxy.address) - - await deployer.deploy(RootChain) - await deployer.deploy(RootChainProxy, RootChain.address, Registry.address, process.env.HEIMDALL_ID) - - await deployer.deploy(ValidatorShareFactory) - await deployer.deploy(StakingInfo, Registry.address) - await deployer.deploy(StakingNFT, 'Matic Validator', 'MV') - - console.log('deploying tokens...') - await deployer.deploy(MaticWeth) - await deployer.deploy(TestToken, 'MATIC', 'MATIC') - const testToken = await TestToken.new('Test ERC20', 'TST20') - await deployer.deploy(RootERC721, 'Test ERC721', 'TST721') - - const stakeManager = await deployer.deploy(StakeManager) - const proxy = await deployer.deploy(StakeManagerProxy, '0x0000000000000000000000000000000000000000') - await proxy.updateAndCall(StakeManager.address, stakeManager.contract.methods.initialize(Registry.address, RootChainProxy.address, TestToken.address, StakingNFT.address, StakingInfo.address, ValidatorShareFactory.address, GovernanceProxy.address).encodeABI()) - - await deployer.deploy(SlashingManager, Registry.address, StakingInfo.address, process.env.HEIMDALL_ID) - await deployer.deploy(ValidatorShare, Registry.address, 0/** dummy id */, StakingInfo.address, StakeManagerProxy.address) - await deployer.deploy(StateSender) - - await deployer.deploy(DepositManager) - await deployer.deploy( - DepositManagerProxy, - DepositManager.address, - Registry.address, - RootChainProxy.address, - GovernanceProxy.address - ) - - await deployer.deploy(WithdrawManager) - await deployer.deploy(ExitNFT, Registry.address) - await deployer.deploy( - WithdrawManagerProxy, - WithdrawManager.address, - Registry.address, - RootChainProxy.address, - ExitNFT.address - ) - - console.log('deploying predicates...') - await deployer.deploy( - ERC20Predicate, - WithdrawManagerProxy.address, - DepositManagerProxy.address, - Registry.address - ) - await deployer.deploy( - ERC721Predicate, - WithdrawManagerProxy.address, - DepositManagerProxy.address - ) - await deployer.deploy( - MarketplacePredicate, - RootChainProxy.address, - WithdrawManagerProxy.address, - Registry.address - ) - await deployer.deploy( - TransferWithSigPredicate, - RootChainProxy.address, - WithdrawManagerProxy.address, - Registry.address - ) - - console.log('writing contract addresses to file...') - const contractAddresses = { - root: { - Registry: Registry.address, - RootChain: RootChain.address, - Governance: Governance.address, - GovernanceProxy: GovernanceProxy.address, - RootChainProxy: RootChainProxy.address, - DepositManager: DepositManager.address, - DepositManagerProxy: DepositManagerProxy.address, - WithdrawManager: WithdrawManager.address, - WithdrawManagerProxy: WithdrawManagerProxy.address, - StakeManager: StakeManager.address, - StakeManagerProxy: StakeManagerProxy.address, - ValidatorShare: ValidatorShare.address, - SlashingManager: SlashingManager.address, - StakingInfo: StakingInfo.address, - ExitNFT: ExitNFT.address, - StateSender: StateSender.address, - predicates: { - ERC20Predicate: ERC20Predicate.address, - ERC721Predicate: ERC721Predicate.address, - MarketplacePredicate: MarketplacePredicate.address, - TransferWithSigPredicate: TransferWithSigPredicate.address - }, - tokens: { - MaticWeth: MaticWeth.address, - MaticToken: TestToken.address, - TestToken: testToken.address, - RootERC721: RootERC721.address - } - } - } - utils.writeContractAddresses(contractAddresses) - }) -} diff --git a/deploy-migrations/3_initialize_state.js b/deploy-migrations/3_initialize_state.js deleted file mode 100644 index b578e0b90..000000000 --- a/deploy-migrations/3_initialize_state.js +++ /dev/null @@ -1,120 +0,0 @@ -const ethUtils = require('ethereumjs-util') -const bluebird = require('bluebird') - -const Registry = artifacts.require('Registry') -const DepositManagerProxy = artifacts.require('DepositManagerProxy') -const StateSender = artifacts.require('StateSender') -const WithdrawManagerProxy = artifacts.require('WithdrawManagerProxy') -const StakeManagerProxy = artifacts.require('StakeManagerProxy') -const SlashingManager = artifacts.require('SlashingManager') -const ERC20Predicate = artifacts.require('ERC20Predicate') -const ERC721Predicate = artifacts.require('ERC721Predicate') -const MarketplacePredicate = artifacts.require('MarketplacePredicate') -const TransferWithSigPredicate = artifacts.require('TransferWithSigPredicate') -const MaticWeth = artifacts.require('MaticWETH') -const Governance = artifacts.require('Governance') -const EventsHubProxy = artifacts.require('EventsHubProxy') - -async function updateContractMap(governance, registry, nameHash, value) { - return governance.update( - registry.address, - registry.contract.methods.updateContractMap(nameHash, value).encodeABI() - ) -} - -module.exports = async function(deployer) { - deployer.then(async() => { - await bluebird - .all([ - Governance.deployed(), - Registry.deployed(), - DepositManagerProxy.deployed(), - StateSender.deployed(), - WithdrawManagerProxy.deployed(), - StakeManagerProxy.deployed(), - SlashingManager.deployed(), - ERC20Predicate.deployed(), - ERC721Predicate.deployed(), - MarketplacePredicate.deployed(), - TransferWithSigPredicate.deployed(), - EventsHubProxy.deployed() - ]) - .spread(async function( - governance, - registry, - depositManagerProxy, - stateSender, - withdrawManagerProxy, - stakeManagerProxy, - slashingManager, - ERC20Predicate, - ERC721Predicate, - MarketplacePredicate, - TransferWithSigPredicate, - EventsHubProxy - ) { - await updateContractMap( - governance, - registry, - ethUtils.keccak256('depositManager'), - depositManagerProxy.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('withdrawManager'), - withdrawManagerProxy.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('stakeManager'), - stakeManagerProxy.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('slashingManager'), - slashingManager.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('stateSender'), - stateSender.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('wethToken'), - MaticWeth.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('eventsHub'), - EventsHubProxy.address - ) - - // whitelist predicates - await governance.update( - registry.address, - registry.contract.methods.addErc20Predicate(ERC20Predicate.address).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.addErc721Predicate(ERC721Predicate.address).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.addPredicate(MarketplacePredicate.address, 3).encodeABI() - ) - await governance.update( - registry.address, - registry.contract.methods.addPredicate(TransferWithSigPredicate.address, 3).encodeABI() - ) - }) - }) -} diff --git a/deploy-migrations/4_deploy_child_contracts.js b/deploy-migrations/4_deploy_child_contracts.js deleted file mode 100644 index 7194ea664..000000000 --- a/deploy-migrations/4_deploy_child_contracts.js +++ /dev/null @@ -1,64 +0,0 @@ -const utils = require('./utils') - -const SafeMath = artifacts.require( - 'openzeppelin-solidity/contracts/math/SafeMath.sol' -) -const ChildChain = artifacts.require('ChildChain') -const MRC20 = artifacts.require('MRC20') - -module.exports = async function(deployer, network, accounts) { - deployer.then(async() => { - await deployer.deploy(SafeMath) - await deployer.link(SafeMath, [ChildChain]) - await deployer.deploy(ChildChain) - - const childChain = await ChildChain.deployed() - const contractAddresses = utils.getContractAddresses() - - let MaticWeth = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.MaticWeth, - 'ETH on Matic', - 'ETH', - 18, - false // _isERC721 - ) - - let TestToken = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.TestToken, - 'Test Token', - 'TST', - 18, - false // _isERC721 - ) - - let RootERC721 = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.RootERC721, - 'Test ERC721', - 'TST721', - 0, - true // _isERC721 - ) - - const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') - const maticOwner = await maticToken.owner() - if (maticOwner === '0x0000000000000000000000000000000000000000') { - // matic contract at 0x1010 can only be initialized once, after the bor image starts to run - await maticToken.initialize(ChildChain.address, contractAddresses.root.tokens.MaticToken) - } - await childChain.mapToken(contractAddresses.root.tokens.MaticToken, '0x0000000000000000000000000000000000001010', false) - - contractAddresses.child = { - ChildChain: ChildChain.address, - tokens: { - MaticWeth: MaticWeth.logs.find(log => log.event === 'NewToken').args.token, - MaticToken: '0x0000000000000000000000000000000000001010', - TestToken: TestToken.logs.find(log => log.event === 'NewToken').args.token, - RootERC721: RootERC721.logs.find(log => log.event === 'NewToken').args.token - } - } - utils.writeContractAddresses(contractAddresses) - }) -} diff --git a/deploy-migrations/5_sync_child_state_to_root.js b/deploy-migrations/5_sync_child_state_to_root.js deleted file mode 100644 index 38dcf657e..000000000 --- a/deploy-migrations/5_sync_child_state_to_root.js +++ /dev/null @@ -1,73 +0,0 @@ -const ethUtils = require('ethereumjs-util') -const utils = require('./utils') - -const Registry = artifacts.require('Registry') -const Governance = artifacts.require('Governance') -const StateSender = artifacts.require('StateSender') -const DepositManager = artifacts.require('DepositManager') - -module.exports = async function(deployer, network, accounts) { - deployer.then(async() => { - const contractAddresses = utils.getContractAddresses() - const registry = await Registry.at(contractAddresses.root.Registry) - const governance = await Governance.at(contractAddresses.root.GovernanceProxy) - const tasks = [] - - tasks.push(governance.update( - contractAddresses.root.Registry, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.MaticWeth, - contractAddresses.child.tokens.MaticWeth, - false /* isERC721 */ - ).encodeABI() - )) - await delay(5) - - tasks.push(governance.update( - contractAddresses.root.Registry, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.MaticToken, - contractAddresses.child.tokens.MaticToken, - false /* isERC721 */ - ).encodeABI() - )) - await delay(5) - - tasks.push(governance.update( - contractAddresses.root.Registry, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.TestToken, - contractAddresses.child.tokens.TestToken, - false /* isERC721 */ - ).encodeABI() - )) - await delay(5) - - tasks.push(governance.update( - contractAddresses.root.Registry, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.RootERC721, - contractAddresses.child.tokens.RootERC721, - true /* isERC721 */ - ).encodeABI() - )) - await delay(5) - - tasks.push(governance.update( - contractAddresses.root.Registry, - registry.contract.methods.updateContractMap( - ethUtils.keccak256('childChain'), - contractAddresses.child.ChildChain - ).encodeABI() - )) - await Promise.all(tasks) - - await (await StateSender.at(contractAddresses.root.StateSender)).register(contractAddresses.root.DepositManagerProxy, contractAddresses.child.ChildChain) - let depositManager = await DepositManager.at(contractAddresses.root.DepositManagerProxy) - await depositManager.updateChildChainAndStateSender() - }) -} - -function delay(s) { - return new Promise(resolve => setTimeout(resolve, s * 1000)); -} diff --git a/deploy-migrations/README.md b/deploy-migrations/README.md deleted file mode 100644 index 4dd155f4d..000000000 --- a/deploy-migrations/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# Deploy Contracts - -### :one: We have some network configrations available. - -| Network Name | URL | Network ID | -| ------------ | :-------------------------------------: | ---------: | -| ropsten | https://ropsten.infura.io/v3/${API_KEY} | 3 | -| mainnet | https://mainnet.infura.io/v3/${API_KEY} | 1 | -| development | http://localhost:9545 | \* | -| bor | http://localhost:8545 | \* | - -Feel free to add your own. Update the chain url in `networks.matic` key in [truffle-config.js](../truffle-config.js). - -### :two: Export variables - -``` -// (Optional) Only if you are using ethereum testnets -export API_KEY= - -// For `developement` networks you can use the mnemonic present in package.json -export MNEMONIC= - -export HEIMDALL_ID=<> -e.g. export HEIMDALL_ID="heimdall-P5rXwg" -``` - -### :three: Choose Bor Chain Id - -``` -npm run template:process -- --bor-chain-id -for instance, npm run template:process -- --bor-chain-id 80001 -``` - -### :four: Compile contracts - -``` -npm run truffle:compile -``` - -### :five: Deploy contracts - -We need to deploy our set of contracts on 2 chains: - -- Base Chain: Ideally a higher security EVM chain which can be used for dispute resolution. For testing ganache or any other EVM chain should work. -- Child Chain: EVM compatible chain to work as our sidechain. For testing note that using `ganache` for child-chain is not recommended, instead invoking `npm run bor:simulate` would be better. - -``` - -// Root contracts are deployed on base chain -npm run truffle:migrate -- --reset --to 4 --network - -// Contracts like ChildERC20Token are deployed on child chain aka BOR chain -// NOTE: You need to deploy or simulate BOR before running the below command -npm run truffle:migrate -- --reset -f 5 --to 5 --network - - -// Contracts deployed on BOR are mapped to the registry contract deployed on-chain -npm run truffle:migrate -- -f 6 --to 6 --network -``` - -Post successfull deployment all contract addresses will be written to a `contractAddresses.json` file. - -> Check account that you are deploying from has ether for the network you are deploying on. - -### :six: Stake to become a validator - -``` -// (Optional) Export mnemonic or the private key (without the 0x prefix) -// This account needs to have test token -export MNEMONIC=<> - -// (Optional) Infura PROJECT ID, if required -export API_KEY= - -npm run truffle exec scripts/stake.js -- --network <# tokens to stake> -``` diff --git a/deploy-migrations/utils.js b/deploy-migrations/utils.js deleted file mode 100644 index 6457f02c7..000000000 --- a/deploy-migrations/utils.js +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require('fs') - -export function getContractAddresses() { - return JSON.parse(fs.readFileSync(`${process.cwd()}/contractAddresses.json`).toString()) -} - -export function writeContractAddresses(contractAddresses) { - fs.writeFileSync( - `${process.cwd()}/contractAddresses.json`, - JSON.stringify(contractAddresses, null, 2) // Indent 2 spaces - ) -} diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js deleted file mode 100644 index 1eb6f9daf..000000000 --- a/migrations/1_initial_migration.js +++ /dev/null @@ -1,5 +0,0 @@ -var Migrations = artifacts.require('./Migrations.sol') - -module.exports = function(deployer) { - deployer.deploy(Migrations) -} diff --git a/migrations/2_deploy_root_contracts.js b/migrations/2_deploy_root_contracts.js deleted file mode 100644 index bad2271c7..000000000 --- a/migrations/2_deploy_root_contracts.js +++ /dev/null @@ -1,308 +0,0 @@ -// Deploy minimal number of contracts to link the libraries with the contracts -const utils = require('./utils') - -const bluebird = require('bluebird') - -const SafeMath = artifacts.require( - 'openzeppelin-solidity/contracts/math/SafeMath.sol' -) - -const RLPReader = artifacts.require('solidity-rlp/contracts/RLPReader.sol') - -const BytesLib = artifacts.require('BytesLib') -const Common = artifacts.require('Common') -const ECVerify = artifacts.require('ECVerify') -const Merkle = artifacts.require('Merkle') -const MerklePatriciaProof = artifacts.require('MerklePatriciaProof') -const PriorityQueue = artifacts.require('PriorityQueue') -const RLPEncode = artifacts.require('RLPEncode') - -const Registry = artifacts.require('Registry') -const Governance = artifacts.require('Governance') -const GovernanceProxy = artifacts.require('GovernanceProxy') -const RootChain = artifacts.require('RootChain') -const RootChainProxy = artifacts.require('RootChainProxy') -const DepositManager = artifacts.require('DepositManager') -const DepositManagerProxy = artifacts.require('DepositManagerProxy') -const WithdrawManager = artifacts.require('WithdrawManager') -const WithdrawManagerProxy = artifacts.require('WithdrawManagerProxy') -const StateSender = artifacts.require('StateSender') -const StakeManager = artifacts.require('StakeManager') -const StakeManagerProxy = artifacts.require('StakeManagerProxy') -const SlashingManager = artifacts.require('SlashingManager') -const StakingInfo = artifacts.require('StakingInfo') -const StakingNFT = artifacts.require('StakingNFT') -const ValidatorShareFactory = artifacts.require('ValidatorShareFactory') -const ValidatorShare = artifacts.require('ValidatorShare') -const ERC20Predicate = artifacts.require('ERC20Predicate') -const ERC721Predicate = artifacts.require('ERC721Predicate') -const MintableERC721Predicate = artifacts.require('MintableERC721Predicate') -const Marketplace = artifacts.require('Marketplace') -const MarketplacePredicate = artifacts.require('MarketplacePredicate') -const MarketplacePredicateTest = artifacts.require('MarketplacePredicateTest') -const TransferWithSigPredicate = artifacts.require('TransferWithSigPredicate') -const TransferWithSigUtils = artifacts.require('TransferWithSigUtils') - -const StakeManagerTestable = artifacts.require('StakeManagerTestable') -const StakeManagerTest = artifacts.require('StakeManagerTest') - -const ExitNFT = artifacts.require('ExitNFT') -const MaticWeth = artifacts.require('MaticWETH') -const TestToken = artifacts.require('TestToken') -const RootERC721 = artifacts.require('RootERC721') - -const StakeManagerExtension = artifacts.require('StakeManagerExtension') -const EventsHub = artifacts.require('EventsHub') -const EventsHubProxy = artifacts.require('EventsHubProxy') - -const ZeroAddress = '0x0000000000000000000000000000000000000000'; - -const libDeps = [ - { - lib: BytesLib, - contracts: [WithdrawManager, ERC20Predicate, ERC721Predicate, MintableERC721Predicate] - }, - { - lib: Common, - contracts: [ - WithdrawManager, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate, - MarketplacePredicate, - MarketplacePredicateTest, - TransferWithSigPredicate - ] - }, - { - lib: ECVerify, - contracts: [ - StakeManager, - SlashingManager, - StakeManagerTestable, - MarketplacePredicate, - MarketplacePredicateTest, - TransferWithSigPredicate - ] - }, - { - lib: Merkle, - contracts: [ - WithdrawManager, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate, - StakeManager, - StakeManagerTestable, - StakeManagerTest - ] - }, - { - lib: MerklePatriciaProof, - contracts: [WithdrawManager, ERC20Predicate, ERC721Predicate, MintableERC721Predicate] - }, - { - lib: PriorityQueue, - contracts: [WithdrawManager] - }, - { - lib: RLPEncode, - contracts: [ - WithdrawManager, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate, - MarketplacePredicate, - MarketplacePredicateTest - ] - }, - { - lib: RLPReader, - contracts: [ - RootChain, - StakeManager, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate, - MarketplacePredicate, - MarketplacePredicateTest - ] - }, - { - lib: SafeMath, - contracts: [ - RootChain, - ERC20Predicate, - ERC721Predicate, - MintableERC721Predicate, - MarketplacePredicate, - MarketplacePredicateTest, - TransferWithSigPredicate, - StakeManager, - SlashingManager, - StakingInfo, - StateSender, - StakeManagerExtension - ] - }, - { - lib: SafeMath, - contracts: [RootChain, ERC20Predicate] - }, - { - lib: TransferWithSigUtils, - contracts: [ - TransferWithSigPredicate, - MarketplacePredicate, - MarketplacePredicateTest - ] - } -] - -module.exports = async function(deployer, network, accounts) { - if (!process.env.HEIMDALL_ID) { - console.log('HEIMDALL_ID is not set; defaulting to heimdall-P5rXwg') - process.env.HEIMDALL_ID = 'heimdall-P5rXwg' - } - - deployer.then(async() => { - await bluebird.map(libDeps, async e => { - await deployer.deploy(e.lib) - deployer.link(e.lib, e.contracts) - }) - - await deployer.deploy(Governance) - await deployer.deploy(GovernanceProxy, Governance.address) - await deployer.deploy(Registry, GovernanceProxy.address) - await deployer.deploy(ValidatorShareFactory) - await deployer.deploy(ValidatorShare) - const maticToken = await deployer.deploy(TestToken, 'MATIC', 'MATIC') - await deployer.deploy(TestToken, 'Test ERC20', 'TEST20') - await deployer.deploy(RootERC721, 'Test ERC721', 'TST721') - await deployer.deploy(StakingInfo, Registry.address) - await deployer.deploy(StakingNFT, 'Matic Validator', 'MV') - - await deployer.deploy(RootChain) - await deployer.deploy(RootChainProxy, RootChain.address, Registry.address, process.env.HEIMDALL_ID) - await deployer.deploy(StateSender) - await deployer.deploy(StakeManagerTestable) - await deployer.deploy(StakeManagerTest) - - await deployer.deploy(DepositManager) - await deployer.deploy( - DepositManagerProxy, - DepositManager.address, - Registry.address, - RootChainProxy.address, - GovernanceProxy.address - ) - - await deployer.deploy(ExitNFT, Registry.address) - await deployer.deploy(WithdrawManager) - await deployer.deploy( - WithdrawManagerProxy, - WithdrawManager.address, - Registry.address, - RootChainProxy.address, - ExitNFT.address - ) - - { - let eventsHubImpl = await deployer.deploy(EventsHub) - let proxy = await deployer.deploy(EventsHubProxy, ZeroAddress) - await proxy.updateAndCall(eventsHubImpl.address, eventsHubImpl.contract.methods.initialize( - Registry.address - ).encodeABI()) - } - - const stakeManager = await deployer.deploy(StakeManager) - const stakeMangerProxy = await deployer.deploy(StakeManagerProxy, ZeroAddress) - const auctionImpl = await deployer.deploy(StakeManagerExtension) - await stakeMangerProxy.updateAndCall( - StakeManager.address, - stakeManager.contract.methods.initialize( - Registry.address, - RootChainProxy.address, - maticToken.address, - StakingNFT.address, - StakingInfo.address, - ValidatorShareFactory.address, - GovernanceProxy.address, - accounts[0], - auctionImpl.address - ).encodeABI() - ) - - await deployer.deploy(SlashingManager, Registry.address, StakingInfo.address, process.env.HEIMDALL_ID) - let stakingNFT = await StakingNFT.deployed() - await stakingNFT.transferOwnership(StakeManagerProxy.address) - - await deployer.deploy(MaticWeth) - - await Promise.all([ - deployer.deploy( - ERC20Predicate, - WithdrawManagerProxy.address, - DepositManagerProxy.address, - Registry.address - ), - deployer.deploy( - ERC721Predicate, - WithdrawManagerProxy.address, - DepositManagerProxy.address - ), - deployer.deploy( - MintableERC721Predicate, - WithdrawManagerProxy.address, - DepositManagerProxy.address - ), - deployer.deploy(Marketplace), - deployer.deploy(MarketplacePredicateTest), - deployer.deploy( - MarketplacePredicate, - RootChain.address, - WithdrawManagerProxy.address, - Registry.address - ), - deployer.deploy( - TransferWithSigPredicate, - RootChain.address, - WithdrawManagerProxy.address, - Registry.address - ) - ]) - - const contractAddresses = { - root: { - Registry: Registry.address, - RootChain: RootChain.address, - GovernanceProxy: GovernanceProxy.address, - RootChainProxy: RootChainProxy.address, - DepositManager: DepositManager.address, - DepositManagerProxy: DepositManagerProxy.address, - WithdrawManager: WithdrawManager.address, - WithdrawManagerProxy: WithdrawManagerProxy.address, - StakeManager: StakeManager.address, - StakeManagerProxy: StakeManagerProxy.address, - SlashingManager: SlashingManager.address, - StakingInfo: StakingInfo.address, - ExitNFT: ExitNFT.address, - StateSender: StateSender.address, - predicates: { - ERC20Predicate: ERC20Predicate.address, - ERC721Predicate: ERC721Predicate.address, - MarketplacePredicate: MarketplacePredicate.address, - TransferWithSigPredicate: TransferWithSigPredicate.address - }, - tokens: { - MaticToken: maticToken.address, - MaticWeth: MaticWeth.address, - TestToken: TestToken.address, - RootERC721: RootERC721.address - } - } - } - - utils.writeContractAddresses(contractAddresses) - }) -} diff --git a/migrations/3_drain_stake_manager.js b/migrations/3_drain_stake_manager.js deleted file mode 100644 index 66d348c83..000000000 --- a/migrations/3_drain_stake_manager.js +++ /dev/null @@ -1,7 +0,0 @@ -const DrainStakeManager = artifacts.require('DrainStakeManager') - -module.exports = async function(deployer) { - deployer.then(async() => { - await deployer.deploy(DrainStakeManager) - }) -} diff --git a/migrations/4_initialize_state.js b/migrations/4_initialize_state.js deleted file mode 100644 index 7535a1eda..000000000 --- a/migrations/4_initialize_state.js +++ /dev/null @@ -1,130 +0,0 @@ -const ethUtils = require('ethereumjs-util') -const bluebird = require('bluebird') -const utils = require('./utils') -const Registry = artifacts.require('Registry') -const ValidatorShare = artifacts.require('ValidatorShare') -const DepositManagerProxy = artifacts.require('DepositManagerProxy') -const StateSender = artifacts.require('StateSender') -const WithdrawManagerProxy = artifacts.require('WithdrawManagerProxy') -const StakeManagerProxy = artifacts.require('StakeManagerProxy') -const SlashingManager = artifacts.require('SlashingManager') -const ERC20Predicate = artifacts.require('ERC20Predicate') -const ERC721Predicate = artifacts.require('ERC721Predicate') -const MarketplacePredicate = artifacts.require('MarketplacePredicate') -const TransferWithSigPredicate = artifacts.require('TransferWithSigPredicate') -const MaticWeth = artifacts.require('MaticWETH') -const Governance = artifacts.require('Governance') -const EventsHubProxy = artifacts.require('EventsHubProxy') - -async function updateContractMap(governance, registry, nameHash, value) { - return governance.update( - registry.address, - registry.contract.methods.updateContractMap(nameHash, value).encodeABI() - ) -} - -module.exports = async function(deployer) { - deployer.then(async() => { - const contractAddresses = utils.getContractAddresses() - const governance = await Governance.at(contractAddresses.root.GovernanceProxy) - - await bluebird - .all([ - Registry.deployed(), - ValidatorShare.deployed(), - DepositManagerProxy.deployed(), - StateSender.deployed(), - WithdrawManagerProxy.deployed(), - StakeManagerProxy.deployed(), - SlashingManager.deployed(), - ERC20Predicate.deployed(), - ERC721Predicate.deployed(), - MarketplacePredicate.deployed(), - TransferWithSigPredicate.deployed(), - EventsHubProxy.deployed() - ]) - .spread(async function( - registry, - validatorShare, - depositManagerProxy, - stateSender, - withdrawManagerProxy, - stakeManagerProxy, - slashingManager, - ERC20Predicate, - ERC721Predicate, - MarketplacePredicate, - TransferWithSigPredicate, - EventsHubProxy - ) { - await updateContractMap( - governance, - registry, - ethUtils.keccak256('validatorShare'), - validatorShare.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('depositManager'), - depositManagerProxy.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('withdrawManager'), - withdrawManagerProxy.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('stakeManager'), - stakeManagerProxy.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('slashingManager'), - slashingManager.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('stateSender'), - stateSender.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('wethToken'), - MaticWeth.address - ) - await updateContractMap( - governance, - registry, - ethUtils.keccak256('eventsHub'), - EventsHubProxy.address - ) - - // whitelist predicates - await governance.update( - registry.address, - registry.contract.methods.addErc20Predicate(ERC20Predicate.address).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.addErc721Predicate(ERC721Predicate.address).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.addPredicate(MarketplacePredicate.address, 3).encodeABI() - ) - await governance.update( - registry.address, - registry.contract.methods.addPredicate(TransferWithSigPredicate.address, 3).encodeABI() - ) - }) - }) -} diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js deleted file mode 100644 index a634357be..000000000 --- a/migrations/5_deploy_child_contracts.js +++ /dev/null @@ -1,70 +0,0 @@ -const utils = require('./utils') - -const SafeMath = artifacts.require( - 'openzeppelin-solidity/contracts/math/SafeMath.sol' -) -const ChildChain = artifacts.require('ChildChain') -const MRC20 = artifacts.require('MRC20') - -module.exports = async function(deployer, network, accounts) { - if (deployer.network !== 'bor') { - return - } - - console.log(deployer.network); - - deployer.then(async() => { - await deployer.deploy(SafeMath) - await deployer.link(SafeMath, [ChildChain]) - await deployer.deploy(ChildChain) - - const childChain = await ChildChain.deployed() - const contractAddresses = utils.getContractAddresses() - - let MaticWeth = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.MaticWeth, - 'ETH on Matic', - 'ETH', - 18, - false // _isERC721 - ) - - let TestToken = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.TestToken, - 'Test Token', - 'TST', - 18, - false // _isERC721 - ) - - let RootERC721 = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.RootERC721, - 'Test ERC721', - 'TST721', - 0, - true // _isERC721 - ) - - const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') - const maticOwner = await maticToken.owner() - if (maticOwner === '0x0000000000000000000000000000000000000000') { - // matic contract at 0x1010 can only be initialized once, after the bor image starts to run - await maticToken.initialize(ChildChain.address, contractAddresses.root.tokens.MaticToken) - } - await childChain.mapToken(contractAddresses.root.tokens.MaticToken, '0x0000000000000000000000000000000000001010', false) - - contractAddresses.child = { - ChildChain: ChildChain.address, - tokens: { - MaticWeth: MaticWeth.logs.find(log => log.event === 'NewToken').args.token, - MaticToken: '0x0000000000000000000000000000000000001010', - TestToken: TestToken.logs.find(log => log.event === 'NewToken').args.token, - RootERC721: RootERC721.logs.find(log => log.event === 'NewToken').args.token - } - } - utils.writeContractAddresses(contractAddresses) - }) -} diff --git a/migrations/6_sync_child_state_to_root.js b/migrations/6_sync_child_state_to_root.js deleted file mode 100644 index 0b8b17b7b..000000000 --- a/migrations/6_sync_child_state_to_root.js +++ /dev/null @@ -1,69 +0,0 @@ -const ethUtils = require('ethereumjs-util') -const utils = require('./utils') - -const Registry = artifacts.require('Registry') -const Governance = artifacts.require('Governance') -const StateSender = artifacts.require('StateSender') -const DepositManager = artifacts.require('DepositManager') - -module.exports = async function(deployer, network, accounts) { - deployer.then(async() => { - const contractAddresses = utils.getContractAddresses() - - if (!contractAddresses.child) { - return - } - - const registry = await Registry.at(contractAddresses.root.Registry) - const governance = await Governance.at(contractAddresses.root.GovernanceProxy) - - await governance.update( - registry.address, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.MaticWeth, - contractAddresses.child.tokens.MaticWeth, - false /* isERC721 */ - ).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.MaticToken, - contractAddresses.child.tokens.MaticToken, - false /* isERC721 */ - ).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.TestToken, - contractAddresses.child.tokens.TestToken, - false /* isERC721 */ - ).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.mapToken( - contractAddresses.root.tokens.RootERC721, - contractAddresses.child.tokens.RootERC721, - true /* isERC721 */ - ).encodeABI() - ) - - await governance.update( - registry.address, - registry.contract.methods.updateContractMap( - ethUtils.keccak256('childChain'), - contractAddresses.child.ChildChain - ).encodeABI() - ) - - const stateSenderContract = await StateSender.at(contractAddresses.root.StateSender) - await stateSenderContract.register(contractAddresses.root.DepositManagerProxy, contractAddresses.child.ChildChain) - let depositManager = await DepositManager.at(contractAddresses.root.DepositManagerProxy) - await depositManager.updateChildChainAndStateSender() - }) -} diff --git a/migrations/utils.js b/migrations/utils.js deleted file mode 100644 index 6457f02c7..000000000 --- a/migrations/utils.js +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require('fs') - -export function getContractAddresses() { - return JSON.parse(fs.readFileSync(`${process.cwd()}/contractAddresses.json`).toString()) -} - -export function writeContractAddresses(contractAddresses) { - fs.writeFileSync( - `${process.cwd()}/contractAddresses.json`, - JSON.stringify(contractAddresses, null, 2) // Indent 2 spaces - ) -} diff --git a/moonwalker-migrations/1_queueJobs.js b/moonwalker-migrations/1_queueJobs.js deleted file mode 100644 index b53fb77bb..000000000 --- a/moonwalker-migrations/1_queueJobs.js +++ /dev/null @@ -1,73 +0,0 @@ -const EthDeployer = require('moonwalker').default - -let id = 0 - -async function deploy() { - if (!process.env.HEIMDALL_ID) { - throw new Error('Please export HEIMDALL_ID environment variable') - } - if (!process.env.MATIC_NAME) { - throw new Error('Please export MATIC_NAME environment variable') - } - - const qClient = await EthDeployer.getQueue() - const deployer = new EthDeployer.Sender(qClient) - - // Libs - await deployer.deploy(transformArtifact('BytesLib')) - await deployer.deploy(transformArtifact('Common')) - await deployer.deploy(transformArtifact('ECVerify')) - await deployer.deploy(transformArtifact('Merkle')) - await deployer.deploy(transformArtifact('MerklePatriciaProof')) - await deployer.deploy(transformArtifact('PriorityQueue')) - await deployer.deploy(transformArtifact('RLPEncode')) - await deployer.deploy(transformArtifact('RLPReader')) - await deployer.deploy(transformArtifact('SafeMath')) - - // contracts, id = 9 - await deployer.deploy(transformArtifact('Governance')) - await deployer.deploy(transformArtifact('GovernanceProxy', ['Governance'])) - await deployer.deploy(transformArtifact('Registry', ['GovernanceProxy'])) - await deployer.deploy(transformArtifact('RootChain')) - await deployer.deploy(transformArtifact('RootChainProxy', [ - 'RootChain', - 'Registry', - { value: process.env.HEIMDALL_ID } - ])) - - await deployer.deploy(transformArtifact('ValidatorShareFactory')) - await deployer.deploy(transformArtifact('StakingInfo', ['Registry'])) - await deployer.deploy(transformArtifact('StakingNFT', [{ value: 'Matic Validator' }, { value: 'MV' }])) - - await deployer.deploy(transformArtifact('TestToken', [{ value: process.env.MATIC_NAME }, { value: process.env.MATIC_NAME }])) - await deployer.deploy(transformArtifact('TestToken', [{ value: `ERC20-${process.env.MATIC_NAME}` }, { value: `ERC20-${process.env.MATIC_NAME}` }])) - await deployer.deploy(transformArtifact('RootERC721', [{ value: `ERC721-${process.env.MATIC_NAME}` }, { value: `ERC721-${process.env.MATIC_NAME}` }])) - await deployer.deploy(transformArtifact('MaticWETH')) - - await deployer.deploy(transformArtifact('StakeManager')) - await deployer.deploy(transformArtifact('StakeManagerProxy', ['StakeManager'])) - await deployer.deploy(transformArtifact('SlashingManager', ['Registry', 'StakingInfo', { value: process.env.HEIMDALL_ID }])) - await deployer.deploy(transformArtifact('ValidatorShare', ['Registry', { value: '0' }, 'StakingNFT', 'StakeManagerProxy'])) - - await deployer.deploy(transformArtifact('StateSender')) - await deployer.deploy(transformArtifact('DepositManager')) - await deployer.deploy(transformArtifact('DepositManagerProxy', ['DepositManager', 'Registry', 'RootChainProxy', 'GovernanceProxy'])) - - await deployer.deploy(transformArtifact('WithdrawManager')) - await deployer.deploy(transformArtifact('ExitNFT', ['Registry'])) - await deployer.deploy(transformArtifact('WithdrawManagerProxy', ['WithdrawManager', 'Registry', 'RootChainProxy', 'ExitNFT'])) - await deployer.deploy(transformArtifact('ERC20PredicateBurnOnly', ['WithdrawManagerProxy', 'DepositManagerProxy', 'Registry'])) - await deployer.deploy(transformArtifact('ERC721PredicateBurnOnly', ['WithdrawManagerProxy', 'DepositManagerProxy'])) -} - -function transformArtifact(contract, args = []) { - const res = { - contract, // abi - args, - id: id++, - type: 'deploy' - } - return JSON.stringify(res) -} - -deploy().then() diff --git a/moonwalker-migrations/2_queueJobs.js b/moonwalker-migrations/2_queueJobs.js deleted file mode 100644 index 111cf8d78..000000000 --- a/moonwalker-migrations/2_queueJobs.js +++ /dev/null @@ -1,221 +0,0 @@ -const fs = require('fs') - -const Registry = artifacts.require('Registry') - -const ethUtils = require('ethereumjs-util') -const EthDeployer = require('moonwalker').default - -let id = 33 // THIS SHOULD BE NUMBER OF JOBS PROCESSED IN THE PREVIOUS SCRIPT - -async function deploy() { - const qClient = await EthDeployer.getQueue() - const deployer = new EthDeployer.Sender(qClient) - - // just need this for encodeABI() - const registry = await Registry.new('0x0000000000000000000000000000000000000000') - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.updateContractMap( - ethUtils.bufferToHex(ethUtils.keccak256('depositManager')), - getAddressForContract('DepositManagerProxy') - ).encodeABI() - } - ], - 'GovernanceProxy' - ) - ) - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.updateContractMap( - ethUtils.bufferToHex(ethUtils.keccak256('withdrawManager')), - getAddressForContract('WithdrawManagerProxy') - ).encodeABI() - } - ], - 'GovernanceProxy' - ) - ) - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.updateContractMap( - ethUtils.bufferToHex(ethUtils.keccak256('slashingManager')), - getAddressForContract('SlashingManager') - ).encodeABI() - } - ], - 'GovernanceProxy' - ) - ) - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.updateContractMap( - ethUtils.bufferToHex(ethUtils.keccak256('stakeManager')), - getAddressForContract('StakeManagerProxy') - ).encodeABI() - } - ], - 'GovernanceProxy' - ) - ) - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.updateContractMap( - ethUtils.bufferToHex(ethUtils.keccak256('validatorShare')), - getAddressForContract('ValidatorShare') - ).encodeABI() - } - ], - 'GovernanceProxy' - ) - ) - - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.updateContractMap( - ethUtils.bufferToHex(ethUtils.keccak256('stateSender')), - getAddressForContract('StateSender') - ).encodeABI() - }, - ], - 'GovernanceProxy' - ) - ) - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.updateContractMap( - ethUtils.bufferToHex(ethUtils.keccak256('wethToken')), - getAddressForContract('MaticWETH') - ).encodeABI() - }, - ], - 'GovernanceProxy' - ) - ) - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.addErc20Predicate( - getAddressForContract('ERC20Predicate') - ).encodeABI() - }, - ], - 'GovernanceProxy' - ) - ) - - await deployer.deploy( - tx('Governance', 'update', - [ - 'Registry', - { - value: - registry.contract.methods.addErc721Predicate( - getAddressForContract('ERC721Predicate') - ).encodeABI() - }, - ], - 'GovernanceProxy' - ) - ) - - await deployer.deploy(tx('StakingNFT', 'transferOwnership', ['StakeManagerProxy'])) - await deployer.deploy(tx('StakeManager', 'initialize', [ - 'Registry', - 'RootChainProxy', - 'TestToken', - 'StakingNFT', - 'StakingInfo', - 'ValidatorShareFactory', - 'GovernanceProxy', - { value: process.env.FROM } // owner - ], - 'StakeManagerProxy' -)) -} - -function tx(contract, method, args, addressArtifact) { - return JSON.stringify({ - contract, // abi - addressArtifact, // allowed to be undefined - method, - args, - id: id++, - type: 'transaction' - }) -} - -function getStatus() { - let status = {} - const statusFile = `${process.cwd()}/build/status.json` - if (fs.existsSync(statusFile)) { - try { - status = JSON.parse(fs.readFileSync(statusFile).toString()) - } catch (e) { - console.log(e) - } - } - return status -} - -function getAddressForContract(contract) { - const status = getStatus() - for (let i = 0; i < Object.keys(status).length; i++) { - if (status[i].contract === contract) return status[i].address - } - throw new Error(`${contract} not found in status file`) -} - -function wait(ms) { - return new Promise((resolve, reject) => { - setTimeout(function() { resolve() }, ms); - }) -} - -module.exports = async function(callback) { - try { - await deploy() - await wait(3000) // otherwise the tasks are not queued - } catch (e) { - // truffle exec