Update smart contract

add-txt2txt-models
Guillermo Rodriguez 2023-06-04 14:06:41 -03:00
parent 0cb2565d65
commit d5b04a673c
No known key found for this signature in database
GPG Key ID: EC3AB66D5D83B392
5 changed files with 98 additions and 25 deletions

View File

@ -174,7 +174,10 @@ async def open_dgpu_node(
lower_bound=int(time.time()) - 3600 lower_bound=int(time.time()) - 3600
) )
except asks.errors.RequestTimeout: except (
asks.errors.RequestTimeout,
json.JSONDecodeError
):
return [] return []
async def get_status_by_request_id(request_id: int): async def get_status_by_request_id(request_id: int):
@ -201,16 +204,6 @@ async def open_dgpu_node(
else: else:
return None 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): async def begin_work(request_id: int):
logging.info('begin_work') logging.info('begin_work')
return await cleos.a_push_action( return await cleos.a_push_action(
@ -218,7 +211,8 @@ async def open_dgpu_node(
'workbegin', 'workbegin',
{ {
'worker': Name(account), 'worker': Name(account),
'request_id': request_id 'request_id': request_id,
'max_workers': 2
}, },
account, key, account, key,
permission=permission permission=permission
@ -328,7 +322,7 @@ async def open_dgpu_node(
if rid not in my_results: if rid not in my_results:
statuses = await get_status_by_request_id(rid) statuses = await get_status_by_request_id(rid)
if len(statuses) < config['verification_amount']: if len(statuses) < req['min_verification']:
# parse request # parse request
body = json.loads(req['body']) body = json.loads(req['body'])

View File

@ -148,7 +148,8 @@ class SkynetTelegramFrontend:
'user': Name(self.account), 'user': Name(self.account),
'request_body': body, 'request_body': body,
'binary_data': binary_data, 'binary_data': binary_data,
'reward': asset_from_str(reward) 'reward': asset_from_str(reward),
'min_verification': 1
}, },
self.account, self.key, permission=self.permission self.account, self.key, permission=self.permission
) )

View File

@ -145,7 +145,7 @@ def open_nodeos(cleanup: bool = True):
ec, out = cleos.push_action( ec, out = cleos.push_action(
'telos.gpu', 'telos.gpu',
'config', 'config',
[1, 'eosio.token', '4,GPU'], ['eosio.token', '4,GPU'],
f'telos.gpu@active' f'telos.gpu@active'
) )
assert ec == 0 assert ec == 0

View File

@ -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", "name": "clean",
"base": "", "base": "",
@ -30,10 +64,6 @@
"name": "config", "name": "config",
"base": "", "base": "",
"fields": [ "fields": [
{
"name": "verification_amount",
"type": "uint8"
},
{ {
"name": "token_contract", "name": "token_contract",
"type": "name" "type": "name"
@ -72,11 +102,15 @@
}, },
{ {
"name": "binary_data", "name": "binary_data",
"type": "bytes" "type": "string"
}, },
{ {
"name": "reward", "name": "reward",
"type": "asset" "type": "asset"
},
{
"name": "min_verification",
"type": "uint32"
} }
] ]
}, },
@ -84,10 +118,6 @@
"name": "global_configuration_struct", "name": "global_configuration_struct",
"base": "", "base": "",
"fields": [ "fields": [
{
"name": "verification_amount",
"type": "uint8"
},
{ {
"name": "token_contract", "name": "token_contract",
"type": "name" "type": "name"
@ -154,13 +184,21 @@
"name": "reward", "name": "reward",
"type": "asset" "type": "asset"
}, },
{
"name": "min_verification",
"type": "uint32"
},
{
"name": "nonce",
"type": "uint64"
},
{ {
"name": "body", "name": "body",
"type": "string" "type": "string"
}, },
{ {
"name": "binary_data", "name": "binary_data",
"type": "bytes" "type": "string"
}, },
{ {
"name": "timestamp", "name": "timestamp",
@ -213,6 +251,10 @@
{ {
"name": "request_id", "name": "request_id",
"type": "uint64" "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", "name": "worker_status_struct",
"base": "", "base": "",
@ -296,6 +360,13 @@
} }
], ],
"tables": [ "tables": [
{
"name": "cards",
"type": "card",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{ {
"name": "config", "name": "config",
"type": "global_configuration_struct", "type": "global_configuration_struct",
@ -330,6 +401,13 @@
"index_type": "i64", "index_type": "i64",
"key_names": [], "key_names": [],
"key_types": [] "key_types": []
},
{
"name": "workers",
"type": "worker",
"index_type": "i64",
"key_names": [],
"key_types": []
} }
], ],
"ricardian_clauses": [], "ricardian_clauses": [],