Skip to content

Commit

Permalink
Merge pull request #32 from valory-xyz/feat/chained-abci
Browse files Browse the repository at this point in the history
Feat/chained abci
  • Loading branch information
0xArdi authored Sep 28, 2022
2 parents 87f03e2 + 58268b0 commit 42c51cd
Show file tree
Hide file tree
Showing 17 changed files with 868 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
17717b5732caefaecc0bc57d64a3ce8c89052577:packages/balancer/skills/autonomous_fund_abci/skill.yaml:generic-api-key:81
8efa33c0e847f2d75bdca1b0cdf5fd134f6b322b:packages/balancer/skills/autonomous_fund_abci/skill.yaml:generic-api-key:81
c5417dfdd2c3aa5d1d7ab05e7ccbcf6d6c6487aa:packages/balancer/skills/pool_manager_abci/skill.yaml:generic-api-key:79
920341fcf1d179421c4afdbbbb4f9d23235023fd:packages/balancer/contracts/managed_pool_controller/tests/helpers/constants.py:generic-api-key:46
fba2d8c0f6c143478db8b998f037f8d6f0954e81:packages/valory/connections/http_client/connection.yaml:generic-api-key:14
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ new_env: clean
fix-abci-app-specs:
export PYTHONPATH=${PYTHONPATH}:${PWD} && autonomy analyse abci generate-app-specs packages.balancer.skills.fear_and_greed_oracle_abci.rounds.FearAndGreedOracleAbciApp packages/balancer/skills/fear_and_greed_oracle_abci/fsm_specification.yaml || (echo "Failed to check fear_and_greed_oracle_abci abci consistency" && exit 1)
export PYTHONPATH=${PYTHONPATH}:${PWD} && autonomy analyse abci generate-app-specs packages.balancer.skills.pool_manager_abci.rounds.PoolManagerAbciApp packages/balancer/skills/pool_manager_abci/fsm_specification.yaml || (echo "Failed to check pool_manager_abci abci consistency" && exit 1)
export PYTHONPATH=${PYTHONPATH}:${PWD} && autonomy analyse abci generate-app-specs packages.balancer.skills.autonomous_fund_abci.composition.AutonomousFundAbciApp packages/balancer/skills/autonomous_fund_abci/fsm_specification.yaml || (echo "Failed to check fear_and_greed_oracle_abci abci consistency" && exit 1)
51 changes: 49 additions & 2 deletions packages/balancer/agents/autonomous_fund/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,26 @@ fingerprint:
tests/test_contracts/test_weighted_pool/__init__.py: bafybeibtrvod3qxiehjgnezoxhembuinyapcow7dtekwbqfpiwsyb2nyjy
tests/test_contracts/test_weighted_pool/test_contract.py: bafybeig2db5cusxt3fqcls24kldtftoofjemjlj5ylekegco76d4brw46e
fingerprint_ignore_patterns: []
connections: []
connections:
- valory/abci:0.1.0:bafybeiejtgtkfxrrigsro6tvaaqgktrpao7bx476ob3n2wezonblnxi3xy
- valory/http_client:0.1.0:bafybeiet6defg3qvov4r2ucjtkywkz53xcg6mgarjfdqmnxfgdixgcx45y
- valory/ledger:0.1.0:bafybeicfycqnhdzg5nsir33dlcgs2k4ijjncysqjcn67zvzv2fkwr43eby
- valory/p2p_libp2p_client:0.1.0:bafybeigvayl4ykzqf6o6bw2irv7am3qvczjoeu7yjhzn27ajiwvcio3lxm
contracts:
- balancer/managed_pool_controller:0.1.0:bafybeiajqgorg5yfrp4zwwqjvtexrdzbzh53v4nwn5uukjbovrjyydwmt4
- balancer/weighted_pool:0.1.0:bafybeifz5t65kwgf6yhxdo5pvvpran5fmh2yjm2pm7cx6cikihlvjwpmd4
protocols:
- open_aea/signing:1.0.0:bafybeiambqptflge33eemdhis2whik67hjplfnqwieoa6wblzlaf7vuo44
skills: []
skills:
- balancer/autonomous_fund_abci:0.1.0:bafybeifx2x3g3dhlq3clq2irf5ciqsj2gadyyelfhop7mlfiwj2yx5xri4
- balancer/fear_and_greed_oracle_abci:0.1.0:bafybeicmttoiyfvh2usfyrsuog475rkxoszb3ymh6ue3lnsc3p6q4aky6q
- balancer/pool_manager_abci:0.1.0:bafybeihb5jzxuf7piv44v6ovhxvg222uwf7ke3y6bjxl7jipszqd7ay2bm
- valory/abstract_abci:0.1.0:bafybeigqbgoej3zhsz6e5ibdu5tewv6plh4yzxllguyftbymj5bp2zaxyq
- valory/abstract_round_abci:0.1.0:bafybeiasu3lbnwqdgdzoaxrvbos5qgabxtxkhb52r3rosrp4s4c246467a
- valory/registration_abci:0.1.0:bafybeie7lxe5spcitc7pwfilapsu5wlictp4ibz7gbko5yg3nx6llcjisu
- valory/reset_pause_abci:0.1.0:bafybeiamkbck2c35uc6h7c6sotmsobr7h6tc2vzskoxztlu7o6af6mcacm
- valory/safe_deployment_abci:0.1.0:bafybeifgljjbc2x42xcynmirchrno7iwwq6ufnhpqr37ypeoqstfnjujli
- valory/transaction_settlement_abci:0.1.0:bafybeia2gs36s2mz32yaznhlidiolhw5swkumiej4vgwywphppjvurldie
default_ledger: ethereum
required_ledgers:
- ethereum
Expand All @@ -36,3 +49,37 @@ logging_config:
dependencies:
open-aea-ledger-ethereum: {}
default_connection: null
---
public_id: valory/abci:0.1.0
type: connection
config:
target_skill_id: balancer/autonomous_fund_abci:0.1.0
host: ${ABCI_HOST:str:localhost}
port: ${ABCI_PORT:int:26658}
use_tendermint: ${ABCI_USE_TENDERMINT:bool:false}
---
public_id: valory/ledger:0.1.0
type: connection
config:
ledger_apis:
ethereum:
address: ${CONNECTION_LEDGER_CONFIG_LEDGER_APIS_ETHEREUM_ADDRESS:str:http://localhost:8545}
chain_id: ${CONNECTION_LEDGER_CONFIG_LEDGER_APIS_ETHEREUM_CHAIN_ID:int:31337}
poa_chain: ${CONNECTION_LEDGER_CONFIG_LEDGER_APIS_ETHEREUM_POA_CHAIN:bool:false}
default_gas_price_strategy: ${CONNECTION_LEDGER_CONFIG_LEDGER_APIS_ETHEREUM_DEFAULT_GAS_PRICE_STRATEGY:str:eip1559}
---
public_id: valory/p2p_libp2p_client:0.1.0
type: connection
config:
nodes:
- uri: ${P2P_URI:str:acn.staging.autonolas.tech:9005}
public_key: ${P2P_PUBLIC_KEY:str:0250827315351f6f4d3777b77d4bfd67280156240313bf221750b36404344bb35d}
cert_requests:
- identifier: acn
ledger_id: ethereum
message_format: '{public_key}'
not_after: '2022-01-01'
not_before: '2021-01-01'
public_key: ${P2P_PUBLIC_KEY:str:0250827315351f6f4d3777b77d4bfd67280156240313bf221750b36404344bb35d}
save_path: .certs/acn_cosmos_9005.txt
is_abstract: true
25 changes: 25 additions & 0 deletions packages/balancer/skills/autonomous_fund_abci/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains the implementation of the default skill."""

from aea.configurations.base import PublicId


PUBLIC_ID = PublicId.from_str("balancer/autonomous_fund:0.1.0")
63 changes: 63 additions & 0 deletions packages/balancer/skills/autonomous_fund_abci/behaviours.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This package contains round behaviours of AutonomousFundAbciApp."""
from typing import Set, Type

from packages.balancer.skills.autonomous_fund_abci.composition import (
AutonomousFundAbciApp,
)
from packages.balancer.skills.fear_and_greed_oracle_abci.behaviours import (
FearAndGreedOracleRoundBehaviour,
)
from packages.balancer.skills.pool_manager_abci.behaviours import (
PoolManagerRoundBehaviour,
)
from packages.valory.skills.abstract_round_abci.behaviours import (
AbstractRoundBehaviour,
BaseBehaviour,
)
from packages.valory.skills.registration_abci.behaviours import (
AgentRegistrationRoundBehaviour,
RegistrationStartupBehaviour,
)
from packages.valory.skills.reset_pause_abci.behaviours import (
ResetPauseABCIConsensusBehaviour,
)
from packages.valory.skills.safe_deployment_abci.behaviours import (
SafeDeploymentRoundBehaviour,
)
from packages.valory.skills.transaction_settlement_abci.behaviours import (
TransactionSettlementRoundBehaviour,
)


class AutonomousFundConsensusBehaviour(AbstractRoundBehaviour):
"""Class to define the behaviours this AbciApp has."""

initial_behaviour_cls = RegistrationStartupBehaviour
abci_app_cls = AutonomousFundAbciApp
behaviours: Set[Type[BaseBehaviour]] = {
*FearAndGreedOracleRoundBehaviour.behaviours,
*PoolManagerRoundBehaviour.behaviours,
*AgentRegistrationRoundBehaviour.behaviours,
*SafeDeploymentRoundBehaviour.behaviours,
*TransactionSettlementRoundBehaviour.behaviours,
*ResetPauseABCIConsensusBehaviour.behaviours,
}
58 changes: 58 additions & 0 deletions packages/balancer/skills/autonomous_fund_abci/composition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This package contains round behaviours of AutonomousFundAbciApp."""
import packages.balancer.skills.fear_and_greed_oracle_abci.rounds as FearAndGreedAbci
import packages.balancer.skills.pool_manager_abci.rounds as PoolManagerAbci
import packages.valory.skills.registration_abci.rounds as RegistrationAbci
import packages.valory.skills.reset_pause_abci.rounds as ResetAndPauseAbci
import packages.valory.skills.safe_deployment_abci.rounds as SafeDeploymentAbci
import packages.valory.skills.transaction_settlement_abci.rounds as TransactionSubmissionAbci
from packages.valory.skills.abstract_round_abci.abci_app_chain import (
AbciAppTransitionMapping,
chain,
)


# here we define how the transition between the FSMs should happen
# more information here: https://docs.autonolas.network/fsm_app_introduction/#composition-of-fsm-apps
abci_app_transition_mapping: AbciAppTransitionMapping = {
RegistrationAbci.FinishedRegistrationRound: SafeDeploymentAbci.RandomnessSafeRound,
RegistrationAbci.FinishedRegistrationFFWRound: FearAndGreedAbci.ObservationRound,
SafeDeploymentAbci.FinishedSafeRound: FearAndGreedAbci.ObservationRound,
FearAndGreedAbci.FinishedDataCollectionRound: PoolManagerAbci.DecisionMakingRound,
PoolManagerAbci.FinishedTxPreparationRound: TransactionSubmissionAbci.RandomnessTransactionSubmissionRound,
PoolManagerAbci.FinishedWithoutTxRound: ResetAndPauseAbci.ResetAndPauseRound,
TransactionSubmissionAbci.FinishedTransactionSubmissionRound: ResetAndPauseAbci.ResetAndPauseRound,
ResetAndPauseAbci.FinishedResetAndPauseRound: FearAndGreedAbci.ObservationRound,
TransactionSubmissionAbci.FailedRound: ResetAndPauseAbci.ResetAndPauseRound,
ResetAndPauseAbci.FinishedResetAndPauseErrorRound: RegistrationAbci.RegistrationRound,
}

AutonomousFundAbciApp = chain(
(
RegistrationAbci.AgentRegistrationAbciApp,
SafeDeploymentAbci.SafeDeploymentAbciApp,
FearAndGreedAbci.FearAndGreedOracleAbciApp,
PoolManagerAbci.PoolManagerAbciApp,
TransactionSubmissionAbci.TransactionSubmissionAbciApp,
ResetAndPauseAbci.ResetPauseABCIApp,
),
abci_app_transition_mapping,
)
71 changes: 71 additions & 0 deletions packages/balancer/skills/autonomous_fund_abci/dialogues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains the classes required for dialogue management."""

from packages.valory.skills.abstract_round_abci.dialogues import (
AbciDialogue as BaseAbciDialogue,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
AbciDialogues as BaseAbciDialogues,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
ContractApiDialogue as BaseContractApiDialogue,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
ContractApiDialogues as BaseContractApiDialogues,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
HttpDialogue as BaseHttpDialogue,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
HttpDialogues as BaseHttpDialogues,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
LedgerApiDialogue as BaseLedgerApiDialogue,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
LedgerApiDialogues as BaseLedgerApiDialogues,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
SigningDialogue as BaseSigningDialogue,
)
from packages.valory.skills.abstract_round_abci.dialogues import (
SigningDialogues as BaseSigningDialogues,
)


AbciDialogue = BaseAbciDialogue
AbciDialogues = BaseAbciDialogues


HttpDialogue = BaseHttpDialogue
HttpDialogues = BaseHttpDialogues


SigningDialogue = BaseSigningDialogue
SigningDialogues = BaseSigningDialogues


LedgerApiDialogue = BaseLedgerApiDialogue
LedgerApiDialogues = BaseLedgerApiDialogues


ContractApiDialogue = BaseContractApiDialogue
ContractApiDialogues = BaseContractApiDialogues
Loading

0 comments on commit 42c51cd

Please sign in to comment.