Algorithms, Blockchain and Cloud

How to Compute the Chain Age, Uptime and Downtime for Steem Blockchain?


Steem Blockchain has been running for a while, and how to compute the Chain Age, Uptime and Downtime? It is similar to compute the Uptime, Downtime or Fault Rate for a server/service.

There were a couple of times that Steem Chain was halted due to a bug on the chain. I remember that once it was due to a hard-fork when the New Resource Model was introduced to the Chain, and at that time, the Steem Chain halted for about 2-3 times within a couple days. Steem Inc was organizing the witnesses/developers to fix the bugs, and then restarted the chain several times during that few days.

The Blockchain halted (stop) twice in the past.

Steem Genesis Block and Time

This is known, and we should remember this: The Genesis Block (Block Number One) for Steem Blockchain is at 2016-03-24 16:05:00.

Time Needed Per Block Generated or Produced

We know on Steem Blockchain, it takes 3 seconds for a block to be produced by a elected witness (block producer). The Steem Blockchain utilizes the DPOS (Delegated Proof of Stakes) Consensus algorithm.

Latest Head Block and Time

We can use the Steem JS Library to query the latest head block on the steem blockchain, also we can get the timestamp of the block:

steem.api.getDynamicGlobalProperties(function(err, result) {
    var latestBlock = result.head_block_number;
    var latestBlockTime = result.time;
    console.log(`Latest Head Block on Steem Blockchain is ${latestBlock}.`);
    console.log(`Latest Head Block Timestamp on Steem Blockchain is ${latestBlockTime}.`);
}

Steem Blockchain Age

This is simple to compute, we can just calculate the seconds between two dates/timestamps: Genesis Block Time, and the Latest Block Time.

Where A is age (length in seconds), T is the timestamp for the head block, and T’ is the Genesis Block Time.

Javascript Function to Compute Seconds Between Two Date Strings

Here is the Javascript Function to Compute the Seconds Between Two Timestamps, in the format of “YYYY-MM-DD HH:MM:SS” UTC. For example: “2016-03-24 16:05:00”

function secondsBetweenDates(dateStr1, dateStr2) {
  const date1 = new Date(dateStr1);
  const date2 = new Date(dateStr2);
  // Get difference in milliseconds
  const diffMilliseconds = Math.abs(date2 - date1);
  // Convert to seconds
  const diffSeconds = diffMilliseconds / 1000;
  return diffSeconds;
}

With the seconds, we can easily convert to minutes, hours, days, months or even years!

Down Time of the Steem Blockchain

With the latest Block Number and the Time Needed Per Block (which is 3 seconds), we can compute the total number of time taken to generate all the blocks (head block number) – let it be t.

where B is the Latest Head Block.

Then we can compute the uptime easily by: where T is the Steem Blockchain Age.

The downtime equals . And the Fault Rate can be computed as percentage: .

Here is the Javascript to compute the downtime for the steem blockchain:

function compute_down_time_for_steem_blockchain(latestBlock, latestBlockTime) {
  latestBlockTime = latestBlockTime.replace("T", " ");
  const genesisBlockTime = "2016-03-24 16:05:00";
  const timePerBlock = 3;
  const secondsBetween = secondsBetweenDates(genesisBlockTime, latestBlockTime);
  const downTime = secondsBetween - (latestBlock * timePerBlock);
  return downTime;
}

Steem Blockchain Tool Update

I have now added these information based on the above methods in this post to the Steem Blockchain Overview and Statistics, so now you can view these realtime information (Uptime, Downtime, Chain Age) regarding the Steem Blockchain in this tool.

Steem Blockchain Facts: Uptime, Downtime and Chain Age.

Steem to the Moon🚀!

–EOF (The Ultimate Computing & Technology Blog) —

962 words
Last Post: How to Solve 403 Forbidden Error (Denied by Referer ACL) when Downloading Weibo Video?
Next Post: Learn to Manage Your MySQL Database with a Python Script

The Permanent URL is: How to Compute the Chain Age, Uptime and Downtime for Steem Blockchain? (AMP Version)

Exit mobile version