diff --git a/app/lib/collator_mint.py b/app/lib/collator_mint.py index dbdeea3..d8788d1 100644 --- a/app/lib/collator_mint.py +++ b/app/lib/collator_mint.py @@ -1,4 +1,5 @@ import logging +import time import traceback from substrateinterface import Keypair @@ -107,23 +108,25 @@ def collator_set_keys(node_name, para_id, ss58_format): collator_account_funds = get_account_funds(node_client.url, collator_account_address) # 3. If insufficient, add funds with teleport if collator_account_funds < 0.5 * 10 ** 9: - log.info(f"Funding {collator_account_address} (funds={collator_account_funds}) via Teleport from relay-chain") relay_chain_client = get_relay_chain_client() sudo_keypair = Keypair.create_from_seed(network_sudo_seed()) + log.info(f"Funding {collator_account_address}[ss58format={ss58_format}](funds={collator_account_funds}) via Teleport from relay-chain") # Get corresponding collator account address on the relay-chain (with the relay-chain ss58 format) relay_chain_collator_account = get_derived_collator_keypair(node_name, get_network_ss58_format()) - teleport_result = teleport_funds(relay_chain_client, sudo_keypair, para_id, [collator_account_address], 1 * 10 ** 12) + teleport_result = teleport_funds(relay_chain_client, sudo_keypair, para_id, [relay_chain_collator_account], 1 * 10 ** 12) if not teleport_result: log.error("Unable fund account: {}, node: {}".format( collator_account_address, getattr(relay_chain_client, 'url', 'NO_URL'))) return None + log.info("Waiting 1 minute for teleport to complete") + time.sleep(60) # 4. Check node has aura key aura_public_key = "0x" + collator_keypair.public_key.hex() if not node_keystore_has_key(node_client, 'aura', aura_public_key): log.error(f'Node ({node_name}) doesn\'t have the required aura key in its keystore') return None # 5. Setting aura key on chain via "set session key" if not already set - if check_has_session_keys(node_client.url, {'aura': aura_public_key}): + if check_has_session_keys(node_client, {'aura': aura_public_key}): set_session_key_result = set_node_session_key(node_client.url, collator_keypair.seed_hex, aura_public_key) if not set_session_key_result: log.error(f"Unable to set session key for node: {node_client.url}, session_key={aura_public_key}") diff --git a/app/lib/network_utils.py b/app/lib/network_utils.py index cd66db4..0a973b7 100644 --- a/app/lib/network_utils.py +++ b/app/lib/network_utils.py @@ -21,7 +21,8 @@ get_parachains_ids, get_all_parachain_leases_count, get_all_parachain_current_code_hashes, \ get_permanent_slot_lease_period_length, get_all_parachain_heads from app.lib.session_keys import rotate_node_session_keys, set_node_session_key, get_queued_keys -from app.lib.stash_accounts import get_derived_node_stash_account_address, get_node_stash_account_mnemonic +from app.lib.stash_accounts import get_derived_node_stash_account_address, get_node_stash_account_mnemonic, \ + get_account_funds from app.lib.substrate import get_relay_chain_client, get_node_client, substrate_rpc_request from app.lib.validator_manager import get_validator_set, get_validators_pending_addition, \ get_validators_pending_deletion, \ @@ -207,6 +208,7 @@ def get_substrate_node(node_name): validators_to_add = get_validators_pending_addition(ws_endpoint) validators_to_retire = get_validators_pending_deletion(ws_endpoint) node_info['validator_account'] = get_validator_account_from_pod(pod) + node_info['validator_account_funds'] = get_account_funds(ws_endpoint, node_info['validator_account']) node_info['validator_status'] = get_validator_status(node_info['validator_account'], validator_set, validators_to_add, validators_to_retire) node_info['on_chain_session_keys'] = get_account_session_keys(ws_endpoint, node_info['validator_account']) @@ -222,6 +224,7 @@ def get_substrate_node(node_name): chain = pod.metadata.labels['chain'] ws_endpoint = node_ws_endpoint(node_name) node_client = get_node_client(node_name) + node_info['collator_account_funds'] = get_account_funds(ws_endpoint, node_info['collator_account']) node_info['on_chain_session_keys'] = get_account_session_keys(ws_endpoint, node_info['collator_account']) # If not present in on-chain state, get derived session keys if node_info['on_chain_session_keys']: diff --git a/app/templates/node_info.html b/app/templates/node_info.html index d179969..595be68 100644 --- a/app/templates/node_info.html +++ b/app/templates/node_info.html @@ -38,6 +38,10 @@ <h3>{{ node.name }}</h3> <td>Validator Account</td> <td>{{ node.validator_account }}</td> </tr> + <tr> + <td>Validator Account Funds</td> + <td>{{ node.validator_account_funds }}</td> + </tr> <tr> <td>Validator Active</td> <td>{{ node.validator_status }}</td> @@ -52,6 +56,10 @@ <h3>{{ node.name }}</h3> <td>Collator Account</td> <td>{{ node.collator_account }}</td> </tr> + <tr> + <td>Collator Account Funds</td> + <td>{{ node.collator_account_funds }}</td> + </tr> <tr> <td>Collator Status</td> <td>{{ node.collator_status }}</td>