def e2e_execution(): # prepare ves = VerifiableExecutionSystem() dapp_x = DApp(info_x) dapp_y = DApp(info_y) dapp_z = DApp(info_z) ves.appenduserlink([dapp_x, dapp_y, dapp_z]) console_logger.info('{0} built, info:{1}'.format(dapp_x, dapp_x.info)) console_logger.info('{0} built, info:{1}'.format(dapp_y, dapp_y.info)) console_logger.info('{0} built, info:{1}'.format(dapp_z, dapp_z.info)) console_logger.info('{0} built, info:{1}'.format(ves, ves.__dict__)) # load Sample.json op_intents_json = FileLoad.getopintents("./test/opintents4.json") # for intent in op_intents_json['Op-intents']: # intent['contract_domain'] = "Ethereum://" + intent['contract_domain'] latency_profile = LatencyProfile() tot_time = time.perf_counter() session_content, isc, session_signature, tx_intents = ves.session_setup_prepare( op_intents_json) dapp_x.ackinit(ves, isc, session_content, session_signature, ves.nsb.host, testing=False) dapp_y.ackinit(ves, isc, session_content, session_signature, ves.nsb.host, testing=False) dapp_z.ackinit(ves, isc, session_content, session_signature, ves.nsb.host, testing=False) latency_profile.isc_init = time.perf_counter() - tot_time # print("raw: ", ves.address) # print(isc.is_owner(ves.address)) # print(isc.is_raw_sender(ves.address)) # print(isc.is_owner(dapp_x.info[ves.nsb.host]['address'])) # print(isc.is_owner(dapp_y.info[ves.nsb.host]['address'])) # print(isc.tx_info_length()) # print(isc.get_isc_state()) # print(ves.nsb.is_active_isc(isc.address)) user_table = [ (dapp_x, ves), (dapp_y, ves), (dapp_x, ves), (ves, dapp_z), (dapp_z, ves), ] session_id = int(session_content[0]) tag_time = None tag_time_end = None atte_computation = [] action_staking = [] proof_retriveal = [] print("prepare end..", time.perf_counter() - tot_time) for idx, [u, v] in enumerate(user_table): # assert tx_intent is on ISC # Part_A # inited ############################################################################################## print("compute on_chain_tx") tag_time = time.perf_counter() # compute on_chain_tx tx = tx_intents.intents[idx].jsonize() console_logger.info( 'on chain transaction computed index: {0}, content: {1}'.format( idx, tx)) tag_time_end = time.perf_counter() - tag_time print("compute on_chain_tx", tag_time_end) print("attestation inited") # compute attestation tag_time = time.perf_counter() atte = u.init_attestation(tx, StateType.inited, session_id, idx, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time print("Atte computation", tag_time_end) atte_computation.append(tag_time_end) # send inited attestaion tag_time = time.perf_counter() ret = u.send_attestation(session_id, atte, idx, StateType.inited, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time action_staking.append(tag_time_end) print("Action staking", tag_time_end) # receive attestaion tag_time = time.perf_counter() atte_rec = v.receive(atte.encode(), int(session_content[0]), idx, StateType.inited.value, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time proof_retriveal.append(tag_time_end) print("attestation inited", tag_time_end) # laz_func = u.send_attestation(session_id, atte, idx, StateType.inited, ves.nsb.host) # u.unlockself(ves.nsb.host) # laz_func.transact() # console_logger.info('nsb received action, response: {}'.format(laz_func.loop_and_wait())) console_logger.info('nsb received action, response: {}'.format(ret)) # Part_Z # open ################################################################################################ print("attestation open") # compute attestation tag_time = time.perf_counter() rlped_data = v.sign_attestation(atte_rec) tag_time_end = time.perf_counter() - tag_time print("Atte computation", tag_time_end) atte_computation.append(tag_time_end) # send open-request attestion tag_time = time.perf_counter() ret = v.send_attestation(session_id, atte_rec, idx, StateType.open, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time print("Action staking", tag_time_end) action_staking.append(tag_time_end) # no necessary to ack, just verify it tag_time = time.perf_counter() u.receive(rlped_data, int(session_content[0]), idx, StateType.open.value, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time proof_retriveal.append(tag_time_end) print("attestation open", tag_time_end) # laz_func = v.send_attestation(session_id, atte_rec, idx, StateType.open, ves.nsb.host) # v.unlockself(ves.nsb.host) # laz_func.transact() # console_logger.info('nsb received action, response: {}'.format(laz_func.loop_and_wait())) console_logger.info('nsb received action, response: {}'.format(ret)) # Part_A # opened ############################################################################################## # open transaction print("transact") tag_time = time.perf_counter() # u.unlockself(tx_intents.intents[idx].chain_host) # temporary_transact(tx, tx_intents.intents[idx].chain_host, u) tag_time_end = time.perf_counter() - tag_time print("transact", tag_time_end) print("attestation opened") # compute opened attestaion tag_time = time.perf_counter() atte = u.init_attestation(tx, StateType.opened, int(session_content[0]), 0, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time atte_computation.append(tag_time_end) # send opened attestion tag_time = time.perf_counter() ret = u.send_attestation(session_id, atte, idx, StateType.opened, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time action_staking.append(tag_time_end) # no necessary to ack, just verify it tag_time = time.perf_counter() v.receive(atte.encode(), int(session_content[0]), idx, StateType.opened.value, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time proof_retriveal.append(tag_time_end) print("attestation opened", tag_time_end) # laz_func = u.send_attestation(session_id, atte, idx, StateType.opened, ves.nsb.host) # laz_func.transact() # console_logger.info('nsb received action, response: {}'.format(laz_func.loop_and_wait())) console_logger.info('nsb received action, response: {}'.format(ret)) # Part_Z # closed ############################################################################################## # atte = v.init_attestation(tx, StateType.closed, int(session_content[0]), 0, ves.nsb.host) # laz_func = v.send_attestation(session_id, atte, idx, StateType.closed, ves.nsb.host) # laz_func.transact() # console_logger.info('nsb received action, response: {}'.format(laz_func.loop_and_wait())) # compute closed attestaion print("attestation closed") tag_time = time.perf_counter() atte = v.init_attestation(tx, StateType.closed, int(session_content[0]), 0, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time atte_computation.append(tag_time_end) # send closed attestion tag_time = time.perf_counter() ret = v.send_attestation(session_id, atte, idx, StateType.closed, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time action_staking.append(tag_time_end) # receive closed attestion tag_time = time.perf_counter() u.receive(atte.encode(), int(session_content[0]), idx, StateType.closed.value, ves.nsb.host) tag_time_end = time.perf_counter() - tag_time proof_retriveal.append(tag_time_end) print("attestation closed", tag_time_end) console_logger.info('nsb received action, response: {}'.format(ret)) # end ########################################################################################################## print("----------end transaction----------") # # # # # settle # # # # # close latency_profile.atte_computation = sum(atte_computation) / len( atte_computation) latency_profile.action_staking = sum(action_staking) / len(action_staking) latency_profile.proof_retrieval = sum(proof_retriveal) / len( proof_retriveal) print("tot_time", time.perf_counter() - tot_time) return latency_profile
console_logger.info('{0} built, info:{1}'.format(dapp_x, dapp_x.info)) console_logger.info('{0} built, info:{1}'.format(dapp_y, dapp_y.info)) console_logger.info('{0} built, info:{1}'.format(ves, ves.__dict__)) # load Sample.json op_intents_json = FileLoad.getopintents("./opintents2.json") for intent in op_intents_json['Op-intents']: intent['contract_domain'] = "Ethereum://" + intent['contract_domain'] session_content, isc, session_signature, tx_intents = ves.session_setup_prepare( op_intents_json) dapp_x.ackinit(ves, isc, session_content, session_signature, ves.chain_host, testing=False) dapp_y.ackinit(ves, isc, session_content, session_signature, ves.chain_host, testing=False) print("raw: ", ves.address) print(isc.is_owner(ves.address)) print(isc.is_raw_sender(ves.address)) print(isc.is_owner(dapp_x.info[ves.chain_host]['address'])) print(isc.is_owner(dapp_y.info[ves.chain_host]['address'])) print(isc.tx_info_length())
ves = VerifiableExecutionSystem() dapp_x = DApp(info_x) dapp_y = DApp(info_y) relay_x = DApp(info_relay_x) relay_y = DApp(info_relay_y) ves.appenduserlink([dapp_x, dapp_y]) # load Sample.json op_intents_json = FileLoad.getopintents("./opintents.json") session_content, isc, session_signature, tx_intents = ves.session_setup_prepare( op_intents_json) # print('session_content:', session_content) # print('session_signature:', session_signature) dapp_x.ackinit(ves, isc, session_content, session_signature) dapp_y.ackinit(ves, isc, session_content, session_signature) # print(isc.handle.handle.funcs()) # # print("raw: ", ves.address) # print(isc.handle.is_owner(ves.address)) # print(isc.handle.is_raw_sender(ves.address)) # print(isc.handle.is_owner(dapp_x.address)) # print(isc.handle.is_owner(dapp_y.address)) # print(isc.handle.tx_info_length()) print(isc) print(isc.__dict__) print(isc.handle.get_isc_state()) # print(formated_json(ves.txs_pool[int(session_content[0])]['ack_dict']))