December 31, 2022

OKP4 analysis of the blockchain system related to validators

Introduction

In this article, I would like to find out how heavily loaded the network is with transactions. I think this is an important part and it will be useful to check how it will analyze the density and see how much the share is consumed.

Consider the current parameters in the okp4-nemeton-1 network

A block is formed approximately every 5-6 seconds. Based on this, we can roughly conclude that 15,000 blocks are formed per day.
This is not an exact figure, if you need more accurate numbers, use a different calculation formula.

Analysis and calculation

The Python function was written as a basis

def getTransactions(min_height, max_height):
    txs = 0    
    for i in range(min_height, max_height, 20):
        min = i        
        max = i+19        
        res = requests.get(f"http://65.109.27.156:29657/blockchain?minHeight={min}&maxHeight={max}")        
        data = res.json()        
        for block in data['result']['block_metas']:            
            num_txs = int(block['num_txs'])            
            txs += num_txs            
            print(block['header']['height'], num_txs)    
     return txs

It scans the blockchain and returns the number of transactions per block period.
I took five values ​​along the X axis:
A - about the first day
B - about the second day C - about the third day D - about the fourth day F - about the fifth day

Let's denote the block ranges for these values
A - (from 1 to 15000 block) B - (from 15000 to 30000 block) C - (from 30000 to 45000 block) D - (from 45000 to 60000 block) F - (from 60000 to 75000 block)

I will build a graph using the matplotlib library

Let's run the recorded script and see the result

From this graph, we can see that every day there are more and more transactions. From our analysis, most often we see transactions associated with the delegation and the removal of rewards from the validator.

Full code

from matplotlib import pyplot as plt
import requests

def getTransactions(min_height, max_height):    
txs = 0    
for i in range(min_height, max_height, 20):        
    min = i        
    max = i+19        
    res = requests.get(f"http://65.109.27.156:29657/blockchain?minHeight={min}&maxHeight={max}")        
    data = res.json()        
    for block in data['result']['block_metas']:            
        num_txs = int(block['num_txs'])            
        txs += num_txs            
        print(block['header']['height'], num_txs)    
    return txs

x = [1,2,3,4,5]
y = []

plt.title("count of transactions")
plt.ylabel('count')
plt.xlabel('days')

k = 15000
for i in x:    
    min_height = (i-1) * k   
    max_height = i * k    
    num_txs = getTransactions(min_height, max_height)    
    y.append(num_txs)

plt.plot(x, y)
plt.show()

Thanks for reading the article! I think this code will be useful for you

DragonDev is actively helping to contribute to the project. We help projects at the development stage: (in the development of the Cosmos SDK binary file, the organization of the testnet and also conduct stress tests on the blockchain and on the nodes with a validator).

Our characteristic skills:

- Assistance in organizing tesnets (creating dev applications)
- Development of dapps applications
- Highly resilient servers with protection against anti-ddos attacks.
- Own devops system to support your node ecosystems.

Group telegram: https://t.me/icodragondev
Validator: https://okp4.explorers.guru/validator/okp4valoper1mpqwnped27q2avlg60w3lz83ncsfhn4ranxxxm