Detailed Technical Description of February 5th Upgrade

Christina Liu
OntologyNetwork
Published in
3 min readFeb 10, 2019

--

On February 5th, 2019,the Ontology team informed all nodes to start an urgent upgrade of the stake authorisation on the MainNet.You can read the announcement here.

There are two ways for a node to increase its stake value:

1. By increasing the initial stake of the node, which is InitPos;

2. By accepting authorized stakes from individuals, which is TotalPos.

The funds information authorized by each user to the node is stored in the user node table:

Fields starting with Withdraw are the refund lock process. After each round, the locked funds will move down one layer, and only the funds in WithdrawUnfreezePos can be withdrawn from the contract.

The logic code for stake authorizer’s fee sharing is:

validatePos is the user’s valid staking to the node, including the funds that are cancelled but still in the lockout period. totalPos is the total authorized stake of the node. totalAmount is the total compensation assigned to all authorizations to the node.

While increasing the node stake authorization function, we allow nodes to increase and decrease their InitPos, and the reduced InitPos cannot be less than the PromisePos (promised stake) of the node. PromisePos is currently the initial staking value when the node first passed the application process. Reducing InitPos involves the withdrawal of funds, which will go through the unlocking process. The reduced InitPos will be treated as the node’s own authorized staking, which will increase its unlocking funds.

As a result, the locked funds of the node generated by its reduced InitPos behavior will be added in the node owner’s validatePos, thus the node will receive compensation that should not be assigned, which causes a funds error and system exception.

Before the full function was released on the Ontology MainNet, a node added its InitPos, and then reduced its InitPos by not quitting the process of its own stake authorization and also entered the stake unlocking process. Since the entire stake unlocking process uses a unified withdrawal pathway to make sure for fund security and convenient reconciliation, part of the unlocking stake in the above process took part in the fee sharing process of the authorized staking. In order to avoid fund issues, the system throws an exception.

The detailed upgrade plan is as follows:

Without causing bifurcation, we modified the fee-sharing logic as planned, meaning the node owner will not be able to participate in the fee-sharing of stakes authorized by other authorizers. The code has been modified to the following:

During stake authorization, the node owner is prohibited from authorizing stakes to its own node. It can only increase the node staking value by increasing its InitPos. This also prevents the node from mitigating the punishment for malicious behavior by increasing the authorized stake instead of the InitPos.

--

--