Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
py-g1-migrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tools
py-g1-migrator
Commits
ed076808
Commit
ed076808
authored
2 years ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
WIP manage monetary mass mismatch
parent
3513a3f5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/functions.py
+27
-10
27 additions, 10 deletions
lib/functions.py
main.py
+3
-2
3 additions, 2 deletions
main.py
with
30 additions
and
12 deletions
lib/functions.py
+
27
−
10
View file @
ed076808
...
...
@@ -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
():
...
...
This diff is collapsed.
Click to expand it.
main.py
+
3
−
2
View file @
ed076808
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment