diff --git a/packages/packages.json b/packages/packages.json index 5f4a31cb..a12bc4d6 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -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", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 4423efe4..daea582c 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -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 diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 2194108c..58f9b55f 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:bafybeifaw3dk5uklcgj5iftcdhj4p2ymkidoli3uxibq4olddd3eboey7e +agent: valory/trader:0.1.0:bafybeiddrqpwljunbl5abjtkmfmrhqsvlbokocxqqcnlerdx34iek56pxu number_of_agents: 4 deployment: agent: diff --git a/packages/valory/services/trader_pearl/service.yaml b/packages/valory/services/trader_pearl/service.yaml index 25724b12..1919d5a6 100644 --- a/packages/valory/services/trader_pearl/service.yaml +++ b/packages/valory/services/trader_pearl/service.yaml @@ -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: 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 8ec49bdc..5b23352a 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -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] 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 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 diff --git a/packages/valory/skills/decision_maker_abci/behaviours/sampling.py b/packages/valory/skills/decision_maker_abci/behaviours/sampling.py index 5bd9ca35..11ec5819 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/sampling.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/sampling.py @@ -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)}" + ) # 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) diff --git a/packages/valory/skills/decision_maker_abci/fsm_specification.yaml b/packages/valory/skills/decision_maker_abci/fsm_specification.yaml index b4b76fc9..dc8c3d3f 100644 --- a/packages/valory/skills/decision_maker_abci/fsm_specification.yaml +++ b/packages/valory/skills/decision_maker_abci/fsm_specification.yaml @@ -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 diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 932479db..f0d4e2cb 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -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] = [] + self.simulated_now_timestamps_idx: int = 0 # 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 + + # 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) + 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 + + 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() diff --git a/packages/valory/skills/decision_maker_abci/payloads.py b/packages/valory/skills/decision_maker_abci/payloads.py index fdfe8d2b..b74e7ee5 100644 --- a/packages/valory/skills/decision_maker_abci/payloads.py +++ b/packages/valory/skills/decision_maker_abci/payloads.py @@ -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) diff --git a/packages/valory/skills/decision_maker_abci/rounds.py b/packages/valory/skills/decision_maker_abci/rounds.py index e2c33dc3..571c10d7 100644 --- a/packages/valory/skills/decision_maker_abci/rounds.py +++ b/packages/valory/skills/decision_maker_abci/rounds.py @@ -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, + Event.MOCK_TX: FinishedWithoutDecisionRound, Event.ROUND_TIMEOUT: DecisionReceiveRound, # loop on the same state until Mech deliver is received }, BlacklistingRound: { diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 18d34577..ee9761da 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -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 diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index 3938fbba..83495b39 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -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.""" diff --git a/packages/valory/skills/decision_maker_abci/states/sampling.py b/packages/valory/skills/decision_maker_abci/states/sampling.py index 427bc6c5..b07326d1 100644 --- a/packages/valory/skills/decision_maker_abci/states/sampling.py +++ b/packages/valory/skills/decision_maker_abci/states/sampling.py @@ -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 diff --git a/packages/valory/skills/trader_abci/fsm_specification.yaml b/packages/valory/skills/trader_abci/fsm_specification.yaml index 91dde644..78a573bc 100644 --- a/packages/valory/skills/trader_abci/fsm_specification.yaml +++ b/packages/valory/skills/trader_abci/fsm_specification.yaml @@ -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 diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 17ba15bb..f4a765e6 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -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 diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 717fed92..b4a2d14c 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -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: