-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR #4023: Genesis port script v0.33.x to v0.34.0
- Loading branch information
1 parent
576eb51
commit bec4689
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
*.swn | ||
.vscode | ||
.idea | ||
*.pyc | ||
|
||
# Build | ||
vendor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#4018 create genesis port script for release v.0.34.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import json | ||
import sys | ||
|
||
|
||
def init_default_argument_parser(prog_desc, default_chain_id, default_start_time): | ||
parser = argparse.ArgumentParser(description=prog_desc) | ||
parser.add_argument( | ||
'exported_genesis', | ||
help='exported genesis.json file', | ||
type=argparse.FileType('r'), default=sys.stdin, | ||
) | ||
parser.add_argument('--chain-id', type=str, default=default_chain_id) | ||
parser.add_argument('--start-time', type=str, default=default_start_time) | ||
return parser | ||
|
||
|
||
def main(argument_parser, process_genesis_func): | ||
args = argument_parser.parse_args() | ||
if args.chain_id.strip() == '': | ||
sys.exit('chain-id required') | ||
|
||
genesis = json.loads(args.exported_genesis.read()) | ||
|
||
print(json.dumps(process_genesis_func( | ||
genesis=genesis, parsed_args=args,), indent=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import lib | ||
|
||
|
||
def process_raw_genesis(genesis, parsed_args): | ||
# update genesis with breaking changes | ||
genesis['consensus_params']['block'] = genesis['consensus_params']['block_size'] | ||
del genesis['consensus_params']['block_size'] | ||
|
||
genesis['app_state']['crisis'] = { | ||
'constant_fee': { | ||
'amount': '1333000000', # ~$5,000 worth of uatoms | ||
'denom': 'uatom', | ||
}, | ||
} | ||
|
||
# proposal #1 updates | ||
genesis['app_state']['mint']['params']['blocks_per_year'] = '4855015' | ||
|
||
# proposal #2 updates | ||
genesis['consensus_params']['block']['max_gas'] = '2000000' | ||
genesis['consensus_params']['block']['max_bytes'] = '200000' | ||
|
||
# enable transfers | ||
genesis['app_state']['bank']['send_enabled'] = True | ||
genesis['app_state']['distr']['withdraw_addr_enabled'] = True | ||
|
||
# Set new chain ID and genesis start time | ||
genesis['chain_id'] = parsed_args.chain_id.strip() | ||
genesis['genesis_time'] = parsed_args.start_time | ||
|
||
return genesis | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = lib.init_default_argument_parser( | ||
prog_desc='Convert genesis.json from v0.33.x to v0.34.0', | ||
default_chain_id='cosmoshub-n', | ||
default_start_time='2019-02-11T12:00:00Z', | ||
) | ||
lib.main(parser, process_raw_genesis) |