Closed shanev closed 5 years ago
How do we fund module accounts / pools?
Questions:
A: must have module_name
and module_permissions
in genesis account
address: cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta
name: fee_collector
permissions: []
address: cosmos1ed82m7snyk8mux8xxpwygvtyq633a4k43rfp8l
name: user_reward_tokens_pool
permissions: []
GenesisAccount struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins" yaml:"coins"`
Sequence uint64 `json:"sequence_number" yaml:"sequence_number"`
AccountNumber uint64 `json:"account_number" yaml:"account_number"`
OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"`
DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"`
DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"`
StartTime int64 `json:"start_time" yaml:"start_time"`
EndTime int64 `json:"end_time" yaml:"end_time"`
ModuleName string `json:"module_name" yaml:"module_name"`
ModulePermissions []string `json:"module_permissions" yaml:"module_permissions"`
}
A module account address is the cosmos address generated by sdk.AccAddress(crypto.AddressHash([]byte(MODULE_ACCOUNT_NAME)))
New issue:
E[2019-09-25|18:14:20.594] WARNING: Attempt to allocate proposer rewards to unknown proposer . This should happen only if the proposer unbonded completely within a single block, which generally should not happen except in exceptional circumstances (or fuzz testing). We recommend you investigate immediately. module=x/distribution
validator address cosmosvaloper1em44grl9ylmmnwawwp5fjn079kesatwpl2hn74
panic: UnmarshalBinaryLengthPrefixed cannot decode empty bytes
Seems we need to run an actual tesnet for inflation to work. See how much we can fake out in genesis to make progress. Try with docker localnet.
Update: Works with local docker testnet with 4 validators
migrate genesis with beta clone:
"outstanding_rewards": null,
1000000000000tru
supply (A: because when starting from a clean chain, the only account is the reward_broker with 1000000000000tru
)genutils should be:
"genutil": {
"gentxs": null
},
panic: invariant broken: supply: total supply invariant
sum of accounts coins: 100000000tru
supply.Total: 253644628704484tru
CRITICAL please submit the following transaction:
tx crisis invariant-broken supply total-supply
Fix tests:
Fix initializing chain from scratch
Export is broken:
truchaind export > test.json
--- level 0 ---
2:48286["s/1,v208" .. "s/latest,v209"]
WARNING: State is not initialized. Returning genesis file.
Fixed: Bug in Cosmos: https://github.com/cosmos/cosmos-sdk/pull/5103/files#diff-bbb4aa0e4c30192fba47fc18e560af52R95
Error validating genesis: ERROR: error validating genesis file test.json: UnmarshalJSON cannot decode empty bytes
Iterating accounts to calculate supply is broken. Find out why it's blank:
panic: invariant broken: supply: total supply invariant
sum of accounts coins:
supply.Total: 253644628704484tru
CRITICAL please submit the following transaction:
tx crisis invariant-broken supply total-supply
A: Because Cosmos moved accounts to be under auth
. Added migration command to CLI.
How to migrate chain with data:
# run trustory migration
python3 github.com/TruStory/truchain/contrib/migration/16-token-inflation.py --exported-genesis ~/genesis.json > genesis2.json
# run cosmos migration
truchaind migrate v0.38 ~/genesis2.json > ~/genesis3.json
# remove old chain data
rm -rf ~/.truchaind
# init chain
truchaind init test
# copy genesis to home folder
cp genesis3.json ~/.truchaind/config/genesis.json
# add back validator
truchaind gentx --name reward_broker --home-client ~/.octopus
truchaind collect-gentxs
# start
truchaind start
Issue with migrating the latest data:
panic: invariant broken: staking: bonded and not bonded module account coins invariant
Pool's bonded tokens: 100000000
sum of bonded tokens: 0
not bonded token invariance:
Pool's not bonded tokens: 0
sum of not bonded tokens: 0
module accounts total (bonded + not bonded):
Module Accounts' tokens: 100000000
sum tokens: 0
CRITICAL please submit the following transaction:
tx crisis invariant-broken staking module-accounts
For some reason, the bonded tokens pool starts with 100000000 tru. Remove it from genesis and re-try.
Update: This fucks up the supply because it adds 100000000 to it. Figure out where this is happening.
Update: This is because there's delegated shares in the staking module.
Solution: Write a migration to change it to 0.
Use fund pools instead of registrar/reward broker and minting out of thin air:
Module account for stakes: