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: add a max block window size #148

Merged
merged 3 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 8 additions & 8 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"dev": {
"connection/valory/websocket_client/0.1.0": "bafybeiflmystocxaqblhpzqlcop2vkhsknpzjx2jomohomaxamwskeokzm",
"skill/valory/contract_subscription/0.1.0": "bafybeicyugrkx5glat4p4ezwf6i7oduh26eycfie6ftd4uxrknztzl3ik4",
"agent/valory/mech/0.1.0": "bafybeigpn5qnabtrwamfqpnerefnlgo2dumjni22kl4zcwhjzq4srrmnt4",
"skill/valory/mech_abci/0.1.0": "bafybeiej4fot4ee27d5tujxxb2u5w4rtbanpm7txwfti73rrhgmf43xmwq",
"contract/valory/agent_mech/0.1.0": "bafybeiggowhbqwg7ex2yfz57l3qzorlnu4fkipdrlzs23nrldrbbfa7dri",
"service/valory/mech/0.1.0": "bafybeieany5auucyblft2i7hssabpv6hi3v7j3ulugrnkqcngawgbqqkze",
"agent/valory/mech/0.1.0": "bafybeigbatk43mn52ll753wngwgogs7asf6o4ik4g7t2odsjae6r7gvnzm",
"skill/valory/mech_abci/0.1.0": "bafybeignzfwlcgvzxj35o6lrnxi7p4n43nveiicfnskhuyrbshrantkzl4",
"contract/valory/agent_mech/0.1.0": "bafybeie4vkd7etviknttpxjhfw35wejwtyz5uz7iaj7c6bwcec2myzx5tu",
"service/valory/mech/0.1.0": "bafybeibwqbe63ut4z4doydnblo2b4dyqhezot55efowd64wobmkbn6vuri",
"protocol/valory/acn_data_share/0.1.0": "bafybeih5ydonnvrwvy2ygfqgfabkr47s4yw3uqxztmwyfprulwfsoe7ipq",
"skill/valory/task_submission_abci/0.1.0": "bafybeiewwpv5veykxbd7wfbq7vvnlcnfsraxhz6ymqxcaf5nfz6nz7g2pa",
"skill/valory/task_execution/0.1.0": "bafybeidmvbucjd472m5lo3ebyhlojpl2o25mndlnllqtakqe73r7vghztq",
"skill/valory/task_submission_abci/0.1.0": "bafybeida6wxfyvnsm5iudyuiwb4y62pcbui2c5gyingmto4kymu2hpzkb4",
"skill/valory/task_execution/0.1.0": "bafybeibj6rfawiyggaubinrhwelvidyzbgbvdg2ud47qqwzgp5iqoaksj4",
"contract/valory/agent_registry/0.1.0": "bafybeiargayav6yiztdnwzejoejstcx4idssch2h4f5arlgtzj3tgsgfmu",
"protocol/valory/websocket_client/0.1.0": "bafybeih43mnztdv3v2hetr2k3gezg7d3yj4ur7cxdvcyaqhg65e52s5sf4",
"skill/valory/websocket_client/0.1.0": "bafybeidwntmkk4b2ixq5454ycbkknclqx7a6vpn7aqpm2nw3duszqrxvta",
"contract/valory/hash_checkpoint/0.1.0": "bafybeieys27hidb5m267jwqsxdgorf5v37o6lvrfy2oga557stjn4xgoaa",
"skill/valory/subscription_abci/0.1.0": "bafybeibtm62zrvzg2jp7yb5oi77pi6glrgewg2tael5oildf4wd6nzugbm"
"skill/valory/subscription_abci/0.1.0": "bafybeicjdbwivmhm5asiptmlqtjanlbhdkajfyeccn5redwjus2g5gadz4"
},
"third_party": {
"skill/valory/transaction_settlement_abci/0.1.0": "bafybeiaefgqbs7zsn5xe5kdwrujj7ivygkn3ujpw6crnvi3knvxw75qmja",
Expand All @@ -40,6 +40,6 @@
"contract/valory/gnosis_safe_proxy_factory/0.1.0": "bafybeidvcgnbbmjtha6tl7st2ysna2l3iiqfhnzjfasyvml5unecozeeka",
"contract/valory/gnosis_safe/0.1.0": "bafybeidll7frtdsq2ckiluazkwk4zpkp7natt4kdejjehwvykqwzyuf6ei",
"contract/valory/multisend/0.1.0": "bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y",
"connection/valory/http_server/0.22.0": "bafybeib6axuzanyktdidtygeibsm426fw4a2dcpc5ppdwsjblaboeepmry"
"connection/valory/http_server/0.22.0": "bafybeiasbuy4c65ai5plg6i73apzjdjm5vhpqmcxus65rq3zr6qpbahvge"
}
}
13 changes: 7 additions & 6 deletions packages/valory/agents/mech/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ fingerprint_ignore_patterns: []
connections:
- valory/abci:0.1.0:bafybeiejo5uyurbmafretedivyci2ktastxclbmgrkwcwc2yt36jftyqgm
- valory/http_client:0.23.0:bafybeiddrfvomrmgvh5yuv2coq7ci72wcdf663stayi3m5aawnj4srggce
- valory/http_server:0.22.0:bafybeib6axuzanyktdidtygeibsm426fw4a2dcpc5ppdwsjblaboeepmry
- valory/http_server:0.22.0:bafybeiasbuy4c65ai5plg6i73apzjdjm5vhpqmcxus65rq3zr6qpbahvge
- valory/ipfs:0.1.0:bafybeihx7wb5hngjobw2salzqqryrhxvmxfuw7o2npjyqd2talmh2flqeq
- valory/ledger:0.19.0:bafybeia47rr37ianvwsh77tjjpv3nwif5sywhhy2fbdshnz4a2icwln76a
- valory/p2p_libp2p_client:0.1.0:bafybeihge56dn3xep2dzomu7rtvbgo4uc2qqh7ljl3fubqdi2lq44gs5lq
- valory/websocket_client:0.1.0:bafybeiflmystocxaqblhpzqlcop2vkhsknpzjx2jomohomaxamwskeokzm
contracts:
- valory/agent_mech:0.1.0:bafybeiggowhbqwg7ex2yfz57l3qzorlnu4fkipdrlzs23nrldrbbfa7dri
- valory/agent_mech:0.1.0:bafybeie4vkd7etviknttpxjhfw35wejwtyz5uz7iaj7c6bwcec2myzx5tu
- valory/agent_registry:0.1.0:bafybeiargayav6yiztdnwzejoejstcx4idssch2h4f5arlgtzj3tgsgfmu
- valory/gnosis_safe:0.1.0:bafybeidll7frtdsq2ckiluazkwk4zpkp7natt4kdejjehwvykqwzyuf6ei
- valory/gnosis_safe_proxy_factory:0.1.0:bafybeidvcgnbbmjtha6tl7st2ysna2l3iiqfhnzjfasyvml5unecozeeka
Expand All @@ -38,12 +38,12 @@ skills:
- valory/abstract_abci:0.1.0:bafybeiflcfufixmsrhobf56bn5745m2iipcfqyulwk2qegtnagb3kvaaxi
- valory/abstract_round_abci:0.1.0:bafybeiaqcl7h2famylusiffigwem7tevkcsyocdu5xd42jkmgq6kvowzgq
- valory/contract_subscription:0.1.0:bafybeicyugrkx5glat4p4ezwf6i7oduh26eycfie6ftd4uxrknztzl3ik4
- valory/mech_abci:0.1.0:bafybeiej4fot4ee27d5tujxxb2u5w4rtbanpm7txwfti73rrhgmf43xmwq
- valory/mech_abci:0.1.0:bafybeignzfwlcgvzxj35o6lrnxi7p4n43nveiicfnskhuyrbshrantkzl4
- valory/registration_abci:0.1.0:bafybeic2ynseiak7jpta7jfwuqwyp453b4p7lolr4wihxmpn633uekv5am
- valory/reset_pause_abci:0.1.0:bafybeidzajbe3erygeh2xbd6lrjv7nsptznjuzrt24ykgvhgotdeyhfnba
- valory/subscription_abci:0.1.0:bafybeibtm62zrvzg2jp7yb5oi77pi6glrgewg2tael5oildf4wd6nzugbm
- valory/task_execution:0.1.0:bafybeidmvbucjd472m5lo3ebyhlojpl2o25mndlnllqtakqe73r7vghztq
- valory/task_submission_abci:0.1.0:bafybeiewwpv5veykxbd7wfbq7vvnlcnfsraxhz6ymqxcaf5nfz6nz7g2pa
- valory/subscription_abci:0.1.0:bafybeicjdbwivmhm5asiptmlqtjanlbhdkajfyeccn5redwjus2g5gadz4
- valory/task_execution:0.1.0:bafybeibj6rfawiyggaubinrhwelvidyzbgbvdg2ud47qqwzgp5iqoaksj4
- valory/task_submission_abci:0.1.0:bafybeida6wxfyvnsm5iudyuiwb4y62pcbui2c5gyingmto4kymu2hpzkb4
- valory/termination_abci:0.1.0:bafybeie4zvjfxvdu7qrulmur3chpjz3kpj5m4bjsxvpk4gvj5zbyyayfaa
- valory/transaction_settlement_abci:0.1.0:bafybeiaefgqbs7zsn5xe5kdwrujj7ivygkn3ujpw6crnvi3knvxw75qmja
- valory/websocket_client:0.1.0:bafybeidwntmkk4b2ixq5454ycbkknclqx7a6vpn7aqpm2nw3duszqrxvta
Expand Down Expand Up @@ -202,6 +202,7 @@ models:
num_agents: ${int:4}
from_block_range: ${int:50000}
timeout_limit: ${int:3}
max_block_window: ${int:500}
---
public_id: valory/ledger:0.19.0
type: connection
Expand Down
9 changes: 8 additions & 1 deletion packages/valory/contracts/agent_mech/contract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023 Valory AG
# Copyright 2023-2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -82,6 +82,9 @@
]


BLOCK_INDEXING_TOLERANCE = 50


Adamantios marked this conversation as resolved.
Show resolved Hide resolved
class MechOperation(Enum):
"""Operation types."""

Expand Down Expand Up @@ -270,9 +273,13 @@ def get_multiple_undelivered_reqs(
contract_address: str,
contract_addresses: List[str],
from_block: BlockIdentifier = "earliest",
max_block_window: int = 1000,
**kwargs: Any,
) -> JSONLike:
"""Get the requests that are not delivered."""
current_block = ledger_api.api.eth.block_number
if from_block != "earliest" and current_block - from_block > max_block_window:
from_block = current_block - max_block_window
Adamantios marked this conversation as resolved.
Show resolved Hide resolved
pending_tasks: List[Dict[str, Any]] = []
for contract_address in contract_addresses:
pending_tasks_batch = cls.get_undelivered_reqs(
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/contracts/agent_mech/contract.yaml
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:
__init__.py: bafybeigpq5lxfj2aza6ok3fjuywtdafelkbvoqwaits7regfbgu4oynmku
build/AgentMech.json: bafybeienu4zryyvn6jvjfuhlzxonij7oim7hm3nf2atpjl7swx2amagv4q
contract.py: bafybeibyqhwdez2d2sewagzaqxqvaxwqd2lpfj3tjt5cmkylv4apaspwyu
contract.py: bafybeiahdym4a2chelsov3stbhq46skjbhbg5ky2vf4265evg3w4bt3f3e
fingerprint_ignore_patterns: []
class_name: AgentMechContract
contract_interface_paths:
Expand Down
6 changes: 5 additions & 1 deletion packages/valory/services/mech/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: bafybeif7ia4jdlazy6745ke2k2x5yoqlwsgwr6sbztbgqtwvs3ndm2p7ba
fingerprint_ignore_patterns: []
agent: valory/mech:0.1.0:bafybeigpn5qnabtrwamfqpnerefnlgo2dumjni22kl4zcwhjzq4srrmnt4
agent: valory/mech:0.1.0:bafybeigbatk43mn52ll753wngwgogs7asf6o4ik4g7t2odsjae6r7gvnzm
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -169,6 +169,7 @@ type: skill
agent_index: ${AGENT_INDEX_0:int:0}
num_agents: ${NUM_AGENTS:int:4}
timeout_limit: ${TIMEOUT_LIMIT:int:3}
max_block_window: ${MAX_BLOCK_WINDOW:int:500}
1:
models:
params:
Expand All @@ -181,6 +182,7 @@ type: skill
agent_index: ${AGENT_INDEX_1:int:1}
num_agents: ${NUM_AGENTS:int:4}
timeout_limit: ${TIMEOUT_LIMIT:int:3}
max_block_window: ${MAX_BLOCK_WINDOW:int:500}
2:
models:
params:
Expand All @@ -193,6 +195,7 @@ type: skill
agent_index: ${AGENT_INDEX_2:int:2}
num_agents: ${NUM_AGENTS:int:4}
timeout_limit: ${TIMEOUT_LIMIT:int:3}
max_block_window: ${MAX_BLOCK_WINDOW:int:500}
3:
models:
params:
Expand All @@ -205,6 +208,7 @@ type: skill
agent_index: ${AGENT_INDEX_3:int:3}
num_agents: ${NUM_AGENTS:int:4}
timeout_limit: ${TIMEOUT_LIMIT:int:3}
max_block_window: ${MAX_BLOCK_WINDOW:int:500}
---
public_id: valory/ledger:0.19.0
type: connection
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/skills/mech_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ fingerprint:
models.py: bafybeigpimz5vhgzelhc7c3ipo56wh2o7d7whyqcjd2kjigtxos5d6bwqa
fingerprint_ignore_patterns: []
connections:
- valory/http_server:0.22.0:bafybeib6axuzanyktdidtygeibsm426fw4a2dcpc5ppdwsjblaboeepmry
- valory/http_server:0.22.0:bafybeiasbuy4c65ai5plg6i73apzjdjm5vhpqmcxus65rq3zr6qpbahvge
contracts: []
protocols:
- valory/http:1.0.0:bafybeiejoqgv7finfxo3rcvvovrlj5ccrbgxodjq43uo26ylpowsa3llfe
skills:
- valory/abstract_round_abci:0.1.0:bafybeiaqcl7h2famylusiffigwem7tevkcsyocdu5xd42jkmgq6kvowzgq
- valory/registration_abci:0.1.0:bafybeic2ynseiak7jpta7jfwuqwyp453b4p7lolr4wihxmpn633uekv5am
- valory/reset_pause_abci:0.1.0:bafybeidzajbe3erygeh2xbd6lrjv7nsptznjuzrt24ykgvhgotdeyhfnba
- valory/task_submission_abci:0.1.0:bafybeiewwpv5veykxbd7wfbq7vvnlcnfsraxhz6ymqxcaf5nfz6nz7g2pa
- valory/task_submission_abci:0.1.0:bafybeida6wxfyvnsm5iudyuiwb4y62pcbui2c5gyingmto4kymu2hpzkb4
- valory/termination_abci:0.1.0:bafybeie4zvjfxvdu7qrulmur3chpjz3kpj5m4bjsxvpk4gvj5zbyyayfaa
- valory/transaction_settlement_abci:0.1.0:bafybeiaefgqbs7zsn5xe5kdwrujj7ivygkn3ujpw6crnvi3knvxw75qmja
- valory/subscription_abci:0.1.0:bafybeibtm62zrvzg2jp7yb5oi77pi6glrgewg2tael5oildf4wd6nzugbm
- valory/subscription_abci:0.1.0:bafybeicjdbwivmhm5asiptmlqtjanlbhdkajfyeccn5redwjus2g5gadz4
behaviours:
main:
args: {}
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/subscription_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fingerprint:
fingerprint_ignore_patterns: []
connections: []
contracts:
- valory/agent_mech:0.1.0:bafybeiggowhbqwg7ex2yfz57l3qzorlnu4fkipdrlzs23nrldrbbfa7dri
- valory/agent_mech:0.1.0:bafybeie4vkd7etviknttpxjhfw35wejwtyz5uz7iaj7c6bwcec2myzx5tu
- valory/gnosis_safe:0.1.0:bafybeidll7frtdsq2ckiluazkwk4zpkp7natt4kdejjehwvykqwzyuf6ei
- valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y
protocols:
Expand Down
3 changes: 2 additions & 1 deletion packages/valory/skills/task_execution/behaviours.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023 Valory AG
# Copyright 2023-2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -225,6 +225,7 @@ def _check_for_new_reqs(self) -> None:
from_block=self.params.from_block,
chain_id=GNOSIS_CHAIN,
contract_addresses=self.params.agent_mech_contract_addresses,
max_block_window=self.params.max_block_window,
)
),
counterparty=LEDGER_API_ADDRESS,
Expand Down
4 changes: 3 additions & 1 deletion packages/valory/skills/task_execution/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023 Valory AG
# Copyright 2023-2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,6 +62,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
enforce(self.from_block_range is not None, "from_block_range must be set!")
self.timeout_limit = kwargs.get("timeout_limit", None)
enforce(self.timeout_limit is not None, "timeout_limit must be set!")
self.max_block_window = kwargs.get("max_block_window", None)
enforce(self.max_block_window is not None, "max_block_window must be set!")
# maps the request id to the number of times it has timed out
self.request_id_to_num_timeouts: Dict[int, int] = defaultdict(lambda: 0)
super().__init__(*args, **kwargs)
Expand Down
7 changes: 4 additions & 3 deletions packages/valory/skills/task_execution/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeidqhvvlnthkbnmrdkdeyjyx2f2ab6z4xdgmagh7welqnh2v6wczx4
behaviours.py: bafybeia4ohotkawmpee6k7jr3jin2cnuoikxnm2r7vd3mgapewbt6ea6vy
behaviours.py: bafybeib6ft3iigddo37zv7iejgzcc4wp3v7ocvwvx2czwzt4jhdyadmluu
dialogues.py: bafybeid4zxalqdlo5mw4yfbuf34hx4jp5ay5z6chm4zviwu4cj7fudtwca
handlers.py: bafybeidbt5ezj74cgfogk3w4uw4si2grlnk5g54veyumw7g5yh6gdscywu
models.py: bafybeihc2kmymmh5oousjddbc7xujqbk5niermuqak2dhtgryukzq5wxeq
models.py: bafybeihgclxctyltuehj2f4fzj26edptqugrrm4phd6ovuulezrqot6qo4
utils/__init__.py: bafybeiccdijaigu6e5p2iruwo5mkk224o7ywedc7nr6xeu5fpmhjqgk24e
utils/ipfs.py: bafybeidinbdqkidix44ibz5hug7inkcbijooag53gr5mtbaa72tk335uqq
utils/task.py: bafybeieuziu7owtk543z3umgmayhjh67klftk7vrhz24l6rlaii5lvkqh4
Expand All @@ -20,7 +20,7 @@ connections:
- valory/ipfs:0.1.0:bafybeihx7wb5hngjobw2salzqqryrhxvmxfuw7o2npjyqd2talmh2flqeq
- valory/p2p_libp2p_client:0.1.0:bafybeihge56dn3xep2dzomu7rtvbgo4uc2qqh7ljl3fubqdi2lq44gs5lq
contracts:
- valory/agent_mech:0.1.0:bafybeiggowhbqwg7ex2yfz57l3qzorlnu4fkipdrlzs23nrldrbbfa7dri
- valory/agent_mech:0.1.0:bafybeie4vkd7etviknttpxjhfw35wejwtyz5uz7iaj7c6bwcec2myzx5tu
protocols:
- valory/acn_data_share:0.1.0:bafybeih5ydonnvrwvy2ygfqgfabkr47s4yw3uqxztmwyfprulwfsoe7ipq
- valory/contract_api:1.0.0:bafybeialhbjvwiwcnqq3ysxcyemobcbie7xza66gaofcvla5njezkvhcka
Expand Down Expand Up @@ -86,6 +86,7 @@ models:
num_agents: 4
polling_interval: 30.0
task_deadline: 240.0
max_block_window: 500
use_slashing: false
timeout_limit: 3
slash_cooldown_hours: 3
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/task_submission_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fingerprint:
fingerprint_ignore_patterns: []
connections: []
contracts:
- valory/agent_mech:0.1.0:bafybeiggowhbqwg7ex2yfz57l3qzorlnu4fkipdrlzs23nrldrbbfa7dri
- valory/agent_mech:0.1.0:bafybeie4vkd7etviknttpxjhfw35wejwtyz5uz7iaj7c6bwcec2myzx5tu
- valory/agent_registry:0.1.0:bafybeiargayav6yiztdnwzejoejstcx4idssch2h4f5arlgtzj3tgsgfmu
- valory/gnosis_safe:0.1.0:bafybeidll7frtdsq2ckiluazkwk4zpkp7natt4kdejjehwvykqwzyuf6ei
- valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y
Expand Down
Loading