Skip to content

Commit

Permalink
mylib replaced with eBlocBroker.
Browse files Browse the repository at this point in the history
  • Loading branch information
avatar-lavventura committed Mar 13, 2018
1 parent f989997 commit c9625e7
Show file tree
Hide file tree
Showing 15 changed files with 1,695 additions and 52 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ eudatPassword\.txt

contracts/populus\.ini

\.node-xmlhttprequest-sync-18637

\.#main\.js
contractCalls/\.node-xmlhttprequest-sync-13830

contract/receipt\.txt

\.#main\.js
Empty file added .node-xmlhttprequest-sync-18637
Empty file.
10 changes: 5 additions & 5 deletions Driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ def isSlurmOn():
contractCallPath = constants.EBLOCPATH + '/contractCalls'; os.environ['contractCallPath'] = contractCallPath;
# ---------------

header = "var mylib = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;
header = "var eBlocBroker = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;
clusterID = constants.CLUSTER_ID; os.environ['clusterID'] = clusterID;

isClusterExist = contractCall('echo "$header; console.log( \'\' + mylib.isClusterExist(\'$clusterID\') )"');
isClusterExist = contractCall('echo "$header; console.log( \'\' + eBlocBroker.isClusterExist(\'$clusterID\') )"');

if (isClusterExist.lower() == "false"):
print("Error: Your Ethereum address (" + clusterID + ") \n"
Expand Down Expand Up @@ -135,7 +135,7 @@ def isSlurmOn():
logTest(blockReadFrom);
sys.exit();

clusterGainedAmount = contractCall('echo "$header; console.log( \'\' + mylib.getClusterReceivedAmount(\'$clusterID\') )"');
clusterGainedAmount = contractCall('echo "$header; console.log( \'\' + eBlocBroker.getClusterReceivedAmount(\'$clusterID\') )"');
squeueStatus = os.popen("squeue").read();

if "squeue: error:" in str(squeueStatus):
Expand All @@ -161,7 +161,7 @@ def isSlurmOn():

printFlag = 1;
time.sleep(2);
currentBlockNumber = contractCall('echo "$header; console.log( \'\' + mylib.blockNumber )"');
currentBlockNumber = contractCall('echo "$header; console.log( \'\' + eBlocBroker.blockNumber )"');

if (passedPrintFlag == 0):
logTest("Passed incremented block number... Continue to wait from block number: " + blockReadFrom);
Expand All @@ -171,7 +171,7 @@ def isSlurmOn():
os.environ['blockReadFrom'] = str(blockReadFrom) # Starting reading event's location has been updated

# Waits here until new job submitted into the cluster
returnVal = contractCall('echo "$header; console.log( \'\' + mylib.LogJob($blockReadFrom, \'$jobsReadFromPath\') )"');
returnVal = contractCall('echo "$header; console.log( \'\' + eBlocBroker.LogJob($blockReadFrom, \'$jobsReadFromPath\') )"');

if os.path.isfile(jobsReadFromPath): #{ Waits until generated file on log is completed
fR = open(jobsReadFromPath, 'r' )
Expand Down
1 change: 1 addition & 0 deletions contract/.cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1,644 changes: 1,644 additions & 0 deletions contract/.cache/v/populus/project/compiled_contracts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contract/.cache/v/populus/project/compiled_contracts_mtime
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1520698158.4366739
2 changes: 1 addition & 1 deletion contractCalls/getJobInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def ipfsBytesToString(ipfsID):
else:
clusterAddress = "0x6af0204187a93710317542d383a1b547fa42e705";
jobKey = "3d8e2dc2-b855-1036-807f-9dbd8c6b1579=267575587427153420186990249657380315186";
index = 1;
index = 5;

print(eBlocBroker.call().getJobInfo(clusterAddress, jobKey, index));
#}
6 changes: 3 additions & 3 deletions driverFunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def driverEudatCall(jobKey, index):
owner = jobKeyTemp[0]
folderName = jobKeyTemp[1]

header = "var mylib = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;
header = "var eBlocBroker = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;

f = open(eblocPath + '/eudatPassword.txt', 'r') # Password is read from the file. password.txt is have only user access
password = f.read().rstrip('\n').replace(" ", ""); f.close()
Expand Down Expand Up @@ -179,7 +179,7 @@ def driverIpfsCall(ipfsHash, index, ipfsType, miniLockId):
else:
os.environ['miniLockId'] = miniLockId

header = "var mylib = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;
header = "var eBlocBroker = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;
logTest( "ipfsHash: " + ipfsHash);

jobSavePath = ipfsHashes + '/' + ipfsHash + "_" + index;
Expand Down Expand Up @@ -236,7 +236,7 @@ def driverIpfsCall(ipfsHash, index, ipfsType, miniLockId):

os.system("cp run.sh ${ipfsHash}_${index}_${folderIndex}_${shareToken}_$miniLockId.sh");

jobInfo = contractCall('echo "$header; console.log( \'\' + mylib.getJobInfo( \'$clusterID\', \'$ipfsHash\', \'$index\' ) )"');
jobInfo = contractCall('echo "$header; console.log( \'\' + eBlocBroker.getJobInfo( \'$clusterID\', \'$ipfsHash\', \'$index\' ) )"');
jobInfo = jobInfo.split(',');
jobCoreNum = jobInfo[1]

Expand Down
13 changes: 7 additions & 6 deletions eBlocBrokerHeader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var mylib = require('./contract.js');
var eBlocBroker = require('./contract.js');

Web3 = require("web3");
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
Expand All @@ -8,11 +8,12 @@ if(!web3.isConnected()){
process.exit();
}

var COINBASE="0xffffffffffffffffffffffffffffffffffffffff"; //Should be the address of the cluster.
//web3.eth.defaultAccount=web3.eth.accounts[0]; //check calismaya bilir.
var COINBASE="0x6af0204187a93710317542d383a1b547fa42e705"; //Should be the address of the cluster.
web3.eth.defaultAccount = COINBASE;

var whoami = web3.eth.defaultAccount;
var myContractInstance = web3.eth.contract(mylib.abi).at(mylib.address);
var myContractInstance = web3.eth.contract(eBlocBroker.abi).at(eBlocBroker.address);
var blockNumber = web3.eth.blockNumber;

var gasLimit = 4500000;
Expand All @@ -37,8 +38,8 @@ job_state_id['14'] = 'SUSPENDED'
job_state_id['15'] = 'TIMEOUT'

//Global variables are used.
exports.address = mylib.address;
exports.abi = mylib.abi;
exports.address = eBlocBroker.address;
exports.abi = eBlocBroker.abi;
exports.whoami = whoami;
exports.blockNumber = blockNumber;
exports.job_state_id = job_state_id;
Expand Down Expand Up @@ -66,7 +67,7 @@ exports.isTransactionPassed = function(transaction_id) {
var web3 = web3_extended.create(options);
if(!web3.isConnected())
console.log("not connected");
var myContractInstance = web3.eth.contract(mylib.abi).at(mylib.address);
var myContractInstance = web3.eth.contract(eBlocBroker.abi).at(eBlocBroker.address);

var checkPassed = 0;
var receipt = web3.eth.getTransactionReceipt( transaction_id );
Expand Down
10 changes: 5 additions & 5 deletions eBlocBrokerNodeCall.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
var nodePaths = require('./nodePaths');
var mylib = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');
var eBlocBroker = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');

const args = process.argv;

var setJobStatus = "setJobStatus"
var val = args[2];

if( args[2].toString() == "setJobStatus" ){
mylib.setJobStatus(args[3], args[4], args[5], args[6]);
eBlocBroker.setJobStatus(args[3], args[4], args[5], args[6]);
}
else if( args[2].toString() == "getJobInfo" ){
console.log('' + mylib.getJobInfo( args[3], args[4], args[5] ));
console.log('' + eBlocBroker.getJobInfo( args[3], args[4], args[5] ));
}
else if( args[2].toString() == "receiptCheck" ){
mylib.receiptCheck(args[3], args[4], args[5], args[6], args[7], args[8]);
eBlocBroker.receiptCheck(args[3], args[4], args[5], args[6], args[7], args[8]);
}
else if( args[2].toString() == "bs58_encode" ){
mylib.bs58_encode( args[3] );
eBlocBroker.bs58_encode( args[3] );
}
2 changes: 1 addition & 1 deletion endCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def endCall(jobKey, index, storageType, shareToken, miniLockId, folderName):
programPath = constants.PROGRAM_PATH
encodedShareToken = base64.b64encode(shareToken + ':')

header = "var mylib = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;
header = "var eBlocBroker = require('" + eblocPath + "/eBlocBrokerHeader.js')"; os.environ['header'] = header;

os.environ['programPath'] = str(programPath)
os.environ['cluster_id'] = constants.CLUSTER_ID
Expand Down
9 changes: 2 additions & 7 deletions jobResults.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
# Paths---------
eblocPath = constants.EBLOCPATH;
contractCallPath = constants.EBLOCPATH + '/contractCalls'; os.environ['contractCallPath'] = contractCallPath;
fname = constants.LOG_PATH + '/queuedJobs.txt';
# ---------------

fname="/home/alper/.eBlocBroker/queuedJobs.txt";

sum1=0;

counter = 1;
with open(fname, "r") as ins:
array = []
Expand All @@ -30,9 +28,6 @@
print(str(counter) + " " + res[1] + " " + res[2] + " " + res[3] + " | " + constants.job_state_code[r[0]] + "," + r[1] + "," + r[2] + "," + r[3] + "," + r[4] + "," + r[5]);
counter = counter + 1;

print(counter)


print(counter)
print("GAINED: " + str(sum1));


11 changes: 6 additions & 5 deletions log.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var nodePaths = require('./nodePaths');
var mylib = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');
var eBlocBroker = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');

console.log('' + mylib.getDeployedBlockNumber())
console.log('' + eBlocBroker.getDeployedBlockNumber())

readFrom = 1799549; //mylib.getDeployedBlockNumber();
readFrom = 1799549; //eBlocBroker.getDeployedBlockNumber();

eBlocBroker.LogReceipt(readFrom, nodePaths.LOG_PATH + '/queuedJobs.txt');
//eBlocBroker.LogJob(readFrom, nodePaths.LOG_PATH + '/queuedJobs.txt' ); /* Prints jobs, which are not COMPLETED */

mylib.LogJob(readFrom, nodePaths.LOG_PATH + '/queuedJobs.txt' ); /* Prints jobs, which are not COMPLETED */

//mylib.LogReceipt(readFrom, nodePaths.LOG_PATH + '/queuedJobs.txt');
28 changes: 14 additions & 14 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
var conv = require('binstring');

var nodePaths = require('./nodePaths');
var mylib = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');
var eBlocBroker = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');

printLog = 1

clusterID = "0x6af0204187a93710317542d383a1b547fa42e705";

tx="0x5224a5a7a7a957f57ce18330b9f1b8ea50fd4746f37fcf642061a2d6ced519f3"
//console.log( "TransactionPassed ?= " + tx + " " + mylib.isTransactionPassed(tx) );
//console.log( "TransactionPassed ?= " + tx + " " + eBlocBroker.isTransactionPassed(tx) );

//mylib.updateCluster( 4, "ebloc", "0x", "0x", 1, "0x");
//eBlocBroker.updateCluster( 4, "ebloc", "0x", "0x", 1, "0x");

//console.log( "Contract's deployed block number: " + mylib.getDeployedBlockNumber() );
//console.log( "Contract's deployed block number: " + eBlocBroker.getDeployedBlockNumber() );

//a = "1220" + mylib.getClusterIpfsId(clusterID).substr(2);
//console.log( "ClusterInfo: " + mylib.getClusterInfo(clusterID) /*+ " " + mylib.bs58_decode(a)*/ );
//a = "1220" + eBlocBroker.getClusterIpfsId(clusterID).substr(2);
//console.log( "ClusterInfo: " + eBlocBroker.getClusterInfo(clusterID) /*+ " " + eBlocBroker.bs58_decode(a)*/ );

//TEST-SIDE
/*
for(i = 2; i < 12; i++)
mylib.setMiniLockId( "jj2Fn8St9tzLeErBiXA6oiZatnDwJ2YrnLY3Uyn4msD8k", i )
eBlocBroker.setMiniLockId( "jj2Fn8St9tzLeErBiXA6oiZatnDwJ2YrnLY3Uyn4msD8k", i )
for(i = 2; i < 12; i++)
console.log( "miniLockId of web3.eth.accounts[" + i + "]: " + mylib.getMiniLockId( i ) )
console.log( "miniLockId of web3.eth.accounts[" + i + "]: " + eBlocBroker.getMiniLockId( i ) )
*/



//LOG-RECEIPT
console.log( "Cluster Gained Amount: " + mylib.getClusterReceivedAmount(clusterID))
console.log( "Cluster Gained Amount: " + eBlocBroker.getClusterReceivedAmount(clusterID))
var fs = require('fs');
var array = fs.readFileSync(nodePaths.LOG_PATH + '/queuedJobs.txt').toString().split("\n");
for(i in array) {
var arr = array[i].split(" ");
if( array[i] != '' && clusterID == arr[1] ){
var str = mylib.getJobInfo(arr[1], arr[2], 0).toString().split(",");
var str = eBlocBroker.getJobInfo(arr[1], arr[2], 0).toString().split(",");
str = str.toString()
//str = str.replace('0x0000000000000000000000000000000000000000000000000000000000000000,', '')
console.log( "Job " + i + ": " + " | "+ arr[2], arr[3], arr[4], arr[5] + "|" + mylib.job_state_id[str[0]] + ' ' +str);
console.log( "Job " + i + ": " + " | "+ arr[2], arr[3], arr[4], arr[5] + "|" + eBlocBroker.job_state_id[str[0]] + ' ' +str);
}
}

Expand All @@ -47,21 +47,21 @@ for(i in array) {
if (printLog==1) {
sum=0;
sum1=0;
console.log( "Cluster Gained Amount: " + mylib.getClusterReceivedAmount(clusterID) )
console.log( "Cluster Gained Amount: " + eBlocBroker.getClusterReceivedAmount(clusterID) )
console.log( "Status|Core|StartTimeStamp|Recieved|CoreMinutePrice|CoreMinuteGas" )
var fs = require('fs');
var array = fs.readFileSync(nodePaths.LOG_PATH + '/queuedJobs.txt').toString().split("\n");
for(i in array) {
var arr = array[i].split(" ");
if( array[i] != '' && clusterID == arr[1] ){
var str = mylib.getJobInfo(arr[1], arr[2], arr[3]).toString().split(",");
var str = eBlocBroker.getJobInfo(arr[1], arr[2], arr[3]).toString().split(",");
if(str[0] == '1'){
sum += parseInt(str[3])
sum1+=(parseInt(arr[7]) - parseInt(arr[8]))
}
console.log( "Job "+ i +": " + mylib.job_state_id[str[0]] + ' ' + str[1] + " " + str[2] + " " + str[3] + " " + str[4] + " " + str[5] + " | "
console.log( "Job "+ i +": " + eBlocBroker.job_state_id[str[0]] + ' ' + str[1] + " " + str[2] + " " + str[3] + " " + str[4] + " " + str[5] + " | "
+ arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8] );
}
}
Expand Down
4 changes: 2 additions & 2 deletions transactionCheck.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var nodePaths = require('./nodePaths');
var mylib = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');
var eBlocBroker = require(nodePaths.EBLOCBROKER + '/eBlocBrokerHeader.js');

var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('t.txt')
Expand All @@ -11,7 +11,7 @@ lineReader.on('line', function (line) {

//console.log(line[0])
tx=line[0]
max += console.log( '' + mylib.getTransactionGas(line[0]))
max += console.log( '' + eBlocBroker.getTransactionGas(line[0]))
});

console.log("max: " + max);

0 comments on commit c9625e7

Please sign in to comment.