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 issues introduced by the benchmarking mode changes #363

Merged
merged 7 commits into from
Nov 29, 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
12 changes: 6 additions & 6 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"contract/valory/staking_token/0.1.0": "bafybeiep4r6qyilbfgzdvx6t7zvpgaioxqktmxm7puwtnbpb2ftlib43gy",
"contract/valory/relayer/0.1.0": "bafybeicawmds6czx7db2lcktvexwrp245jpekgulndtos5s5zdid3ilvq4",
"skill/valory/market_manager_abci/0.1.0": "bafybeicztk62pslofv6ui3aw3giw2tnvlfwfmatqbyvvzv4ampneu6isqa",
"skill/valory/decision_maker_abci/0.1.0": "bafybeicx3vjswhjzgfa2ddl7zxqzncuqbvej3m2unseje5lsajdhio7mji",
"skill/valory/trader_abci/0.1.0": "bafybeiapf3qng7wczem3t7s5cysdlhzc3xign4sqkhyopro3p7x33hdugu",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeic7wcls7yvvnpqrl7vfrab3dt37vyoytu2hef7emmc5556puqjpri",
"skill/valory/decision_maker_abci/0.1.0": "bafybeigef5xufpkcrwxpekw35zqtxcsliudhagg3bybcnfpgb3hcucwaxm",
"skill/valory/trader_abci/0.1.0": "bafybeihdwrcx5c4k57g64jm47cmuug5igynm5tn6ic4k6usx4g2v2uqf5e",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeicex6xclnh3tduca2wydokodintbtfxx735fnuckmvtsns6xuyixy",
"skill/valory/staking_abci/0.1.0": "bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeifmi64g4ki6zwbcncb35ovhd4sllw4xrszrkturpeqdhgf5bkiini",
"agent/valory/trader/0.1.0": "bafybeieoklf7wjrnupyv4egny5hfn6mbxtrjwwtrqyznjoxodiy72cj3na",
"service/valory/trader/0.1.0": "bafybeidzaf6gytftigur646mo4fw2p5urq4cpvbf5t2gbw3fz5v6sseppq",
"service/valory/trader_pearl/0.1.0": "bafybeieqyhrucksqrxxhy2ad4blgsjd3iwhg4m6q3lgm2wlj2wlhz52xjq"
"agent/valory/trader/0.1.0": "bafybeiandy3tuazyv5rzqzku3aic2ye7nuhily2gnch27omjfmo4rq5o4i",
"service/valory/trader/0.1.0": "bafybeidv5ovi6avyzz5vemgk6d3vz4d6n7pq276qgtuq3dyfry3hzzn32i",
"service/valory/trader_pearl/0.1.0": "bafybeigee5p7yryn6kfcozmymf7vvjraaz3htq44pbmhc5pdsswa7yay64"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:bafybeic7wcls7yvvnpqrl7vfrab3dt37vyoytu2hef7emmc5556puqjpri
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeicex6xclnh3tduca2wydokodintbtfxx735fnuckmvtsns6xuyixy
- valory/market_manager_abci:0.1.0:bafybeicztk62pslofv6ui3aw3giw2tnvlfwfmatqbyvvzv4ampneu6isqa
- valory/decision_maker_abci:0.1.0:bafybeicx3vjswhjzgfa2ddl7zxqzncuqbvej3m2unseje5lsajdhio7mji
- valory/trader_abci:0.1.0:bafybeiapf3qng7wczem3t7s5cysdlhzc3xign4sqkhyopro3p7x33hdugu
- valory/decision_maker_abci:0.1.0:bafybeigef5xufpkcrwxpekw35zqtxcsliudhagg3bybcnfpgb3hcucwaxm
- valory/trader_abci:0.1.0:bafybeihdwrcx5c4k57g64jm47cmuug5igynm5tn6ic4k6usx4g2v2uqf5e
- valory/staking_abci:0.1.0:bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne
- valory/check_stop_trading_abci:0.1.0:bafybeifmi64g4ki6zwbcncb35ovhd4sllw4xrszrkturpeqdhgf5bkiini
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader/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: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeieoklf7wjrnupyv4egny5hfn6mbxtrjwwtrqyznjoxodiy72cj3na
agent: valory/trader:0.1.0:bafybeiandy3tuazyv5rzqzku3aic2ye7nuhily2gnch27omjfmo4rq5o4i
number_of_agents: 4
deployment:
agent:
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader_pearl/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeieoklf7wjrnupyv4egny5hfn6mbxtrjwwtrqyznjoxodiy72cj3na
agent: valory/trader:0.1.0:bafybeiandy3tuazyv5rzqzku3aic2ye7nuhily2gnch27omjfmo4rq5o4i
number_of_agents: 1
deployment:
agent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def _is_profitable(
if self.benchmarking_mode.enabled:
bet = self.get_active_sampled_bet() # no reset
self.context.logger.info(f"Bet used for benchmarking: {bet}")
self._update_shared_data_liquidity()
self._update_market_liquidity()
else:
# this call is destroying what it was in self.bets
bet = self.sampled_bet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def async_act(self) -> Generator:
"""Do the action."""
with self.context.benchmark_tool.measure(self.behaviour_id).local():
idx = self._sample()
benchmarking_finished = False
day_increased = False
benchmarking_finished = None
day_increased = None
Comment on lines -154 to +155
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing an issue in the normal flow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still trying to understand why None is a valid value and False not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because otherwise the NONE event cannot ever be emitted from the round.

if idx is None and self.benchmarking_mode.enabled:
self.context.logger.info(
"No more markets to bet in the simulated day. Increasing simulated day."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ transition_func:
(SamplingRound, NEW_SIMULATED_RESAMPLE): SamplingRound
(SamplingRound, NONE): FinishedWithoutDecisionRound
(SamplingRound, NO_MAJORITY): SamplingRound
(SamplingRound, ROUND_TIMEOUT): SamplingRound
(SubscriptionRound, DONE): FinishedSubscriptionRound
(SubscriptionRound, MOCK_TX): ToolSelectionRound
(SubscriptionRound, NONE): SubscriptionRound
Expand Down
2 changes: 2 additions & 0 deletions packages/valory/skills/decision_maker_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class DecisionMakerAbciApp(AbciApp[Event]):
- done: 4.
- none: 16.
- no majority: 3.
- round timeout: 3.
- new simulated resample: 3.
- benchmarking enabled: 6.
- benchmarking finished: 21.
Expand Down Expand Up @@ -218,6 +219,7 @@ class DecisionMakerAbciApp(AbciApp[Event]):
Event.DONE: SubscriptionRound,
Event.NONE: FinishedWithoutDecisionRound,
Event.NO_MAJORITY: SamplingRound,
Event.ROUND_TIMEOUT: SamplingRound,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing an issue in the normal flow.

Event.NEW_SIMULATED_RESAMPLE: SamplingRound,
Event.BENCHMARKING_ENABLED: ToolSelectionRound,
Event.BENCHMARKING_FINISHED: BenchmarkingDoneRound,
Expand Down
12 changes: 6 additions & 6 deletions packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ fingerprint:
behaviours/blacklisting.py: bafybeifitqx2omj5qdwokizhqjkxvybtsyxo22dxkucbtxaocafzgbseku
behaviours/check_benchmarking.py: bafybeiao2lyj7apezkqrpgsyzb3dwvrdgsrgtprf6iuhsmlsufvxfl5bci
behaviours/claim_subscription.py: bafybeigbqkhc6mb73rbwaks32tfiqx6u2xza43uiy6rvbtrnqd6m4fru3e
behaviours/decision_receive.py: bafybeiga2eddrkbwnqcvzonbens4kj3i3fvfkdngoml5neoob23jgxtcpy
behaviours/decision_receive.py: bafybeiempl2rdkxxkup7ibtvdx5kleeucfij2upglzwqlgqysifwxareom
behaviours/decision_request.py: bafybeia22omb7tvocyfe3z2ucn5au5mcas7dg37ha42u7znefzrewjpk7y
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: bafybeidrcyeecrh2wzw3n56iwyon56rommc7nyjnlcdzhldpvoh25sfeoe
behaviours/sampling.py: bafybeicimvm5ii26cjbmonznk5qi7jwyq7wbgkhbecfa44yi4rkfjnpdum
behaviours/storage_manager.py: bafybeiez6daaj2bufxdcsghtmqybyrzdh74z26cc4ajsqsiy5krgjo2tla
behaviours/tool_selection.py: bafybeienlxcgjs3ogyofli3d7q3p5rst3mcxxcnwqf7qolqjeefjtixeke
dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm
fsm_specification.yaml: bafybeiaokkmrfs5dewl5vmfeqwfqrwgzjhjml4t5o6krdellcqprrdxyqq
fsm_specification.yaml: bafybeigwlvvi6fav72wg4wz22xjekegenzjnub5efwz5xu6qsrjnxluspq
handlers.py: bafybeigod6gbjrxy4mbmulbzsbokeaoycoqys64vqtxnumishfukzf73za
io_/__init__.py: bafybeifxgmmwjqzezzn3e6keh2bfo4cyo7y5dq2ept3stfmgglbrzfl5rq
io_/loader.py: bafybeih3sdsx5dhe4kzhtoafexjgkutsujwqy3zcdrlrkhtdks45bc7exa
models.py: bafybeieqknkktfrs5e4maq4cosevabkbneszw4dp44sz7mavr4hpdy6yem
payloads.py: bafybeihzwxhdc6a6ek2lvsyzkex4ypsl7fnahszal3dxtr7ce6wp7nmgmm
policy.py: bafybeihlzs4o5e7yfmfzcvvrzkf4bhxfsg5gxnzsrpepwgfugh45gafye4
redeem_info.py: bafybeifiiix4gihfo4avraxt34sfw35v6dqq45do2drrssei2shbps63mm
rounds.py: bafybeidky5eoxti37j3j6ue3uyna6ibljskzzfadhehyj6jqry2lwoi7ou
rounds.py: bafybeiazjcsukgefair52aw37hhvxzlopnzqqmi4ntqrinakljlcm4kt4a
states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy
states/base.py: bafybeifiqeedqo2etvp4s7owkza6ykepho4s3nvkf43rcwgh4pado2wdiy
states/base.py: bafybeihqabaawgms5kwz544jmlxvp5y5zr5jv7qgp3kzweg7bdl5asq764
states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda
states/blacklisting.py: bafybeiapelgjhbjjn4uq4z5gspyirqzwzgccg5anktrp5kxdwamfnfw5mi
states/check_benchmarking.py: bafybeiabv6pq7q45jd3nkor5afmlycqgec5ctuwcfbdukkjjm4imesv4ni
Expand All @@ -50,7 +50,7 @@ fingerprint:
states/order_subscription.py: bafybeidrcef2op3nhq4tjgri3ct5hfhmc22xw2ep6dk4ro6tg7ob6cmioa
states/randomness.py: bafybeiceoo4nx3t4dofpwczw3v5mclramwmzpwjs6hv7l56arodrjx4l5u
states/redeem.py: bafybeica6cn4xg7shea2wjhbqnddgxe5zao2hkmceltze7qknxdhtsoaxe
states/sampling.py: bafybeihnziujwxmxl623id7zrkaefzs3tvb2vdxjujcyyn3gcun3k2gcdu
states/sampling.py: bafybeif2yuwl5swelp7oh5nfuupdf3vg2ijjzapk2xqht7e6i6ggcsl2zy
states/tool_selection.py: bafybeiak5ihuie4nxh3sguiea6pcdgyxr4k4xyzvq6o2uj5xpf7urocawy
tests/__init__.py: bafybeiakpi3k3kc7wrjj7hrluvjcj36lu2gezpmrctwiz5yg2fe7ggnf3i
tests/behaviours/__init__.py: bafybeic7icz7lfhfepdkqkase7y7zn3a6pwdw6fx4ah2hajmgejawpolc4
Expand Down
8 changes: 4 additions & 4 deletions packages/valory/skills/decision_maker_abci/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def sampled_bet_index(self) -> int:
return int(self.db.get_strict("sampled_bet_index"))

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

@property
def simulated_day(self) -> int:
def simulated_day(self) -> bool:
"""Get the flag of simulated_day."""
return int(self.db.get_strict("simulated_day"))
return bool(self.db.get_strict("simulated_day"))

@property
def is_mech_price_set(self) -> bool:
Expand Down
15 changes: 7 additions & 8 deletions packages/valory/skills/decision_maker_abci/states/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SamplingRound(UpdateBetsRound):
get_name(SynchronizedData.benchmarking_finished),
get_name(SynchronizedData.simulated_day),
)
synchronized_data_class = SynchronizedData
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing an issue in the normal flow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still sampling is connected with two different SynchronizedData classes in two different abcis

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on that?


def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
"""Process the end of the block."""
Expand All @@ -57,18 +58,16 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:

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

if event != Event.DONE:
return 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 synced_data.simulated_day:
self.context.logger.info(
"Entering the sampling Round for a new simulated day"
)
# re-enter the SamplingRound
return synced_data, Event.NEW_SIMULATED_RESAMPLE
if event == Event.DONE and self.context.benchmarking_mode.enabled:

if self.context.benchmarking_mode.enabled:
return synced_data, Event.BENCHMARKING_ENABLED

return res
1 change: 1 addition & 0 deletions packages/valory/skills/trader_abci/fsm_specification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ transition_func:
(SamplingRound, NEW_SIMULATED_RESAMPLE): SamplingRound
(SamplingRound, NONE): RedeemRound
(SamplingRound, NO_MAJORITY): SamplingRound
(SamplingRound, ROUND_TIMEOUT): SamplingRound
(SelectKeeperTransactionSubmissionARound, DONE): CollectSignatureRound
(SelectKeeperTransactionSubmissionARound, INCORRECT_SERIALIZATION): HandleFailedTxRound
(SelectKeeperTransactionSubmissionARound, NO_MAJORITY): ResetRound
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/skills/trader_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fingerprint:
behaviours.py: bafybeigc6hszbu66ccajny5eh7thfgsrlr36je4mzziwp4mupgvtaeu6aa
composition.py: bafybeifxerfvssuhodqmtvkz6umlmrmdqjv5ptpszhnwlavzxaavdpdyly
dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm
fsm_specification.yaml: bafybeicbwdpl7w65yljzuyvx4y5kaoon5cqsiskxtg5r25mc5r7ggqnqyi
fsm_specification.yaml: bafybeiea2w6rhdxwc2ogvdnoxw2wbklnlspsoxyzhpz6h6x6dnctqurnoi
handlers.py: bafybeibbxybbi66em63ad33cllymypr3za3f5xvor3m2krhuxoyxnqjnxu
models.py: bafybeih2vkf4ln7n7ar27iemho7w7sdr4clmhbnhbcznmsri6mc2skkky4
tests/__init__.py: bafybeiadatapyjh3e7ucg2ehz77oms3ihrbutwb2cs2tkjehy54utwvuyi
Expand All @@ -27,8 +27,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeic7q7recyka272udwcupblwbkc3jkodgp74fvcdxb7urametg5dae
- valory/termination_abci:0.1.0:bafybeib5l7jhew5ic6iq24dd23nidcoimzqkrk556gqywhoziatj33zvwm
- valory/market_manager_abci:0.1.0:bafybeicztk62pslofv6ui3aw3giw2tnvlfwfmatqbyvvzv4ampneu6isqa
- valory/decision_maker_abci:0.1.0:bafybeicx3vjswhjzgfa2ddl7zxqzncuqbvej3m2unseje5lsajdhio7mji
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeic7wcls7yvvnpqrl7vfrab3dt37vyoytu2hef7emmc5556puqjpri
- valory/decision_maker_abci:0.1.0:bafybeigef5xufpkcrwxpekw35zqtxcsliudhagg3bybcnfpgb3hcucwaxm
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeicex6xclnh3tduca2wydokodintbtfxx735fnuckmvtsns6xuyixy
- valory/staking_abci:0.1.0:bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne
- valory/check_stop_trading_abci:0.1.0:bafybeifmi64g4ki6zwbcncb35ovhd4sllw4xrszrkturpeqdhgf5bkiini
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:bafybeicx3vjswhjzgfa2ddl7zxqzncuqbvej3m2unseje5lsajdhio7mji
- valory/decision_maker_abci:0.1.0:bafybeigef5xufpkcrwxpekw35zqtxcsliudhagg3bybcnfpgb3hcucwaxm
- valory/staking_abci:0.1.0:bafybeictd5pxhscuhqntvctb7l5lfjausxt2m22rg5mkaiuj4cwwcxpvne
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
behaviours:
Expand Down
Loading