Skip to content

Commit

Permalink
Merge pull request #2059 from valory-xyz/release/v0.12.0.post2
Browse files Browse the repository at this point in the history
Release `v0.12.1.post2`
  • Loading branch information
angrybayblade authored Sep 20, 2023
2 parents 0f63846 + 4968e01 commit 847808f
Show file tree
Hide file tree
Showing 71 changed files with 2,087 additions and 254 deletions.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,16 @@ packages/valory/protocols/contract_api
packages/valory/protocols/http
packages/valory/protocols/ledger_api

autonomy/data/contracts/registries_manager
autonomy/data/contracts/component_registry
autonomy/data/contracts/service_registry
autonomy/data/contracts/agent_registry
autonomy/data/contracts/component_registry
autonomy/data/contracts/erc20
autonomy/data/contracts/gnosis_safe
autonomy/data/contracts/gnosis_safe_proxy_factory
autonomy/data/contracts/multisend
autonomy/data/contracts/registries_manager
autonomy/data/contracts/service_manager
autonomy/data/contracts/service_registry
autonomy/data/contracts/service_registry_token_utility

.vscode/

Expand Down
3 changes: 2 additions & 1 deletion .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,5 @@ selection_key
0.10.10.post1
unbond
chiado
0.12.1.post1
0.12.1.post1
0.12.1.post2
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Release History - `open-autonomy`


# 0.12.1.post2 (2023-09-20)

Autonomy:

- Adds missing contract packages to the `eject-contracts` make target
- Adds check to make sure service is in `pre-registration` before updating the service hash
- Adds check to make sure all required environment variables are present for on-chain interactions

# 0.12.1.post1 (2023-09-14)

Autonomy:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ install: clean

.PHONY: eject-contracts
eject-contracts:
@for contract in registries_manager service_manager component_registry agent_registry service_registry ; do \
@for contract in component_registry agent_registry registries_manager service_manager service_registry gnosis_safe gnosis_safe_proxy_factory service_registry_token_utility multisend erc20 ; do \
echo Updating $$contract contract; \
rm -rf autonomy/data/contracts/$$contract ; \
cp -r packages/valory/contracts/$$contract autonomy/data/contracts/$$contract ; \
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The following table shows which versions of `open-autonomy` are currently being

| Version | Supported |
| --------- | ------------------ |
| `0.12.1.post1` | :white_check_mark: |
| `0.12.1.post2` | :white_check_mark: |
| `< 0.12.x` | :x: |

## Reporting a Vulnerability
Expand Down
2 changes: 1 addition & 1 deletion autonomy/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__title__ = "open-autonomy"
__description__ = "A framework for the creation of autonomous agent services."
__url__ = "https://github.com/valory-xyz/open-autonomy.git"
__version__ = "0.12.1.post1"
__version__ = "0.12.1.post2"
__author__ = "Valory AG"
__license__ = "Apache-2.0"
__copyright__ = "2021-2022 Valory AG"
134 changes: 131 additions & 3 deletions autonomy/cli/helpers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
from texttable import Texttable

from autonomy.chain.base import ServiceState, UnitType
from autonomy.chain.config import ChainConfigs, ChainType, ContractConfigs
from autonomy.chain.config import (
ChainConfigs,
ChainType,
ContractConfig,
ContractConfigs,
)
from autonomy.chain.constants import (
AGENT_REGISTRY_CONTRACT,
COMPONENT_REGISTRY_CONTRACT,
Expand Down Expand Up @@ -185,6 +190,25 @@ def get_ledger_and_crypto_objects(

return ledger_api, crypto

def check_required_enviroment_variables(
self, configs: Tuple[ContractConfig, ...]
) -> None:
"""Check for required enviroment variables when working with the custom chain."""
if self.chain_type != ChainType.CUSTOM:
return
missing = []
for config in configs:
if config.contracts[self.chain_type] is None:
missing.append(config)

if len(missing) == 0:
return

error = "Addresses for following contracts are None, please set them using their respective environment variables\n"
for config in missing:
error += f"- Set `{config.name}` address using `CUSTOM_{config.name.upper()}_ADDRESS`\n"
raise click.ClickException(error[:-1])


class MintHelper(OnChainHelper): # pylint: disable=too-many-instance-attributes
"""Mint helper."""
Expand Down Expand Up @@ -243,18 +267,27 @@ def load_metadata(self) -> "MintHelper": # pragma: nocover
contract_address = ContractConfigs.get(
SERVICE_REGISTRY_CONTRACT.name
).contracts[self.chain_type]
self.check_required_enviroment_variables(
configs=(ContractConfigs.service_registry,)
)
elif self.package_type == PackageType.AGENT:
is_service = False
is_agent = True
contract_address = ContractConfigs.get(
AGENT_REGISTRY_CONTRACT.name
).contracts[self.chain_type]
self.check_required_enviroment_variables(
configs=(ContractConfigs.agent_registry,)
)
else:
is_service = False
is_agent = False
contract_address = ContractConfigs.get(
COMPONENT_REGISTRY_CONTRACT.name
).contracts[self.chain_type]
self.check_required_enviroment_variables(
configs=(ContractConfigs.component_registry,)
)

self.old_metadata = resolve_component_id(
ledger_api=self.ledger_api,
Expand Down Expand Up @@ -357,6 +390,18 @@ def mint_component(
component_type: UnitType = UnitType.COMPONENT,
) -> None:
"""Mint component."""

self.check_required_enviroment_variables(
configs=(
ContractConfigs.registries_manager,
(
ContractConfigs.component_registry
if component_type == UnitType.COMPONENT
else ContractConfigs.agent_registry
),
)
)

try:
self.token_id = _mint_component(
ledger_api=self.ledger_api,
Expand Down Expand Up @@ -405,6 +450,18 @@ def mint_service(
) -> None:
"""Mint service"""

if self.chain_type == ChainType.CUSTOM and token is not None:
raise click.ClickException(
"Cannot use custom token for bonding on L2 chains"
)

self.check_required_enviroment_variables(
configs=(
ContractConfigs.service_manager,
ContractConfigs.service_registry,
)
)

try:
token_id = _mint_service(
ledger_api=self.ledger_api,
Expand Down Expand Up @@ -442,6 +499,16 @@ def mint_service(

def update_component(self, component_type: UnitType = UnitType.COMPONENT) -> None:
"""Update component."""
self.check_required_enviroment_variables(
configs=(
ContractConfigs.registries_manager,
(
ContractConfigs.component_registry
if component_type == UnitType.COMPONENT
else ContractConfigs.agent_registry
),
)
)
try:
self.token_id = _update_component(
ledger_api=self.ledger_api,
Expand All @@ -455,7 +522,7 @@ def update_component(self, component_type: UnitType = UnitType.COMPONENT) -> Non
raise click.ClickException(f"Invalid parameters provided; {e}") from e
except ComponentMintFailed as e:
raise click.ClickException(
f"Component mint failed with following error; {e}"
f"Component update failed with following error; {e}"
) from e

click.echo("Component hash updated:")
Expand All @@ -481,6 +548,24 @@ def update_service(
) -> None:
"""Update service"""

self.check_required_enviroment_variables(
configs=(
ContractConfigs.service_manager,
ContractConfigs.service_registry,
)
)

*_, state, _ = get_service_info(
ledger_api=self.ledger_api,
chain_type=self.chain_type,
token_id=cast(int, self.update_token),
)

if ServiceState(state) != ServiceState.PRE_REGISTRATION:
raise click.ClickException(
"Cannot update service hash, service needs to be in the pre-registration state"
)

try:
token_id = _update_service(
ledger_api=self.ledger_api,
Expand All @@ -501,7 +586,7 @@ def update_service(
)
except ComponentMintFailed as e:
raise click.ClickException(
f"Service mint failed with following error; {e}"
f"Service update failed with following error; {e}"
) from e

click.echo("Service updated with:")
Expand Down Expand Up @@ -539,6 +624,11 @@ def check_is_service_token_secured(
token: Optional[str] = None,
) -> "ServiceHelper":
"""Check if service"""
if self.chain_type == ChainType.CUSTOM:
self.token = token
self.token_secured = False
return self

self.token = token
self.token_secured = is_service_token_secured(
ledger_api=self.ledger_api,
Expand Down Expand Up @@ -584,6 +674,13 @@ def activate_service(self) -> None:
spender=spender,
)

self.check_required_enviroment_variables(
configs=(
ContractConfigs.service_manager,
ContractConfigs.service_registry,
)
)

try:
_activate_service(
ledger_api=self.ledger_api,
Expand Down Expand Up @@ -619,6 +716,13 @@ def register_instance(
spender=spender,
)

self.check_required_enviroment_variables(
configs=(
ContractConfigs.service_manager,
ContractConfigs.service_registry,
)
)

try:
_register_instance(
ledger_api=self.ledger_api,
Expand All @@ -642,6 +746,16 @@ def deploy_service(
) -> None:
"""Deploy a service with registration activated"""

self.check_required_enviroment_variables(
configs=(
ContractConfigs.service_manager,
ContractConfigs.service_registry,
ContractConfigs.gnosis_safe_proxy_factory,
ContractConfigs.gnosis_safe_same_address_multisig,
ContractConfigs.multisend,
)
)

try:
_deploy_service(
ledger_api=self.ledger_api,
Expand All @@ -660,6 +774,13 @@ def deploy_service(
def terminate_service(self) -> None:
"""Terminate a service"""

self.check_required_enviroment_variables(
configs=(
ContractConfigs.service_manager,
ContractConfigs.service_registry,
)
)

try:
_terminate_service(
ledger_api=self.ledger_api,
Expand All @@ -675,6 +796,13 @@ def terminate_service(self) -> None:
def unbond_service(self) -> None:
"""Unbond a service"""

self.check_required_enviroment_variables(
configs=(
ContractConfigs.service_manager,
ContractConfigs.service_registry,
)
)

try:
_unbond_service(
ledger_api=self.ledger_api,
Expand Down
2 changes: 1 addition & 1 deletion autonomy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
ACN_IMAGE_NAME = os.environ.get("ACN_IMAGE_NAME", "valory/open-acn-node")
DEFAULT_DOCKER_IMAGE_AUTHOR = "valory"
OAR_IMAGE = "{image_author}/oar-{agent}:{version}"
ABSTRACT_ROUND_ABCI_SKILL_WITH_HASH = "valory/abstract_round_abci:0.1.0:bafybeicqwr73cs3vndzafrjrjpw63vvqbbjsur7ptek77hsw3lurnood5y"
ABSTRACT_ROUND_ABCI_SKILL_WITH_HASH = "valory/abstract_round_abci:0.1.0:bafybeifnqddpl3rui4gzh7x75feptzlxwzvix72kbqo5t5yvof2r62jzke"
2 changes: 1 addition & 1 deletion deployments/Dockerfiles/autonomy-user/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open-autonomy[all]==0.12.1.post1
open-autonomy[all]==0.12.1.post2
open-aea[all]==1.39.0
open-aea-cli-ipfs==1.39.0
open-aea-ledger-ethereum==1.39.0
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced_reference/commands/autonomy_fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ autonomy --registry-path=./packages fetch valory/hello_world:0.1.0 --service --l

Fetch the agent service `hello_world` from a remote registry ([IPFS](https://ipfs.io)):
```bash
autonomy fetch valory/hello_world:0.1.0:bafybeibao4o6x2b5qrfe5zo2ksz2skhv2sgazhoixz67l5ndwbomjq6sv4 --service --remote
autonomy fetch valory/hello_world:0.1.0:bafybeia3r5ulvcgux6cfdk6atja75h4r6nzazqs4v4xewuhohhvxg5gzla --service --remote
```
11 changes: 11 additions & 0 deletions docs/api/cli/helpers/chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ def get_ledger_and_crypto_objects(

Create ledger_api and crypto objects

<a id="autonomy.cli.helpers.chain.OnChainHelper.check_required_enviroment_variables"></a>

#### check`_`required`_`enviroment`_`variables

```python
def check_required_enviroment_variables(
configs: Tuple[ContractConfig, ...]) -> None
```

Check for required enviroment variables when working with the custom chain.

<a id="autonomy.cli.helpers.chain.MintHelper"></a>

## MintHelper Objects
Expand Down
Loading

0 comments on commit 847808f

Please sign in to comment.