Skip to content

Commit

Permalink
feat: add custom REDEEM_ROUND_TIMEOUT and only reset progress once …
Browse files Browse the repository at this point in the history
…txs are settled
  • Loading branch information
0xArdi committed Dec 1, 2023
1 parent 6eb8261 commit 6bd9255
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 20 deletions.
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dev": {
"skill/valory/market_manager_abci/0.1.0": "bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i",
"skill/valory/decision_maker_abci/0.1.0": "bafybeibpftqsvijeysldhuqte2gvr3e5lfzm44lt5lepamqy3nczyez2pe",
"skill/valory/trader_abci/0.1.0": "bafybeibgtnlmlqh3mxrw5dw7gomjbqe54l6maf5agkiwhfdzoz27qlqbi4",
"skill/valory/decision_maker_abci/0.1.0": "bafybeigrtd3td5b5ibq4tz7vzokan72h62fppfs75il7epxkm7l4afi2f4",
"skill/valory/trader_abci/0.1.0": "bafybeie2mofvch2nvg6ywvqueckxhwauxzbplktgxzpw4cmzgw2axelrre",
"contract/valory/market_maker/0.1.0": "bafybeid5jnetbsusgxkpqzwyiqlwut55xktfbeloipxcemcuu5oopmqtl4",
"agent/valory/trader/0.1.0": "bafybeicj45neb7lxxfm5dqttti2erul5wuogtcva22igkpml6x5457kzeu",
"service/valory/trader/0.1.0": "bafybeig7dmcobdhd57whem2lx6qqh7loy27r6bbch4cyz2zpm7dp54zwpy",
"agent/valory/trader/0.1.0": "bafybeieliixs2whsx4slzvyo5p7yyyaia43w2fqcm2yiktnylkne3s7wne",
"service/valory/trader/0.1.0": "bafybeibmhqz2rhc6tlqxnco2g7pcabzcniq3bfv7d5gf57hcdxz4r6bndq",
"contract/valory/erc20/0.1.0": "bafybeiepg5ymxhtylgijs3mf3lezz6cwcsougbrv2gr4xcq3bp5wxusi64",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeigvxa2cfueh5ytwcpzszalw2gznyg2ctmbjq46krqewy7cxsvq2gi",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiayt5mk22qmba74qhcszy6oaukewl2glscf4fsh6aai2klac6tege",
"contract/valory/mech/0.1.0": "bafybeieo65rtidzgrx22la7z7azoqbisd35hnoqfw7l3xxctotvctjlkju",
"contract/valory/realitio/0.1.0": "bafybeieoily22pasgkzzcyawhqyrsko7b52lghnvwuskhomavb7tlb6pxa",
"contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4",
Expand Down
7 changes: 4 additions & 3 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeiencz2uytz6fqj5wg7mcunevxjh4xg5gd6pqcgkshgqywhcimweyi
- valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224
- valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigvxa2cfueh5ytwcpzszalw2gznyg2ctmbjq46krqewy7cxsvq2gi
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiayt5mk22qmba74qhcszy6oaukewl2glscf4fsh6aai2klac6tege
- valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i
- valory/decision_maker_abci:0.1.0:bafybeibpftqsvijeysldhuqte2gvr3e5lfzm44lt5lepamqy3nczyez2pe
- valory/trader_abci:0.1.0:bafybeibgtnlmlqh3mxrw5dw7gomjbqe54l6maf5agkiwhfdzoz27qlqbi4
- valory/decision_maker_abci:0.1.0:bafybeigrtd3td5b5ibq4tz7vzokan72h62fppfs75il7epxkm7l4afi2f4
- valory/trader_abci:0.1.0:bafybeie2mofvch2nvg6ywvqueckxhwauxzbplktgxzpw4cmzgw2axelrre
- valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe
default_ledger: ethereum
required_ledgers:
Expand Down Expand Up @@ -196,6 +196,7 @@ models:
max_filtering_retries: ${int:6}
redeeming_batch_size: ${int:5}
slippage: ${float:0.01}
redeem_round_timeout: ${float:3600.0}
policy_epsilon: ${float:0.1}
policy_store_path: ${str:/data/}
irrelevant_tools: ${list:["openai-text-davinci-002", "openai-text-davinci-003",
Expand Down
6 changes: 5 additions & 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:bafybeicj45neb7lxxfm5dqttti2erul5wuogtcva22igkpml6x5457kzeu
agent: valory/trader:0.1.0:bafybeieliixs2whsx4slzvyo5p7yyyaia43w2fqcm2yiktnylkne3s7wne
number_of_agents: 4
deployment: {}
---
Expand Down Expand Up @@ -120,6 +120,7 @@ type: skill
agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000}
refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10}
tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1}
redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0}
benchmark_tool: &id005
args:
log_dir: ${LOG_DIR:str:/benchmarks}
Expand Down Expand Up @@ -200,6 +201,7 @@ type: skill
agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000}
refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10}
tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1}
redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0}
benchmark_tool: *id005
2:
models:
Expand Down Expand Up @@ -278,6 +280,7 @@ type: skill
agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000}
refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10}
tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1}
redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0}
benchmark_tool: *id005
3:
models:
Expand Down Expand Up @@ -356,6 +359,7 @@ type: skill
agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000}
refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10}
tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1}
redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0}
benchmark_tool: *id005
---
public_id: valory/ledger:0.19.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@ def _store_utilized_tools(self) -> None:

def finish_behaviour(self, payload: BaseTxPayload) -> Generator:
"""Finish the behaviour."""
self.redeeming_progress = RedeemingProgress()
self._store_utilized_tools()
yield from super().finish_behaviour(payload)

Expand Down
3 changes: 3 additions & 0 deletions packages/valory/skills/decision_maker_abci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.redeeming_batch_size: int = self._ensure(
"redeeming_batch_size", kwargs, int
)
self.redeem_round_timeout: float = self._ensure(
"redeem_round_timeout", kwargs, float
)
# a slippage in the range of [0, 1] to apply to the `minOutcomeTokensToBuy` when buying shares on a fpmm
self._slippage: float = 0.0
self.slippage: float = self._ensure("slippage", kwargs, float)
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/decision_maker_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class DecisionMakerAbciApp(AbciApp[Event]):
Event.NO_MAJORITY: RedeemRound,
# in case of a round timeout, there likely is something wrong with redeeming
# it could be the RPC, or some other issue. We don't want to be stuck trying to redeem.
Event.ROUND_TIMEOUT: FinishedWithoutRedeemingRound,
Event.REDEEM_ROUND_TIMEOUT: FinishedWithoutRedeemingRound,
# this is here because of `autonomy analyse fsm-specs` falsely reporting it as missing from the transition
Event.NONE: ImpossibleRound,
},
Expand Down
9 changes: 5 additions & 4 deletions packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ fingerprint:
behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m
behaviours/decision_request.py: bafybeievr7vae43e7jr4eqqhwe3emvgiih7ysa66jcb5g2oz5lbxua232q
behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm
behaviours/reedem.py: bafybeihhphnm3p47fweedutfrwcgtcd62hywxlscsnvlk2gsvpgmmb7m3a
behaviours/reedem.py: bafybeifegxnjid4obmbodlc7ogw2ahoa64bgfneeltxw6mdubglfijylq4
behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm
behaviours/sampling.py: bafybeifzhm4sspdvt227ksl5hjn26offgqpwempgbcwbr6dq7gyi2a46sm
behaviours/tool_selection.py: bafybeifpvrrbftlkjsoiysnasihzttousk6hxnukzrln6z2d33e3zexkje
dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm
fsm_specification.yaml: bafybeiefakgrltqy5grptkymrdscli7ergicqkaxef42okv2l7krjqd6iq
handlers.py: bafybeihj33szgrcxnpd73s4nvluyxwwsvhjum2cuq3ilhhe6vfola3k7vy
models.py: bafybeictrsjmxflyo7ryveu6bbpm7xut23tex2xjbb7ftmcrhuotam7xgu
models.py: bafybeif3ubulx7cr7bh7yvwhik2footnfi6ofvjoioym3w6eka3owi67pe
payloads.py: bafybeigcic4vewdglakzpyqevhfwsolh4ywnbvxo5bgned7gl5uo3jif7m
policy.py: bafybeidpmx4ek3qze63zpuwixyf6t7bdv62ewgkzt3ljrzadiwdw64cueq
redeem_info.py: bafybeibddfxwp3577c3dl2utaowwltquu5fg6crezpumoebw563wxpbfrm
rounds.py: bafybeibpku2xlqptxcvyynomdwjemd64yu7odahll6645lhngkch7xsgfe
rounds.py: bafybeib3ylhqybc7dhmq2vbe6luka6uv4d23xmmrqcgva4wrzwpjn227om
states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy
states/base.py: bafybeid265zag7ivlc6fng5croomwds2r43ozzcmom7yp4kzfz7o5bav6a
states/base.py: bafybeibhcc4pc3m6qelvdvxssnuglcwfaff55cr2kule74ekauyf3bahpq
states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda
states/blacklisting.py: bafybeifruvxwwltndwazkzzbpc5nnnad3z5t5ofy6d3i7nssljbxl6gvxu
states/decision_receive.py: bafybeib3roo27nccj4eylaqwwzztzzzwsi6px5atjrch5wbqmpln2kyy6y
Expand Down Expand Up @@ -190,6 +190,7 @@ models:
conditional_tokens_address: '0xCeAfDD6bc0bEF976fdCd1112955828E00543c0Ce'
realitio_proxy_address: '0xAB16D643bA051C11962DA645f74632d3130c81E2'
realitio_address: '0x79e32aE03fb27B07C89c0c568F80287C01ca2E57'
redeem_round_timeout: 3600.0
event_filtering_batch_size: 5000
reduce_factor: 0.25
max_filtering_retries: 6
Expand Down
1 change: 1 addition & 0 deletions packages/valory/skills/decision_maker_abci/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Event(Enum):
BLACKLIST = "blacklist"
NO_OP = "no_op"
ROUND_TIMEOUT = "round_timeout"
REDEEM_ROUND_TIMEOUT = "redeem_round_timeout"
NO_MAJORITY = "no_majority"


Expand Down
2 changes: 2 additions & 0 deletions packages/valory/skills/trader_abci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from packages.valory.skills.termination_abci.models import TerminationParams
from packages.valory.skills.trader_abci.composition import TraderAbciApp
from packages.valory.skills.transaction_settlement_abci.rounds import Event as TSEvent
from packages.valory.skills.decision_maker_abci.rounds import Event as DecisionMakerEvent
from packages.valory.skills.tx_settlement_multiplexer_abci.models import (
TxSettlementMultiplexerParams,
)
Expand Down Expand Up @@ -116,6 +117,7 @@ def setup(self) -> None:
TSEvent.VALIDATE_TIMEOUT: self.params.validate_timeout,
TSEvent.FINALIZE_TIMEOUT: self.params.finalize_timeout,
TSEvent.CHECK_TIMEOUT: self.params.history_check_timeout,
DecisionMakerEvent.REDEEM_ROUND_TIMEOUT: self.params.redeem_round_timeout,
ResetPauseEvent.RESET_AND_PAUSE_TIMEOUT: reset_pause_timeout,
}

Expand Down
7 changes: 4 additions & 3 deletions packages/valory/skills/trader_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fingerprint:
dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm
fsm_specification.yaml: bafybeiecxat37q634mgmv3hwgevulr726k3cc6ild3kylititnf3w7gl5m
handlers.py: bafybeicamc6vmozij5dwvkxmbxjazsgf3sacojhstbjtq7vfggszxugvey
models.py: bafybeifxiptjrnv4hbw5l3mfxvb7hksmxf726kvab5lcms5btuc3vaahem
models.py: bafybeifyk4dmnpq2vblrj3ldoaicsamidww6am4zvbind6ijlpbdawcz4m
fingerprint_ignore_patterns: []
connections: []
contracts: []
Expand All @@ -25,8 +25,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq
- valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224
- valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i
- valory/decision_maker_abci:0.1.0:bafybeibpftqsvijeysldhuqte2gvr3e5lfzm44lt5lepamqy3nczyez2pe
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigvxa2cfueh5ytwcpzszalw2gznyg2ctmbjq46krqewy7cxsvq2gi
- valory/decision_maker_abci:0.1.0:bafybeigrtd3td5b5ibq4tz7vzokan72h62fppfs75il7epxkm7l4afi2f4
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiayt5mk22qmba74qhcszy6oaukewl2glscf4fsh6aai2klac6tege
- valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe
behaviours:
main:
Expand Down Expand Up @@ -190,6 +190,7 @@ models:
staking_contract_address: '0x5add592ce0a1B5DceCebB5Dcac086Cd9F9e3eA5C'
agent_balance_threshold: 10000000000000000
refill_check_interval: 10
redeem_round_timeout: 3600.0
tool_punishment_multiplier: 1
class_name: TraderParams
network_subgraph:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
AbstractRoundBehaviour,
BaseBehaviour,
)
from packages.valory.skills.decision_maker_abci.models import RedeemingProgress
from packages.valory.skills.decision_maker_abci.payloads import VotingPayload
from packages.valory.skills.tx_settlement_multiplexer_abci.models import (
TxSettlementMultiplexerParams,
Expand Down Expand Up @@ -128,10 +129,26 @@ def synchronized_data(self) -> SynchronizedData:
"""Return the synchronized data."""
return SynchronizedData(super().synchronized_data.db)

def _on_redeem_round_tx_settled(self) -> None:
"""Handle the redeem round."""
self.context.logger.info("Redeeming transaction was settled. Resetting the redeeming progress.")
self.shared_state.redeeming_progress = RedeemingProgress()

def _on_tx_settled(self) -> None:
"""Handle the tx settled event."""
tx_submitter = self.synchronized_data.tx_submitter
handler_name = f"_on_{tx_submitter}_tx_settled"
handler = getattr(self, handler_name, None)
if handler is None:
self.context.logger.info(f"No post tx settlement handler exists for {tx_submitter} txs.")
return
handler()

def async_act(self) -> Generator:
"""Simply log that a tx is settled and wait for the round end."""
msg = f"The transaction submitted by {self.synchronized_data.tx_submitter} was successfully settled."
self.context.logger.info(msg)
self._on_tx_settled()
yield from self.wait_until_round_end()
self.set_done()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
README.md: bafybeiegcjg2wjrsqhrmvyulioch3d67rnbzkx5af3ztkaw7kxathjreda
__init__.py: bafybeide6k22zk4f3hyzhpapaoddsnxpw5elqcfvrxxj4nfvpzctv6jqhu
behaviours.py: bafybeihmhpvorg4tgdhrhtv6ks6uxza4k5qxvnxanfhil75t54rfb5ykta
behaviours.py: bafybeiakntvnx7wcdpoylswfb76r5odsamsj7bpiworqf3enzuubvqn6cm
dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm
fsm_specification.yaml: bafybeidwxjna36auqbtqlehx73kyb6o74suhzj5bothgtiapcj35b7gzve
handlers.py: bafybeiafbqr7ojfcbwohvee7x4zzswad3ymfrrbjlfz7uuuttmn3qdfs6q
Expand All @@ -21,7 +21,7 @@ protocols:
- valory/ledger_api:1.0.0:bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru
skills:
- valory/abstract_round_abci:0.1.0:bafybeidau7loztcfy3mxvoqrv7otbpciemd2wf3lsxyjraq4dcvuvib25e
- valory/decision_maker_abci:0.1.0:bafybeibpftqsvijeysldhuqte2gvr3e5lfzm44lt5lepamqy3nczyez2pe
- valory/decision_maker_abci:0.1.0:bafybeigrtd3td5b5ibq4tz7vzokan72h62fppfs75il7epxkm7l4afi2f4
- valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe
behaviours:
main:
Expand Down

0 comments on commit 6bd9255

Please sign in to comment.