From 48889c2195e1778dc8594113585716723f4e3891 Mon Sep 17 00:00:00 2001 From: Oren Sokolowsky Date: Thu, 26 Nov 2020 10:26:20 +0200 Subject: [PATCH 1/3] support arbitium chain --- migrate-base.js | 9 +----- migrate-dao.js | 11 +------ migrate.js | 31 ++++++++---------- migration.json | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ utils.js | 18 +++++++++++ 5 files changed, 119 insertions(+), 35 deletions(-) diff --git a/migrate-base.js b/migrate-base.js index 75f6e197..387f29c8 100644 --- a/migrate-base.js +++ b/migrate-base.js @@ -11,14 +11,7 @@ async function migrateBase ({ arcVersion, web3, spinner, confirm, opts, logTx, p } const addresses = {} - let network = await web3.eth.net.getNetworkType() - if (network === 'private') { - if (await web3.eth.net.getId() === 100) { - network = 'xdai' - } else if (await web3.eth.net.getId() === 77) { - network = 'sokol' - } - } + let network = await utils.getNetworkName(web3) async function deploy ({ contractName, abi, bytecode, deployedBytecode }, deps, ...args) { deps = deps || [] for (let existing in previousMigration.base) { diff --git a/migrate-dao.js b/migrate-dao.js index a40ebcb8..178d2886 100644 --- a/migrate-dao.js +++ b/migrate-dao.js @@ -2,19 +2,10 @@ const utils = require('./utils.js') const sanitize = require('./sanitize') async function migrateDAO ({ arcVersion, web3, spinner, confirm, opts, migrationParams, logTx, previousMigration, customAbisLocation, restart, getState, setState, cleanState, sendTx, getArcVersionNumber, optimizedAbis }) { - let network = await web3.eth.net.getNetworkType() + let network = await utils.getNetworkName(web3) if (network === 'main') { network = 'mainnet' } - - if (network === 'private') { - if (await web3.eth.net.getId() === 100) { - network = 'xdai' - } else if (await web3.eth.net.getId() === 77) { - network = 'sokol' - } - } - if (restart) { cleanState(network) } diff --git a/migrate.js b/migrate.js index 6604830a..d99cdc01 100755 --- a/migrate.js +++ b/migrate.js @@ -13,6 +13,7 @@ const migrateDemoTest = require('./migrate-demo-test') const updateDAORegistry = require('./helper-scripts/dao-registry') const allocateReputation = require('./helper-scripts/rep-allocation') const path = require('path') +const utils = require('./utils.js') async function migrate (opts) { const base = await migrateBase(opts) @@ -89,18 +90,12 @@ const wrapCommand = fn => async options => { spinner.info(`${transactionHash} | ${Number(txCost).toFixed(5)} ETH | ${msg}`) } } + let network = await utils.getNetworkName(web3) - let network = await web3.eth.net.getNetworkType() - if (network === 'private') { - if (await web3.eth.net.getId() === 100) { - network = 'xdai' - } else if (await web3.eth.net.getId() === 77) { - network = 'sokol' - } - } if (network === 'main') { network = 'mainnet' } + console.log(network) const balance = await web3.eth.getBalance(web3.eth.defaultAccount) @@ -111,6 +106,7 @@ const wrapCommand = fn => async options => { // default opts for web3 const block = await web3.eth.getBlock('latest') + //console.log("await web3.eth.getBlock('latest')",await web3.eth.getBlock('latest')) const opts = { from: web3.eth.defaultAccount, gas: block.gasLimit - 100000, @@ -190,16 +186,17 @@ const wrapCommand = fn => async options => { spinner.start(msg) let gas = 0 let nonce = await web3.eth.getTransactionCount(web3.eth.defaultAccount) - const blockLimit = await web3.eth.getBlock('latest').gasLimit - try { - gas = (await tx.estimateGas()) - if (gas * 1.1 < blockLimit - 100000) { - gas *= 1.1 - } - } catch (error) { - gas = blockLimit - 100000 + if (utils.getNetworkName() !== 'arbitium') { + const blockLimit = await web3.eth.getBlock('latest').gasLimit + try { + gas = (await tx.estimateGas()) + if (gas * 1.1 < blockLimit - 100000) { + gas *= 1.1 + } + } catch (error) { + gas = blockLimit - 100000 + } } - let result = tx.send({ gas, nonce }) let receipt = await new Promise(resolve => result.on('receipt', resolve).on('error', async error => { spinner.fail('Transaction failed: ' + error) diff --git a/migration.json b/migration.json index 9223a88d..8c6f7894 100644 --- a/migration.json +++ b/migration.json @@ -5434,5 +5434,90 @@ "arcVersion": "0.0.1-rc.39" } } + }, + "arbitium": { + "base": { + "0.0.1-rc.51": { + "GEN": "0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf", + "DAORegistry": "0x6340D4787B1C313Bb9c24B63bD0F64c9752Fe3eA", + "DAOTracker": "0xb4c759d04467b0486cb2E526FbB4b101254Ae331", + "ControllerCreator": "0xbDa54347737730b91e614a9b90E41970f804D23e", + "DaoCreator": "0x38a7824d06026AFc726e8302A9d2F2DeccB01497", + "GenesisProtocol": "0x6D70cad8e9E39D3d711331ce4bE77C6Ab5665883", + "SchemeRegistrar": "0xe1326fDB8CAb008B2Be17061400323C7025FA492", + "UpgradeScheme": "0xFCa8D6bc11803F2EDd6f540a302A8f70d9deCD37", + "GlobalConstraintRegistrar": "0x0DaC9B02E8c9eF1D05e628203358731e04f9805b", + "ContributionReward": "0x9a57409455F676f0f5Ff165512340F7fc8C5234f", + "AbsoluteVote": "0xd4f4671cFf15358a5A7EC330d5e6AE20B348A2F8", + "QuorumVote": "0x6df62D9FF648875bB4fAd50115C356Ac4C79a0cf", + "TokenCapGC": "0xe932873A917DccfFAb76b8A7bB3514a8F2A22318", + "VoteInOrganizationScheme": "0xF43a07d42fF2073D01B15fa3a08EAC89ED52d551", + "OrganizationRegister": "0x13d19581f588990baf7226C662102d75a70d3492", + "Redeemer": "0xE84Bf11b614917754d0677ADe80AE3770BAB897c", + "GenericSchemeMultiCallFactory": "0xAf9eb2F8fb85191e387F42aFC8cE4cBE22Bfe77C" + } + }, + "dao": { + "0.0.1-rc.51": { + "name": "Pendulous Salad", + "Avatar": "0x47A2Fa69722DDD2e7617167ce7e572139A29E3E5", + "DAOToken": "0x01ce0C8F708be2441E4e7b5e80B08E77084b2dEa", + "Reputation": "0xaFa8e818c13465863a6596eeE08E6928DC9c5E72", + "Controller": "0x9CF30ddAc33408d9DB6Ac23a77da7299B6F3105b", + "Schemes": [ + { + "name": "GenericScheme", + "alias": "GenericSchemeAlias", + "address": "0xA73E74bBc384B237E7B7fEA4D76D18c8a37ED608", + "arcVersion": "0.0.1-rc.51" + }, + { + "name": "ContributionRewardExt", + "alias": "ContributionRewardExt", + "address": "0x2Ea0BE07DFC0357F40884365F2C9cFD2A36D4a6E", + "arcVersion": "0.0.1-rc.43" + }, + { + "name": "GenericSchemeMultiCall", + "alias": "GenericSchemeMultiCall", + "address": "0x8e8a12588d14E17D710F323999Cc8C2F15257c0B", + "arcVersion": "0.0.1-rc.51" + } + ], + "StandAloneContracts": [ + { + "name": "Wallet", + "address": "0x9d592E592c0C44A8075215b94b986F617a8A6229", + "arcVersion": "0.0.1-rc.51" + }, + { + "name": "ContributionRewardExt", + "address": "0x2Ea0BE07DFC0357F40884365F2C9cFD2A36D4a6E", + "arcVersion": "0.0.1-rc.43" + }, + { + "name": "Competition", + "address": "0xe46a36BF47864F8cc8eA8A668653bcc43FA7E601", + "arcVersion": "0.0.1-rc.43" + }, + { + "name": "GenericSchemeMultiCall", + "address": "0x8e8a12588d14E17D710F323999Cc8C2F15257c0B", + "arcVersion": "0.0.1-rc.51" + }, + { + "name": "ActionMock", + "address": "0xc72e85debf6e663B3Ae8EDB631AA7d982D892f6b", + "arcVersion": "0.0.1-rc.51" + }, + { + "name": "DxDaoSchemeConstraints", + "address": "0x9b1780385602Ab43Dd60aA6f568253809cB63eF3", + "arcVersion": "0.0.1-rc.51" + } + ], + "arcVersion": "0.0.1-rc.51" + } + } } } \ No newline at end of file diff --git a/utils.js b/utils.js index af1ca8a0..d1d1ae04 100644 --- a/utils.js +++ b/utils.js @@ -29,3 +29,21 @@ exports.importAbi = function (abiPath) { } return abi } + +const ARBITIUM_CHAIN_ID = 152709604825713 +exports.getNetworkName = async function (web3) { + if (await web3.eth.net.getId() === ARBITIUM_CHAIN_ID) { + return 'arbitium' + } + let network = await web3.eth.net.getNetworkType() + if (network === 'private') { + if (await web3.eth.net.getId() === 100) { + network = 'xdai' + } else if (await web3.eth.net.getId() === 77) { + network = 'sokol' + } else if (await web3.eth.net.getId() === ARBITIUM_CHAIN_ID) { + network = 'arbitium' + } + } + return network; +} From 858ea2c078b7202f705b59bebeecf140d06973ff Mon Sep 17 00:00:00 2001 From: Oren Sokolowsky Date: Thu, 26 Nov 2020 10:31:43 +0200 Subject: [PATCH 2/3] test net v2 --- migrate.js | 2 +- migration.json | 4 ++-- utils.js | 8 +++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/migrate.js b/migrate.js index d99cdc01..1f7a023d 100755 --- a/migrate.js +++ b/migrate.js @@ -186,7 +186,7 @@ const wrapCommand = fn => async options => { spinner.start(msg) let gas = 0 let nonce = await web3.eth.getTransactionCount(web3.eth.defaultAccount) - if (utils.getNetworkName() !== 'arbitium') { + if (utils.getNetworkName() !== 'arbitium_testnet_v2') { const blockLimit = await web3.eth.getBlock('latest').gasLimit try { gas = (await tx.estimateGas()) diff --git a/migration.json b/migration.json index 8c6f7894..68d00d24 100644 --- a/migration.json +++ b/migration.json @@ -5435,7 +5435,7 @@ } } }, - "arbitium": { + "arbitium_testnet_v2": { "base": { "0.0.1-rc.51": { "GEN": "0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf", @@ -5520,4 +5520,4 @@ } } } -} \ No newline at end of file +} diff --git a/utils.js b/utils.js index d1d1ae04..076e86b8 100644 --- a/utils.js +++ b/utils.js @@ -30,10 +30,10 @@ exports.importAbi = function (abiPath) { return abi } -const ARBITIUM_CHAIN_ID = 152709604825713 +const ARBITIUM_TESTNET_V2_CHAIN_ID = 152709604825713 exports.getNetworkName = async function (web3) { - if (await web3.eth.net.getId() === ARBITIUM_CHAIN_ID) { - return 'arbitium' + if (await web3.eth.net.getId() === ARBITIUM_TESTNET_V2_CHAIN_ID) { + return 'arbitium_testnet_v2' } let network = await web3.eth.net.getNetworkType() if (network === 'private') { @@ -41,8 +41,6 @@ exports.getNetworkName = async function (web3) { network = 'xdai' } else if (await web3.eth.net.getId() === 77) { network = 'sokol' - } else if (await web3.eth.net.getId() === ARBITIUM_CHAIN_ID) { - network = 'arbitium' } } return network; From bdedb7d1024ff7af4cbfc668f590f0ed26be0e05 Mon Sep 17 00:00:00 2001 From: Oren Sokolowsky Date: Thu, 26 Nov 2020 10:37:05 +0200 Subject: [PATCH 3/3] lint --- migrate.js | 17 ++++++++--------- utils.js | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/migrate.js b/migrate.js index 1f7a023d..a378ba7f 100755 --- a/migrate.js +++ b/migrate.js @@ -106,7 +106,6 @@ const wrapCommand = fn => async options => { // default opts for web3 const block = await web3.eth.getBlock('latest') - //console.log("await web3.eth.getBlock('latest')",await web3.eth.getBlock('latest')) const opts = { from: web3.eth.defaultAccount, gas: block.gasLimit - 100000, @@ -187,15 +186,15 @@ const wrapCommand = fn => async options => { let gas = 0 let nonce = await web3.eth.getTransactionCount(web3.eth.defaultAccount) if (utils.getNetworkName() !== 'arbitium_testnet_v2') { - const blockLimit = await web3.eth.getBlock('latest').gasLimit - try { - gas = (await tx.estimateGas()) - if (gas * 1.1 < blockLimit - 100000) { - gas *= 1.1 - } - } catch (error) { - gas = blockLimit - 100000 + const blockLimit = await web3.eth.getBlock('latest').gasLimit + try { + gas = (await tx.estimateGas()) + if (gas * 1.1 < blockLimit - 100000) { + gas *= 1.1 } + } catch (error) { + gas = blockLimit - 100000 + } } let result = tx.send({ gas, nonce }) let receipt = await new Promise(resolve => result.on('receipt', resolve).on('error', async error => { diff --git a/utils.js b/utils.js index 076e86b8..eb5f9cca 100644 --- a/utils.js +++ b/utils.js @@ -30,10 +30,10 @@ exports.importAbi = function (abiPath) { return abi } -const ARBITIUM_TESTNET_V2_CHAIN_ID = 152709604825713 +const ARBITIUM_TESTNET_V2_CHAIN_ID = 152709604825713 // https://kovan2.arbitrum.io/rpc exports.getNetworkName = async function (web3) { if (await web3.eth.net.getId() === ARBITIUM_TESTNET_V2_CHAIN_ID) { - return 'arbitium_testnet_v2' + return 'arbitium_testnet_v2' } let network = await web3.eth.net.getNetworkType() if (network === 'private') { @@ -43,5 +43,5 @@ exports.getNetworkName = async function (web3) { network = 'sokol' } } - return network; + return network }