Skip to content

Commit

Permalink
Local testnet setup: Optional target adress for municipal infl.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbukva committed Aug 12, 2023
1 parent b16e6cf commit 71f3452
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
environment:
NUM_VALIDATORS: 3
CHAINID: localnet
# Address bellow generated from mnemonic of node0 using account=0 index=1 in HD path
MUNICIPAL_INFL_TARGET_ADDRESS: fetch12w7ud5hv93zu82as4d64tn00pc596ue2fs74tj

volumes:
Expand Down
38 changes: 25 additions & 13 deletions entrypoints/run-localnet-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ def get_gentxs():


def main():
for name in ('CHAINID', 'NUM_VALIDATORS', 'MUNICIPAL_INFL_TARGET_ADDRESS'):
MUNICIPAL_INFL_TARGET_ADDRESS = 'MUNICIPAL_INFL_TARGET_ADDRESS'

for name in ('CHAINID', 'NUM_VALIDATORS'):
if name not in os.environ:
print('{} environment variable not present'.format(name))
sys.exit(1)

# extract the environment variables
chain_id = os.environ['CHAINID']
num_validators = int(os.environ['NUM_VALIDATORS'])
municipal_infl_target_address = os.environ['MUNICIPAL_INFL_TARGET_ADDRESS']
municipal_infl_target_address = os.environ.get(MUNICIPAL_INFL_TARGET_ADDRESS, None)

# create the initial genesis file
if os.path.exists(GENESIS_PATH):
Expand All @@ -58,14 +60,16 @@ def main():
genesis = json.load(f)
genesis["app_state"]["staking"]["params"]["max_validators"] = 10
genesis["app_state"]["staking"]["params"]["max_entries"] = 10
genesis["app_state"]["mint"]["minter"]["municipal_inflation"].extend([
{"denom": "nanomobx", "target_address": municipal_infl_target_address, "inflation": "0.03"},
{"denom": "denom005", "target_address": municipal_infl_target_address, "inflation": "0.05"},
{"denom": "denom100", "target_address": municipal_infl_target_address, "inflation": "1.0"},
{"denom": "denom010", "target_address": municipal_infl_target_address, "inflation": "0.1"},
{"denom": "denom050", "target_address": municipal_infl_target_address, "inflation": "0.5"},
{"denom": "denom020", "target_address": municipal_infl_target_address, "inflation": "0.2"}
])
municipal_infl_genesis_conf = genesis["app_state"]["mint"]["minter"]["municipal_inflation"]
if municipal_infl_target_address:
municipal_infl_genesis_conf.extend([
{"denom": "nanomobx", "inflation": {"target_address": municipal_infl_target_address, "value": "0.03"}},
{"denom": "denom005", "inflation": {"target_address": municipal_infl_target_address, "value": "0.05"}},
{"denom": "denom100", "inflation": {"target_address": municipal_infl_target_address, "value": "1.0"}},
{"denom": "denom010", "inflation": {"target_address": municipal_infl_target_address, "value": "0.1"}},
{"denom": "denom050", "inflation": {"target_address": municipal_infl_target_address, "value": "0.5"}},
{"denom": "denom020", "inflation": {"target_address": municipal_infl_target_address, "value": "0.2"}}
])

f.seek(0)
json.dump(genesis, f, indent=4)
Expand All @@ -83,9 +87,17 @@ def main():
validator, '200000000000000000000atestfet']
subprocess.check_call(cmd)

cmd = ['fetchd', 'add-genesis-account',
municipal_infl_target_address, '200000000000000000000atestfet,1000000000000000000nanomobx,1000000000000000000denom005,1000000000000000000denom010,1000000000000000000denom020,1000000000000000000denom050,1000000000000000000denom100']
subprocess.check_call(cmd)
if municipal_infl_target_address:
token_list = ["200000000000000000000atestfet"]

for infl in municipal_infl_genesis_conf:
token_list.append(f'{10**18}{infl["denom"]}')
tokens = ','.join(token_list)

cmd = ['fetchd', 'add-genesis-account',
municipal_infl_target_address, tokens]

subprocess.check_call(cmd)

# copy the generated genesis file
shutil.copy(GENESIS_PATH, '/setup/genesis.intermediate.json')
Expand Down

0 comments on commit 71f3452

Please sign in to comment.