Skip to content

Commit

Permalink
Fix equence has incorrect length in process_payment().
Browse files Browse the repository at this point in the history
  • Loading branch information
avatar-lavventura committed Jun 11, 2022
1 parent 3218f29 commit aa99b80
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
4 changes: 4 additions & 0 deletions broker/eblocbroker_scripts/Contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ def timeout_wrapper(self, method, *args):
try:
return self.timeout(method, *args)
except ValueError as e:
if "Sequence has incorrect length" in str(e):
print_tb(e)
raise QuietExit from e

if "There is another transaction with same nonce in the queue" in str(e):
log(f"warning: Tx: {e}")
log("#> sleeping for 15 seconds, will try again")
Expand Down
7 changes: 3 additions & 4 deletions broker/eblocbroker_scripts/process_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ def process_payment(
int(ended_timestamp),
int(data_transfer_in),
int(data_transfer_out),
# int(elapsed_time), # TODO
int(elapsed_time),
core,
run_time,
final_job,
]
tx = self._process_payment(job_key, args, int(elapsed_time), result_ipfs_hash)
# tx = self._process_payment(job_key, args, result_ipfs_hash) # TODO
tx = self._process_payment(job_key, args, result_ipfs_hash)
except Exception as e:
print_tb(e)
raise e
Expand Down Expand Up @@ -123,7 +122,7 @@ def main():
core,
run_time,
)
log(f"tx_hash={tx_hash}")
log(f"tx_hash={tx_hash}", "bold")
except:
sys.exit(1)

Expand Down
28 changes: 22 additions & 6 deletions broker/eblocbroker_scripts/watch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import os
import sys
import time
from pathlib import Path
Expand All @@ -8,6 +9,8 @@
from broker._utils import _log
from broker._utils._log import _console_clear
from broker._utils.tools import _date, log, print_tb
from broker._utils.yaml import Yaml
from broker.errors import QuietExit
from broker.lib import state

# from broker.test_setup.user_set import providers
Expand All @@ -16,15 +19,28 @@
watch_only_jobs = True


def get_eth_address_from_cfg():
hidden_base_dir = Path.home() / ".ebloc-broker"
fn = hidden_base_dir / "cfg.yaml"
if not os.path.isfile(fn):
if not os.path.isdir(hidden_base_dir):
raise QuietExit(f"E: {hidden_base_dir} is not initialized")

raise QuietExit(f"E: {fn} is not created")

cfg_yaml = Yaml(fn)
cfg = cfg_yaml["cfg"]
return cfg.w3.toChecksumAddress(cfg["eth_address"].lower())


def watch(eth_address="", from_block=None):
from_block = 15394725
# if not eth_address:
# # TODO: pull from cfg
# eth_address = "0xeab50158e8e51de21616307a99c9604c1c453a02"

if not eth_address:
log("E: eth_address is empty, run as: ./watch.py <eth_address>")
sys.exit(1)
try:
eth_address = get_eth_address_from_cfg()
except Exception as e:
log(f"E: {e}\neth_address is empty, run as: ./watch.py <eth_address>")
sys.exit(1)

if not from_block:
from_block = Ebb.get_block_number() - cfg.ONE_DAY_BLOCK_DURATION
Expand Down

0 comments on commit aa99b80

Please sign in to comment.