Skip to content

Commit

Permalink
fix: do not blacklist if the tool selection has not been run
Browse files Browse the repository at this point in the history
This fixes an edge case which is caused when the tx settlement round fails and no tool has been selected. This can happen in two cases: a) after the nevermined subscription round b) after the KPI has been met and the tool selection is skipped intentionally. If this happens, the `HandleFailedTxRound` is called, and then the `BlacklistingRound`. During the blacklisting, no tool has been selected for the current round, and therefore we get:

```
ValueError: 'mech_tool_idx' field is not set for this period [x] and no default value was provided.
```
  • Loading branch information
Adamantios committed Jun 10, 2024
1 parent c51c7d7 commit 900b0af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def setup(self) -> None:

def async_act(self) -> Generator:
"""Do the action."""
# if the tool selection has not been run for the current period, do not do anything
if not self.synchronized_data.has_tool_selection_run:
policy = self.policy.serialize()
payload = BlacklistingPayload(self.context.agent_address, None, policy)
yield from self.finish_behaviour(payload)

with self.context.benchmark_tool.measure(self.behaviour_id).local():
self.read_bets()
Expand Down
6 changes: 6 additions & 0 deletions packages/valory/skills/decision_maker_abci/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def policy(self) -> EGreedyPolicy:
policy = self.db.get_strict("policy")
return EGreedyPolicy.deserialize(policy)

@property
def has_tool_selection_run(self) -> bool:
"""Get whether the tool selection has run."""
mech_tool_idx = self.db.get("mech_tool_idx", None)
return mech_tool_idx is not None

@property
def mech_tool_idx(self) -> int:
"""Get the mech tool's index."""
Expand Down

0 comments on commit 900b0af

Please sign in to comment.