New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added iExec environment #17

Open
wants to merge 19 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@KarowM

KarowM commented May 16, 2018

Added the iExec environment along with a simple test class.

s"""export PATH="${jobDescription.IexecFilesPath}:$${PATH}" && cd ${jobDescription.workDirectory} && iexec result ${job.jobId} --dapp ${jobDescription.dappAddress} --save""",
impl.parseState)(server, job)
def clean[S](server: S, job: BatchJob)(implicit hn: HeadNode[S]): Unit = {

This comment has been minimized.

@jopasserat

jopasserat May 20, 2018

Member

// TODO no cancel command yet indeed but i'd be surprised if it wasn't showing up at some point ;)

|#!/bin/bash
|export PATH="${description.IexecFilesPath}:$${PATH}"
|cd ${description.workDirectory}
|iexec account login

This comment has been minimized.

@jopasserat

jopasserat May 20, 2018

Member

iExec maintains a session based on your wallet address => you shouldn't have to login everytime, you can call iexec account show first to see if you're logged in

|export PATH="${description.IexecFilesPath}:$${PATH}"
|cd ${description.workDirectory}
|iexec account login
|iexec account allow ${description.dappCost}

This comment has been minimized.

@jopasserat

jopasserat May 20, 2018

Member

we will want a mode where you allow more than the dApp price to be able to submit multiple jobs without having to wait for a transaction to be mined everytime, so this should be a separate function
you can verify the account balance before submission (iexec account show) and compare it to the dapp price

later with a finer integration you'll be able to query the dApp's price from its smart contract directly

@jopasserat jopasserat requested a review from romainreuillon May 20, 2018

KarowM added some commits May 21, 2018

- extracted login and account allow from submission script
- iexec account needs to be populated before submission, allows for multiple job submission with a single account allow transaction
- verification ensuring account balance is at least as much as the dappCost
@openmolebot

This comment has been minimized.

openmolebot commented May 31, 2018

Can one of the admins verify this patch?

def loginIexecAccount[S](server: S, description: IEXECJobDescription)(implicit hn: HeadNode[S], system: Effect[System]) = {
if (!new java.io.File(s"""/${description.workDirectory}/account.json""").exists) {
hn.execute(server, s"""cd ${description.workDirectory} && export PATH="${description.IexecFilesPath}:$${PATH}" && iexec account login""")
}

This comment has been minimized.

@jopasserat

jopasserat May 31, 2018

Member

Would be good to find out whether the token generated with iexec acount login expires at some point? Maybe ask the team on Slack

val rlcBalance = ropstenBalanceLine.substring(ropstenBalanceLine.indexOf(":")+1, ropstenBalanceLine.indexOf(" nRLC")).trim.toInt
assert(rlcBalance >= description.dappCost, s"iExec account does not have enough tokens to execute this DApp, account needs at least ${description.dappCost} but has ${rlcBalance}")
}

This comment has been minimized.

@jopasserat

jopasserat May 31, 2018

Member

Perfect! Now you just need another function to set the allowance. It would not be called automatically in submit but available to be called manually by the user.

@jopasserat

This comment has been minimized.

Member

jopasserat commented Jun 9, 2018

please build this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment