Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: misc #266

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"contract/valory/mech_marketplace/0.1.0": "bafybeigulghv7bvx4evl6kmogvv6gjxovyt22tkwlbdmeretmop2crdmem",
"connection/valory/websocket_client/0.1.0": "bafybeic4ag3gqc7kd3k2o3pucddj2odck5yrfbgmwh5veqny7zao5qayli",
"skill/valory/contract_subscription/0.1.0": "bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy",
"skill/valory/mech_abci/0.1.0": "bafybeiela4chgu4ricmgweqnoswisfcfbwvddwwurolhxfba66hkmhwmui",
"skill/valory/task_submission_abci/0.1.0": "bafybeihy4a4b2rsmygsiuvoxap5d6m4fp5wjvdhrduvenj33zqziz7tequ",
"skill/valory/task_execution/0.1.0": "bafybeiagehlvfakmj632ta2yw6s3pa5um4goipcmcjnlwj7yrffmnhn26a",
"skill/valory/mech_abci/0.1.0": "bafybeibf5gxrngzn6j7qr5zvsshjoaxitt5e2bj6bybj73k6e3gdbggzge",
"skill/valory/task_submission_abci/0.1.0": "bafybeigrhzhk6qkmb5kaslkymsr3mnagoycl2kxqtiqfp6whkuyqc65lim",
"skill/valory/task_execution/0.1.0": "bafybeiafdhx4tyke5qao47cx5yuqnaivl47kuuu4xfdx3ndym6mvng3jve",
"skill/valory/websocket_client/0.1.0": "bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m",
"skill/valory/subscription_abci/0.1.0": "bafybeicazs3nnrztew6j5vanmpb3lnhx4a2rclcqxjr7tmtu3adhn5dziy",
"agent/valory/mech/0.1.0": "bafybeia7qkuszlbngi7n7typcccb5zooalfvt3oayj7rsgxx7icfclzb2e",
"service/valory/mech/0.1.0": "bafybeic5fodulsvrcu6gqy5huxntcanmzowfmlaetd2aotrkl52dkc73la"
"agent/valory/mech/0.1.0": "bafybeigk33wlthqhriruwyv44gcx754xzlne3ywynxg6ezswabac7dcmmq",
"service/valory/mech/0.1.0": "bafybeihy67owel7dgyoaaugjqbcvk6x2edgw7ogsqn7qjvpu32rkjim4y4"
},
"third_party": {
"protocol/valory/default/1.0.0": "bafybeifqcqy5hfbnd7fjv4mqdjrtujh2vx3p2xhe33y67zoxa6ph7wdpaq",
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/agents/mech/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ skills:
- valory/abstract_abci:0.1.0:bafybeieo7pe5wqjphs5izpz5aujjbubymlxub62b3rhx6yglu65ibalffu
- valory/abstract_round_abci:0.1.0:bafybeibiw4oqwqvo4jccwz5fb73iardzychgvcl66tceiildohoju2ikti
- valory/contract_subscription:0.1.0:bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy
- valory/mech_abci:0.1.0:bafybeiela4chgu4ricmgweqnoswisfcfbwvddwwurolhxfba66hkmhwmui
- valory/mech_abci:0.1.0:bafybeibf5gxrngzn6j7qr5zvsshjoaxitt5e2bj6bybj73k6e3gdbggzge
- valory/registration_abci:0.1.0:bafybeib3n6vqkfbrcubcbliebjnuwyywdinxkbzt76n6gbn2kg7ace47dq
- valory/reset_pause_abci:0.1.0:bafybeihkj6lmaypspyxe5qqrjgnolyck62pyvqoylr24ab6ue4steqcw7e
- valory/subscription_abci:0.1.0:bafybeicazs3nnrztew6j5vanmpb3lnhx4a2rclcqxjr7tmtu3adhn5dziy
- valory/task_execution:0.1.0:bafybeiagehlvfakmj632ta2yw6s3pa5um4goipcmcjnlwj7yrffmnhn26a
- valory/task_submission_abci:0.1.0:bafybeihy4a4b2rsmygsiuvoxap5d6m4fp5wjvdhrduvenj33zqziz7tequ
- valory/task_execution:0.1.0:bafybeiafdhx4tyke5qao47cx5yuqnaivl47kuuu4xfdx3ndym6mvng3jve
- valory/task_submission_abci:0.1.0:bafybeigrhzhk6qkmb5kaslkymsr3mnagoycl2kxqtiqfp6whkuyqc65lim
- valory/termination_abci:0.1.0:bafybeifi2uodnrjsrivj53g3sjutocmyusbx6mlsb6oanqdyt2mfbyvusy
- valory/transaction_settlement_abci:0.1.0:bafybeigh2vkt74jrad5gtsczrgqcuhcqe7jkgjy7jdw56yamlzwwnaymjy
- valory/websocket_client:0.1.0:bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m
Expand Down
14 changes: 5 additions & 9 deletions packages/valory/services/mech/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeif7ia4jdlazy6745ke2k2x5yoqlwsgwr6sbztbgqtwvs3ndm2p7ba
fingerprint_ignore_patterns: []
agent: valory/mech:0.1.0:bafybeia7qkuszlbngi7n7typcccb5zooalfvt3oayj7rsgxx7icfclzb2e
agent: valory/mech:0.1.0:bafybeigk33wlthqhriruwyv44gcx754xzlne3ywynxg6ezswabac7dcmmq
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -197,8 +197,7 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
tools_to_package_hash: ${TOOLS_TO_PACKAGE_HASH:dict:{}}
api_keys: ${API_KEYS:dict:{}}
polling_interval: ${POLLING_INTERVAL:float:30.0}
agent_index: ${AGENT_INDEX_0:int:0}
Expand All @@ -213,8 +212,7 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
tools_to_package_hash: ${TOOLS_TO_PACKAGE_HASH:dict:{}}
api_keys: ${API_KEYS:dict:{}}
polling_interval: ${POLLING_INTERVAL:float:30.0}
mech_marketplace_address: ${MECH_MARKETPLACE_ADDRESS:str:0x0000000000000000000000000000000000000000}
Expand All @@ -229,8 +227,7 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
tools_to_package_hash: ${TOOLS_TO_PACKAGE_HASH:dict:{}}
api_keys: ${API_KEYS:dict:{}}
polling_interval: ${POLLING_INTERVAL:float:30.0}
mech_marketplace_address: ${MECH_MARKETPLACE_ADDRESS:str:0x0000000000000000000000000000000000000000}
Expand All @@ -245,8 +242,7 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
tools_to_package_hash: ${TOOLS_TO_PACKAGE_HASH:dict:{}}
api_keys: ${API_KEYS:dict:{}}
mech_marketplace_address: ${MECH_MARKETPLACE_ADDRESS:str:0x0000000000000000000000000000000000000000}
polling_interval: ${POLLING_INTERVAL:float:30.0}
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/mech_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skills:
- valory/abstract_round_abci:0.1.0:bafybeibiw4oqwqvo4jccwz5fb73iardzychgvcl66tceiildohoju2ikti
- valory/registration_abci:0.1.0:bafybeib3n6vqkfbrcubcbliebjnuwyywdinxkbzt76n6gbn2kg7ace47dq
- valory/reset_pause_abci:0.1.0:bafybeihkj6lmaypspyxe5qqrjgnolyck62pyvqoylr24ab6ue4steqcw7e
- valory/task_submission_abci:0.1.0:bafybeihy4a4b2rsmygsiuvoxap5d6m4fp5wjvdhrduvenj33zqziz7tequ
- valory/task_submission_abci:0.1.0:bafybeigrhzhk6qkmb5kaslkymsr3mnagoycl2kxqtiqfp6whkuyqc65lim
- valory/termination_abci:0.1.0:bafybeifi2uodnrjsrivj53g3sjutocmyusbx6mlsb6oanqdyt2mfbyvusy
- valory/transaction_settlement_abci:0.1.0:bafybeigh2vkt74jrad5gtsczrgqcuhcqe7jkgjy7jdw56yamlzwwnaymjy
- valory/subscription_abci:0.1.0:bafybeicazs3nnrztew6j5vanmpb3lnhx4a2rclcqxjr7tmtu3adhn5dziy
Expand Down
16 changes: 15 additions & 1 deletion packages/valory/skills/task_execution/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ def _execute_task(self) -> None:
self._executing_task = task_data
task_data_ = task_data["data"]
ipfs_hash = get_ipfs_file_hash(task_data_)
if ipfs_hash is None:
self.context.logger.error(f"Invalid request data on {task_data_}")
self._invalid_request = True
return
self.context.logger.info(f"IPFS hash: {ipfs_hash}")
ipfs_msg, message = self._build_ipfs_get_file_req(ipfs_hash)
self.send_message(ipfs_msg, message, self._handle_get_task)
Expand Down Expand Up @@ -413,9 +417,19 @@ def _handle_timeout_task(self) -> None:
)
self._handle_done_task(task_result)

def _safely_get_task_data(self, message: IpfsMessage) -> Optional[Dict[str, Any]]:
"""Safely get task data."""
try:
[json.loads(content) for content in message.files.values()][0]
except Exception as e: # pylint: disable=broad-except
self.context.logger.error(
f"Exception raised while decoding task data: {str(e)}"
)
return None

def _handle_get_task(self, message: IpfsMessage, dialogue: Dialogue) -> None:
"""Handle the response from ipfs for a task request."""
task_data = [json.loads(content) for content in message.files.values()][0]
task_data = self._safely_get_task_data(message)
is_data_valid = (
task_data
and isinstance(task_data, dict)
Expand Down
4 changes: 2 additions & 2 deletions packages/valory/skills/task_execution/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeidqhvvlnthkbnmrdkdeyjyx2f2ab6z4xdgmagh7welqnh2v6wczx4
behaviours.py: bafybeihlkuquunpfz6vc5ffoqsayi7567rpbbto7eblcac6e4h72qh74qe
behaviours.py: bafybeiexshowozpbzuomhezg3a5b2re77ikidjkiy3fov2tsfiqyk6dmwe
dialogues.py: bafybeid4zxalqdlo5mw4yfbuf34hx4jp5ay5z6chm4zviwu4cj7fudtwca
handlers.py: bafybeidbt5ezj74cgfogk3w4uw4si2grlnk5g54veyumw7g5yh6gdscywu
models.py: bafybeigszq73slogvebsaxh32p325fxthyuuwwtot7qxj3bdyho7x7spuq
utils/__init__.py: bafybeiccdijaigu6e5p2iruwo5mkk224o7ywedc7nr6xeu5fpmhjqgk24e
utils/apis.py: bafybeidqt5nqcymlpwlycnvpsheeeexk3tb3yboceeeizwpd6miqewtr7u
utils/benchmarks.py: bafybeiafnee7iay6dyjnatyqyzjov5c4ibl3ojamjmgfjri7cyghl7qayq
utils/cost_calculation.py: bafybeighafxied73w3mcmgziwfp3u2x6t4qlztw4kyekyq2ddgyhdge74q
utils/ipfs.py: bafybeic7cbuv3tomi2xv7h2qowrqnpoufpanngzlgzljl4ptimpss3meqm
utils/ipfs.py: bafybeicp6d2y4aguetcod2yzxrbiqqwkzarzccyf2iajuwvrcfckmn6jm4
utils/task.py: bafybeicb6nqd475ul6mz4hcexpva33ivkn4fygicgmlb4clu5cuzr34diy
fingerprint_ignore_patterns: []
connections:
Expand Down
9 changes: 7 additions & 2 deletions packages/valory/skills/task_execution/utils/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# ------------------------------------------------------------------------------
"""This module contains helpers for IPFS interaction."""
from typing import Any, Dict, Tuple
from typing import Any, Dict, Optional, Tuple

import yaml
from aea.helpers.cid import CID
Expand All @@ -28,16 +28,21 @@
CID_PREFIX = "f01701220"


def get_ipfs_file_hash(data: bytes) -> str:
def get_ipfs_file_hash(data: bytes) -> Optional[str]:
"""Get hash from bytes"""
try:
return str(CID.from_string(data.decode()))
except Exception: # noqa
# if something goes wrong, fallback to sha256
pass
try:
file_hash = data.hex()
file_hash = CID_PREFIX + file_hash
file_hash = str(CID.from_string(file_hash))
return file_hash
except Exception:
# return None if all fails
return None


def to_multihash(hash_string: str) -> str:
Expand Down
3 changes: 2 additions & 1 deletion packages/valory/skills/task_submission_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class TaskSubmissionAbciApp(AbciApp[Event]):
}
db_post_conditions: Dict[AppState, Set[str]] = {
FinishedTaskPoolingRound: {"most_voted_tx_hash", "final_tx_hash"},
# added to avoid ABCI check errors
FinishedWithoutTasksRound: {"most_voted_tx_hash", "final_tx_hash"},
FinishedTaskExecutionWithErrorRound: set(),
FinishedWithoutTasksRound: set(),
}
4 changes: 2 additions & 2 deletions packages/valory/skills/task_submission_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fingerprint:
handlers.py: bafybeibe5n7my2vd2wlwo73sbma65epjqc7kxgtittewlylcmvnmoxtxzq
models.py: bafybeicoes4rtg2edxpdxlrow5dmnof2lm6xscagzp55mocrkbxy2xlxwe
payloads.py: bafybeia2yorri2u5rwh6vukb6iwdrbn53ygsuuhthns2txptvjipyb6f4e
rounds.py: bafybeibgoozf7jmk7g6ahxl6zxaswny35amyiwjakgo5ixxvp7lokz4huu
rounds.py: bafybeicsh6fagw7yv37nsyqcwvqztgwugbndqv5w7kzs6p36qntthmkyfa
tasks.py: bafybeicu5t5cvfhbndgpxbbtmp4vbmtyb6fba6vsnlewftvuderxp5lwcy
fingerprint_ignore_patterns: []
connections: []
Expand All @@ -32,7 +32,7 @@ protocols:
skills:
- valory/abstract_round_abci:0.1.0:bafybeibiw4oqwqvo4jccwz5fb73iardzychgvcl66tceiildohoju2ikti
- valory/transaction_settlement_abci:0.1.0:bafybeigh2vkt74jrad5gtsczrgqcuhcqe7jkgjy7jdw56yamlzwwnaymjy
- valory/task_execution:0.1.0:bafybeiagehlvfakmj632ta2yw6s3pa5um4goipcmcjnlwj7yrffmnhn26a
- valory/task_execution:0.1.0:bafybeiafdhx4tyke5qao47cx5yuqnaivl47kuuu4xfdx3ndym6mvng3jve
behaviours:
main:
args: {}
Expand Down
Loading