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

Feat/multibet benchmarking #347

Merged
merged 71 commits into from
Nov 28, 2024
Merged
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
3235d9d
default value for sample bet index
cyberosa Oct 29, 2024
65bab35
initial commit
cyberosa Nov 6, 2024
fe7334c
updating hashes of packages
cyberosa Nov 6, 2024
76e3f98
preparing decisionreceive behaviour for sampled_bet
cyberosa Nov 6, 2024
546fd93
fix a parameter in compute scaledLiqudityMeasure
cyberosa Nov 7, 2024
9739692
update: fsm for benchmarking multi bet
keshav1998 Nov 7, 2024
550593c
update: transitions for decision maker abci
keshav1998 Nov 7, 2024
51713f1
add: read bets functionality for benchmarking
keshav1998 Nov 7, 2024
875c490
add: transition for benchmarking mode
keshav1998 Nov 7, 2024
17ecc9f
add: bet id manager state
keshav1998 Nov 7, 2024
2e8fa39
add: bet id row extraction for benchmarkin
keshav1998 Nov 7, 2024
1ad0d75
update: benchamrking for multi market
keshav1998 Nov 7, 2024
9380e0f
update: packages for benchmarking
keshav1998 Nov 7, 2024
408f956
edit: revert outcomes benchmarking variables
keshav1998 Nov 7, 2024
0c2a45a
update: hashes for benchmarking
keshav1998 Nov 7, 2024
27b81df
fix: benchmarking fixes for decision rounds
keshav1998 Nov 7, 2024
41b0849
latest status working but bets.json not updated
cyberosa Nov 7, 2024
8df465b
fix: empty list popping in bets manager
keshav1998 Nov 8, 2024
c0a4f2d
mergeof hotfixes
cyberosa Nov 8, 2024
747fbc3
updating hashes
cyberosa Nov 8, 2024
ee1b2fa
cleaning, several fixes and adding blacklisting
cyberosa Nov 8, 2024
61fb6b1
Fixing the n_bets wrong update
cyberosa Nov 11, 2024
551431c
fixing packages hashes
cyberosa Nov 12, 2024
deac394
merge with main
cyberosa Nov 14, 2024
6f67953
fix: blacklisting round transitions for benchmarking
keshav1998 Nov 14, 2024
6c1922e
Finishing benchmarking from SamplingRound
cyberosa Nov 15, 2024
cc62c3d
bending time and fixed randomness in benchmarking
cyberosa Nov 18, 2024
a940e0f
merge with main
cyberosa Nov 20, 2024
c164516
Update packages/valory/agents/trader/aea-config.yaml
cyberosa Nov 21, 2024
5b03068
Update packages/valory/skills/decision_maker_abci/behaviours/decision…
cyberosa Nov 21, 2024
8845f9c
Comments from PR review
cyberosa Nov 21, 2024
719e562
Merge branch 'feat/multibet_benchmarking' of https://github.com/valor…
cyberosa Nov 21, 2024
14f67c1
merging more comments
cyberosa Nov 21, 2024
becb37f
removed old benchmarking params not used anymore
cyberosa Nov 22, 2024
099beaa
removed old benchmarking params not used anymore
cyberosa Nov 22, 2024
7ed4d2a
using question_id_field
cyberosa Nov 22, 2024
83e9843
new PR comments
cyberosa Nov 22, 2024
8fa9722
Update packages/valory/skills/decision_maker_abci/behaviours/decision…
cyberosa Nov 22, 2024
69511d5
Update packages/valory/skills/decision_maker_abci/behaviours/decision…
cyberosa Nov 22, 2024
1ad3178
Update packages/valory/skills/decision_maker_abci/behaviours/sampling.py
cyberosa Nov 22, 2024
ca67f79
Update packages/valory/skills/decision_maker_abci/behaviours/sampling.py
cyberosa Nov 22, 2024
e22734a
more PR comments
cyberosa Nov 22, 2024
41d4c02
Merge branch 'feat/multibet_benchmarking' of https://github.com/valor…
cyberosa Nov 22, 2024
b34b48a
Update packages/valory/skills/decision_maker_abci/behaviours/sampling.py
cyberosa Nov 22, 2024
8ede944
Merge branch 'feat/multibet_benchmarking' of https://github.com/valor…
cyberosa Nov 22, 2024
d20cedf
restoring init in skills
cyberosa Nov 22, 2024
03c91dc
restoring init file in valory folder
cyberosa Nov 22, 2024
95d9d95
merge with main
cyberosa Nov 27, 2024
359e238
Updating hashes
cyberosa Nov 27, 2024
d157b3c
new try to fix hashes
cyberosa Nov 27, 2024
5d3b93c
fixing code checks
cyberosa Nov 27, 2024
1ee0ae6
fixing last linter check
cyberosa Nov 27, 2024
e236a6c
adding precision to token prices
cyberosa Nov 27, 2024
530b815
Update packages/valory/skills/decision_maker_abci/behaviours/base.py
cyberosa Nov 27, 2024
2838a0c
Update packages/valory/skills/decision_maker_abci/behaviours/decision…
cyberosa Nov 27, 2024
e53dbb0
updating hashes
cyberosa Nov 27, 2024
d72e4b9
fixing linter checks
cyberosa Nov 27, 2024
f1a2c02
fixing black formatting
cyberosa Nov 27, 2024
b55ff80
Fixing docstrings
cyberosa Nov 27, 2024
9f772a3
fix: create a new event for the resampling
Adamantios Nov 27, 2024
9560768
refactor: convert the token precision to a constant
Adamantios Nov 27, 2024
889025b
fix: remove `BENCHMARKING_FINISHED` event
Adamantios Nov 27, 2024
7029d78
updating hashes after last PR comments
cyberosa Nov 27, 2024
1922032
black formatting
cyberosa Nov 27, 2024
e4d438b
fixing docstrings
cyberosa Nov 27, 2024
ac570c7
fixing docstrings
cyberosa Nov 27, 2024
73ae01b
fixing fsm spec errors
cyberosa Nov 27, 2024
6294e84
fixing loop
cyberosa Nov 27, 2024
8de81f5
black formatting
cyberosa Nov 27, 2024
1944fe4
trying to fix tests
cyberosa Nov 27, 2024
fd089f4
fixing test payload
cyberosa Nov 28, 2024
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
Prev Previous commit
Next Next commit
Finishing benchmarking from SamplingRound
cyberosa committed Nov 15, 2024
commit 6c1922eff6aaa2989a480353331ecf652e9d617a
14 changes: 7 additions & 7 deletions packages/packages.json
Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@
"contract/valory/mech_activity/0.1.0": "bafybeibmqmle5fnal3gxlpdmcos2kogzra4q3pr3o5nh7shplxuilji3t4",
"contract/valory/staking_token/0.1.0": "bafybeiep4r6qyilbfgzdvx6t7zvpgaioxqktmxm7puwtnbpb2ftlib43gy",
"contract/valory/relayer/0.1.0": "bafybeicawmds6czx7db2lcktvexwrp245jpekgulndtos5s5zdid3ilvq4",
"skill/valory/market_manager_abci/0.1.0": "bafybeicia7itulcrxlwbmhfzxppgo5i33tb2nmcycwizftw7gps4dareka",
"skill/valory/decision_maker_abci/0.1.0": "bafybeiaizbnlz46lba6tcwmajpo2z37cpxuobeqmlgdqbdxnt65jr6rely",
"skill/valory/trader_abci/0.1.0": "bafybeido4dpfcvpyrobs2veoliuwaz2ltuzvo2gqfbsqxgd5tdr7zllyru",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeieszb6lxyy5gt4m4f75fjicuzf3ewsxgxcc5dh4l2tjjau7wcrgxe",
"skill/valory/market_manager_abci/0.1.0": "bafybeid42tfvzicskpdxeppatzvghj2i2bqdtkgs4wobgadwgtp3jr5rme",
"skill/valory/decision_maker_abci/0.1.0": "bafybeibwwruz3ivtmfzgvdp6x5u4xju2xgzowyr7bcaetdwwujaccxccwa",
"skill/valory/trader_abci/0.1.0": "bafybeic42a6pqlbzboldym3vdmbaqntyxrdffbd3jxeomb357va2xkf2iq",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiatdmznskbmr7wxsipv7vqmdagkg2qtdulkyylxdqemkna7hvtqke",
"skill/valory/staking_abci/0.1.0": "bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeifmi64g4ki6zwbcncb35ovhd4sllw4xrszrkturpeqdhgf5bkiini",
"agent/valory/trader/0.1.0": "bafybeifaw3dk5uklcgj5iftcdhj4p2ymkidoli3uxibq4olddd3eboey7e",
"service/valory/trader/0.1.0": "bafybeiaqqlwqjiofrezpnk4hq6doiccbquzgmd6pcgtfx7akmfhhvyoipi",
"service/valory/trader_pearl/0.1.0": "bafybeidzv544ive2oozjk2szmengrcszea7ai54qts7ehdjdkwevwtwfba"
"agent/valory/trader/0.1.0": "bafybeiddrqpwljunbl5abjtkmfmrhqsvlbokocxqqcnlerdx34iek56pxu",
"service/valory/trader/0.1.0": "bafybeifge5kwtoomw7py3id7zvezs7bwmxoi2s7n6hwl2epkpmcxgbpnyy",
"service/valory/trader_pearl/0.1.0": "bafybeigfonh6ktksn6so63qgxqw5xkk33th353nglaeuoznqtmjelar6j4"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
8 changes: 4 additions & 4 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
@@ -45,10 +45,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeigrdlxed3xlsnxtjhnsbl3cojruihxcqx4jxhgivkd5i2fkjncgba
- valory/termination_abci:0.1.0:bafybeib5l7jhew5ic6iq24dd23nidcoimzqkrk556gqywhoziatj33zvwm
- valory/transaction_settlement_abci:0.1.0:bafybeic7q7recyka272udwcupblwbkc3jkodgp74fvcdxb7urametg5dae
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeieszb6lxyy5gt4m4f75fjicuzf3ewsxgxcc5dh4l2tjjau7wcrgxe
- valory/market_manager_abci:0.1.0:bafybeicia7itulcrxlwbmhfzxppgo5i33tb2nmcycwizftw7gps4dareka
- valory/decision_maker_abci:0.1.0:bafybeiaizbnlz46lba6tcwmajpo2z37cpxuobeqmlgdqbdxnt65jr6rely
- valory/trader_abci:0.1.0:bafybeido4dpfcvpyrobs2veoliuwaz2ltuzvo2gqfbsqxgd5tdr7zllyru
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiatdmznskbmr7wxsipv7vqmdagkg2qtdulkyylxdqemkna7hvtqke
- valory/market_manager_abci:0.1.0:bafybeid42tfvzicskpdxeppatzvghj2i2bqdtkgs4wobgadwgtp3jr5rme
- valory/decision_maker_abci:0.1.0:bafybeibwwruz3ivtmfzgvdp6x5u4xju2xgzowyr7bcaetdwwujaccxccwa
- valory/trader_abci:0.1.0:bafybeic42a6pqlbzboldym3vdmbaqntyxrdffbd3jxeomb357va2xkf2iq
- valory/staking_abci:0.1.0:bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne
- valory/check_stop_trading_abci:0.1.0:bafybeifmi64g4ki6zwbcncb35ovhd4sllw4xrszrkturpeqdhgf5bkiini
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
2 changes: 1 addition & 1 deletion packages/valory/services/trader/service.yaml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeifaw3dk5uklcgj5iftcdhj4p2ymkidoli3uxibq4olddd3eboey7e
agent: valory/trader:0.1.0:bafybeiddrqpwljunbl5abjtkmfmrhqsvlbokocxqqcnlerdx34iek56pxu
number_of_agents: 4
deployment:
agent:
2 changes: 1 addition & 1 deletion packages/valory/services/trader_pearl/service.yaml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeifaw3dk5uklcgj5iftcdhj4p2ymkidoli3uxibq4olddd3eboey7e
agent: valory/trader:0.1.0:bafybeiddrqpwljunbl5abjtkmfmrhqsvlbokocxqqcnlerdx34iek56pxu
number_of_agents: 1
deployment:
agent:
Original file line number Diff line number Diff line change
@@ -109,6 +109,9 @@ def _next_dataset_row(self) -> Optional[Dict[str, str]]:
if available_rows_for_market:
next_mock_data_row = self.shared_state.bet_id_row_manager[sampled_bet_id][0]
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
cyberosa marked this conversation as resolved.
Show resolved Hide resolved
else:
# no more bets available for this market
msg = f"No more mock responses for the market with id: {sampled_bet_id}"
self.context.logger.info(msg)
self.shared_state.last_benchmarking_has_run = True
self._rows_exceeded = True
return None
@@ -184,6 +187,8 @@ def _get_decision(
self._get_response()

if self._mech_response is None:
# TODO this use-case should never happened.
# no more trades for this market
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
self.context.logger.info("The benchmarking has finished!")
return None

@@ -511,7 +516,11 @@ def _update_selected_bet(
# update the bet's timestamp of processing and its number of bets for the given id
if self.benchmarking_mode.enabled:
active_sampled_bet = self.get_active_sampled_bet()
active_sampled_bet.processed_timestamp = self.synced_timestamp
active_sampled_bet.processed_timestamp = (
self.shared_state.get_simulated_now_timestamp(
self.bets, self.params.safe_voting_range
)
)
if prediction_response is not None:
active_sampled_bet.n_bets += 1

43 changes: 38 additions & 5 deletions packages/valory/skills/decision_maker_abci/behaviours/sampling.py
Original file line number Diff line number Diff line change
@@ -60,18 +60,24 @@ def has_liquidity_changed(self, bet: Bet) -> bool:
previous_bet_liquidity = self.shared_state.liquidity_cache.get(bet.id, None)
return bet.scaledLiquidityMeasure != previous_bet_liquidity

def processable_bet(self, bet: Bet) -> bool:
def processable_bet(self, bet: Bet, now: int) -> bool:
"""Whether we can process the given bet."""
now = self.synced_timestamp

self.context.logger.info(f"Analyzing bet: {bet}")
# Note: `openingTimestamp` is the timestamp when a question stops being available for voting.
within_opening_range = bet.openingTimestamp <= (
now + self.params.sample_bets_closing_days * UNIX_DAY
)
self.context.logger.info(f"within_opening_range ={within_opening_range}")
within_safe_range = now < bet.openingTimestamp + self.params.safe_voting_range
self.context.logger.info(f"within_safe_range ={within_safe_range}")
within_ranges = within_opening_range and within_safe_range

# if we should not rebet, we have all the information we need
if not self.should_rebet:
self.context.logger.info(
f"should rebet is False and has_liquidity_changed is: {self.has_liquidity_changed(bet)}"
)
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
cyberosa marked this conversation as resolved.
Show resolved Hide resolved
# the `has_liquidity_changed` check is dangerous; this can result in a bet never being processed
# e.g.:
# 1. a market is selected
@@ -105,7 +111,16 @@ def _sampled_bet_idx(self, bets: List[Bet]) -> int:

def _sample(self) -> Optional[int]:
"""Sample a bet, mark it as processed, and return its index."""
available_bets = list(filter(self.processable_bet, self.bets))
# modify time "NOW" in benchmarking mode
if self.benchmarking_mode.enabled:
now = self.shared_state.get_simulated_now_timestamp(
self.bets, self.params.safe_voting_range
)
else:
now = self.synced_timestamp
available_bets = list(
filter(lambda bet: self.processable_bet(bet, now=now), self.bets)
)

if len(available_bets) == 0:
msg = "There were no unprocessed bets available to sample from!"
@@ -128,13 +143,31 @@ def _sample(self) -> Optional[int]:
def async_act(self) -> Generator:
"""Do the action."""
with self.context.benchmark_tool.measure(self.behaviour_id).local():

idx = self._sample()
benchmarking_finished = False
if self.benchmarking_mode.enabled:
if idx == None:
self.context.logger.info(
f"No more markets to bet in the simulated day"
)
self.shared_state.increase_one_day_simulation()
if self.shared_state.check_benchmarking_finished():
self.context.logger.info(
f"No more days to simulate in benchmarking mode"
)
# HERE IS the point we need to change the Payload somehow to trigger the END
# then we should force this round to trigger event.NONE and then benchmarking finished.
benchmarking_finished = True
else:
# try sampling again
idx = self._sample()
self.store_bets()
if idx is None:
bets_hash = None
else:
bets_hash = self.hash_stored_bets()
payload = SamplingPayload(self.context.agent_address, bets_hash, idx)
payload = SamplingPayload(
self.context.agent_address, bets_hash, idx, benchmarking_finished
)

yield from self.finish_behaviour(payload)
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ transition_func:
(ClaimRound, NO_MAJORITY): ClaimRound
(ClaimRound, ROUND_TIMEOUT): ClaimRound
(ClaimRound, SUBSCRIPTION_ERROR): ClaimRound
(DecisionReceiveRound, BENCHMARKING_FINISHED): BenchmarkingDoneRound
(DecisionReceiveRound, MOCK_TX): FinishedWithoutDecisionRound
(DecisionReceiveRound, DONE): BetPlacementRound
(DecisionReceiveRound, MECH_RESPONSE_ERROR): BlacklistingRound
(DecisionReceiveRound, NO_MAJORITY): DecisionReceiveRound
@@ -118,6 +118,7 @@ transition_func:
(SamplingRound, NO_MAJORITY): SamplingRound
(SamplingRound, ROUND_TIMEOUT): SamplingRound
(SamplingRound, BENCHMARK_ENABLED): ToolSelectionRound
(SamplingRound, BENCHMARKING_FINISHED): BenchmarkingDoneRound
(SubscriptionRound, DONE): FinishedSubscriptionRound
(SubscriptionRound, MOCK_TX): ToolSelectionRound
(SubscriptionRound, NONE): SubscriptionRound
47 changes: 47 additions & 0 deletions packages/valory/skills/decision_maker_abci/models.py
Original file line number Diff line number Diff line change
@@ -20,8 +20,10 @@
"""This module contains the models for the skill."""

import os
import time
import re
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from pathlib import Path
from string import Template
from typing import (
@@ -60,6 +62,7 @@
MarketManagerParams,
Subgraph,
)
from packages.valory.skills.market_manager_abci.bets import Bet
from packages.valory.skills.mech_interact_abci.models import (
Params as MechInteractParams,
)
@@ -211,6 +214,9 @@ def __init__(self, *args: Any, skill_context: SkillContext, **kwargs: Any) -> No
# a mapping from market id to scaled liquidity measure
# also used for the benchmarking mode
self.liquidity_cache: Dict[str, float] = {}
# list with the simulated timestamps for the benchmarking mode
self.simulated_now_timestamps: List[int] = []
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
self.simulated_now_timestamps_idx: int = 0
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
# latest liquidity information (only relevant to the benchmarking mode)
self.liquidity_amounts: Dict[str, List[int]] = {}
self.liquidity_prices: Dict[str, List[float]] = {}
@@ -270,6 +276,47 @@ def bet_id_row_manager(self, mapping: Dict[str, List[int]]) -> None:
"""Set the next_mock_data_row."""
self._bet_id_row_manager = mapping

def _initialize_simulated_now_timestamps(
self, bets: List[Bet], safe_voting_range: int
) -> None:
self.simulated_now_timestamps_idx = 0
# Find the maximum timestamp from openingTimestamp field
max_timestamp = max(bet.openingTimestamp for bet in bets)
# adding range to allow voting (it has to be <)
max_timestamp = max_timestamp - safe_voting_range - 1
Adamantios marked this conversation as resolved.
Show resolved Hide resolved

# Get current timestamp
now_timestamp = int(time.time())
# Convert timestamps to datetime objects
max_date = datetime.fromtimestamp(max_timestamp)
now_date = datetime.fromtimestamp(now_timestamp)
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
self.context.logger.info(
f"Simulating timestamps between {now_date} and {max_date}"
)
# Generate list of timestamps with one day intervals
timestamps = []
current_date = now_date
Adamantios marked this conversation as resolved.
Show resolved Hide resolved

while current_date <= max_date:
timestamps.append(int(current_date.timestamp()))
current_date += timedelta(days=1)
self.context.logger.info(f"Simulated timestamps: {timestamps}")
self.simulated_now_timestamps = timestamps

def increase_one_day_simulation(self) -> None:
self.simulated_now_timestamps_idx += 1

def check_benchmarking_finished(self) -> bool:
return self.simulated_now_timestamps_idx >= len(self.simulated_now_timestamps)

def get_simulated_now_timestamp(
self, bets: List[Bet], safe_voting_range: int
) -> int:
if len(self.simulated_now_timestamps) == 0:
self._initialize_simulated_now_timestamps(bets, safe_voting_range)

return self.simulated_now_timestamps[self.simulated_now_timestamps_idx]

def setup(self) -> None:
"""Set up the model."""
super().setup()
1 change: 1 addition & 0 deletions packages/valory/skills/decision_maker_abci/payloads.py
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ class SamplingPayload(UpdateBetsPayload):
"""Represents a transaction payload for the sampling of a bet."""

index: Optional[int]
benchmarking_finished: Optional[bool]


@dataclass(frozen=True)
3 changes: 2 additions & 1 deletion packages/valory/skills/decision_maker_abci/rounds.py
Original file line number Diff line number Diff line change
@@ -218,6 +218,7 @@ class DecisionMakerAbciApp(AbciApp[Event]):
Event.NO_MAJORITY: SamplingRound,
Event.ROUND_TIMEOUT: SamplingRound,
Event.BENCHMARKING_ENABLED: ToolSelectionRound,
Event.BENCHMARKING_FINISHED: BenchmarkingDoneRound,
# this is here because of `autonomy analyse fsm-specs` falsely reporting it as missing from the transition
MarketManagerEvent.FETCH_ERROR: ImpossibleRound,
},
@@ -257,7 +258,7 @@ class DecisionMakerAbciApp(AbciApp[Event]):
Event.NO_MAJORITY: DecisionReceiveRound,
Event.TIE: BlacklistingRound,
Event.UNPROFITABLE: BlacklistingRound,
Event.BENCHMARKING_FINISHED: BenchmarkingDoneRound,
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
Event.MOCK_TX: FinishedWithoutDecisionRound,
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
Event.ROUND_TIMEOUT: DecisionReceiveRound, # loop on the same state until Mech deliver is received
},
BlacklistingRound: {
20 changes: 10 additions & 10 deletions packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
@@ -17,28 +17,28 @@ fingerprint:
behaviours/blacklisting.py: bafybeifitqx2omj5qdwokizhqjkxvybtsyxo22dxkucbtxaocafzgbseku
behaviours/check_benchmarking.py: bafybeiao2lyj7apezkqrpgsyzb3dwvrdgsrgtprf6iuhsmlsufvxfl5bci
behaviours/claim_subscription.py: bafybeigbqkhc6mb73rbwaks32tfiqx6u2xza43uiy6rvbtrnqd6m4fru3e
behaviours/decision_receive.py: bafybeifb7aeu6g4xzmiyfc5ltipigsikfot3foux55gw5oaz2o5u5a4ume
behaviours/decision_request.py: bafybeiabjzzcwcfbfmtoftjhewmkgbhxfnigbc5cwmmxl6cob5gv64jwwa
behaviours/decision_receive.py: bafybeibm7org6gaglndwdsuetrtisik6yil2hi56imwousu52oafma7z5u
behaviours/decision_request.py: bafybeifc5kmafyjae3nrydqytpn5nbjabvfxdliwlisl6ejlqk76hmcr6y
behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm
behaviours/order_subscription.py: bafybeicrmdvhci5prfldvuf3bclbbqi6j7lpv6hmphw3qwgmkmwat3od44
behaviours/randomness.py: bafybeiaoj3awyyg2onhpsdsn3dyczs23gr4smuzqcbw3e5ocljwxswjkce
behaviours/reedem.py: bafybeiaxwp4lx62owcaqfp6xcqh6567f5yvwnl4rage2f5hmq4nltkzjjy
behaviours/round_behaviour.py: bafybeih63hpia2bwwzu563hxs5yd3t5ycvxvkfnhvxbzghbyy3mw3xjl3i
behaviours/sampling.py: bafybeiekxzublnsvgjb2y2uvtye4zkethvmsxh4itonnwmb3sbviyyhsgq
behaviours/storage_manager.py: bafybeif7mrnmhrarndx225e26jseuieosdja4jnlewnv2mtxqdydevxuze
behaviours/sampling.py: bafybeih4lqdqhf5ip6tmtlmxbttyikjcxdey7jfgujcthkyih245pvs7je
behaviours/storage_manager.py: bafybeic7c23rtp3dvgstcusmyxkcm22bpf2bfydljiam2nf55tleym5j3u
behaviours/tool_selection.py: bafybeienlxcgjs3ogyofli3d7q3p5rst3mcxxcnwqf7qolqjeefjtixeke
dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm
fsm_specification.yaml: bafybeier5p5vvk5a44jnewxbuf23zvkudyioygimnzakbqnm7sce3fueki
fsm_specification.yaml: bafybeid5d47zwe7zegrmgzswdkjr6to4veequs43uqxgcs7lol6unadary
handlers.py: bafybeigod6gbjrxy4mbmulbzsbokeaoycoqys64vqtxnumishfukzf73za
io_/__init__.py: bafybeifxgmmwjqzezzn3e6keh2bfo4cyo7y5dq2ept3stfmgglbrzfl5rq
io_/loader.py: bafybeih3sdsx5dhe4kzhtoafexjgkutsujwqy3zcdrlrkhtdks45bc7exa
models.py: bafybeiamwncnjlck2wekswn2czhqtmd4zkzqnf5oqnx6psq5lh2skant5y
payloads.py: bafybeicloiy4ax7dlipwp4czlueflgjgtlev4a6vhn2m7ztoehnemiiko4
models.py: bafybeid7tjyr2sat4spvex2ea2zskxxt42iermpfzraqzoria75s7bs54y
payloads.py: bafybeiehb4dsntwpzalz3ikx2mf3fxdhe7gbntonigibdir4iwu4b4aphu
policy.py: bafybeihcltocxg7zsmvjtx44ilal4zir4fz2rupgmhacktzv5neb2lmas4
redeem_info.py: bafybeifiiix4gihfo4avraxt34sfw35v6dqq45do2drrssei2shbps63mm
rounds.py: bafybeid725s64adnl2iaoapjwrnsqg5j7u5nhxwwolwexwwjjjtelyanpy
rounds.py: bafybeiaf7fh6b5th2vcjtzhayp4jblxuiyaxoe5fli2rg76eg6jdyi4qrq
states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy
states/base.py: bafybeibyebyeskjnuem3rfwqqkcbqojqfed5ah2nkakfvcstdlstnumlmq
states/base.py: bafybeibdo7xkufqa3ki6wy4xkidk3ffwwfr2vomlxngkztjk3mcvkme6ku
states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda
states/blacklisting.py: bafybeiapelgjhbjjn4uq4z5gspyirqzwzgccg5anktrp5kxdwamfnfw5mi
states/check_benchmarking.py: bafybeiabv6pq7q45jd3nkor5afmlycqgec5ctuwcfbdukkjjm4imesv4ni
@@ -50,7 +50,7 @@ fingerprint:
states/order_subscription.py: bafybeidrcef2op3nhq4tjgri3ct5hfhmc22xw2ep6dk4ro6tg7ob6cmioa
states/randomness.py: bafybeiceoo4nx3t4dofpwczw3v5mclramwmzpwjs6hv7l56arodrjx4l5u
states/redeem.py: bafybeica6cn4xg7shea2wjhbqnddgxe5zao2hkmceltze7qknxdhtsoaxe
states/sampling.py: bafybeiep54qm442c7dc7ajfrcs76fa65qh4wnhg6mo44urwjwlmdkm4thy
states/sampling.py: bafybeig3katlffomj4scvhbfgnk64iqnhtkxpoghc4dhiqtploqzqr2psu
states/tool_selection.py: bafybeiak5ihuie4nxh3sguiea6pcdgyxr4k4xyzvq6o2uj5xpf7urocawy
tests/__init__.py: bafybeiakpi3k3kc7wrjj7hrluvjcj36lu2gezpmrctwiz5yg2fe7ggnf3i
tests/behaviours/__init__.py: bafybeic7icz7lfhfepdkqkase7y7zn3a6pwdw6fx4ah2hajmgejawpolc4
5 changes: 5 additions & 0 deletions packages/valory/skills/decision_maker_abci/states/base.py
Original file line number Diff line number Diff line change
@@ -79,6 +79,11 @@ def sampled_bet_index(self) -> int:
"""Get the sampled bet."""
return int(self.db.get_strict("sampled_bet_index"))

@property
def benchmarking_finished(self) -> int:
"""Get the flag of benchmarking finished."""
return int(self.db.get_strict("benchmarking_finished"))

@property
def is_mech_price_set(self) -> bool:
"""Get whether mech's price is known."""
13 changes: 12 additions & 1 deletion packages/valory/skills/decision_maker_abci/states/sampling.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,10 @@
from enum import Enum
from typing import Any, cast, Optional, Tuple, Type

from packages.valory.skills.abstract_round_abci.base import BaseSynchronizedData, get_name
from packages.valory.skills.abstract_round_abci.base import (
BaseSynchronizedData,
get_name,
)
from packages.valory.skills.decision_maker_abci.payloads import SamplingPayload
from packages.valory.skills.decision_maker_abci.states.base import (
Event,
@@ -42,6 +45,7 @@ class SamplingRound(UpdateBetsRound):
selection_key: Any = (
UpdateBetsRound.selection_key,
get_name(SynchronizedData.sampled_bet_index),
get_name(SynchronizedData.benchmarking_finished),
)

def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
@@ -51,6 +55,13 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
return None

synced_data, event = cast(Tuple[SynchronizedData, Enum], res)

if synced_data.benchmarking_finished:
self.context.logger.info(
"No more markets to bet. The benchmarking has finished!"
)
return synced_data, Event.BENCHMARKING_FINISHED

if event == Event.DONE and self.context.benchmarking_mode.enabled:
return synced_data, Event.BENCHMARKING_ENABLED
return res
4 changes: 3 additions & 1 deletion packages/valory/skills/trader_abci/fsm_specification.yaml
Original file line number Diff line number Diff line change
@@ -144,7 +144,8 @@ transition_func:
(CollectSignatureRound, DONE): FinalizationRound
(CollectSignatureRound, NO_MAJORITY): ResetRound
(CollectSignatureRound, ROUND_TIMEOUT): CollectSignatureRound
(DecisionReceiveRound, BENCHMARKING_FINISHED): ResetAndPauseRound
(DesisionReceiveRound, MOCK_TX): RedeemRound
#(DecisionReceiveRound, BENCHMARKING_FINISHED): ResetAndPauseRound
(DecisionReceiveRound, DONE): BetPlacementRound
(DecisionReceiveRound, MECH_RESPONSE_ERROR): BlacklistingRound
(DecisionReceiveRound, NO_MAJORITY): DecisionReceiveRound
@@ -210,6 +211,7 @@ transition_func:
(SamplingRound, NO_MAJORITY): SamplingRound
(SamplingRound, ROUND_TIMEOUT): SamplingRound
(SamplingRound, BENCHMARK_ENABLED): ToolSelectionRound
(SamplingRound, BENCHMARKING_FINISHED): ResetAndPauseRound
(SelectKeeperTransactionSubmissionARound, DONE): CollectSignatureRound
(SelectKeeperTransactionSubmissionARound, INCORRECT_SERIALIZATION): HandleFailedTxRound
(SelectKeeperTransactionSubmissionARound, NO_MAJORITY): ResetRound
8 changes: 4 additions & 4 deletions packages/valory/skills/trader_abci/skill.yaml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ fingerprint:
behaviours.py: bafybeigc6hszbu66ccajny5eh7thfgsrlr36je4mzziwp4mupgvtaeu6aa
composition.py: bafybeifxerfvssuhodqmtvkz6umlmrmdqjv5ptpszhnwlavzxaavdpdyly
dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm
fsm_specification.yaml: bafybeifip5hzb42f746k4hhpsmixtrdpqogrhnsw722vf6mtjelihmrj7q
fsm_specification.yaml: bafybeic23myoa7y2lvwa2jflx2x32avr2tcgziicnxodyhplxzcletedmm
handlers.py: bafybeibbxybbi66em63ad33cllymypr3za3f5xvor3m2krhuxoyxnqjnxu
models.py: bafybeih2vkf4ln7n7ar27iemho7w7sdr4clmhbnhbcznmsri6mc2skkky4
tests/__init__.py: bafybeiadatapyjh3e7ucg2ehz77oms3ihrbutwb2cs2tkjehy54utwvuyi
@@ -26,9 +26,9 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeigrdlxed3xlsnxtjhnsbl3cojruihxcqx4jxhgivkd5i2fkjncgba
- valory/transaction_settlement_abci:0.1.0:bafybeic7q7recyka272udwcupblwbkc3jkodgp74fvcdxb7urametg5dae
- valory/termination_abci:0.1.0:bafybeib5l7jhew5ic6iq24dd23nidcoimzqkrk556gqywhoziatj33zvwm
- valory/market_manager_abci:0.1.0:bafybeicia7itulcrxlwbmhfzxppgo5i33tb2nmcycwizftw7gps4dareka
- valory/decision_maker_abci:0.1.0:bafybeiaizbnlz46lba6tcwmajpo2z37cpxuobeqmlgdqbdxnt65jr6rely
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeieszb6lxyy5gt4m4f75fjicuzf3ewsxgxcc5dh4l2tjjau7wcrgxe
- valory/market_manager_abci:0.1.0:bafybeid42tfvzicskpdxeppatzvghj2i2bqdtkgs4wobgadwgtp3jr5rme
- valory/decision_maker_abci:0.1.0:bafybeibwwruz3ivtmfzgvdp6x5u4xju2xgzowyr7bcaetdwwujaccxccwa
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiatdmznskbmr7wxsipv7vqmdagkg2qtdulkyylxdqemkna7hvtqke
- valory/staking_abci:0.1.0:bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne
- valory/check_stop_trading_abci:0.1.0:bafybeifmi64g4ki6zwbcncb35ovhd4sllw4xrszrkturpeqdhgf5bkiini
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ protocols:
- valory/ledger_api:1.0.0:bafybeihdk6psr4guxmbcrc26jr2cbgzpd5aljkqvpwo64bvaz7tdti2oni
skills:
- valory/abstract_round_abci:0.1.0:bafybeib733xfbndtpvkf44mtk7oyodnficgloo6xhn7xmqxxeos33es65u
- valory/decision_maker_abci:0.1.0:bafybeiaizbnlz46lba6tcwmajpo2z37cpxuobeqmlgdqbdxnt65jr6rely
- valory/decision_maker_abci:0.1.0:bafybeibwwruz3ivtmfzgvdp6x5u4xju2xgzowyr7bcaetdwwujaccxccwa
- valory/staking_abci:0.1.0:bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
behaviours: