Attention CyberWay validators: Need for HardFork

in #cyberway4 years ago (edited)

Dear CyberWay platform validators and users!

In the span of last week CyberWay blockchain development team has discovered unaccounted CYBER tokens in the amount of 429’498.7290 CYBER on the balance of the cyber.stake account. We found out and fixed the problem, but need CyberWay validators to update the software.

If you want to double-check the information you can perform the following queries in the Mongo DBMS on a server with CyberWay node.

View the staking amount of user balances:

db.getSiblingDB("CYBERWAY").stake_agent.aggregate([{"$group":{"_id":0, "total":{"$sum":"$balance"}}}])

The result you may get is:
{ "_id" : 0, "total" : NumberLong("1976178966366") }

View how many CYBER tokens were transferred to staking state by the users:

db.getSiblingDB("_CYBERWAY_cyber_token").accounts.find({"SERVICE.scope":"cyber.stake", "balance._sym":"CYBER"},{_id:0,"balance._amount":1})

The result you may get:
{ "balance" : { "_amount" : NumberLong("1980473953656") } }

  1. Accordingly, the difference between these two values ​​is:
    1980473953656 - 1976178966366 = 4294987290

  2. Given the accuracy of 4 digits of the CYBER token:
    429’498.7290 CYBER

Last week the team studied the issue of returning lost funds to the balances of the affected accounts. During the research, we were able to identify two reasons for that.

The first reason is the numerical overflow during the operation of downvoting a validator.

To fix this problem, the validators need to update the node code and make a full replay of the chain, starting from the very first block. After validators complete this procedure, CYBER 429’496,7296 will return to the balances of affected users.

The replay has a negative moment to it - if all network validators start doing it at the same time, then the chain will stop generating blocks. Therefore, we propose to update nodes in a round. We ask validators to let others know about the beginning and the end of the replay procedure in Validators’ channel.

To speed up the update procedure, CyberWay validators could use a quick recovery procedure from the dump state of the CyberWay blockchain, provided by CyberWay dev team:

https://download.cyberway.io/snapshot-v2.0.3-20191204.tgz

The second reason of the problem is a mismatch of behavior of cyber.stake contract with the node code. To prevent a possibility of recurrence, our dev team needs to update the cyber.stake contract.

Before updating the contract, validators are invited to remove the two-week restriction on transactions on behalf of the cyber@prods account.

429’496,7296 CYBER token need to be brought back from the cyber.stake account balance to their rightful owners. For this there is not only a need to update the software, but to sign the transactions to transfer funds from the cyber.stake account to the users balance. There are three such users:

Our dev team will create the appropriate proposal to complete the transfer operation.

Restore a node from a snapshot

A snapshot can be used to deploy the state of one node to another in the quickest way possible (only the deficient blocks will be synchronized from the network once the node starts). Please, note that creating and restoring a snapshot is now possible in manual mode only. It is worth paying special attention to the consistent state of the node and database data. To ensure the process efficiently, make sure to perform all the work strictly on a stopped node.

Perform the following steps in the following order to restore a state from a snapshot (the commands are written under the assumption that the image is in the snapshot-20191126 directory):

  1. Head over to the directory containing docker-compose.yml (this is the / var / lib / cyberway): cd / var / lib / cyberway directory by default)
  2. Pause the node: sudo docker-compose down -t 120
  3. Delete nodeos and mongo volumes: docker volume rm cyberway-nodeos-data cyberway-mongodb-data
  4. Make sure that docker volume ls volume is missing
  5. Create an empty volume for nodeos: sudo docker volume create cyberway-nodeos-data
  6. Create an empty volume for mongo: sudo docker volume create cyberway-mongodb-data
  7. Restore the nodeos image: sudo docker run --rm -ti -v readlink -f snapshot-20191126: / host: ro -v cyberway-nodeos-data: / data: rw cyberway / cyberway: v2.0.3 tar -xPvf / host / nodeos.tar
  8. Restore the mongo image: sudo docker run --rm -ti -v `readlink -f snapshot-20191126: / host: ro -v cyberway-mongodb-data: / data: rw cyberway / cyberway: v2.0.3 tar -xPvf / host /mongodb.tar

Then perform the following steps (the commands are concluded under the assumption that the image will be saved in the snapshot-20191126 directory) to obtain a snapshot:

  1. Enter the directory containing docker-compose.yml (this is the / var / lib / cyberway): cd / var / lib / cyberway directory by default)
  2. Pause the node: sudo docker-compose down -t 120
  3. Create a directory for saving images: mkdir snapshot-20191126
  4. Remove the nodeos image: sudo docker run --rm -ti -v readlink -f snapshot-20191126: / host: rw -v cyberway-nodeos-data: / data: ro cyberway / cyberway: v2.0.3 tar -cPvf / host / nodeos.tar / data
  5. Remove the mongo image: sudo docker run --rm -ti -v readlink -f snapshot-20191126: / host: rw -v cyberway-mongodb-data: / data: ro cyberway / cyberway: v2.0.3 tar -cPvf / host / mongodb.tar / data

We call all of our validators to attention when it comes to this HardFork. Please note: it’s important that the operation is performed in a sequence, not by multiple validators (all or various at once) so we kindly ask each validator to notify our dev team and other members of the CyberWay validator community to drop a short line to the chat: https://t.me/cyberway_validators both when initiating the process and straight after completing the HF. There’s no specific order needed, any top validator can be the first to start and any other can be the next to follow. HF has to be completed by 6 PM Moscow time tomorrow, December 5th in order to avoid any inconsistencies/discrepancies during the weekend.

Don't hesitate to join our community via:

Telegram:

Twitter:

We'll keep you updated over https://twitter.com/cyberwayio