cosmos-sdk
cosmos-sdk copied to clipboard
bug(export): genesis.json shows some plain-text logs
@Pantani commented on Tue Sep 06 2022
Summary of Bug
Export genesis JSON from a local chain will add some log lines to the begging of the file.
Version
v7.0.3
Steps to Reproduce
- run a local chain
- stop the node
- export the genesis:
gaiad export --for-zero-height --height=5 > local-genesis.json
12:35PM INF asserting crisis invariants inv=1/13 module=x/crisis name=distribution/nonnegative-outstanding
12:35PM INF asserting crisis invariants inv=2/13 module=x/crisis name=distribution/can-withdraw
12:35PM INF asserting crisis invariants inv=3/13 module=x/crisis name=distribution/reference-count
12:35PM INF asserting crisis invariants inv=4/13 module=x/crisis name=distribution/module-account
12:35PM INF asserting crisis invariants inv=5/13 module=x/crisis name=liquidity/escrow-amount
12:35PM INF asserting crisis invariants inv=6/13 module=x/crisis name=bank/nonnegative-outstanding
12:35PM INF asserting crisis invariants inv=7/13 module=x/crisis name=bank/total-supply
12:35PM INF asserting crisis invariants inv=8/13 module=x/crisis name=gov/module-account
12:35PM INF asserting crisis invariants inv=9/13 module=x/crisis name=staking/module-accounts
12:35PM INF asserting crisis invariants inv=10/13 module=x/crisis name=staking/nonnegative-power
12:35PM INF asserting crisis invariants inv=11/13 module=x/crisis name=staking/positive-delegation
12:35PM INF asserting crisis invariants inv=12/13 module=x/crisis name=staking/delegator-shares
12:35PM INF asserting crisis invariants inv=13/13 module=x/crisis name=group/Group-TotalWeight
12:35PM INF asserted all invariants duration=2.899084 height=5 module=x/crisis
{"app_hash":"","app_state":{"auth":{"accounts":[{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"2","address":"cosmos1y2krvz7ex966mtlyf00s76a8d3l0xzhe7t4nk3","pub_key":null,"sequence":"0"}....
...
Solution
Remove the stdout from the context logger for the export command.
For Admin Use
- [ ] Not duplicate issue
- [ ] Appropriate labels applied
- [ ] Appropriate contributors tagged
- [ ] Contributor assigned/self-assigned
- [ ] Is a spike necessary to map out how the issue should be approached?
@okwme commented on Mon Sep 19 2022
could be related to this: https://github.com/cosmos/cosmos-sdk/issues/8498
Mhhh smells like a regression :/
It looks like crisis invariants are run on export, if you skip them does it fix the issue you are running into?
Either way, we should ensure the output goes to dev/null unless the invariants fail.
@alexanderbez What about writing genesis to a file instead of printing to stdout? We could add a flag like below.
Usage:
simd export [flags]
Flags:
--output string Output file path (default "./genesis.json")
Even if we eliminate invariants logs, simd export
has other info and warning messages printed to the stdout.
For example:
- https://github.com/cosmos/cosmos-sdk/blob/a3e1b99f6ad0d152551c336f4c963213b2a940e1/server/export.go#L47
- https://github.com/cosmos/cosmos-sdk/blob/a3e1b99f6ad0d152551c336f4c963213b2a940e1/baseapp/baseapp.go#L303
Is there an easy way to send info logs to /dev/null?
@jacobhjkim I'm in favor of that :)