def main_validator() -> None: # TODO: # Merge into trinity platform # 1. CLI parsing # 2. Loading config from file and/or cmd line # 3. Logging logger = _setup_logging() arguments = parse_cli_args() root_data_dir = (Path(os.environ["HOME"]) / ".local" / "share" / "trinity" / "eth2" / "validator_client") slots_per_epoch = Slot(4) seconds_per_slot = 2 genesis_time = int(time.time()) + slots_per_epoch * seconds_per_slot + 3 num_validators = 16 key_pairs = tuple( _mk_random_key_pair(index) for index in range(num_validators)) config = Config( key_store_constructor=_mk_key_store_from_key_pairs(key_pairs), root_data_dir=root_data_dir, slots_per_epoch=slots_per_epoch, seconds_per_slot=seconds_per_slot, genesis_time=genesis_time, demo_mode=arguments.demo_mode, ) trio.run(arguments.func, logger, config, arguments)
def main_validator() -> None: logger = _setup_logging() parser = parse_cli_args() arguments = parser.parse_args() trinity_config = load_trinity_config_from_parser_args( parser, arguments, APP_IDENTIFIER_VALIDATOR_CLIENT, (ValidatorClientAppConfig,) ) # NOTE: we do not want the rest of the functionality in # ``trinity.bootstrap.ensure_data_dir_is_initialized create_dir_if_missing(trinity_config.data_dir) validator_client_app_config = trinity_config.get_app_config( ValidatorClientAppConfig ) root_dir = validator_client_app_config.root_dir create_dir_if_missing(root_dir) try: genesis_config = _load_genesis_config_at( validator_client_app_config.genesis_config_path ) except FileNotFoundError: genesis_time = Timestamp(int(time.time())) genesis_config = generate_genesis_config("minimal", genesis_time) eth2_config = Eth2Config.from_formatted_dict(genesis_config["eth2_config"]) override_lengths(eth2_config) key_pairs = load_genesis_key_map(genesis_config["genesis_validator_key_pairs"]) genesis_state = from_formatted_dict(genesis_config["genesis_state"], BeaconState) slots_per_epoch = Slot(eth2_config.SLOTS_PER_EPOCH) seconds_per_slot = eth2_config.SECONDS_PER_SLOT genesis_time = genesis_state.genesis_time config = Config( key_pairs=key_pairs, root_data_dir=root_dir, slots_per_epoch=slots_per_epoch, seconds_per_slot=seconds_per_slot, genesis_time=genesis_time, ) # NOTE: we deviate from the multiprocess-driven Component-based # application machinery here until said machinery is more stable # with respect to boot, shutdown and general concurrent control. trio.run(arguments.func, logger, config, arguments)