This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Bounty 7: Problem to solve, Observation and Proposals #28
Comments
piux2
changed the title
Bounty 7: Problem To Solve, Observations and Proposal
Bounty 7: Problem To solve, Observation and Proposals
Apr 16, 2022
piux2
changed the title
Bounty 7: Problem To solve, Observation and Proposals
Bounty 7: Problem to solve, Observation and Proposals
Apr 16, 2022
Jacob, @LL-Cosmo, Can we identify the ICF's and AIB's addresses here? What are their amounts? |
Also can somebody please write a short script to sum all the numbers, to verify against mintscan etc? |
AIB Mintscan
ICF MULTISIG 1 Mintscan
ICF MULTISIG 2 Mintscan
Source: |
Part 2 solution A is here https://github.com/piux2/gnobounty7/blob/main/README2.md The state data was exported at a height 7,368,387. 2021-08-20 08:58:06 Here is the merged results AIB
Multisig 1
Multisig2
To verify it, we need a RPC endpoint that can return balance and delegations state at a height 7368387
However, https://rpc.cosmos.network:443 does not have the state. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Problems to solve, Observation and Proposals
Part 1
Observation: Verified.
Proposal:
gaiad export --height will export state in json. It can be used as a genesis state to bootstrap a node.
I found an exported genesis state snapshot for Vega upgrade testnet.
https://github.com/cosmos/vega-test/blob/66e7ccf559998d48a5bd230a3e6146bed856a83b/public-testnet/README.md#genesis-file
https://github.com/cosmos/vega-test/blob/66e7ccf559998d48a5bd230a3e6146bed856a83b/exported_unmodified_genesis.json.gz
"genesis_time", 2019-12-11T16:11:34Z
"initial_height", 7,368,387
It was after the Delta (Gravity DEX) 13/07/21 6,910,000 cosmoshub-4 v0.34.x
Example to find balance on IBC
find all accounts with ibc balances
find accounts holding OSMO tokens
The token name and denom mapping can be found here token hub
To program fancy logic, we can use gojq
https://github.com/itchyny/gojq
Part 2
Observation:
we can get current snapshot balances of all accounts from the exported state.
OR an account's balances.
The exported state does not contain user transactions during a period of time
Same for the delegation, it has the current delegation state of each account without the delegation records.
There are 171,027 accounts with balances
There are 144,197 records in the delegations
Because delegated tokens are not part of the account balance, we will need to merge these two together to calculate how many tokens each account owns.
Proposal:
We have two options
[ A ] write a program that just merges the two files in on Json that include delegation share as the additional coin in app_state.bank.balances.coins[]
Since the dataset is not huge, we merge it in memory. We can sort delegations array by delegations.delegator_address and balances array by address first. We loop through both arrays and put the result in a merged array.
The time complexity is O(N log N) for quicksort, as the address is quite random, and O(N) for merging
The space complexity is O(log N) for quicksort and O(1) for merging
PROS: simple
CONS: not flexible. we have to modify the code and get additional insights into the data set.
RESULTS: Less than 3 seconds
Joined and Merged 300,587 Accounts and 144,197 Delegations and tallied staking shares for less than 3s.
real 0m2.437s
user 0m2.085s
sys 0m0.600s
Will publish the source code soon
[ B ] dump it to two tables in postgreSQL and write the go program to query the database.
Once we dump data in postgreSQL as balances_table and delegation_table. we joined two tables, and add atoms amount and shares amount to get the total atoms that each account owns.
PROS: a lot more flexible to run SQL against the data once it is imported into the database, especially when we want to retrieve other insights from the same dataset.
CONS: complicated to set up at the beginning.
For this part of the requirement, it is the same as getting the current balance of each account.
For this part of the requirement, it needs to calculate how many coins are added or removed from the account. Since the exported state file does not contains individual transactions. We can loop through send, delegation, and unbound messages from the state.db to a postgreSQL database and then query it.
part 3
Observations:
Votes from each account are not exported. Proposals only contain tallied results in the exported state file
Proposal:
We can loop through vote messages from state.db to a postgreSQL database and then query it.
The text was updated successfully, but these errors were encountered: