-
Notifications
You must be signed in to change notification settings - Fork 16
Slashing idle validators #13
Comments
SummaryAfter the end of the validation period, each validator checks other validators for the number of blocks they have processed in this last validation period. If the number of blocks is not enough and no one has sent a complaint about this idle validator yet, the validator creates a complaint. The validator also checks the submitted complaints and if they are valid and he has not yet voted for the fine of this idle validator during this validation period, he votes for the complaint. Since most of the network validators use mytonctrl, the functionality of creating a complaints (to fine idle validator) and voting for complaints was implemented in mytonctrl. The author of the algorithm and implementation is a igroman787. In the process of work mytonctrl does:
Implementation of detecting idle validators and checking complaints made in the lite-client, mytonctrl just calls these methods. Testing PeriodAt the beginning, the fine is reduced to 101 coins. This is done in order not to scare away validators during testing. The validator can be fined only once during the validation period. So in order to participate in the slashing process now, you need to use the last code from https://github.com/newton-blockchain/ton/ In the future, the fine will be returned to significant values. Detailed description of the algorithm0. Time to check, create and vote a complaintWe can create a complaint only at a certain period of time, when the elector has frozen the validators' stakes. We will take the time intervals from network config 15:
Here we are interested in the We also need the
So in our example, we can check the work of the validator, create a complaint and vote for it from 05.04.21 03:05:28 to 05.04.21 12:11:36 (UTC). 1.1. Checking the work quality of the validatorsWe will check the work of the validators with the
Here we can see that 5 validators were found that worked poorly. 5 log files were created for these validators. We will need them in the next paragraph to create a complaint. 1.2. Checking that the complaint does not exist yetBefore creating a complaint, we need to check that this complaint does not exist yet in network. Otherwise, our complaint will not make sense and we will waste our coins. We will check by calling the elector method
We can transform the received data into a more readable form. The conversion code in python3 can be viewed here (https://github.com/igroman787/mytonctrl/blob/6873aef03cefdf9ef54f204ffe20a1e0ad617d38/mytoncore.py#L1723). Another option would be to convert the validator pubkey to a number (hex2dec):
We see that a complaint has not yet been created for the last idle validator. For this last validator we will create a complaint. 1.3. Creating a complaintTo create a complaint, we will use the fift script
Here we got the 1.4. Signing a complaint by a walletWe sign the file with the complaint
Where 3815 is seqno, you can get it by running the command 1.5. Submitting a complaint to the network
2.1. Checking an existing complaintTo punish an idle validator, we need to collect 2/3 of the votes of all validators.
Here we got the complaint files for each validator. Let's check them with the
Here lite-client advises us to vote on the complaint. Let's check other complaints in the same way. We also need to check that we have not already voted on any complaint for this validator (identified by the public key) during this given validation period. We must do this check so as not to fine the validator more than once during the validation period. 2.2. Vote on complaintAfter checking the complaint, we must vote for it. Create a file for voting with the command
Here we are interested in the field 56744350001960697E786275F0A1EF13D0026AB9326E18C34D58637A381E4FED6A8705DA3600915D2AA8. We will need it further. 2.3. Getting a validator keyFor the next point, we need a validator key, we will take it from the validator configuration file (/var/ton-work/db/config.json). We are interested in the validators section:
Here we see two sections. We need to select the one that is currently relevant. For example now unixtimestamp = 1617644084. So we need the first section (1617591928 < 1617644084 < 1617657764). 2.4. Getting the signature of the validatorNext, we need to get the signature of the validator with the
2.5. Getting the public key of the validatorFor the next point, we need validator_pubkey. We will get it with the
2.6. Adding a validator signature to your voteThe next step is to add the validator signature to the message with our vote with the
2.7. Signing vote by walletWe sign the file with our vote with the
2.8. Sending vote to the network
|
Validators who do not use mytonctrl need to create their own scripts that implement the algorithm for voting for complaintsSince 2/3 votes are needed to accept a complaint, it is necessary that all validators vote and vote according to the same rules. The process of creating a complaint can be left to validators who use mytonctrl. Validators who do not use mytonctrl need to create their own scripts that implement the algorithm for voting for complaints as detailed in #13 (comment): After end of validation period while the stakes are still holding (paragraph 0):
You need to use the last code from https://github.com/newton-blockchain/ton/ so that the amount of the fine does not differ. |
https://github.com/newton-blockchain/punisher/ - script for those validators that do not use mytonctrl for some reason. This script implements receiving complaints about idle or cheating validators, checking complaints and voting for complaints to fine such validators. If you are using mytonctrl (recommended) you do not need to use this script, as the complete slashing process is already built into mytonctrl. Note that identifying idle or cheating validators and submitting a complaint for such validators is not implemented in the script and it is assumed that this is done by validators using mytonctrl This single file script has no dependencies and can be easily reviewed. |
Complete slashing of idle validators.
Initially mytonctrl will act as a panisher.
The text was updated successfully, but these errors were encountered: