Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix v0.33.x export script to port gov data correctly #4163

Merged
merged 3 commits into from
Apr 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion contrib/export/v0.33.x-to-v0.34.0.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def process_raw_genesis(genesis, parsed_args):
},
}

# default tm value
# migrate governance state as the internal structure of proposals has changed
migrate_gov_data(genesis['app_state']['gov'])

# default Tendermint block time (ms)
genesis['consensus_params']['block']['time_iota_ms'] = '1000'

# proposal #1 updates
Expand All @@ -36,6 +39,36 @@ def process_raw_genesis(genesis, parsed_args):
return genesis


def migrate_gov_data(gov_data):
for p in gov_data['proposals']:
# get Amino type and value
t = p['type']
v = p['value']

del p['type']
del p['value']

assert t == 'gov/TextProposal', 'invalid proposal type: {t}'
assert p == {}, 'expected proposal to be empty after deleting contents'

p['proposal_content'] = {
'type': t,
'value': {
'title': v['title'],
'description': v['description']
}
}

p['proposal_id'] = v['proposal_id']
p['proposal_status'] = v['proposal_status']
p['final_tally_result'] = v['final_tally_result']
p['submit_time'] = v['submit_time']
p['deposit_end_time'] = v['deposit_end_time']
p['total_deposit'] = v['total_deposit']
p['voting_start_time'] = v['voting_start_time']
p['voting_end_time'] = v['voting_end_time']


if __name__ == '__main__':
parser = lib.init_default_argument_parser(
prog_desc='Convert genesis.json from v0.33.x to v0.34.0',
Expand Down