Skip to content

Commit

Permalink
Merge pull request #637 from golemfactory/bug-fix-calculate-subtask-v…
Browse files Browse the repository at this point in the history
…erification-time-uses-calculate-maximum-download-time

Fix calculate_subtask_verification_time to use only concent settings
  • Loading branch information
pawelkisielewicz authored Jul 13, 2018
2 parents b27ae04 + d058d3c commit e175336
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions concent_api/concent_api/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

GETH_ADDRESS = 'http://localhost:8545'

CONCENT_UPLOAD_RATE = int(384 / 8) # KB/s = kbps / 8

STORAGE_SERVER_INTERNAL_ADDRESS = 'http://127.0.0.1:8001/'

VERIFIER_STORAGE_PATH = os.path.join(BASE_DIR, 'verifier_storage')
6 changes: 3 additions & 3 deletions concent_api/concent_api/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@

STORAGE_CLUSTER_ADDRESS = 'http://localhost/'

CONCENT_MESSAGING_TIME = 2

STORAGE_SERVER_INTERNAL_ADDRESS = 'http://localhost/'

VERIFIER_STORAGE_PATH = '/tmp/'

CONCENT_MESSAGING_TIME = 0
CONCENT_MESSAGING_TIME = 2

CONCENT_UPLOAD_RATE = int(384 / 8) # KB/s = kbps / 8

FORCE_ACCEPTANCE_TIME = 5

Expand Down
5 changes: 4 additions & 1 deletion concent_api/core/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def test_that_calculate_subtask_verification_time_will_not_call_subtask_verifica
mock_subtask_verification_time.assert_not_called()

@override_settings(
CONCENT_MESSAGING_TIME=int(constants.CMT.total_seconds())
CONCENT_MESSAGING_TIME=int(constants.CMT.total_seconds()),
CONCENT_UPLOAD_RATE=constants.DEFAULT_UPLOAD_RATE,
DOWNLOAD_LEADIN_TIME=constants.DOWNLOAD_LEADIN_TIME.total_seconds(),
CUSTOM_PROTOCOL_TIMES=True # overridden to ensure this setting is always True, otherwise this test has no sense
)
def test_that_both_subtask_verification_time_implementation_should_return_same_result_when_golem_messages_constants_match_concent_settings(self):
current_time = get_current_utc_timestamp()
Expand Down
5 changes: 4 additions & 1 deletion concent_api/core/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from base64 import b64encode
from typing import List
from typing import Optional
from typing import Union
import datetime
import functools
import mock
Expand Down Expand Up @@ -167,7 +168,7 @@ def _get_deserialized_report_computed_task(

def _get_deserialized_task_to_compute(
self,
timestamp: Optional[str] = None,
timestamp: Union[str, datetime.datetime, None] = None,
deadline = None,
task_id: str = '1',
subtask_id: str = '2',
Expand Down Expand Up @@ -197,6 +198,8 @@ def _get_deserialized_task_to_compute(
assert isinstance(requestor_public_key, str) or requestor_public_key is None
assert isinstance(provider_id, str) or provider_id is None
assert isinstance(provider_public_key, str) or provider_public_key is None
assert isinstance(timestamp, (str, datetime.datetime)) or timestamp is None

with freeze_time(timestamp or self._get_timestamp_string()):
task_to_compute = TaskToComputeFactory(
compute_task_def=compute_task_def,
Expand Down
5 changes: 3 additions & 2 deletions concent_api/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ def calculate_subtask_verification_time(report_computed_task: message.ReportComp
assert isinstance(report_computed_task, message.ReportComputedTask)

if settings.CUSTOM_PROTOCOL_TIMES:
mdt = maximum_download_time(
mdt = calculate_maximum_download_time(
size=report_computed_task.size,
rate=settings.CONCENT_UPLOAD_RATE
)
ttc_dt = datetime.datetime.utcfromtimestamp(
report_computed_task.task_to_compute.timestamp,
Expand All @@ -63,7 +64,7 @@ def calculate_subtask_verification_time(report_computed_task: message.ReportComp

return int(
(4 * settings.CONCENT_MESSAGING_TIME) +
(3 * mdt.total_seconds()) +
(3 * mdt) +
(0.5 * subtask_timeout.total_seconds())
)
else:
Expand Down

0 comments on commit e175336

Please sign in to comment.