def helios_root_dir(self) -> Path: """ The helios_root_dir is the base directory that all helios data is stored under. The default ``data_dir`` path will be resolved relative to this directory. """ if self._helios_root_dir is not None: return self._helios_root_dir else: return get_xdg_helios_root()
def main() -> None: event_bus = EventBus(ctx) main_endpoint = event_bus.create_endpoint(MAIN_EVENTBUS_ENDPOINT) main_endpoint.connect() plugin_manager = setup_plugins( MainAndIsolatedProcessScope(event_bus, main_endpoint) ) plugin_manager.amend_argparser_config(parser, subparser) args = parser.parse_args() # # Dev testing stuff # if args.start_memory_profile: os.environ["PYTHONTRACEMALLOC"] = '1' if args.rand_db: os.environ["GENERATE_RANDOM_DATABASE"] = 'true' if args.instance is not None: from helios.utils.xdg import get_xdg_helios_root args.port = args.port + args.instance * 2 if args.instance != 0: args.do_rpc_http_server = False subdir = 'instance_' + str(args.instance) absolute_path = get_xdg_helios_root() / subdir absolute_dir = os.path.dirname(os.path.realpath(__file__)) absolute_keystore_path = absolute_dir + '/keystore/' args.keystore_path = absolute_keystore_path + subdir args.keystore_password = '******' os.environ["HELIOS_DATA_DIR"] = str(absolute_path.resolve()) os.environ["INSTANCE_NUMBER"] = str(args.instance) # # # if not args.keystore_password and not hasattr(args, 'func'): password = getpass.getpass(prompt='Keystore Password: '******'default'] = TRACE_LEVEL_NUM log_levels['hvm'] = TRACE_LEVEL_NUM log_levels['hp2p'] = TRACE_LEVEL_NUM log_levels['helios'] = TRACE_LEVEL_NUM log_levels['urllib3'] = TRACE_LEVEL_NUM log_levels['ssdp'] = TRACE_LEVEL_NUM log_levels['Service'] = TRACE_LEVEL_NUM log_levels['Action'] = TRACE_LEVEL_NUM log_levels['Device'] = TRACE_LEVEL_NUM log_levels['helios.extensibility'] = TRACE_LEVEL_NUM else: log_levels['default'] = logging.INFO log_levels['urllib3'] = logging.INFO log_levels['ssdp'] = logging.INFO log_levels['Service'] = logging.INFO log_levels['hvm'] = logging.DEBUG #sets all of hvm log_levels['hvm.db.account.AccountDB'] = logging.DEBUG log_levels['hvm.vm.base.VM.VM'] = logging.DEBUG log_levels['hvm.chain'] = logging.DEBUG #log_levels['hvm.chain.chain.Chain'] = logging.DEBUG log_levels['hvm.db.chain_head.ChainHeadDB'] = logging.DEBUG log_levels['hvm.db.chain_db.ChainDB'] = logging.DEBUG log_levels['hvm.db.consensus'] = logging.DEBUG log_levels['hvm.memoryLogger'] = logging.DEBUG #log_levels['hp2p'] = logging.INFO log_levels['hp2p.peer'] = logging.DEBUG log_levels['hp2p.peer.PeerPool'] = logging.DEBUG log_levels['hp2p.consensus.Consensus'] = logging.DEBUG log_levels['hp2p.SmartContractChainManager'] = logging.DEBUG log_levels['hp2p.kademlia.KademliaProtocol'] = logging.DEBUG log_levels['hp2p.discovery.DiscoveryProtocol'] = logging.INFO log_levels['hp2p.discovery.DiscoveryService'] = logging.INFO log_levels['hp2p.nat.UPnPService'] = logging.CRITICAL log_levels['connectionpool'] = logging.CRITICAL log_levels['hp2p.protocol'] = logging.DEBUG log_levels['hp2p.protocol.Protocol'] = logging.DEBUG #log_levels['helios'] = logging.INFO log_levels['helios.rpc.ipc'] = logging.INFO log_levels['helios.Node'] = logging.INFO log_levels['helios.sync'] = logging.DEBUG log_levels['helios.protocol'] = logging.INFO log_levels['helios.protocol.common'] = logging.DEBUG log_levels['helios.protocol.hls.peer.HLSPeer'] = 5 log_levels['helios.memoryLogger'] = logging.DEBUG log_levels['hp2p.hls'] = logging.INFO log_levels['helios.server.FullServer'] = logging.DEBUG log_levels['Action'] = logging.INFO log_levels['Device'] = logging.INFO log_levels['helios.extensibility'] = logging.INFO setup_log_levels(log_levels = log_levels) try: chain_config = ChainConfig.from_parser_args(args) except AmbigiousFileSystem: parser.error(HELIOS_AMBIGIOUS_FILESYSTEM_INFO) if not is_data_dir_initialized(chain_config): # TODO: this will only work as is for chains with known genesis # parameters. Need to flesh out how genesis parameters for custom # chains are defined and passed around. try: initialize_data_dir(chain_config) except AmbigiousFileSystem: parser.error(HELIOS_AMBIGIOUS_FILESYSTEM_INFO) except MissingPath as e: parser.error( "\n" f"It appears that {e.path} does not exist. " "Helios does not attempt to create directories outside of its root path. " "Either manually create the path or ensure you are using a data directory " "inside the XDG_HELIOS_ROOT path" ) file_logger, log_queue, listener = setup_helios_file_and_queue_logging( stderr_logger, formatter, handler_stream, chain_config, args.file_log_level, ) display_launch_logs(chain_config) # compute the minimum configured log level across all configured loggers. min_configured_log_level = min( stderr_logger.level, file_logger.level, *(args.log_levels or {}).values(), *(log_levels or {}).values() ) extra_kwargs = { 'log_queue': log_queue, 'log_level': min_configured_log_level, 'log_levels': log_levels, 'profile': args.profile, } # Plugins can provide a subcommand with a `func` which does then control # the entire process from here. if hasattr(args, 'func'): args.func(args, chain_config) else: helios_boot( args, chain_config, extra_kwargs, plugin_manager, listener, event_bus, main_endpoint, stderr_logger, )
import time from helios.utils.xdg import get_xdg_helios_root from helios_web3 import HeliosWeb3 as Web3 from web3 import WebsocketProvider, IPCProvider # # You must manually start the node before running this test # helios_home_dir = get_xdg_helios_root() ipc_path = helios_home_dir / 'instance_0' / 'jsonrpc.ipc' ipc_path_instance_1 = helios_home_dir / 'instance_1' / 'jsonrpc.ipc' from hvm.constants import GAS_TX, BLOCK_GAS_LIMIT from eth_utils import to_wei, encode_hex from hvm.constants import random_private_keys from hvm.chains.testnet import ( TESTNET_GENESIS_PARAMS, TESTNET_GENESIS_STATE, TESTNET_GENESIS_PRIVATE_KEY, TESTNET_NETWORK_ID, ) from eth_keys import keys def get_primary_node_private_helios_key(instance_number=0): return keys.PrivateKey(random_private_keys[instance_number])