Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
avatar-lavventura committed Mar 12, 2024
2 parents c2a81d4 + b9087bb commit d30ad1a
Show file tree
Hide file tree
Showing 29 changed files with 650 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .semver
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
:major: 2
:minor: 3
:patch: 5
:patch: 7
:special: ''
2 changes: 1 addition & 1 deletion broker/Driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def tools(bn):
check_output, gdrive_gmail = gdrive.check_gdrive_about(gmail)
if not check_output:
log(
f"E: provider's registered gmail=[m]{gmail}[/m] does not match with the set gdrive's gmail=[m]{gdrive_gmail}[/m]",
f"E: provider's registered gmail=[m]{gmail}[/m] does not match with the already set gdrive's gmail=[m]{gdrive_gmail}[/m]",
is_code=True,
h=False,
)
Expand Down
9 changes: 9 additions & 0 deletions broker/_utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,12 @@ def gdrive_about_user() -> str:
return ret[1]

raise Exception()


def get_online_idle_core(ip) -> int:
while True:
with suppress(Exception):
return int(run(["curl", "-s", f"http://{ip}:5000"]))

log("|", end="")
time.sleep(2)
5 changes: 3 additions & 2 deletions broker/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
IS_FULL_TEST = False # check whether the full-long test is applied
IS_FIRST_CYCLE = True
BERG_CMPE_IP = "79.123.176.66" # "berg-cmpe-boun.duckdns.org" // may be down once in a while
NETWORK_ID = "bloxberg_core" # "bloxberg"
# NETWORK_ID = "bloxberg" # "bloxberg"
NETWORK_ID = "bloxberg"
# NETWORK_ID = "bloxberg_boun"
# NETWORK_ID = "bloxberg_core"
# NETWORK_ID = "sepolia"
TEST_JOB_COUNTER = 0

Expand Down
9 changes: 6 additions & 3 deletions broker/eblocbroker_scripts/Contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from brownie.network.transaction import TransactionReceipt

if cfg.NETWORK_ID == "sepolia":
GAS_PRICE = 5
GAS_PRICE = 5.0
else: #: for bloxberg
GAS_PRICE = 0.25 # was 1.21 Gwei
GAS_PRICE = 0.004 # was 1.21 Gwei

EXIT_AFTER = 1000 # seconds

Expand Down Expand Up @@ -168,6 +168,8 @@ def _wait_for_transaction_receipt(self, tx_hash, compact=False, is_verbose=False
tx_receipt = cfg.w3.eth.get_transaction_receipt(tx_hash)
except TransactionNotFound as e:
log(f"warning: TransactionNotFound tx={tx_hash} {e}")
if attempt == 5:
raise Exception("TransactionNotFound")
except Exception as e:
print_tb(e)
tx_receipt = None
Expand Down Expand Up @@ -439,7 +441,6 @@ def timeout_wrapper(self, method, contract, *args):
log(f"warning: Tx: {e}", is_code=True)
else:
log(f"E: Tx: {e}")
breakpoint() # DEBUG

if ("Try increasing the gas price" in str(e)) or (
"Transaction with the same hash was already imported." in str(e)
Expand Down Expand Up @@ -512,6 +513,7 @@ def _submit_job(self, required_confs, requester, job_price, *args) -> "Transacti
except Exception as e:
raise Exception(f"Approve transaction is failed, {e}")

time.sleep(2)
self.gas_price = GAS_PRICE
method_name = "submitJob"
idx = 0
Expand Down Expand Up @@ -566,6 +568,7 @@ def _submit_job(self, required_confs, requester, job_price, *args) -> "Transacti

continue

time.sleep(2)
idx += 1
raise Exception("No valid Tx receipt for 'submitJob' is generated")

Expand Down
32 changes: 16 additions & 16 deletions broker/eblocbroker_scripts/contract.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
networks:
active_network: bloxberg # sepolia # bloxberg change me at cfg.py file as well
active_network: bloxberg # sepolia | change me at cfg.py file as well
bloxberg:
project_dir: ~/ebloc-broker/contract
eBlocBroker:
Expand All @@ -9,11 +9,11 @@ networks:
address: "0xbCc68aEa77cf128A7ae9eB7588f363Efc76349a7"
tx_hash: "0x99004818f181cac56c49d502f871db1a7ecb03a6a6f714a7072ee79f8ad025a6"
ResearchCertificate:
address: "0xD6397bf1A42f01C753dcD638C6eD3486963A09eD"
tx_hash: "0x8cf7bab8993c192c0de1b56aa8f9f0b706cbd341b35b425d500803509026c653"
address: '0xB17dE8C64DC6BB678043457F1A7d992F583A37A0'
tx_hash: '0x22dc1725d46c0844e6fc198e37c3c72d55e151aa192adad959c05848a86bb760'
AutonomousSoftwareOrg:
address: "0x06EE74fa579C771f182624a3f71845697270A9fF"
tx_hash: "0xe76315a96d47584b7da739a3a4d96e1bf64fbe913f35ed85ac4a1e7c4ca7c14e"
address: '0x450eb7EC90418E9D768f85Ffa1b29187AD57251a'
tx_hash: '0xc07dc41d0e435728a5e405a8697470c57db19db26a16aac6c97bdb1e81110359'
sepolia:
project_dir: ~/ebloc-broker/contract
name: sepolia
Expand All @@ -31,18 +31,18 @@ networks:
tx_hash: "0x596adaa251729551525850d913424946f3096821fc8a12e6bb5de0c6094cd29a"
bloxberg-docker:
project_dir: /workspace/ebloc-broker/contract
# eBlocBroker:
# address: '0x35F8ecb17a9EB63cB12cc0D15404A41946371F00'
# tx_hash: '0xa3b58df370bce393762ed92ec2d7dcd6d54e53381d42f76c6a18f9d4d1b2662c'
# USDTmy:
# address: '0x499331123D9861A8A812ccFB81552a4A00786ee2'
# tx_hash: '0x88780cb86701fab9df24c3d1808f21bc2395d70338a527b767942d353fe9299e'
# eBlocBroker:
# address: '0x35F8ecb17a9EB63cB12cc0D15404A41946371F00'
# tx_hash: '0xa3b58df370bce393762ed92ec2d7dcd6d54e53381d42f76c6a18f9d4d1b2662c'
# USDTmy:
# address: '0x499331123D9861A8A812ccFB81552a4A00786ee2'
# tx_hash: '0x88780cb86701fab9df24c3d1808f21bc2395d70338a527b767942d353fe9299e'
networks_old:
bloxberg:
project_dir: ~/ebloc-broker/contract
eBlocBroker:
address: "0x81aF3aeACbE068e7513443572d998bC2A20A83C1"
tx_hash: "0x39b3fb95d0258e42f71c5da835a32e7a197cab4eee2cea9373d627d2f5593d9d"
USDTmy: # dummy
address: "0x56B59aFC0Df1fcc1B42cf6135f94604cf7F7eb77"
tx_hash: "0x3a47a7971f80bf1a320a8409951a7830bf86bffb5005a65df4973c8943ec45f5"
address: '0x81aF3aeACbE068e7513443572d998bC2A20A83C1'
tx_hash: '0x39b3fb95d0258e42f71c5da835a32e7a197cab4eee2cea9373d627d2f5593d9d'
USDTmy: # dummy
address: '0x56B59aFC0Df1fcc1B42cf6135f94604cf7F7eb77'
tx_hash: '0x3a47a7971f80bf1a320a8409951a7830bf86bffb5005a65df4973c8943ec45f5'
Binary file added broker/eblocbroker_scripts/g.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
149 changes: 149 additions & 0 deletions broker/eblocbroker_scripts/original_from_bloxberg.gv
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
digraph G {
size ="40";
// nodesep=.05;
rankdir=LR;
compound=true;
forcelabels=true;
2;
"1.1";
3;
4;
6;
"5.2";
8;
"7.3";
9;
11;
"10.4";
12;
13;
14;
"15.5";
16;
17;
"18.6";
19;
"20.7";
21;
"22.8";
23;
24;
"25.9";
26;
27;
"28.10";
29;
30;
31;
"32.11";
33;
34;
"35.12";
"36.13";
37;
"38.14";
39;
"40.15";
41;
42;
"43.16";
44;
45;
46;
"47.17";
48;
49;
"50.18";
51;
52;
53;
"54.19";
55;
"56.20";
57;
2 -> "1.1";
"1.1" -> 3;
"1.1" -> 4;
3 -> "15.5";
4 -> "5.2";
4 -> "15.5";
4 -> "28.10";
6 -> "5.2";
8 -> "7.3";
8 -> "18.6";
8 -> "28.10";
"7.3" -> 9;
9 -> "18.6";
11 -> "10.4";
"10.4" -> 12;
"10.4" -> 13;
"10.4" -> 14;
13 -> "20.7";
13 -> "22.8";
14 -> "22.8";
"15.5" -> 16;
"15.5" -> 17;
16 -> "36.13";
16 -> "50.18";
17 -> "28.10";
17 -> "36.13";
"18.6" -> 19;
19 -> "20.7";
19 -> "25.9";
19 -> "32.11";
"20.7" -> 21;
21 -> "25.9";
21 -> "32.11";
21 -> "35.12";
"22.8" -> 23;
"22.8" -> 24;
23 -> "38.14";
24 -> "38.14";
"25.9" -> 26;
"25.9" -> 27;
26 -> "32.11";
27 -> "32.11";
27 -> "36.13";
"28.10" -> 29;
"28.10" -> 30;
"28.10" -> 31;
29 -> "43.16";
30 -> "43.16";
31 -> "43.16";
"32.11" -> 33;
"32.11" -> 34;
33 -> "38.14";
33 -> "40.15";
34 -> "35.12";
34 -> "36.13";
34 -> "40.15";
34 -> "50.18";
34 -> "56.20";
"36.13" -> 37;
37 -> "50.18";
"38.14" -> 39;
39 -> "40.15";
"40.15" -> 41;
"40.15" -> 42;
42 -> "54.19";
42 -> "56.20";
"43.16" -> 44;
"43.16" -> 45;
"43.16" -> 46;
44 -> "47.17";
45 -> "47.17";
46 -> "47.17";
"47.17" -> 48;
"47.17" -> 49;
49 -> "50.18";
49 -> "54.19";
"50.18" -> 51;
"50.18" -> 52;
"50.18" -> 53;
51 -> "54.19";
51 -> "56.20";
52 -> "54.19";
53 -> "54.19";
"54.19" -> 55;
"56.20" -> 57;
}
52 changes: 49 additions & 3 deletions broker/eblocbroker_scripts/roc.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,60 @@
#!/usr/bin/env python3

import networkx as nx
from broker._utils._log import log
from broker import cfg, config
from broker.config import env, setup_logger
from broker.utils import print_tb


Ebb = cfg.Ebb
logging = setup_logger()

G = nx.Graph()


# G.add_edge("2", "1.1")

"""
"""


def roc_log():
output = Ebb.get_block_number()
event_filter = config.auto.events.LogSoftwareExecRecord.createFilter(
# argument_filters={"to": str(provider)},
fromBlock=23066710,
toBlock="latest",
)
for logged_receipt in event_filter.get_all_entries():
log(logged_receipt.args)
sw = logged_receipt.args.sourceCodeHash
sw = sw.hex()[32:64]
token_index = config.roc.getTokenIndex(sw)
index = logged_receipt.args.index
sw_str = f"{token_index}.{index}"
#
input_hash_bytes = logged_receipt.args.inputHash
output_hash_bytes = logged_receipt.args.outputHash

input_hash_token_index = []
for inp in input_hash_bytes:
_hash = inp.hex()[32:64]
input_hash_token_index.append(config.roc.getTokenIndex(_hash))

output_hash_token_index = []
for out in output_hash_bytes:
_hash = out.hex()[32:64]
output_hash_token_index.append(config.roc.getTokenIndex(_hash))

for inp in input_hash_token_index:
G.add_edge(inp, sw_str)

for out in output_hash_token_index:
G.add_edge(sw_str, out)

nx.nx_pydot.write_dot(G, "original_from_bloxberg.gv")


def roc():
output = Ebb.get_block_number()
Expand All @@ -21,11 +68,10 @@ def roc():
log(logged_receipt.args)
token_id = logged_receipt.args["tokenId"]

breakpoint() # DEBUG


def main():
roc()
# roc()
roc_log()


if __name__ == "__main__":
Expand Down
10 changes: 10 additions & 0 deletions broker/flask/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ hypercorn app_ebb:app -b 127.0.0.1:8000 --reload
curl -v 127.0.0.1:8000
curl -X POST http://127.0.0.1:8000/webhook -d "0x29e613b04125c16db3f3613563bfdd0ba24cb629 0000-0001-7642-0552"
#+end_src

---------------------------------------------

#+begin_src bash
export FLASK_APP=hello
export FLASK_ENV=development
flask run --host=0.0.0.0

curl http://192.168.1.117:5000/
#+end_src
16 changes: 16 additions & 0 deletions broker/flask/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Flask
from broker.utils import run

app = Flask(__name__)


@app.route("/")
def hello():
core_info = run(["sinfo", "-h", "-o%C"]).split("/")

# allocated_cores = int(core_info[0])
idle_cores = int(core_info[1])
# other_cores = int(core_info[2])
# total_cores = int(core_info[3])

return str(idle_cores)
Loading

0 comments on commit d30ad1a

Please sign in to comment.