mirror of https://github.com/skygpu/skynet.git
				
				
				
			Update nodeos genesis init
							parent
							
								
									e6e3dc2e63
								
							
						
					
					
						commit
						320f13260c
					
				| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					pytz
 | 
				
			||||||
trio
 | 
					trio
 | 
				
			||||||
asks
 | 
					asks
 | 
				
			||||||
numpy
 | 
					numpy
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -334,32 +334,15 @@ def dgpu(
 | 
				
			||||||
    key, account, permission = load_account_info(
 | 
					    key, account, permission = load_account_info(
 | 
				
			||||||
        key, account, permission)
 | 
					        key, account, permission)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    vtestnet = None
 | 
					    trio.run(
 | 
				
			||||||
    try:
 | 
					        partial(
 | 
				
			||||||
        dclient = docker.from_env()
 | 
					            open_dgpu_node,
 | 
				
			||||||
        vtestnet = get_container(
 | 
					            account, permission,
 | 
				
			||||||
            dclient,
 | 
					            CLEOS(None, None, url=node_url, remote=node_url),
 | 
				
			||||||
            default_nodeos_image(),
 | 
					            ipfs_url,
 | 
				
			||||||
            force_unique=True,
 | 
					            auto_withdraw=auto_withdraw,
 | 
				
			||||||
            detach=True,
 | 
					            key=key, initial_algos=json.loads(algos)
 | 
				
			||||||
            network='host',
 | 
					    ))
 | 
				
			||||||
            remove=True)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        cleos = CLEOS(dclient, vtestnet, url=node_url, remote=node_url)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        trio.run(
 | 
					 | 
				
			||||||
            partial(
 | 
					 | 
				
			||||||
                open_dgpu_node,
 | 
					 | 
				
			||||||
                account, permission,
 | 
					 | 
				
			||||||
                cleos,
 | 
					 | 
				
			||||||
                ipfs_url,
 | 
					 | 
				
			||||||
                auto_withdraw=auto_withdraw,
 | 
					 | 
				
			||||||
                key=key, initial_algos=json.loads(algos)
 | 
					 | 
				
			||||||
        ))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    finally:
 | 
					 | 
				
			||||||
        if vtestnet:
 | 
					 | 
				
			||||||
            vtestnet.stop()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@run.command()
 | 
					@run.command()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,8 +15,8 @@ import asks
 | 
				
			||||||
import docker
 | 
					import docker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PIL import Image
 | 
					from PIL import Image
 | 
				
			||||||
from leap.cleos import CLEOS, default_nodeos_image
 | 
					from leap.cleos import CLEOS
 | 
				
			||||||
from leap.sugar import get_container, collect_stdout
 | 
					from leap.sugar import *
 | 
				
			||||||
from leap.hyperion import HyperionAPI
 | 
					from leap.hyperion import HyperionAPI
 | 
				
			||||||
from trio_asyncio import aio_as_trio
 | 
					from trio_asyncio import aio_as_trio
 | 
				
			||||||
from telebot.types import (
 | 
					from telebot.types import (
 | 
				
			||||||
| 
						 | 
					@ -131,6 +131,7 @@ async def work_request(
 | 
				
			||||||
    message, user, chat,
 | 
					    message, user, chat,
 | 
				
			||||||
    account: str,
 | 
					    account: str,
 | 
				
			||||||
    permission: str,
 | 
					    permission: str,
 | 
				
			||||||
 | 
					    private_key: str,
 | 
				
			||||||
    params: dict,
 | 
					    params: dict,
 | 
				
			||||||
    file_id: str | None = None,
 | 
					    file_id: str | None = None,
 | 
				
			||||||
    binary_data: str = ''
 | 
					    binary_data: str = ''
 | 
				
			||||||
| 
						 | 
					@ -152,7 +153,7 @@ async def work_request(
 | 
				
			||||||
    request_time = datetime.now().isoformat()
 | 
					    request_time = datetime.now().isoformat()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    reward = '20.0000 GPU'
 | 
					    reward = '20.0000 GPU'
 | 
				
			||||||
    res = await cleos.s_push_action(
 | 
					    res = await cleos.a_push_action(
 | 
				
			||||||
        'telos.gpu',
 | 
					        'telos.gpu',
 | 
				
			||||||
        'enqueue',
 | 
					        'enqueue',
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -161,7 +162,7 @@ async def work_request(
 | 
				
			||||||
            'binary_data': binary_data,
 | 
					            'binary_data': binary_data,
 | 
				
			||||||
            'reward': asset_from_str(reward)
 | 
					            'reward': asset_from_str(reward)
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        account, key, permission=permission
 | 
					        account, private_key, permission=permission
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if 'code' in res:
 | 
					    if 'code' in res:
 | 
				
			||||||
| 
						 | 
					@ -210,7 +211,7 @@ async def work_request(
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # attempt to get the image and send it
 | 
					    # attempt to get the image and send it
 | 
				
			||||||
    ipfs_link = f'http://test1.us.telos.net:8080/ipfs/{ipfs_hash}/image.png'
 | 
					    ipfs_link = f'https://ipfs.ancap.tech/ipfs/{ipfs_hash}/image.png'
 | 
				
			||||||
    resp = await get_ipfs_file(ipfs_link)
 | 
					    resp = await get_ipfs_file(ipfs_link)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    caption = generate_reply_caption(
 | 
					    caption = generate_reply_caption(
 | 
				
			||||||
| 
						 | 
					@ -262,23 +263,11 @@ async def run_skynet_telegram(
 | 
				
			||||||
    remote_ipfs_node: str,
 | 
					    remote_ipfs_node: str,
 | 
				
			||||||
    key: str = None
 | 
					    key: str = None
 | 
				
			||||||
):
 | 
					):
 | 
				
			||||||
    dclient = docker.from_env()
 | 
					    cleos = CLEOS(None, None, url=node_url, remote=node_url)
 | 
				
			||||||
    vtestnet = get_container(
 | 
					 | 
				
			||||||
        dclient,
 | 
					 | 
				
			||||||
        default_nodeos_image(),
 | 
					 | 
				
			||||||
        force_unique=True,
 | 
					 | 
				
			||||||
        detach=True,
 | 
					 | 
				
			||||||
        network='host',
 | 
					 | 
				
			||||||
        remove=True)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cleos = CLEOS(dclient, vtestnet, url=node_url, remote=node_url)
 | 
					 | 
				
			||||||
    hyperion = HyperionAPI(hyperion_url)
 | 
					    hyperion = HyperionAPI(hyperion_url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    logging.basicConfig(level=logging.INFO)
 | 
					    logging.basicConfig(level=logging.INFO)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if key:
 | 
					 | 
				
			||||||
        cleos.setup_wallet(key)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    bot = AsyncTeleBot(tg_token, exception_handler=SKYExceptionHandler)
 | 
					    bot = AsyncTeleBot(tg_token, exception_handler=SKYExceptionHandler)
 | 
				
			||||||
    logging.info(f'tg_token: {tg_token}')
 | 
					    logging.info(f'tg_token: {tg_token}')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -346,7 +335,7 @@ async def run_skynet_telegram(
 | 
				
			||||||
                ec = await work_request(
 | 
					                ec = await work_request(
 | 
				
			||||||
                    bot, cleos, hyperion,
 | 
					                    bot, cleos, hyperion,
 | 
				
			||||||
                    message, user, chat,
 | 
					                    message, user, chat,
 | 
				
			||||||
                    account, permission, params
 | 
					                    account, permission, key, params
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if ec == 0:
 | 
					                if ec == 0:
 | 
				
			||||||
| 
						 | 
					@ -423,7 +412,7 @@ async def run_skynet_telegram(
 | 
				
			||||||
                ec = await work_request(
 | 
					                ec = await work_request(
 | 
				
			||||||
                    bot, cleos, hyperion,
 | 
					                    bot, cleos, hyperion,
 | 
				
			||||||
                    message, user, chat,
 | 
					                    message, user, chat,
 | 
				
			||||||
                    account, permission, params,
 | 
					                    account, permission, key, params,
 | 
				
			||||||
                    file_id=file_id,
 | 
					                    file_id=file_id,
 | 
				
			||||||
                    binary_data=ipfs_hash
 | 
					                    binary_data=ipfs_hash
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
| 
						 | 
					@ -488,7 +477,7 @@ async def run_skynet_telegram(
 | 
				
			||||||
                await work_request(
 | 
					                await work_request(
 | 
				
			||||||
                    bot, cleos, hyperion,
 | 
					                    bot, cleos, hyperion,
 | 
				
			||||||
                    message, user, chat,
 | 
					                    message, user, chat,
 | 
				
			||||||
                    account, permission, params,
 | 
					                    account, permission, key, params,
 | 
				
			||||||
                    file_id=file_id,
 | 
					                    file_id=file_id,
 | 
				
			||||||
                    binary_data=binary
 | 
					                    binary_data=binary
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
| 
						 | 
					@ -575,6 +564,3 @@ async def run_skynet_telegram(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except KeyboardInterrupt:
 | 
					        except KeyboardInterrupt:
 | 
				
			||||||
            ...
 | 
					            ...
 | 
				
			||||||
 | 
					 | 
				
			||||||
        finally:
 | 
					 | 
				
			||||||
            vtestnet.stop()
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ from contextlib import contextmanager as cm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import docker
 | 
					import docker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from pytz import timezone
 | 
				
			||||||
from leap.cleos import CLEOS, default_nodeos_image
 | 
					from leap.cleos import CLEOS, default_nodeos_image
 | 
				
			||||||
from leap.sugar import get_container, Symbol, random_string
 | 
					from leap.sugar import get_container, Symbol, random_string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,7 +70,7 @@ def open_nodeos(cleanup: bool = True):
 | 
				
			||||||
        cleos.setup_wallet(priv)
 | 
					        cleos.setup_wallet(priv)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        genesis = json.dumps({
 | 
					        genesis = json.dumps({
 | 
				
			||||||
            "initial_timestamp": datetime.now().isoformat(),
 | 
					            "initial_timestamp": '2017-08-29T02:14:00.000',
 | 
				
			||||||
            "initial_key": pub,
 | 
					            "initial_key": pub,
 | 
				
			||||||
            "initial_configuration": {
 | 
					            "initial_configuration": {
 | 
				
			||||||
                "max_block_net_usage": 1048576,
 | 
					                "max_block_net_usage": 1048576,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue