Skip to content

Commit

Permalink
Nonce fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
calina-c committed Oct 25, 2023
1 parent 9419ffe commit d644b33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 1 addition & 3 deletions ocean_lib/data_provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def set_http_client(http_client: Session) -> None:

@staticmethod
@enforce_types
def sign_message(
wallet, msg: str, provider_uri: Optional[str] = None
) -> Tuple[str, str]:
def sign_message(wallet, msg: str, provider_uri: str) -> Tuple[str, str]:
if provider_uri:
method, nonce_endpoint = DataServiceProviderBase.build_endpoint(
"nonce", provider_uri
Expand Down
7 changes: 5 additions & 2 deletions ocean_lib/data_provider/data_service_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
"""Provider module."""
import json
import logging
from datetime import datetime, timezone
from json import JSONDecodeError
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
from unittest.mock import Mock

from enforce_typing import enforce_types
from requests.models import PreparedRequest, Response
Expand Down Expand Up @@ -345,6 +343,7 @@ def compute_job_result(
nonce, signature = DataServiceProvider.sign_message(
consumer,
f"{consumer.address}{job_id}{str(index)}",
provider_uri=dataset_compute_service.service_endpoint,
)

req = PreparedRequest()
Expand Down Expand Up @@ -415,6 +414,7 @@ def _send_compute_request(
nonce, signature = DataServiceProvider.sign_message(
consumer,
f"{consumer.address}{job_id}{did}",
provider_uri=service_endpoint,
)

req = PreparedRequest()
Expand Down Expand Up @@ -473,9 +473,12 @@ def _prepare_compute_payload(
_input, req_key
), f"The received dataset does not have a {req_key}."

# TODO: is the nonce correct here?
# Should it be the one from the compute service or a dataset?
nonce, signature = DataServiceProvider.sign_message(
consumer,
f"{consumer.address}{dataset.did}",
provider_uri=dataset.service.service_endpoint,
)

payload = {
Expand Down
2 changes: 1 addition & 1 deletion tests/readmes/test_readmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_script_execution(self, script_name):
"publish-flow-credentials",
"publish-flow-restapi", # TODO: fix and restore
"gas-strategy-remote",
# "using-clef", # TODO: removed original clef readme, to reinstate in #1461
"using-clef", # TODO: removed original clef readme, to reinstate in #1461
]

if script_name.replace("test_", "").replace(".py", "") in skippable:
Expand Down

0 comments on commit d644b33

Please sign in to comment.