Holger avatar

Verify blocktivity numbers for Hive and Blurt

holger80

Published: 20 Dec 2020 › Updated: 20 Dec 2020Verify blocktivity numbers for Hive and Blurt

Verify blocktivity numbers for Hive and Blurt

therealwolf@therealwolf was wondering on twitter on the high activity numbers on blocktivity.info for blurt:

The stats can be seen here:

blocktivity on 20.12.2020

Lets validate them using beem.
I added the script also to my beem github: blockactivity.py.

import sys
from datetime import datetime, timedelta
import argparse
from timeit import default_timer as timer
import logging
from beem.blockchain import Blockchain
from beem.block import Block
from beem import Hive, Blurt, Steem
from beem.utils import parse_time
from beem.nodelist import NodeList

log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)


def parse_args(args=None):
    d = 'Verify blocktivity by counting operations and trx for the last 24 hours.'
    parser = argparse.ArgumentParser(description=d)
    parser.add_argument('blockchain', type=str, nargs='?',
                        default=sys.stdin,
                        help='Blockchain (hive, blurt or steem)')
    return parser.parse_args(args)


def main(args=None):
    
    args = parse_args(args)
    blockchain = args.blockchain
    
    nodelist = NodeList()
    
    if blockchain == "hive" or blockchain is None:
        max_batch_size = 50
        threading = False
        thread_num = 16
        block_debug = 1000
        nodes = nodelist.get_hive_nodes()
        blk_inst = Hive(node=nodes, num_retries=3, num_retries_call=3, timeout=30)
    elif blockchain == "blurt":
        max_batch_size = None
        threading = False
        thread_num = 8
        block_debug = 20
        nodes = ["https://api.blurt.blog", "https://rpc.blurtworld.com", "https://rpc.blurtworld.com"]
        blk_inst = Blurt(node=nodes, num_retries=3, num_retries_call=3, timeout=30)
    elif blockchain == "steem":
        max_batch_size = 50
        threading = False
        thread_num = 16
        block_debug = 1000
        nodes = nodelist.get_steem_nodes()
        blk_inst = Steem(node=nodes, num_retries=3, num_retries_call=3, timeout=30)
    else:
        raise Exception("Wrong parameter, can be hive, blurt or steem")
    print(blk_inst)
    block_count = 0
    total_ops = 0
    total_trx = 0
    blocksperday = 20 * 60 * 24
    
    blockchain = Blockchain(blockchain_instance=blk_inst)
    last_block_id = blockchain.get_current_block_num() - blocksperday

    last_block = Block(last_block_id, blockchain_instance=blk_inst)

    stopTime = last_block.time() + timedelta(seconds=60 * 60 * 24)

    start = timer()
    for entry in blockchain.blocks(start=last_block_id, max_batch_size=max_batch_size, threading=threading, thread_num=thread_num):
        block_count += 1
        if "block" in entry:
            trxs = entry["block"]["transactions"]
        else:
            trxs = entry["transactions"]
        for tx in trxs:
            total_trx += 1
            for op in tx["operations"]:
                total_ops += 1
        if "block" in entry:
            block_time = parse_time(entry["block"]["timestamp"])
        else:
            block_time = entry["timestamp"]
        ops_per_day = total_ops / block_count * blocksperday
        if block_count % (block_debug) == 0:
            print("%d blocks remaining... estimated ops per day: %.1f" % (blocksperday - block_count, ops_per_day))
        if block_time > stopTime:
            break
    duration = timer() - start
    print("Received %.2f blocks/s." % (block_count / duration))
    print("Bocks: %d, duration %.3f s" % (block_count, duration))
    print("Operations per day: %d" % total_ops)
    print("Trx per day: %d" % total_trx)

if __name__ == '__main__':
    sys.exit(main())

Just save the script as blocktivity.py and call it with the blockchain name (can be hive, steem or blurt).

Checking the blockchain activity

I started the script in three terminals to check the activity on hive, steem and blurt:

python3 blocktivity.py hive
python3 blocktivity.py steem
python3 blocktivity.py blurt

Results

The following table shows the obtained:

HiveSteemBlurt
Blocks287562846628634
Duration128.855117.7128016.021
Blocks/s223.17241.833.57
Trx8839291958926942
Ops8948562009687461
Ratio of Trx to Bitcion Trx0.980.2210.008

Hive

It seems that the activity shown at https://blocktivity.info/ counted every operation twice or it sums up the activity for 48 hours.

The block count reaches 99.84% of the maximum block count 28800.

Steem

The block count reaches 98.84% of the maximum block count 28800.

Blurt

The speed for receiving blocks from the API is really slow, it took 62 times longer as on hive.

The shown activity numbers are completely wrong. 549405 operations are reached in around 74 days and not in 24 hours.

The block count reaches 99.42% of the maximum block count 28800.

It seems that the bug was already found and will be fixed soon:


If you like what I do, consider casting a vote for me as witness on Hivesigner or on PeakD

Leave Verify blocktivity numbers for Hive and Blurt to:

Written by

beem Developer, Hive Witness, beempy.com, rewarding.app

Read more #blocktivity posts


Best Posts From Holger

We have not curated any of holger80's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Holger