HiveSQL - Dynamic Global Properties

@geekgirl
9 mo (edited)
3 Min Read
675 words

hivesql.png

Let's try to understand what Hive dynamic global properties are. According to Hive Developer Portal:

Dynamic Global Properties represent a set of values that are calculated during normal chain operations and reflect the current values of global blockchain properties.

The API returns an object containing information that changes every block interval such as the head block number, the total vesting fund, etc.

Ok. So this is my understanding based on the above description.

  • These are values/properties that have to do with Hive blockchain itself as a whole, rather than individual accounts or transactions on the chain.
  • And these values more likely to change after each block production.
  • There is an API call that returns these values when needed.

Feel free to go to https://hivelibrarian.herokuapp.com/ and click "Get DGP" in dynamic global properties section to see what they are.

First, I tried to get these dynamic global properties using HiveSQL. Why? Because I needed one or two of them in my code. About that in a little bit.

But then I also tried to get the same dynamic global properties using Beem and using Lighthive. I didn't get all identical results from them. And I don't mean identical values, I mean I didn't get same amount of properties returned.

Let's start with Lighthive.

from lighthive.client import Client
import pprint

client = Client()
props = client.get_dynamic_global_properties()
pprint.pprint(props)
print(len(props))

This returned 38 properties with their values.

Now let's try with Beem.

from beem import Hive
from beem.nodelist import NodeList
from beem.amount import Amount
import pprint
nodelist = NodeList()
nodelist.update_nodes()
nodes = nodelist.get_hive_nodes()
hive = Hive(node=nodes)

globalprops = hive.get_dynamic_global_properties()
count = 1
for prop in globalprops:
    print(count, prop, globalprops[prop])
    count +=1
print(count-1)

Beeem returned 39 properties with their values. It seems LightHive doesn't include id. Ok, I don't need id anyway.

But when we try to get the same dynamic global properties from HiveSQL we get 58 properties with values returned. Let's try.

import os
import pymssql
import datetime as dt
from pprint import pprint

def hive_sql(SQLCommand, limit):
    db = os.environ['HIVESQL'].split()
    conn = pymssql.connect(server=db[0], user=db[1], password=db[2], database=db[3])
    cursor = conn.cursor()
    cursor.execute(SQLCommand)
    result = cursor.fetchmany(limit)
    conn.close()
    return result

SQLCommand = '''
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'DynamicGlobalProperties'
'''
result = hive_sql(SQLCommand, 100)
col_names = []
for col_name in result:
    col_names.append(col_name[0])

SQLCommand = '''
SELECT *
FROM DynamicGlobalProperties
'''
result = hive_sql(SQLCommand, 100)
col_values = []
for col_value in result[0]:
    col_values.append(col_value)

dgp = dict(zip(col_names, col_values))

pprint(dgp)
print(len(dgp))

The returned results for dynamic global properties from HiveSQL are at the end of the post.

As I was trying to understand why HiveSQL returns more properties compared to Beem or LightHive, I noticed how HiveSQL splits some of the properties into two, especially to differentiate the asset names like Hive, HBD, and VESTS. That's kinda helpful. I like that.

However, that's not it. There are more properties that HiveSQL returns that do not appear on returned results from Beem and LightHive at all. These properties are:

  • hive_per_vest
  • smt_creation_fee
  • smt_creation_fee_symbol
  • price_hive_usd
  • price_hbd_usd
  • steem_per_vest
  • current_sbd_supply
  • current_sbd_supply_symbol
  • confidential_supply
  • confidentail_supply_symbol
  • confidential_hbd_supply

I don't know there is this discrepancy. But it a helpful discrepancy. Because I have been using hve_per_vest a lot to convert vests to hp. That is super helpful. I can also see price_hive_usd and price_hbd_usd to be really helpful.

I am assuming those referring to steem, sbd, and smts might be old column names. I don't know. If anybody can explain that will be great. Especially, please tell me what confidential_supply is? :)

Anyway, it is great to have easy access to these properties and values. You never know when you might need them. Now everybody can get them. Hive is not confidential. lol

One more thing.

Hive Developer Portal is still referring to assets as sbd and steem. That probably needs to be updated to HBD and Hive.

Here is the list of dynamic global properties and current values:

CountDynamic Global PropertiesValues
1ID0
2head_block_number51287980
3head_block_id030e97ac48953943476345f5f696f4769fd83405
4time2021-02-13 06:55:57
5current_witnesssomeguy123
6total_pow514415
7num_pow_witnesses172
8virtual_supply404250158.487
9virtual_supply_symbolHIVE
10current_supply383471109.892
11current_supply_symbolHIVE
12current_hbd_supply4571390.691
13current_hbd_supply_symbolHBD
14total_vesting_fund_hive143338347.811
15total_vesting_fund_hive_symbolHBD
16total_vesting_shares272575563468.187000
17total_vesting_shares_symbolVESTS
18total_reward_fund_hive0.000
19total_reward_fund_hive_symbolHBD
20total_reward_shares20
21pending_rewarded_vesting_shares776806579.051573
22pending_rewarded_vesting_shares_symbolVESTS
23pending_rewarded_vesting_hive394192.544
24pending_rewarded_vesting_hive_symbolHIVE
25hbd_interest_rate0
26hbd_print_rate10000
27maximum_block_size65536
28required_actions_partition_percent0
29current_aslot51454719
30recent_slots_filled340282366920938463463374607431768211455
31participation_count128
32last_irreversible_block_num51287965
33vote_power_reserve_rate10
34target_votes_per_period0
35delegation_return_period432000
36reverse_auction_seconds300
37available_account_subsidies21137701
38hbd_stop_percent1000
39hbd_start_percent900
40next_maintenance_time2021-02-13 07:29:45
41last_budget_time2021-02-13 06:29:45
42content_reward_percent6500
43vesting_reward_percent1500
44sps_fund_percent1000
45sps_interval_ledger33.995
46sps_interval_ledger_symbolHBD
47downvote_pool_percent2500
48hive_per_vest0.0005258664
49smt_creation_fee0.000
50smt_creation_fee_symbolHBD
51price_hive_usd0.24040000
52price_hbd_usd1.40700000
53steem_per_vest0.0005258664
54current_sbd_supply4571390.691
55current_sbd_supply_symbolSBD
56confidential_supply0.000
57confidential_supply_symbolHIVE
58confidential_hbd_supply0.000

Posted Using LeoFinance Beta