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

Port multi-ledger support on termination skill from IEKIT #2144

Merged
merged 6 commits into from
Jan 23, 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
6 changes: 3 additions & 3 deletions docs/package_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
| skill/valory/transaction_settlement_abci/0.1.0 | `bafybeiatucim5q7qpmxa6okygmotcwvgkqn5sf4xmmleujcg2pcrrvxxke` | ABCI application for transaction settlement. |
| skill/valory/registration_abci/0.1.0 | `bafybeibtqhwmbye7lshqlr75gmnjntu2pibssfxzh6s2eaznvbtp2ecjfi` | ABCI application for common apps. |
| skill/valory/reset_pause_abci/0.1.0 | `bafybeid4lwwmmno5kaenia4wro6dfimm2hdsuvka7kgp7nnoia7umbmaou` | ABCI application for resetting and pausing app executions. |
| skill/valory/termination_abci/0.1.0 | `bafybeib62356b2xz77fvk7maggk4adwbultxeywnskfgjqroe4rcotwvam` | Termination skill. |
| skill/valory/termination_abci/0.1.0 | `bafybeidgicrtvn4lfhdbtnnqkm7j3icyycckriie54muj3xjwygiptcxou` | Termination skill. |
| skill/valory/counter/0.1.0 | `bafybeiffmptcwhlhcpdadxjcmwdvliudoineub4jq4lvlu4ecjw53sozkm` | The ABCI Counter application example. |
| skill/valory/counter_client/0.1.0 | `bafybeicb37pj26xbknovfox5hwpuh26p3p44uh32tclpj5cwpgvhbmdl4y` | A client for the ABCI counter application. |
| skill/valory/register_reset_abci/0.1.0 | `bafybeif6q5edc4hojerfgelv7wtn254rva7zi2ca3exevjpnaicpvdn6cy` | ABCI application for dummy skill that registers and resets |
| skill/valory/register_termination_abci/0.1.0 | `bafybeidgemaijg46dqy7yewtc7bn3j3axvihj2oj2xydoeq7urovo7n7q4` | ABCI application for dummy skill that registers and resets |
| skill/valory/register_termination_abci/0.1.0 | `bafybeibxoza7mqsufoix53ouucwrzgh2ymva6zqdkqjrgqot5xwc5fjwru` | ABCI application for dummy skill that registers and resets |
| skill/valory/test_abci/0.1.0 | `bafybeigb753ltyedz6sgwodcwo3dz5b6oxqspkqtnkheaxjbzqofge62ny` | ABCI application for testing the ABCI connection. |
| agent/valory/abstract_abci/0.1.0 | `bafybeidsnnzdjdmpwjxgrht46pwgrzon4zfziuzhlhqhwwpi45wwkfkx3m` | The abstract ABCI AEA - for testing purposes only. |
| agent/valory/counter/0.1.0 | `bafybeidyf4564w7mqud3ulrw3zbv7x22ku32m4g24qmgmrfsrfgkjvn6cy` | The ABCI Counter example as an AEA |
| agent/valory/counter_client/0.1.0 | `bafybeibupvzr4ctz6p2wyf6ll62k2bb2a3fyphqrg4bdoihc2wrpttjqia` | The ABCI Counter example as an AEA |
| agent/valory/register_reset/0.1.0 | `bafybeibppojxyelzaup6wtiwzpg7icqj24eqjurolesm2lktbr25zrdoqm` | Register reset to replicate Tendermint issue. |
| agent/valory/register_termination/0.1.0 | `bafybeihhqbdyhf3ymelsj4jnlg3ccytl6kdealxsennfunhtcrfiqye4oe` | Register terminate to test the termination feature. |
| agent/valory/register_termination/0.1.0 | `bafybeiauaozhkzmx44palc3gdsui7zfz2gemtnqyq3mlsjxfmx3tkvilem` | Register terminate to test the termination feature. |
| agent/valory/registration_start_up/0.1.0 | `bafybeiew3ogslg5lql5ojcir5lwp7x4zqaceyjyqjt33qdn3botf5ize4i` | Registration start-up ABCI example. |
| agent/valory/test_abci/0.1.0 | `bafybeierjulnwishz4xbtovj54nk3ldkmxm5v6gguvp4vp4xs3ischbnre` | Agent for testing the ABCI connection. |
| service/valory/counter/0.1.0 | `bafybeihsdgsrhdd2vkiwswqztt653wczwegs4umibi45jdrmc4gdssvlg4` | A set of agents incrementing a counter |
Expand Down
6 changes: 3 additions & 3 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
"skill/valory/transaction_settlement_abci/0.1.0": "bafybeiatucim5q7qpmxa6okygmotcwvgkqn5sf4xmmleujcg2pcrrvxxke",
"skill/valory/registration_abci/0.1.0": "bafybeibtqhwmbye7lshqlr75gmnjntu2pibssfxzh6s2eaznvbtp2ecjfi",
"skill/valory/reset_pause_abci/0.1.0": "bafybeid4lwwmmno5kaenia4wro6dfimm2hdsuvka7kgp7nnoia7umbmaou",
"skill/valory/termination_abci/0.1.0": "bafybeib62356b2xz77fvk7maggk4adwbultxeywnskfgjqroe4rcotwvam",
"skill/valory/termination_abci/0.1.0": "bafybeidgicrtvn4lfhdbtnnqkm7j3icyycckriie54muj3xjwygiptcxou",
"skill/valory/counter/0.1.0": "bafybeiffmptcwhlhcpdadxjcmwdvliudoineub4jq4lvlu4ecjw53sozkm",
"skill/valory/counter_client/0.1.0": "bafybeicb37pj26xbknovfox5hwpuh26p3p44uh32tclpj5cwpgvhbmdl4y",
"skill/valory/register_reset_abci/0.1.0": "bafybeif6q5edc4hojerfgelv7wtn254rva7zi2ca3exevjpnaicpvdn6cy",
"skill/valory/register_termination_abci/0.1.0": "bafybeidgemaijg46dqy7yewtc7bn3j3axvihj2oj2xydoeq7urovo7n7q4",
"skill/valory/register_termination_abci/0.1.0": "bafybeibxoza7mqsufoix53ouucwrzgh2ymva6zqdkqjrgqot5xwc5fjwru",
"skill/valory/test_abci/0.1.0": "bafybeigb753ltyedz6sgwodcwo3dz5b6oxqspkqtnkheaxjbzqofge62ny",
"agent/valory/abstract_abci/0.1.0": "bafybeidsnnzdjdmpwjxgrht46pwgrzon4zfziuzhlhqhwwpi45wwkfkx3m",
"agent/valory/counter/0.1.0": "bafybeidyf4564w7mqud3ulrw3zbv7x22ku32m4g24qmgmrfsrfgkjvn6cy",
"agent/valory/counter_client/0.1.0": "bafybeibupvzr4ctz6p2wyf6ll62k2bb2a3fyphqrg4bdoihc2wrpttjqia",
"agent/valory/register_reset/0.1.0": "bafybeibppojxyelzaup6wtiwzpg7icqj24eqjurolesm2lktbr25zrdoqm",
"agent/valory/register_termination/0.1.0": "bafybeihhqbdyhf3ymelsj4jnlg3ccytl6kdealxsennfunhtcrfiqye4oe",
"agent/valory/register_termination/0.1.0": "bafybeiauaozhkzmx44palc3gdsui7zfz2gemtnqyq3mlsjxfmx3tkvilem",
"agent/valory/registration_start_up/0.1.0": "bafybeiew3ogslg5lql5ojcir5lwp7x4zqaceyjyqjt33qdn3botf5ize4i",
"agent/valory/test_abci/0.1.0": "bafybeierjulnwishz4xbtovj54nk3ldkmxm5v6gguvp4vp4xs3ischbnre",
"service/valory/counter/0.1.0": "bafybeihsdgsrhdd2vkiwswqztt653wczwegs4umibi45jdrmc4gdssvlg4",
Expand Down
4 changes: 2 additions & 2 deletions packages/valory/agents/register_termination/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ protocols:
skills:
- valory/abstract_abci:0.1.0:bafybeibqqfgtjdfbvexjw6v4zasz5l6ssnw6joqgookfgpia2qqhvkt33e
- valory/abstract_round_abci:0.1.0:bafybeidjaatj5k2ejme33ybzhycmmcemnlpzysuur5tqc2pfqqlafoxmm4
- valory/register_termination_abci:0.1.0:bafybeidgemaijg46dqy7yewtc7bn3j3axvihj2oj2xydoeq7urovo7n7q4
- valory/register_termination_abci:0.1.0:bafybeibxoza7mqsufoix53ouucwrzgh2ymva6zqdkqjrgqot5xwc5fjwru
- valory/registration_abci:0.1.0:bafybeibtqhwmbye7lshqlr75gmnjntu2pibssfxzh6s2eaznvbtp2ecjfi
- valory/reset_pause_abci:0.1.0:bafybeid4lwwmmno5kaenia4wro6dfimm2hdsuvka7kgp7nnoia7umbmaou
- valory/termination_abci:0.1.0:bafybeib62356b2xz77fvk7maggk4adwbultxeywnskfgjqroe4rcotwvam
- valory/termination_abci:0.1.0:bafybeidgicrtvn4lfhdbtnnqkm7j3icyycckriie54muj3xjwygiptcxou
- valory/transaction_settlement_abci:0.1.0:bafybeiatucim5q7qpmxa6okygmotcwvgkqn5sf4xmmleujcg2pcrrvxxke
default_ledger: ethereum
required_ledgers:
Expand Down
3 changes: 2 additions & 1 deletion packages/valory/skills/register_termination_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ skills:
- valory/abstract_round_abci:0.1.0:bafybeidjaatj5k2ejme33ybzhycmmcemnlpzysuur5tqc2pfqqlafoxmm4
- valory/registration_abci:0.1.0:bafybeibtqhwmbye7lshqlr75gmnjntu2pibssfxzh6s2eaznvbtp2ecjfi
- valory/reset_pause_abci:0.1.0:bafybeid4lwwmmno5kaenia4wro6dfimm2hdsuvka7kgp7nnoia7umbmaou
- valory/termination_abci:0.1.0:bafybeib62356b2xz77fvk7maggk4adwbultxeywnskfgjqroe4rcotwvam
- valory/termination_abci:0.1.0:bafybeidgicrtvn4lfhdbtnnqkm7j3icyycckriie54muj3xjwygiptcxou
behaviours:
main:
args: {}
Expand Down Expand Up @@ -131,6 +131,7 @@ models:
use_slashing: false
use_termination: false
validate_timeout: 1205
termination_from_block: 0
class_name: Params
randomness_api:
args:
Expand Down
7 changes: 7 additions & 0 deletions packages/valory/skills/termination_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def _get_latest_removed_owner_event(self) -> Generator[None, None, Optional[Dict
contract_callable="get_removed_owner_events",
contract_address=self.synchronized_data.safe_contract_address,
removed_owner=self._service_owner_address,
from_block=self.params.termination_from_block,
chain_id=self.params.default_chain_id,
)
if response.performative != ContractApiMessage.Performative.STATE:
self.context.logger.error(
Expand All @@ -216,12 +218,17 @@ def _get_latest_removed_owner_event(self) -> Generator[None, None, Optional[Dict

def _get_latest_termination_signal(self) -> Generator[None, None, Optional[Dict]]:
"""Get the latest termination signal sent by the service owner."""
self.context.logger.info(
f"Retrieving termination events on chain '{self.params.default_chain_id}' from block {self.params.termination_from_block}"
)
response = yield from self.get_contract_api_response(
performative=ContractApiMessage.Performative.GET_STATE, # type: ignore
contract_id=str(GnosisSafeContract.contract_id),
contract_callable="get_zero_transfer_events",
contract_address=self.synchronized_data.safe_contract_address,
sender_address=self._service_owner_address,
from_block=self.params.termination_from_block,
chain_id=self.params.default_chain_id,
)
if response.performative != ContractApiMessage.Performative.STATE:
self.context.logger.error(
Expand Down
3 changes: 3 additions & 0 deletions packages/valory/skills/termination_abci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Set up the termination parameters."""
self.termination_sleep: int = self._ensure("termination_sleep", kwargs, int)
self.multisend_address: str = self._ensure("multisend_address", kwargs, str)
self.termination_from_block: int = self._ensure(
"termination_from_block", kwargs, int
)
super().__init__(*args, **kwargs)


Expand Down
8 changes: 8 additions & 0 deletions packages/valory/skills/termination_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
"""Get the most_voted_tx_hash."""
return cast(str, self.db.get_strict("most_voted_tx_hash")) # pragma: no cover

@property
def chain_id(self) -> Optional[str]:
"""Get the chain name where to send the transactions to."""
return cast(str, self.db.get("chain_id", None))

Check warning on line 74 in packages/valory/skills/termination_abci/rounds.py

View check run for this annotation

Codecov / codecov/patch

packages/valory/skills/termination_abci/rounds.py#L74

Added line #L74 was not covered by tests


class BackgroundRound(CollectSameUntilThresholdRound):
"""Defines the background round, which runs concurrently with other rounds."""
Expand Down Expand Up @@ -119,6 +124,9 @@
get_name(
SynchronizedData.most_voted_tx_hash
): self.most_voted_payload,
get_name(
SynchronizedData.chain_id
): self.context.params.default_chain_id,
},
)
return state, Event.TERMINATE
Expand Down
9 changes: 5 additions & 4 deletions packages/valory/skills/termination_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeidztixckwwbn4ujl6kkvghgsk23xecbgnbiw3e4t3owxldhyjo3au
behaviours.py: bafybeidl5q5fenawxaze2crv3h3nhsjkyylxihsmn67o6dhvdd35wj6mpe
behaviours.py: bafybeicj55rxbnjecidfe5fzcfjod6q3fk37ly7t3preyezq5ftuxp3dlu
dialogues.py: bafybeif7uhfjkcz3ryhti6gafqxhvciw4ec5bdshxvq3355tun5ydkzrna
handlers.py: bafybeibh5b3p4bdvbnwiqwormduqjvuievylb3s2wgj4ald4led7gx2kji
models.py: bafybeif5qygu6bdgsxv53sqoty76vgp3afib6e6fmykofrgnlcubmg4cd4
models.py: bafybeigstlctzmfxb6teywvniojrbgfns6vfvv62eltl3yvcrwjbhrzudq
payloads.py: bafybeihbwfunongkws5lck67sdgpnytq6bdbiv22yuehmyfth4qeypjcpa
rounds.py: bafybeifj7xjobumi7l2vwfdzeqfqdlrcn7oq2vy46tzakketgipxwgh3nu
rounds.py: bafybeiez5xv74sdusfz4hqgaxch2bbpyjrtgwkidccymkzefw4ehbmd5by
tests/__init__.py: bafybeigsjjibb2gcybzp5yrsy25vyiu54rw6oaeyw5onaqemsvul7bmroi
tests/test_behaviours.py: bafybeibkogjosxk6ktneru5ddgzguuiw2wuvx2n63d3rpyqhoy7llnoc5i
tests/test_dialogues.py: bafybeicb6gfanfyt3wiq3svdlvtxiuzpk72oxp7cfdeq4ezed7ixee5yae
tests/test_handlers.py: bafybeiefz2ebr5rlyxziwr4bts2r75abpqgji3k47a6hnrj7e7t2yvgmpu
tests/test_models.py: bafybeih5wtdjuv4hc25fxneeg7mgjiks55xj353zxfamvtrthkw2ydmbbe
tests/test_payloads.py: bafybeibai4dzjjdeyeinyirjndcfzbj2qst6roj6prjvcqwut5m3won3fa
tests/test_rounds.py: bafybeigpc5xuuhlycjq52gbnw6c33o3yvozpuhzhutrrqdm2wtdgqmkcy4
tests/test_rounds.py: bafybeihhjthenhnnqhlyfmn4vofzcisga5gl7ygi636fp3z46plgu5zjuy
fingerprint_ignore_patterns: []
connections: []
contracts:
Expand Down Expand Up @@ -135,6 +135,7 @@ models:
use_slashing: false
use_termination: false
validate_timeout: 1205
termination_from_block: 0
class_name: TerminationParams
requests:
args: {}
Expand Down
6 changes: 5 additions & 1 deletion packages/valory/skills/termination_abci/tests/test_rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def test_run(

test_round = BackgroundRound(
synchronized_data=deepcopy(self.synchronized_data),
context=MagicMock(),
context=MagicMock(
params=MagicMock(
default_chain_id=1,
)
),
)
payload_data = "0xdata"
first_payload, *payloads = [
Expand Down
Loading