Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Update) Steps to deploy and migrate all upgradable contracts to the network #78

Closed
varasev opened this issue May 1, 2018 · 23 comments
Closed
Assignees
Milestone

Comments

@varasev
Copy link
Contributor

varasev commented May 1, 2018

The next steps need to be taken to update all contracts on the network after we finish making them upgradable and after security audit is done.

These steps are implemented inside scripts/migrate/migrateAll.js: https://github.com/varasev/poa-network-consensus-contracts/blob/master/scripts/migrate/migrateAll.js

  1. Deploy PoaNetworkConsensus contract with the current MoC and the current mining keys list in constructor.

  2. Deploy ProxyStorage contract and call its init method with PoaNetworkConsensus address as a parameter.

  3. Call PoaNetworkConsensus.setProxyStorage with the address of ProxyStorage as a parameter.

  4. Run scripts/migrate/migrateKeys.js. It will deploy and initialize KeysManager contract and migrate all keys from an old KeysManager contract.

  5. Run scripts/migrate/migrateVotings.js. It will deploy and initialize BallotsStorage, VotingToChangeKeys, VotingToChangeMinThreshold and VotingToChangeProxyAddress contracts and migrate all thresholds and ballots from old contracts.

  6. Deploy ValidatorMetadata.

  7. Call ProxyStorage.initializeAddresses method.

  8. Run scripts/migrate/migrateMetadataNew.js.

@varasev
Copy link
Contributor Author

varasev commented May 7, 2018

Code refactoring was done today: varasev@5f61157

All tests are successful: https://travis-ci.org/varasev/poa-network-consensus-contracts/builds/375967913

@igorbarinov
Copy link
Member

@varasev are we ready for the audit?

@varasev
Copy link
Contributor Author

varasev commented May 8, 2018

@igorbarinov not yet, but we're almost there. I need about two days to complete code tests (migrations, poa-dapps-voting and poa-test-setup). I'll let you know as soon as everything is ready.

@varasev
Copy link
Contributor Author

varasev commented May 8, 2018

@igorbarinov now everything is ready to start security audit in my repo: https://github.com/varasev/poa-network-consensus-contracts/tree/5f6115761d915252017e851c6fd841fb0d01724e

An actual tree for poa-test-setup in my repo is here (if needed): https://github.com/varasev/poa-test-setup/tree/8b976f11c2d8f046cadd7f415d45a8aea29594cb - all steps are successful.

@igorbarinov
Copy link
Member

auditors will fork the repo, it's better if they will fork out of poanetwork one. Let's organize it in a branch,

@varasev
Copy link
Contributor Author

varasev commented May 9, 2018

@igorbarinov ok, a new branch has been created in poanetwork's repo: https://github.com/poanetwork/poa-network-consensus-contracts/tree/security-audit

@varasev varasev changed the title (Feature) A preliminary plan to deploy all upgradable contracts to the network (Update) Steps to deploy all upgradable contracts to the network May 10, 2018
@varasev varasev changed the title (Update) Steps to deploy all upgradable contracts to the network (Update) Steps to deploy and migrate all upgradable contracts to the network May 10, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 11, 2018
@varasev
Copy link
Contributor Author

varasev commented May 11, 2018

The script for deployment and migration of all contracts is ready: https://github.com/varasev/poa-network-consensus-contracts/blob/a9119ab23cc86ba61c17a986264256391a6f7092/scripts/migrate/migrateAll.js

How to use it for the SOKOL network:

$ cd scripts/migrate
$ NETWORK=sokol node migrateAll

For the CORE network:

$ cd scripts/migrate
$ NETWORK=core node migrateAll

Here is the output after today's test run. It had been working for about 15 minutes:

$ cd scripts/migrate
$ NETWORK=sokol node migrateAll

Enter your private key: 

Retrieve addresses and ABIs...

PoaNetworkConsensus deploy and migration...
  PoaNetworkConsensus compile...
  PoaNetworkConsensus deploy...
  PoaNetworkConsensus address is 0x7dA6965c950f7cD83391Aa7d3212838392dF43B0
  PoaNetworkConsensus checking...
Success

ProxyStorage deploy and init...
  ProxyStorage compile...
  ProxyStorage deploy...
  ProxyStorage implementation address is 0xAcC60B58cb512Af7FC6118448A17ccbec24C81b9
  EternalStorageProxy compile...
  EternalStorageProxy deploy...
  ProxyStorage storage address is 0xa61BdB6dEC6921b9B65aA79C3c620A22962EA164
  ProxyStorage checking...
Success

Retrieve addresses and ABIs...

KeysManager migration...
  KeysManager compile...
  KeysManager deploy...
  KeysManager implementation address is 0x0F2C9D66063860B1BDbcD39b1A27D71CA257E576
  EternalStorageProxy compile...
  EternalStorageProxy deploy...
  KeysManager storage address is 0x46FA4a97A715B8FAC104D8D0256111Dc32f949B5
  Call init method...
  Migrate initial keys...
  Migrate each of 20 mining key(s)...
  Migrate 0xE8DDc5c7A2d2F0D7a9798459c0104fDf5E987ACA...
  Migrate 0x82e4e61e7f5139ff0a4157A5Bc687eF42294c248...
  Migrate 0x23468dB7f4b8Ff4924B0709aB7Ae0971B3Bc8d28...
  Migrate 0xA0B0D4cCF483b000F0aF59C47A1944668477b941...
  Migrate 0xe2ac1c6843A33f81aE4935E5EF1277a392990381...
  Migrate 0xde88a1a783b29a0b476BE28beEF38B4A85c0e024...
  Migrate 0x4E20226355b4464Cf8f3b67Fc318b753A7c125B3...
  Migrate 0xdb1207770E0a4258D7A4Ce49aB037f92564feA85...
  Migrate 0xeD2ACEb63Eb7928e67c854C24F61cF41db311c36...
  Migrate 0x4Ca0f1a7B5a2723A9094B7706BaA23C2B8BD46A0...
  Migrate 0x5B2cf18296B2ABf23288Ef2F9A09C6E1275311e5...
  Migrate 0x58baD7Cf29428c3D17Cb859f5C580D3C25F134CD...
  Migrate 0xcBbcd5Ac86F9a50e13313633B262e16f695a90c1...
  Migrate 0x0b55FdBa9e288C23cF3EB04c6f237D3bd0f751d6...
  Migrate 0x46bc76E617E72cE6658C199E222C07cBa2Fb5aEc...
  Migrate 0xf74769d9FFe1Cd17F20b283995CF9e7fA2A262ed...
  Migrate 0x063fE3bAFcf93D099dd7E09b3372641dc5E04e15...
  Migrate 0x7BD556B838a9E330a815a53EF39e04Ff2fDf2392...
  Migrate 0x706b85eA94221C5f0911a51aD0293e4bBf811C4E...
  Migrate 0xF168667104e8785Ad9C49dBf713e1AfDe250D6e5...
  Checking new contract...
  Check mining key 0xE8DDc5c7A2d2F0D7a9798459c0104fDf5E987ACA...
  Check mining key 0x82e4e61e7f5139ff0a4157A5Bc687eF42294c248...
  Check mining key 0x23468dB7f4b8Ff4924B0709aB7Ae0971B3Bc8d28...
  Check mining key 0xA0B0D4cCF483b000F0aF59C47A1944668477b941...
  Check mining key 0xe2ac1c6843A33f81aE4935E5EF1277a392990381...
  Check mining key 0xde88a1a783b29a0b476BE28beEF38B4A85c0e024...
  Check mining key 0x4E20226355b4464Cf8f3b67Fc318b753A7c125B3...
  Check mining key 0xdb1207770E0a4258D7A4Ce49aB037f92564feA85...
  Check mining key 0xeD2ACEb63Eb7928e67c854C24F61cF41db311c36...
  Check mining key 0x4Ca0f1a7B5a2723A9094B7706BaA23C2B8BD46A0...
  Check mining key 0x5B2cf18296B2ABf23288Ef2F9A09C6E1275311e5...
  Check mining key 0x58baD7Cf29428c3D17Cb859f5C580D3C25F134CD...
  Check mining key 0xcBbcd5Ac86F9a50e13313633B262e16f695a90c1...
  Check mining key 0x0b55FdBa9e288C23cF3EB04c6f237D3bd0f751d6...
  Check mining key 0x46bc76E617E72cE6658C199E222C07cBa2Fb5aEc...
  Check mining key 0xf74769d9FFe1Cd17F20b283995CF9e7fA2A262ed...
  Check mining key 0x063fE3bAFcf93D099dd7E09b3372641dc5E04e15...
  Check mining key 0x7BD556B838a9E330a815a53EF39e04Ff2fDf2392...
  Check mining key 0x706b85eA94221C5f0911a51aD0293e4bBf811C4E...
  Check mining key 0xF168667104e8785Ad9C49dBf713e1AfDe250D6e5...
Success

Retrieve addresses and ABIs...

BallotsStorage migration...
  BallotsStorage compile...
  BallotsStorage deploy...
  BallotsStorage implementation address is 0x7DED0F273D1395cea82Dcb6c3f42f57FE0F14f14
  EternalStorageProxy compile...
  EternalStorageProxy deploy...
  BallotsStorage storage address is 0xA6C5987e5f1049d9b92B6Eb803F46fCE8b855907
  Checking new contract...
Success

VotingToChangeKeys migration...
  VotingToChangeKeys compile...
  VotingToChangeKeys deploy...
  VotingToChangeKeys implementation address is 0xCB80b56DD55E737A87f61A2d60735D2464325471
  EternalStorageProxy compile...
  EternalStorageProxy deploy...
  VotingToChangeKeys storage address is 0x366aE96951Dc5F98205c3a80DC13ba92b5213eb0
  Read Vote event...
  Check totalVoters...
  Set miningByVoting...
  Call migrateBasicAll...
  Handle each of 48 ballot(s)...
  Migrate ballot #0...
  Migrate ballot #1...
  Migrate ballot #2...
  Migrate ballot #3...
  Migrate ballot #4...
  Migrate ballot #5...
  Migrate ballot #6...
  Migrate ballot #7...
  Migrate ballot #8...
  Migrate ballot #9...
  Migrate ballot #10...
  Migrate ballot #11...
  Migrate ballot #12...
  Migrate ballot #13...
  Migrate ballot #14...
  Migrate ballot #15...
  Migrate ballot #16...
  Migrate ballot #17...
  Migrate ballot #18...
  Migrate ballot #19...
  Migrate ballot #20...
  Migrate ballot #21...
  Migrate ballot #22...
  Migrate ballot #23...
  Migrate ballot #24...
  Migrate ballot #25...
  Migrate ballot #26...
  Migrate ballot #27...
  Migrate ballot #28...
  Migrate ballot #29...
  Migrate ballot #30...
  Migrate ballot #31...
  Migrate ballot #32...
  Migrate ballot #33...
  Migrate ballot #34...
  Migrate ballot #35...
  Migrate ballot #36...
  Migrate ballot #37...
  Migrate ballot #38...
  Migrate ballot #39...
  Migrate ballot #40...
  Migrate ballot #41...
  Migrate ballot #42...
  Migrate ballot #43...
  Migrate ballot #44...
  Migrate ballot #45...
  Migrate ballot #46...
  Migrate ballot #47...
  Disable migrations feature of the new contract...
  Checking new contract...
  Check ballot #0...
  Check ballot #1...
  Check ballot #2...
  Check ballot #3...
  Check ballot #4...
  Check ballot #5...
  Check ballot #6...
  Check ballot #7...
  Check ballot #8...
  Check ballot #9...
  Check ballot #10...
  Check ballot #11...
  Check ballot #12...
  Check ballot #13...
  Check ballot #14...
  Check ballot #15...
  Check ballot #16...
  Check ballot #17...
  Check ballot #18...
  Check ballot #19...
  Check ballot #20...
  Check ballot #21...
  Check ballot #22...
  Check ballot #23...
  Check ballot #24...
  Check ballot #25...
  Check ballot #26...
  Check ballot #27...
  Check ballot #28...
  Check ballot #29...
  Check ballot #30...
  Check ballot #31...
  Check ballot #32...
  Check ballot #33...
  Check ballot #34...
  Check ballot #35...
  Check ballot #36...
  Check ballot #37...
  Check ballot #38...
  Check ballot #39...
  Check ballot #40...
  Check ballot #41...
  Check ballot #42...
  Check ballot #43...
  Check ballot #44...
  Check ballot #45...
  Check ballot #46...
  Check ballot #47...
Success

VotingToChangeMinThreshold migration...
  VotingToChangeMinThreshold compile...
  VotingToChangeMinThreshold deploy...
  VotingToChangeMinThreshold implementation address is 0x7c6EDa56035Ce560CFB9bBc403f314E10595b359
  EternalStorageProxy compile...
  EternalStorageProxy deploy...
  VotingToChangeMinThreshold storage address is 0x3e3776B6458F04a56A25a87Ba7c6a2C0255CB5ec
  Read Vote event...
  Check totalVoters...
  Set miningByVoting...
  Call migrateBasicAll...
  Handle each of 3 ballot(s)...
  Migrate ballot #0...
  Migrate ballot #1...
  Migrate ballot #2...
  Disable migrations feature of the new contract...
  Checking new contract...
  Check ballot #0...
  Check ballot #1...
  Check ballot #2...
Success

VotingToChangeProxyAddress migration...
  VotingToChangeProxyAddress compile...
  VotingToChangeProxyAddress deploy...
  VotingToChangeProxyAddress implementation address is 0x8843c11C54525aa9850c80e450C0F7557608d20C
  EternalStorageProxy compile...
  EternalStorageProxy deploy...
  VotingToChangeProxyAddress storage address is 0x694fF688Df5Def21b959d1e942eA56e7d5E7b145
  Read Vote event...
  Check totalVoters...
  Set miningByVoting...
  Call migrateBasicAll...
  Handle each of 1 ballot(s)...
  Migrate ballot #0...
  Disable migrations feature of the new contract...
  Checking new contract...
  Check ballot #0...
Success

Deploy ValidatorMetadata...
  ValidatorMetadata compile...
  ValidatorMetadata deploy...
  ValidatorMetadata implementation address is 0xfD504D8F6854931547f821F56B421D5B32389749
  EternalStorageProxy compile...
  EternalStorageProxy deploy...
  ValidatorMetadata storage address is 0xEeD5D137A7de728cb29Db16f4c7bA4Ae1C80E2B6
Success

ProxyStorage.initializeAddresses...
Success

Retrieve addresses and ABIs...

ValidatorMetadata migration...
  ValidatorMetadata compile...
  ValidatorMetadata storage address is 0xEeD5D137A7de728cb29Db16f4c7bA4Ae1C80E2B6
  Handle each of 20 validator(s)...
  Migrate 0xE8DDc5c7A2d2F0D7a9798459c0104fDf5E987ACA...
  Migrate 0x82e4e61e7f5139ff0a4157A5Bc687eF42294c248...
  Migrate 0x23468dB7f4b8Ff4924B0709aB7Ae0971B3Bc8d28...
  Migrate 0xA0B0D4cCF483b000F0aF59C47A1944668477b941...
  Migrate 0xe2ac1c6843A33f81aE4935E5EF1277a392990381...
  Migrate 0xde88a1a783b29a0b476BE28beEF38B4A85c0e024...
  Migrate 0x4E20226355b4464Cf8f3b67Fc318b753A7c125B3...
  Migrate 0xdb1207770E0a4258D7A4Ce49aB037f92564feA85...
  Migrate 0xeD2ACEb63Eb7928e67c854C24F61cF41db311c36...
  Migrate 0x4Ca0f1a7B5a2723A9094B7706BaA23C2B8BD46A0...
  Migrate 0x5B2cf18296B2ABf23288Ef2F9A09C6E1275311e5...
  Migrate 0x58baD7Cf29428c3D17Cb859f5C580D3C25F134CD...
  Migrate 0xcBbcd5Ac86F9a50e13313633B262e16f695a90c1...
  Migrate 0x0b55FdBa9e288C23cF3EB04c6f237D3bd0f751d6...
  Migrate 0x46bc76E617E72cE6658C199E222C07cBa2Fb5aEc...
  Migrate 0xf74769d9FFe1Cd17F20b283995CF9e7fA2A262ed...
  Migrate 0x063fE3bAFcf93D099dd7E09b3372641dc5E04e15...
  Migrate 0x7BD556B838a9E330a815a53EF39e04Ff2fDf2392...
  Migrate 0x706b85eA94221C5f0911a51aD0293e4bBf811C4E...
  Migrate 0xF168667104e8785Ad9C49dBf713e1AfDe250D6e5...
  Disable migrations feature of the new contract...
  Checking new contract...
  Check 0xE8DDc5c7A2d2F0D7a9798459c0104fDf5E987ACA...
  Check 0x82e4e61e7f5139ff0a4157A5Bc687eF42294c248...
  Check 0x23468dB7f4b8Ff4924B0709aB7Ae0971B3Bc8d28...
  Check 0xA0B0D4cCF483b000F0aF59C47A1944668477b941...
  Check 0xe2ac1c6843A33f81aE4935E5EF1277a392990381...
  Check 0xde88a1a783b29a0b476BE28beEF38B4A85c0e024...
  Check 0x4E20226355b4464Cf8f3b67Fc318b753A7c125B3...
  Check 0xdb1207770E0a4258D7A4Ce49aB037f92564feA85...
  Check 0xeD2ACEb63Eb7928e67c854C24F61cF41db311c36...
  Check 0x4Ca0f1a7B5a2723A9094B7706BaA23C2B8BD46A0...
  Check 0x5B2cf18296B2ABf23288Ef2F9A09C6E1275311e5...
  Check 0x58baD7Cf29428c3D17Cb859f5C580D3C25F134CD...
  Check 0xcBbcd5Ac86F9a50e13313633B262e16f695a90c1...
  Check 0x0b55FdBa9e288C23cF3EB04c6f237D3bd0f751d6...
  Check 0x46bc76E617E72cE6658C199E222C07cBa2Fb5aEc...
  Check 0xf74769d9FFe1Cd17F20b283995CF9e7fA2A262ed...
  Check 0x063fE3bAFcf93D099dd7E09b3372641dc5E04e15...
  Check 0x7BD556B838a9E330a815a53EF39e04Ff2fDf2392...
  Check 0x706b85eA94221C5f0911a51aD0293e4bBf811C4E...
  Check 0xF168667104e8785Ad9C49dBf713e1AfDe250D6e5...
Success

Save contracts.json...
Success

Save ABIs...
Success

Deployment and migration to SOKOL network are successful.
New addresses have been saved to ./sokol/contracts.json
New ABIs have been saved to ./sokol/abis

@vbaranov
Copy link
Collaborator

@varasev do you plan to implement these comments poanetwork/RFC#14 (comment) before audit will start?

@varasev
Copy link
Contributor Author

varasev commented May 11, 2018

@vbaranov yes, I do, if the audit has not been started yet.

@igorbarinov I created security-audit branch two days ago: https://github.com/poanetwork/poa-network-consensus-contracts/tree/security-audit. Are the auditors ready to start?

@igorbarinov
Copy link
Member

@varasev yes, I sent it to two auditors. But they didn't start yet.
They need some time to allocate resources. I sent to :

@rstormsf will assist you with audits

@varasev
Copy link
Contributor Author

varasev commented May 11, 2018

@igorbarinov We conferred with @rstormsf and @vbaranov today and decided that it's better to make some code refactoring before an audit.

Can we start the audit a week later? I need a few days to complete working on EmissionFunds and VotingToManageEmissionFunds (without tests) and make refactoring of voting contracts code.

EmissionFunds and VotingToManageEmissionFunds contracts are part of the consensus, so it's better to include them in the audit too (without unit tests yet).

varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 14, 2018
@varasev
Copy link
Contributor Author

varasev commented May 14, 2018

VotingToChange* contracts were refactored today: varasev@17ee6ba

The current contracts' code can be viewed here: https://github.com/varasev/poa-network-consensus-contracts/tree/17ee6bad37e5f9a2f714457ac1747d460643d929/contracts

I'll change solidity version of all contracts to ^0.4.23 and test them a bit later.

@varasev varasev self-assigned this May 15, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 15, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 15, 2018
@varasev
Copy link
Contributor Author

varasev commented May 15, 2018

All contracts have been updated to solidity v0.4.23: varasev@9fef157

@vbaranov
Copy link
Collaborator

@varasev do Truffle tests work for refactored smart-contracts?

@varasev
Copy link
Contributor Author

varasev commented May 16, 2018

@vbaranov Yes, of course. The results of the tests: https://travis-ci.org/varasev/poa-network-consensus-contracts/builds/379172517

@vbaranov
Copy link
Collaborator

@varasev if it is ready, would you mind to update branch for audit with refactored contracts?

@varasev
Copy link
Contributor Author

varasev commented May 17, 2018

@vbaranov At the moment all contracts are ready for audit, except BlockReward. If this contract is not important for the upcoming audit, let me know, and I'll update the security-audit branch.

@vbaranov
Copy link
Collaborator

I guess the security audit will be started at the specific commit in audit branch. So, there is no problem to move refactored consensus contracts there now, if they are ready, and then add the update for BlockReward contract, when it will be ready.

varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
varasev added a commit to varasev/poa-network-consensus-contracts that referenced this issue May 17, 2018
@varasev
Copy link
Contributor Author

varasev commented May 17, 2018

OK, I've updated security-audit branch.

@vbaranov
Copy link
Collaborator

@varasev would you mind to eliminate solhint errors in refactored contracts?

@vbaranov vbaranov added this to the 2.0 milestone May 18, 2018
@vbaranov
Copy link
Collaborator

@varasev also, let's migrate from ethereumjs-testrpc@6.0.3 to the latest version of ganache-cli, because ethereumjs-testrpc has dependency with known vulnerability:

screen shot 2018-05-18 at 17 18 53

@vbaranov
Copy link
Collaborator

I will create separate issues. It is a mess here...

@varasev
Copy link
Contributor Author

varasev commented May 18, 2018

@vbaranov

would you mind to eliminate solhint errors in refactored contracts?

Yes, I've already checked them with solhint 1.1.10 before an upgrade to 0.4.23 and eliminated all errors which could be fixed. Let me know, please, if you see any errors that I might have missed.

also, let's migrate from ethereumjs-testrpc@6.0.3 to the latest version of ganache-cli, because ethereumjs-testrpc has dependency with known vulnerability

OK, it's already in my TODO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants