diff --git a/skynet/dgpu.py b/skynet/dgpu.py index 763fdd1..209dbc3 100644 --- a/skynet/dgpu.py +++ b/skynet/dgpu.py @@ -174,7 +174,10 @@ async def open_dgpu_node( lower_bound=int(time.time()) - 3600 ) - except asks.errors.RequestTimeout: + except ( + asks.errors.RequestTimeout, + json.JSONDecodeError + ): return [] async def get_status_by_request_id(request_id: int): @@ -201,16 +204,6 @@ async def open_dgpu_node( else: return None - async def get_user_nonce(user: str): - logging.info('get_user_nonce') - return (await cleos.aget_table( - 'telos.gpu', 'telos.gpu', 'users', - index_position=1, - key_type='name', - lower_bound=user, - upper_bound=user - ))[0]['nonce'] - async def begin_work(request_id: int): logging.info('begin_work') return await cleos.a_push_action( @@ -218,7 +211,8 @@ async def open_dgpu_node( 'workbegin', { 'worker': Name(account), - 'request_id': request_id + 'request_id': request_id, + 'max_workers': 2 }, account, key, permission=permission @@ -328,7 +322,7 @@ async def open_dgpu_node( if rid not in my_results: statuses = await get_status_by_request_id(rid) - if len(statuses) < config['verification_amount']: + if len(statuses) < req['min_verification']: # parse request body = json.loads(req['body']) diff --git a/skynet/frontend/telegram/__init__.py b/skynet/frontend/telegram/__init__.py index ecd66fd..f417842 100644 --- a/skynet/frontend/telegram/__init__.py +++ b/skynet/frontend/telegram/__init__.py @@ -148,7 +148,8 @@ class SkynetTelegramFrontend: 'user': Name(self.account), 'request_body': body, 'binary_data': binary_data, - 'reward': asset_from_str(reward) + 'reward': asset_from_str(reward), + 'min_verification': 1 }, self.account, self.key, permission=self.permission ) diff --git a/skynet/nodeos.py b/skynet/nodeos.py index b853208..dddc935 100644 --- a/skynet/nodeos.py +++ b/skynet/nodeos.py @@ -145,7 +145,7 @@ def open_nodeos(cleanup: bool = True): ec, out = cleos.push_action( 'telos.gpu', 'config', - [1, 'eosio.token', '4,GPU'], + ['eosio.token', '4,GPU'], f'telos.gpu@active' ) assert ec == 0 diff --git a/tests/contracts/telos.gpu/telos.gpu.abi b/tests/contracts/telos.gpu/telos.gpu.abi index 406c268..f3708bf 100644 --- a/tests/contracts/telos.gpu/telos.gpu.abi +++ b/tests/contracts/telos.gpu/telos.gpu.abi @@ -21,6 +21,40 @@ } ] }, + { + "name": "card", + "base": "", + "fields": [ + { + "name": "id", + "type": "uint64" + }, + { + "name": "owner", + "type": "name" + }, + { + "name": "card_name", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "total_memory", + "type": "uint64" + }, + { + "name": "mp_count", + "type": "uint32" + }, + { + "name": "extra", + "type": "string" + } + ] + }, { "name": "clean", "base": "", @@ -30,10 +64,6 @@ "name": "config", "base": "", "fields": [ - { - "name": "verification_amount", - "type": "uint8" - }, { "name": "token_contract", "type": "name" @@ -72,11 +102,15 @@ }, { "name": "binary_data", - "type": "bytes" + "type": "string" }, { "name": "reward", "type": "asset" + }, + { + "name": "min_verification", + "type": "uint32" } ] }, @@ -84,10 +118,6 @@ "name": "global_configuration_struct", "base": "", "fields": [ - { - "name": "verification_amount", - "type": "uint8" - }, { "name": "token_contract", "type": "name" @@ -154,13 +184,21 @@ "name": "reward", "type": "asset" }, + { + "name": "min_verification", + "type": "uint32" + }, + { + "name": "nonce", + "type": "uint64" + }, { "name": "body", "type": "string" }, { "name": "binary_data", - "type": "bytes" + "type": "string" }, { "name": "timestamp", @@ -213,6 +251,10 @@ { "name": "request_id", "type": "uint64" + }, + { + "name": "max_workers", + "type": "uint32" } ] }, @@ -234,6 +276,28 @@ } ] }, + { + "name": "worker", + "base": "", + "fields": [ + { + "name": "account", + "type": "name" + }, + { + "name": "joined", + "type": "time_point_sec" + }, + { + "name": "left", + "type": "time_point_sec" + }, + { + "name": "url", + "type": "string" + } + ] + }, { "name": "worker_status_struct", "base": "", @@ -296,6 +360,13 @@ } ], "tables": [ + { + "name": "cards", + "type": "card", + "index_type": "i64", + "key_names": [], + "key_types": [] + }, { "name": "config", "type": "global_configuration_struct", @@ -330,6 +401,13 @@ "index_type": "i64", "key_names": [], "key_types": [] + }, + { + "name": "workers", + "type": "worker", + "index_type": "i64", + "key_names": [], + "key_types": [] } ], "ricardian_clauses": [], diff --git a/tests/contracts/telos.gpu/telos.gpu.wasm b/tests/contracts/telos.gpu/telos.gpu.wasm index 18dc265..6881852 100755 Binary files a/tests/contracts/telos.gpu/telos.gpu.wasm and b/tests/contracts/telos.gpu/telos.gpu.wasm differ