Skip to content

Commit

Permalink
Configure initial delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
novalis committed Apr 22, 2022
1 parent 7f28e12 commit 38b7dfc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions utils/config-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,27 @@ def get_genesis_accounts_pubkey_and_balance(accounts):

return pubkey_and_balance_pairs

#
# get_genesis_delegation(accounts) returns a list
# of dicts: [ 'from_pkh' : key1_from, 'to_pkh': key1_to], ... ] for each
# account that, at bootstrap time, delegates to another.
def get_genesis_delegation(accounts):
delegate_pairs = []

for k, v in accounts.items():
delegate = v.get("delegate_to")
if delegate:
delegator_key = v.get("pkh")
baker_key = accounts[delegate].get("pkh")
delegate_pairs.append(
{
'from_pkh' : delegator_key,
'to_pkh' : baker_key
})
else:
print("no delegate for %s: %s" % (k, v))

return delegate_pairs

#
# bootstrap_contracts are not part of `CHAIN_PARAMS["protocol_parameters"]`.
Expand All @@ -479,6 +500,7 @@ def create_protocol_parameters_json(accounts):
protocol_activation = CHAIN_PARAMS["protocol_activation"]
protocol_params = protocol_activation["protocol_parameters"]
protocol_params["bootstrap_accounts"] = pubkeys_with_balances
protocol_params["bootstrap_delegations"] = get_genesis_delegation(accounts)

print(json.dumps(protocol_activation, indent=4))

Expand Down

0 comments on commit 38b7dfc

Please sign in to comment.