CodeChain Monitoring Bots

Seon Pyo Kim
CodeChain
Published in
5 min readMay 24, 2019

In order to maintain a healthy CodeChain community, there are surveillance bots that are not directly visible to the user but are active in various fields. In this post, I would like to introduce surveillance bots that are hard at work in places that are not seen.

Two Gray Bullet Security Cameras — Pexels

1. Block Generation Monitoring Bot

GoCryptobot — racing bot

The role of participating validating nodes is pivotal for maintaining a healthy CodeChain network running under the Tendermint consensus algorithm and continue block generation. The validating nodes propose blocks in turn, and other nodes thoroughly validate the proposed blocks and vote accordingly to confirm the block. If they do a sloppy validation job, the network will not be able to stay healthy. It is analogous to the principle where if the attendance rate of the members of the National Assembly is low, or if a member does not vote due to falling asleep during the meeting, policies cannot be properly proposed or decided upon.

The block generation monitoring bot exists to prevent this sort of casualty. This bot provides three types of notifications to the CodeChain team: When a notification is received, administrators would get to work and diagnose the situation.

The first type of notification would be sent when a new block isn’t received for over an hour. This means that the node that the bot is monitoring is not working and has come to a halt, and thus, an administrator must respond.

The second type is when `view` becomes high. `view` is a round of the Tendermint consensus, and if you do not reach an agreement,the `view` increases. Currently, it is set up so that a notification will be sent when `view` becomes higher than 3, but we plan on controlling this value flexibly depending on the situation.

The third situation is when a node is sleeping. A sleeping node signifies that the ticket corresponding to a precommit has not been received during the consensus phase. Not receiving a single ticket from one node does not trigger a notification because it may be due to transient network issues, but if a node does not send a ticket more than five times in a row, or when several nodes do not send a ticket at the same time, a notification is sent.

2. Indexer Monitoring Bot

GoCryptobot — auto transaction bot

Even if the voting process is seamless amongst the members of the parliament, the passed legislation’s contents must be well delivered to the people as well. Without this process, members of the general public will have no idea what was agreed upon. In Codechain, the “indexer” is responsible for providing information about which transactions are included in the block, and delivering them to the Explorer, which the user directly accesses.

No matter how seamless CodeChain’s block creation is, the information about the blocks can not be easily observed without an indexer. If new information is not updated on the Explorer, users will think that CodeChain has stopped due to an error. Therefore, the indexer must be monitored thoroughly. The indexer monitor bots make sure whether the indexer is alive and working well and are in sync with the CodeChain’s latest state and send three kinds of notifications:

First, it checks to see if the indexer is alive and if it stops, a notification is sent. In this situation, a common method is to send a `ping` to check if a response can be received. If the surveillance bots `ping ‘and there is no response, a notification is sent to let the administrator restart the indexer.

Second, a notification is sent if the difference between the block that is synchronized via the indexer and the latest block of the CodeChain node is large. If the CodeChain node is not able to synchronize blocks quickly to provide up-to-date information, then the user is likely to be confused as to whether the transaction he or she made has been successful. Thus, if the block number difference is larger than 50, it will send a notification.

Third, a notification is sent when the block number of the node receiving the block synchronization cannot be updated in the indexer. Even if the number of blocks synchronized in the node and the indexer is not different, the indexer will not be able to provide up-to-date information if the node on which the indexer is dependent upon is sleeping or if it’s not synchronized with the CodeChain network. Therefore, the indexer monitor bot can still notify the administrator in this case to help the node that the indexer relies on to be diagnosed quickly.

3. Fee Monitoring Bot

GoCryptobot — dragon bot

Representatives of the members of society who hold meetings, and the legislation that has been decided accordingly, receive the salary via taxes. If the taxes of the members are properly distributed, both the members and the representatives will be satisfied. Block chains are similar. Compensation schemes provide motivation for shareholders to own shares in CodeChain, and motivate validating nodes to vigorously validate blocks. If the compensation is not properly distributed, it will reduce the willingness of stakeholders and validating nodes to participate, and users will also be reluctant to pay commissions.

The fee monitoring bot examines the distribution of CodeChain Coin (CCC), which is the commission paid by users. While other surveillance bots monitor the operational status of the nodes, this bot monitors for bugs that may be inherent in the commission distribution system implemented in CodeChain. Since the dispensing system is directly connected to the coin, it is monitored by the fee monitoring bot.

CodeChain has a different minimum fee for each type of transaction. CodeChain aggregates all the types of transactions that are contained in a block and adds up the amounts that correspond to this minimum fee. The sum is distributed to them in proportion to the share weight of the shareholders, and the excess amount is distributed to the author of the block that created the block.

The fee tracking bots track each block in CodeChain to see if the commission is well distributed according to these rules, compare it with their own calculation system, and provide notifications when differences occur.

So far, we’ve looked at three types of bots that are working hard to maintain the well-being of CodeChain. All three of these monitoring bots work on the Corgi network, a test network of CodeChain. Before we patch the main network, we will diagnose and fix the problems first so that users can use CodeChain with confidence and trust. With the help of monitoring bots like these, CodeChain will continue to maintain a healthy blockchain network.

--

--