From fbae8d31aaf445406d61e6d39537ffa45208e7ce Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 26 Oct 2023 12:24:08 +0300 Subject: [PATCH 1/3] fix: handle invalid responses --- .../behaviours/decision_receive.py | 2 +- .../valory/skills/decision_maker_abci/models.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py index 0acd8657f..0fcd16304 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -199,7 +199,7 @@ def _get_response(self) -> WaitableConditionType: try: self._mech_response = MechInteractionResponse(**res) - except (ValueError, TypeError): + except (ValueError, TypeError, KeyError): self._mech_response = MechInteractionResponse.incorrect_format(res) return True diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index ffc8f0d09..059ca3135 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -207,10 +207,10 @@ class PredictionResponse: def __init__(self, **kwargs: Any) -> None: """Initialize the mech's prediction ignoring extra keys.""" - self.p_yes = kwargs.pop("p_yes") - self.p_no = kwargs.pop("p_no") - self.confidence = kwargs.pop("confidence") - self.info_utility = kwargs.pop("info_utility") + self.p_yes = float(kwargs.pop("p_yes")) + self.p_no = float(kwargs.pop("p_no")) + self.confidence = float(kwargs.pop("confidence")) + self.info_utility = float(kwargs.pop("info_utility")) # all the fields are probabilities; run checks on whether the current prediction response is valid or not. probabilities = (getattr(self, field) for field in self.__annotations__) @@ -240,10 +240,10 @@ def __init__(self, **kwargs: Any) -> None: """Initialize the mech's response ignoring extra keys.""" self.request_id = kwargs.pop("requestId", 0) self.error = kwargs.pop("error", "Unknown") - result = kwargs.pop("result", None) + self.result = kwargs.pop("result", None) - if isinstance(result, str): - self.result = PredictionResponse(**json.loads(result)) + if isinstance(self.result, str): + self.result = PredictionResponse(**json.loads(self.result)) @classmethod def incorrect_format(cls, res: Any) -> "MechInteractionResponse": From bd00e0f909e77633094b6581ab24b91bbda5fe4e Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 26 Oct 2023 12:24:48 +0300 Subject: [PATCH 2/3] fix: the penalty amount should be in xDAI instead of WEI --- .../skills/decision_maker_abci/behaviours/blacklisting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/blacklisting.py b/packages/valory/skills/decision_maker_abci/behaviours/blacklisting.py index 7d54a984f..6e993cdfc 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/blacklisting.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/blacklisting.py @@ -53,7 +53,7 @@ def _blacklist(self) -> Optional[str]: if self.synchronized_data.is_mech_price_set: # impose a penalty equivalent to the mech's price on the tool responsible for blacklisting the market tool_idx = self.synchronized_data.mech_tool_idx - penalty = -self.synchronized_data.mech_price + penalty = -self.wei_to_native(self.synchronized_data.mech_price) self.policy.add_reward(tool_idx, penalty) return serialize_bets(bets) From afd1361f0594df24cb33e06095b147962c76a0b4 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 26 Oct 2023 12:37:08 +0300 Subject: [PATCH 3/3] chore: run generators --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- packages/valory/skills/decision_maker_abci/skill.yaml | 6 +++--- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index acb7f2c61..388e20e91 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigmy3g2klkzdhttti2ouxf575ua5y7ajmh4a3yfpukeukqxjky47m", - "skill/valory/decision_maker_abci/0.1.0": "bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou", - "skill/valory/trader_abci/0.1.0": "bafybeif472rqlrlfyl5orrgaj5t7qevbccv6xgl3olj53nrbc5vdpfpbcq", + "skill/valory/decision_maker_abci/0.1.0": "bafybeichzmhpgyhk5gc6gepocdaghdwyoutq4x3ul4w7av4lasp7bxfb3y", + "skill/valory/trader_abci/0.1.0": "bafybeifrvvhiaioqqjzyouhi3ga37jk7ataxz5sox275mccqqszcsiehju", "contract/valory/market_maker/0.1.0": "bafybeif4mm2s3gxtvp227yypkcnna5ftec7vajcftvtbdmqddh7nprah5m", - "agent/valory/trader/0.1.0": "bafybeibwom2vpz2bkhdfclszqpaswhgafnkn5xyqi2jg6gs5tnvlrxorvq", - "service/valory/trader/0.1.0": "bafybeifljixfiawbcp7jo5ljjpxdxmmghy47ifhr2phu5uoxtzianhqje4", + "agent/valory/trader/0.1.0": "bafybeidfoajq7jno5ojcgvdkcacialgqr4rsayivkspjdyhcd2povbkiri", + "service/valory/trader/0.1.0": "bafybeihwzztpxd5g3pq5awpdtvbirdkwzt66bj26lpulzay2afsrzubfnq", "contract/valory/erc20/0.1.0": "bafybeibysifjwhlcn7nntsjkowdmja53ed6urfzypi6sxfc7chtheecvpi", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiddjn7jyhg2wjdtfex772vj7alopkszh6gejxqak332tdwvfuwavy", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeib5s5ubudn67phubygrx7lmlzfrhwhy4lo6biusef7ffk2jyipn6a", "contract/valory/mech/0.1.0": "bafybeifaavuqr2bz7nypapjwkufc5c6vwxm5ifucmtd3w7sh42tne35nga", "contract/valory/realitio/0.1.0": "bafybeic3wihpzz4deguslpzlnsgrlrabclq3njwuagyaiiv6rzqujfrs6e", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index d9a956f61..823d1cb07 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -41,10 +41,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeicpxn2khtaesuf4cq6ypwdmdmonlqroj2q2i6cxvpizc2y4cw66pe - valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy - valory/transaction_settlement_abci:0.1.0:bafybeia6cdxdlqrcwk2maw25fo7dafzd2p3rs7syropvufophk2pitzbwy -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiddjn7jyhg2wjdtfex772vj7alopkszh6gejxqak332tdwvfuwavy +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeib5s5ubudn67phubygrx7lmlzfrhwhy4lo6biusef7ffk2jyipn6a - valory/market_manager_abci:0.1.0:bafybeigmy3g2klkzdhttti2ouxf575ua5y7ajmh4a3yfpukeukqxjky47m -- valory/decision_maker_abci:0.1.0:bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou -- valory/trader_abci:0.1.0:bafybeif472rqlrlfyl5orrgaj5t7qevbccv6xgl3olj53nrbc5vdpfpbcq +- valory/decision_maker_abci:0.1.0:bafybeichzmhpgyhk5gc6gepocdaghdwyoutq4x3ul4w7av4lasp7bxfb3y +- valory/trader_abci:0.1.0:bafybeifrvvhiaioqqjzyouhi3ga37jk7ataxz5sox275mccqqszcsiehju default_ledger: ethereum required_ledgers: - ethereum diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index f711ec592..4c420e7dd 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeibwom2vpz2bkhdfclszqpaswhgafnkn5xyqi2jg6gs5tnvlrxorvq +agent: valory/trader:0.1.0:bafybeidfoajq7jno5ojcgvdkcacialgqr4rsayivkspjdyhcd2povbkiri number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index e36ec50c1..49333f5e1 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -14,8 +14,8 @@ fingerprint: behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky behaviours/base.py: bafybeidny4y4w4jbjbp5d5qivur6jm37fnuik4mqzchzshiuvpozxe7vwy behaviours/bet_placement.py: bafybeiauzdizqawjgzc3ugx33vuh726e25juhacqdr7c6uztpn6tra5dva - behaviours/blacklisting.py: bafybeih2yrimf4l5t7mdqnmxv3zzv67fuzxytzbwcsmkcs5crbtmwccsry - behaviours/decision_receive.py: bafybeibfnucc444uqcythgsn4cawluubbi4u4q7ab4aqc4ts3lu4qnvhdq + behaviours/blacklisting.py: bafybeicl6b4hcmqmekta2mcuhkkydnzk7jmic6k44e6ns3u2ibad3awzvu + behaviours/decision_receive.py: bafybeiesgn3gaj34n554apuxhq7jldtjgnir77fvnkr3tw5t4fprbvqhum behaviours/decision_request.py: bafybeibrk6jxalkgspinmjboqr3o6d6hl6mxtlkif74a5p32vp2zzhhzua behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm behaviours/reedem.py: bafybeihywv5332ngbz4hhcwjbaglctblwjbfhdenppznnlxbsgnxdhrrim @@ -25,7 +25,7 @@ fingerprint: dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm fsm_specification.yaml: bafybeifnob3ceim2mj7lqagtnpwqjqqxs5eg3oiwc73gwm6x5i2dvvlcya handlers.py: bafybeihj33szgrcxnpd73s4nvluyxwwsvhjum2cuq3ilhhe6vfola3k7vy - models.py: bafybeihp2heb2x7qyyvlaxr7slaxofflkhnrvrfdaorwc5ztnui2f7huly + models.py: bafybeihy4igjg72xsgcntawxnzhimsrq2rlucmlbceeglqdgnihazoclxu payloads.py: bafybeiawx6ix2ljvf545fe3wocdoh7frds6gjvzgv62b3w6huaolgvywqi policy.py: bafybeidpmx4ek3qze63zpuwixyf6t7bdv62ewgkzt3ljrzadiwdw64cueq redeem_info.py: bafybeibddfxwp3577c3dl2utaowwltquu5fg6crezpumoebw563wxpbfrm diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 654e1b4aa..cbdad3b49 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -25,8 +25,8 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeia6cdxdlqrcwk2maw25fo7dafzd2p3rs7syropvufophk2pitzbwy - valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy - valory/market_manager_abci:0.1.0:bafybeigmy3g2klkzdhttti2ouxf575ua5y7ajmh4a3yfpukeukqxjky47m -- valory/decision_maker_abci:0.1.0:bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiddjn7jyhg2wjdtfex772vj7alopkszh6gejxqak332tdwvfuwavy +- valory/decision_maker_abci:0.1.0:bafybeichzmhpgyhk5gc6gepocdaghdwyoutq4x3ul4w7av4lasp7bxfb3y +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeib5s5ubudn67phubygrx7lmlzfrhwhy4lo6biusef7ffk2jyipn6a behaviours: main: args: {} diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index de9482f92..0fb9b460a 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -20,7 +20,7 @@ contracts: [] protocols: [] skills: - valory/abstract_round_abci:0.1.0:bafybeid7neqpxxe4ualp23gxgrtpf6r5u3myr2mmc4uvwameyqshfdoydq -- valory/decision_maker_abci:0.1.0:bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou +- valory/decision_maker_abci:0.1.0:bafybeichzmhpgyhk5gc6gepocdaghdwyoutq4x3ul4w7av4lasp7bxfb3y behaviours: main: args: {}