Skip to content
Snippets Groups Projects
Commit ed076808 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

WIP manage monetary mass mismatch

parent 3513a3f5
Branches
No related tags found
No related merge requests found
......@@ -11,7 +11,8 @@ def get_wallets_data():
# Get wallets balances data
wallets_data = load_json_url("inputs/wallets.json")
wallets = {}
ignored_money = 0
total_money = 0 # counter
ignored_money = 0 # counter
for wallet in wallets_data:
balance = wallet["value"]["balance"]
if "&&" in wallet["key"]:
......@@ -33,12 +34,9 @@ def get_wallets_data():
continue
wallets.update({v1_pubkey_to_v2_address(pubkey): int(balance)})
total_money += balance
# add ignored money to treasury
# FIXME get treasury address
wallets["5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z"] = ignored_money
return wallets
return (wallets, total_money, ignored_money)
def get_membership_expiry():
"""get membership expiry from input file"""
......@@ -49,9 +47,8 @@ def get_membership_expiry():
membership_expiry[membership["key"]] = membership["value"][0]["expires_on"]
return membership_expiry
def get_identities_and_wallets(last_block_time, start_timestamp):
def get_identities_and_wallets(start_timestamp):
"""get identities with certifications and wallets with their balance
last_block_time is the time of the last exported block
start_timestamp is the timestamp of the v2 genesis
used to estimate cert expiration in number of blocks
"""
......@@ -59,9 +56,15 @@ def get_identities_and_wallets(last_block_time, start_timestamp):
blocs = {}
identity_names = {}
identities = {}
treasury = 0
# Get last block info
last_block = load_json_url("inputs/ud_value.json")[0]["value"]
initial_monetary_mass = last_block["mass"]
last_block_time = last_block["medianTime"]
# Get wallets data
wallets = get_wallets_data()
(wallets, total_money, ignored_money) = get_wallets_data()
# Get membership expiry
membership_expiry = get_membership_expiry()
# Get Dex idty data
......@@ -75,6 +78,20 @@ def get_identities_and_wallets(last_block_time, start_timestamp):
# Get custom identities
custom_identities = load_json("custom/identities.json")
# add ignored money to treasury and check initial monetary mass
treasury += ignored_money # add ignored money to treasury
wallet_sum = total_money + ignored_money
missing_money = initial_monetary_mass - wallet_sum
if missing_money != 0:
print(f"⚠️ initial monetary mass {initial_monetary_mass:,} does not equal wallet sum {wallet_sum:,}")
print(f"money on the wallets: {total_money:,}")
print(f"money from ignored sources: {ignored_money:,}")
print(f"missing money (added to treasury): {missing_money:,}")
# add missing money to treasury
treasury += missing_money
# FIXME get real treasury address
wallets["5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z"] = treasury
# TODO make sure that index respects order of arrival
# Get identities names by pubkey
for idty in idty_data:
......@@ -167,7 +184,7 @@ def get_identities_and_wallets(last_block_time, start_timestamp):
# add received certification to identity
identities[r_uid]["certs_received"][i_uid] = cert_expire_on
return [identities, wallets]
return (identities, wallets)
def get_smiths():
......
......@@ -52,7 +52,7 @@ LAST_BLOCK_TIME = last_block["medianTime"]
# Add identities bloc
print(" parse identities...")
(identities_wallets, other_wallets) = get_identities_and_wallets(LAST_BLOCK_TIME, start_timestamp)
(identities, other_wallets) = get_identities_and_wallets(start_timestamp)
# Add wallets bloc
print(" add simple wallets...")
......@@ -65,8 +65,9 @@ gtest_genesis = {
"smiths": smiths,
"technical_committee": technical_committee,
"sudo_key": sudo_key,
"identities": identities_wallets,
"identities": identities,
"wallets": other_wallets,
# "treasury": treasury, # would need to modify pallet treasury, adding it as an account instead
}
# Dump JSON to file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment