From a84f2762c245146de4e9a6c54053c58ab90f738e Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 16:51:19 +0300 Subject: [PATCH 01/57] feat: add contract for agent registry --- .../contracts/agent_registry/__init__.py | 20 + .../agent_registry/build/AgentRegistry.json | 1046 +++++++++++++++++ .../contracts/agent_registry/contract.py | 64 + .../contracts/agent_registry/contract.yaml | 26 + 4 files changed, 1156 insertions(+) create mode 100644 packages/valory/contracts/agent_registry/__init__.py create mode 100644 packages/valory/contracts/agent_registry/build/AgentRegistry.json create mode 100644 packages/valory/contracts/agent_registry/contract.py create mode 100644 packages/valory/contracts/agent_registry/contract.yaml diff --git a/packages/valory/contracts/agent_registry/__init__.py b/packages/valory/contracts/agent_registry/__init__.py new file mode 100644 index 000000000..cf1e8467e --- /dev/null +++ b/packages/valory/contracts/agent_registry/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 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 support resources for the agent registry contract.""" diff --git a/packages/valory/contracts/agent_registry/build/AgentRegistry.json b/packages/valory/contracts/agent_registry/build/AgentRegistry.json new file mode 100644 index 000000000..79a56dba2 --- /dev/null +++ b/packages/valory/contracts/agent_registry/build/AgentRegistry.json @@ -0,0 +1,1046 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "AgentRegistry", + "sourceName": "contracts/AgentRegistry.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "_baseURI", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "AgentInstanceRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "AgentInstancesSlotsFilled", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "AgentNotFound", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "AgentNotInService", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "componentId", + "type": "uint256" + } + ], + "name": "ComponentNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "HashExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expected", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "IncorrectAgentBondingValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expected", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "IncorrectRegistrationDepositValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "ManagerOnly", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provided", + "type": "address" + }, + { + "internalType": "address", + "name": "expected", + "type": "address" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "OnlyOwnServiceMultisig", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "OperatorHasNoInstances", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "OperatorOnly", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "provided", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "Overflow", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnerOnly", + "type": "error" + }, + { + "inputs": [], + "name": "Paused", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuard", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "ServiceMustBeInactive", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "TransferFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "multisig", + "type": "address" + } + ], + "name": "UnauthorizedMultisig", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "WrongAgentId", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "numValues1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "numValues2", + "type": "uint256" + } + ], + "name": "WrongArrayLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "WrongOperator", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "state", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "WrongServiceState", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "currentThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxThreshold", + "type": "uint256" + } + ], + "name": "WrongThreshold", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroValue", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "baseURI", + "type": "string" + } + ], + "name": "BaseURIChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "CreateAgent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "ManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "UpdateAgentHash", + "type": "event" + }, + { + "inputs": [], + "name": "CID_PREFIX", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newManager", + "type": "address" + } + ], + "name": "changeManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "changeOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "agentOwner", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "create", + "outputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "unitId", + "type": "uint256" + } + ], + "name": "exists", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "getHashes", + "outputs": [ + { + "internalType": "uint256", + "name": "numHashes", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "agentHashes", + "type": "bytes32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "manager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "mapAgentIdHashes", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "bURI", + "type": "string" + } + ], + "name": "setBaseURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "tokenByIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "unitId", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "unitId", + "type": "uint256" + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "updateHash", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} \ No newline at end of file diff --git a/packages/valory/contracts/agent_registry/contract.py b/packages/valory/contracts/agent_registry/contract.py new file mode 100644 index 000000000..9acf29aad --- /dev/null +++ b/packages/valory/contracts/agent_registry/contract.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 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 class to connect to the Agent Registry contract.""" + +from aea.common import JSONLike +from aea.configurations.base import PublicId +from aea.contracts.base import Contract +from aea.crypto.base import LedgerApi + + +class AgentRegistryContract(Contract): + """The Agent Registry contract.""" + + contract_id = PublicId.from_str("valory/agent_registry:0.1.0") + + @classmethod + def get_hash( + cls, + ledger_api: LedgerApi, + contract_address: str, + agent_id: int, + ) -> JSONLike: + """Retrieve an operator given its agent instance.""" + + contract_instance = cls.get_instance(ledger_api, contract_address) + res = contract_instance.functions.getHashes(agent_id).call() + # ensure that the returned object has the expected format + if len(res) != 2: + msg = f"The `getHashes` method for {contract_address=} returned data in an unexpected format: {res}" + return dict(error=msg) + + # get the agent hashes + hashes = res.pop(-1) + # ensure that there are hashes returned for the agent + if len(hashes) == 0: + msg = f"The `getHashes` method for {contract_address=} returned no hashes for {agent_id=}: {res}" + return dict(error=msg) + + # get the most recent agent hash + hash_ = hashes.pop(-1) + # ensure that the hash is in bytes + if not isinstance(hash_, bytes): + msg = f"The `getHashes` method for {contract_address=} returned non-bytes {hash_=} for {agent_id=}: {res}" + return dict(error=msg) + + # return the hash in hex + return dict(hash=hash_.hex()) diff --git a/packages/valory/contracts/agent_registry/contract.yaml b/packages/valory/contracts/agent_registry/contract.yaml new file mode 100644 index 000000000..dc9566f46 --- /dev/null +++ b/packages/valory/contracts/agent_registry/contract.yaml @@ -0,0 +1,26 @@ +name: agent_registry +author: valory +version: 0.1.0 +type: contract +description: Agent Registry contract +license: Apache-2.0 +aea_version: '>=1.0.0, <2.0.0' +fingerprint: + __init__.py: bafybeidey4syohls5hxmso6qsp5p4uhtzle5txv2mlbym6ktjzknich6oa + build/AgentRegistry.json: bafybeia4qi2vstrutejzrxfpbb6eift7va5cjs7bparaal2fafiiczuiyy + build/AgentRegistryL2.json: bafybeic2jylwfod4nmdtbs4izyxyi246pd3f35aoqyahnmyrvzn7j3sv4e + contract.py: bafybeibqwl52cnz64cysjd2jnjijuakdvyrffapxq65cdzx6g65gu42deq + tests/__init__.py: bafybeicl2oklx774jomlt6wwwegfdzrxh6iazjxwcyc7h4gepjljkpl4ji + tests/test_contract.py: bafybeicj535veqf35zb3ycu5iqjvqgj4a2kdmogmx5ba7fiolt5chah42a +fingerprint_ignore_patterns: [] +contracts: [] +class_name: AgentRegistryContract +contract_interface_paths: + ethereum: build/AgentRegistry.json +dependencies: + open-aea-ledger-ethereum: + version: ==1.39.0 + open-aea-test-autonomy: + version: ==0.12.1.post1 + open-aea-web3: + version: ==6.0.1 From 86969cf3d203a2a68acee4912f22969db5542286 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 16:52:04 +0300 Subject: [PATCH 02/57] feat: add contract method to get the mech's id [no ci] --- packages/valory/contracts/mech/contract.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/valory/contracts/mech/contract.py b/packages/valory/contracts/mech/contract.py index cc2cab58d..85966e0d5 100644 --- a/packages/valory/contracts/mech/contract.py +++ b/packages/valory/contracts/mech/contract.py @@ -184,3 +184,14 @@ def get_response( return {"error": error} return dict(data=deliver_args["data"]) + + @classmethod + def get_mech_id( + cls, + ledger_api: EthereumApi, + contract_address: str, + ) -> JSONLike: + """Get the price of a request.""" + contract_instance = cls.get_instance(ledger_api, contract_address) + mech_id = ledger_api.contract_method_call(contract_instance, "tokenId") + return dict(id=mech_id) From da8f225578355c86561c6806f8e289e629578282 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 16:54:54 +0300 Subject: [PATCH 03/57] feat: add configs required for the tool selection strategy --- packages/valory/agents/trader/aea-config.yaml | 5 ++++ packages/valory/services/trader/service.yaml | 24 +++++++++++++++++++ .../skills/decision_maker_abci/models.py | 11 ++++++++- .../skills/decision_maker_abci/skill.yaml | 23 ++++++++++++++++++ packages/valory/skills/trader_abci/models.py | 4 ++++ packages/valory/skills/trader_abci/skill.yaml | 23 ++++++++++++++++++ 6 files changed, 89 insertions(+), 1 deletion(-) diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 26128f954..8f649f839 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -147,6 +147,7 @@ models: multisend_address: ${str:0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761} drand_public_key: ${str:868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31} service_registry_address: ${str:null} + agent_registry_address: ${str:null} share_tm_config_on_startup: ${bool:false} sleep_time: ${int:10} tendermint_p2p_url: ${str:localhost:26656} @@ -187,6 +188,10 @@ models: redeeming_batch_size: ${int:5} slippage: ${float:0.01} redeem_margin_days: ${int:15} + epsilon: ${float:0.1} + irrelevant_tools: ${set:{"openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", + "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", + "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"}} --- public_id: valory/p2p_libp2p_client:0.1.0 type: connection diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index d578e0723..346b83031 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -57,6 +57,7 @@ type: skill round_timeout_seconds: ${ROUND_TIMEOUT:float:350.0} service_id: ${SERVICE_ID:str:trader} service_registry_address: ${SERVICE_REGISTRY_ADDRESS:str:0x9338b5153AE39BB89f50468E608eD9d764B755fD} + agent_registry_address: ${AGENT_REGISTRY_ADDRESS:str:0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA} share_tm_config_on_startup: ${USE_ACN:bool:false} sleep_time: ${SLEEP_TIME:int:1} tendermint_check_sleep_delay: ${TM_CHECK_SLEEP_DELAY:int:3} @@ -104,6 +105,11 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} + epsilon: ${EPSILON:float:0.1} + irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + "stabilityai-stable-diffusion-768-v2-1"}} benchmark_tool: &id005 args: log_dir: ${LOG_DIR:str:/benchmarks} @@ -133,6 +139,7 @@ type: skill round_timeout_seconds: ${ROUND_TIMEOUT:float:350.0} service_id: ${SERVICE_ID:str:trader} service_registry_address: ${SERVICE_REGISTRY_ADDRESS:str:0x9338b5153AE39BB89f50468E608eD9d764B755fD} + agent_registry_address: ${AGENT_REGISTRY_ADDRESS:str:0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA} share_tm_config_on_startup: ${USE_ACN:bool:false} sleep_time: ${SLEEP_TIME:int:1} tendermint_check_sleep_delay: ${TM_CHECK_SLEEP_DELAY:int:3} @@ -168,6 +175,11 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} + epsilon: ${EPSILON:float:0.1} + irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + "stabilityai-stable-diffusion-768-v2-1"}} benchmark_tool: *id005 2: models: @@ -195,6 +207,7 @@ type: skill round_timeout_seconds: ${ROUND_TIMEOUT:float:350.0} service_id: ${SERVICE_ID:str:trader} service_registry_address: ${SERVICE_REGISTRY_ADDRESS:str:0x9338b5153AE39BB89f50468E608eD9d764B755fD} + agent_registry_address: ${AGENT_REGISTRY_ADDRESS:str:0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA} share_tm_config_on_startup: ${USE_ACN:bool:false} sleep_time: ${SLEEP_TIME:int:1} tendermint_check_sleep_delay: ${TM_CHECK_SLEEP_DELAY:int:3} @@ -230,6 +243,11 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} + epsilon: ${EPSILON:float:0.1} + irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + "stabilityai-stable-diffusion-768-v2-1"}} benchmark_tool: *id005 3: models: @@ -257,6 +275,7 @@ type: skill round_timeout_seconds: ${ROUND_TIMEOUT:float:350.0} service_id: ${SERVICE_ID:str:trader} service_registry_address: ${SERVICE_REGISTRY_ADDRESS:str:0x9338b5153AE39BB89f50468E608eD9d764B755fD} + agent_registry_address: ${AGENT_REGISTRY_ADDRESS:str:0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA} share_tm_config_on_startup: ${USE_ACN:bool:false} sleep_time: ${SLEEP_TIME:int:1} tendermint_check_sleep_delay: ${TM_CHECK_SLEEP_DELAY:int:3} @@ -292,6 +311,11 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} + epsilon: ${EPSILON:float:0.1} + irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + "stabilityai-stable-diffusion-768-v2-1"}} benchmark_tool: *id005 --- public_id: valory/ledger:0.19.0 diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 4b861687c..3228c33b0 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -122,7 +122,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.redeeming_batch_size = self._ensure("redeeming_batch_size", kwargs, int) # a slippage in the range of [0, 1] to apply to the `minOutcomeTokensToBuy` when buying shares on a fpmm self._slippage = 0.0 - self.slippage = self._ensure("slippage", kwargs, float) + self.slippage: float = self._ensure("slippage", kwargs, float) + self.epsilon: float = self._ensure("epsilon", kwargs, float) + self.agent_registry_address: str = self._ensure( + "agent_registry_address", kwargs, str + ) + self.irrelevant_tools: set = self._ensure("irrelevant_tools", kwargs, set) super().__init__(*args, **kwargs) @property @@ -161,6 +166,10 @@ class MechResponseSpecs(ApiSpecs): """A model that wraps ApiSpecs for the Mech's response specifications.""" +class AgentToolsSpecs(ApiSpecs): + """A model that wraps ApiSpecs for the Mech agent's tools specifications.""" + + @dataclass class MultisendBatch: """A structure representing a single transaction of a multisend.""" diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 426da9bc6..830b7ecba 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -136,6 +136,7 @@ models: round_timeout_seconds: 350.0 service_id: decision_maker service_registry_address: null + agent_registry_address: null setup: all_participants: - '0x0000000000000000000000000000000000000000' @@ -181,6 +182,16 @@ models: realitio_address: '0x79e32aE03fb27B07C89c0c568F80287C01ca2E57' redeeming_batch_size: 5 slippage: 0.01 + epsilon: 0.1 + irrelevant_tools: + ? openai-text-davinci-002 + ? openai-text-davinci-003 + ? openai-gpt-3.5-turbo + ? openai-gpt-4 + ? stabilityai-stable-diffusion-v1-5 + ? stabilityai-stable-diffusion-xl-beta-v2-2-2 + ? stabilityai-stable-diffusion-512-v2-1 + ? stabilityai-stable-diffusion-768-v2-1 class_name: DecisionMakerParams mech_response: args: @@ -194,6 +205,18 @@ models: retries: 5 url: '' class_name: MechResponseSpecs + agent_tools: + args: + api_id: agent_tools + headers: + Content-Type: application/json + method: GET + parameters: { } + response_key: tools + response_type: list + retries: 5 + url: '' + class_name: AgentToolsSpecs requests: args: {} class_name: Requests diff --git a/packages/valory/skills/trader_abci/models.py b/packages/valory/skills/trader_abci/models.py index f5606ffeb..60f0405cc 100644 --- a/packages/valory/skills/trader_abci/models.py +++ b/packages/valory/skills/trader_abci/models.py @@ -33,6 +33,9 @@ from packages.valory.skills.decision_maker_abci.models import ( MechResponseSpecs as DecisionMakerMechResponseSpecs, ) +from packages.valory.skills.decision_maker_abci.models import ( + AgentToolsSpecs as DecisionMakerAgentToolsSpecs, +) from packages.valory.skills.decision_maker_abci.rounds import ( Event as DecisionMakerEvent, ) @@ -68,6 +71,7 @@ OmenSubgraph = MarketManagerOmenSubgraph NetworkSubgraph = MarketManagerNetworkSubgraph MechResponseSpecs = DecisionMakerMechResponseSpecs +AgentToolsSpecs = DecisionMakerAgentToolsSpecs MARGIN = 5 diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index dff539b90..124fdf2a0 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -118,6 +118,7 @@ models: round_timeout_seconds: 350.0 service_id: trader service_registry_address: null + agent_registry_address: null setup: all_participants: - '0x0000000000000000000000000000000000000000' @@ -169,6 +170,16 @@ models: redeeming_batch_size: 5 slippage: 0.01 redeem_margin_days: 15 + epsilon: 0.1 + irrelevant_tools: + ? openai-text-davinci-002 + ? openai-text-davinci-003 + ? openai-gpt-3.5-turbo + ? openai-gpt-4 + ? stabilityai-stable-diffusion-v1-5 + ? stabilityai-stable-diffusion-xl-beta-v2-2-2 + ? stabilityai-stable-diffusion-512-v2-1 + ? stabilityai-stable-diffusion-768-v2-1 class_name: TraderParams network_subgraph: args: @@ -218,6 +229,18 @@ models: retries: 5 url: '' class_name: MechResponseSpecs + agent_tools: + args: + api_id: agent_tools + headers: + Content-Type: application/json + method: GET + parameters: { } + response_key: tools + response_type: list + retries: 5 + url: '' + class_name: AgentToolsSpecs requests: args: {} class_name: Requests From 89d0594984b7e936433fa5755c3a2e8d0385649a Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 16:56:15 +0300 Subject: [PATCH 04/57] feat: remove mech tool which will not be necessary anymore [no ci] --- README.md | 8 -------- packages/valory/agents/trader/aea-config.yaml | 1 - packages/valory/services/trader/service.yaml | 4 ---- packages/valory/skills/decision_maker_abci/models.py | 1 - packages/valory/skills/decision_maker_abci/skill.yaml | 1 - packages/valory/skills/trader_abci/skill.yaml | 1 - 6 files changed, 16 deletions(-) diff --git a/README.md b/README.md index ed0edf5e2..9ebefc76c 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,6 @@ export ALL_PARTICIPANTS='["YOUR_AGENT_ADDRESS"]' export SAFE_CONTRACT_ADDRESS="YOUR_SAFE_ADDRESS" export OMEN_CREATORS='["0x89c5cc945dd550BcFfb72Fe42BfF002429F46Fec"]' -export MECH_TOOL="prediction-online" - export BET_AMOUNT_PER_THRESHOLD_000=0 export BET_AMOUNT_PER_THRESHOLD_010=0 export BET_AMOUNT_PER_THRESHOLD_020=0 @@ -117,12 +115,6 @@ These are the description of the variables used by the Trader service: - `SAFE_CONTRACT_ADDRESS`: address of the agents multisig wallet created [in the previous section](#prepare-the-keys-and-the-safe). - `OMEN_CREATORS`: addresses of the market creator(s) that the service will track for placing bets on Omen. The address `0x89c5cc945dd550BcFfb72Fe42BfF002429F46Fec` corresponds to the Market creator agent for the Hackathon. -- `MECH_TOOL`: the tool that the service will use to get the prediction when performing requests to the AI Mech. - You may find all the available Mech scripts [here](https://github.com/valory-xyz/mech/tree/v0.5.0/tools) - for Mech's version `v0.5.0`. - Each script contains one or more tools. - For example, you may find all the `prediction_request` tools - [here](https://github.com/valory-xyz/mech/blob/v0.5.0/tools/prediction_request.py#L37-L40). - `BET_AMOUNT_PER_THRESHOLD_X`: amount (wei) to bet when the prediction returned by the AI Mech surpasses a threshold of `X`% confidence for a given prediction market. In the values provided above the amounts vary between 0.03 xDAI (60% confidence) and 0.1 xDAI (100% confidence). - `BET_THRESHOLD`: threshold (wei) for placing a bet. A bet will only be placed if `potential_net_profit - BET_THRESHOLD >= 0`. [See below](#some-notes-on-the-service). - `PROMPT_TEMPLATE`: prompt to be used with the prediction AI Mech. Please keep it as a single line including the placeholders `@{question}`, `@{yes}` and `@{no}`. diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 8f649f839..2e771fc1d 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -162,7 +162,6 @@ models: average_block_time: ${int:5} abt_error_mult: ${int:5} mech_agent_address: ${str:0xff82123dfb52ab75c417195c5fdb87630145ae81} - mech_tool: ${str:prediction-online} bet_amount_per_threshold: 0.0: ${int:0} 0.1: ${int:0} diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 346b83031..4081035b4 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -78,7 +78,6 @@ type: skill average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} - mech_tool: ${MECH_TOOL:str:prediction-online} bet_amount_per_threshold: &id004 0.0: ${BET_AMOUNT_PER_THRESHOLD_000:int:0} 0.1: ${BET_AMOUNT_PER_THRESHOLD_010:int:0} @@ -159,7 +158,6 @@ type: skill average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} - mech_tool: ${MECH_TOOL:str:prediction-online} bet_amount_per_threshold: *id004 bet_threshold: ${BET_THRESHOLD:int:100000000000000000} blacklisting_duration: ${BLACKLISTING_DURATION:int:3600} @@ -227,7 +225,6 @@ type: skill average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} - mech_tool: ${MECH_TOOL:str:prediction-online} bet_amount_per_threshold: *id004 bet_threshold: ${BET_THRESHOLD:int:100000000000000000} blacklisting_duration: ${BLACKLISTING_DURATION:int:3600} @@ -295,7 +292,6 @@ type: skill average_block_time: ${ABT:int:5} abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} - mech_tool: ${MECH_TOOL:str:prediction-online} bet_amount_per_threshold: *id004 bet_threshold: ${BET_THRESHOLD:int:100000000000000000} blacklisting_duration: ${BLACKLISTING_DURATION:int:3600} diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 3228c33b0..28f948b32 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -92,7 +92,6 @@ class DecisionMakerParams(MarketManagerParams): def __init__(self, *args: Any, **kwargs: Any) -> None: """Initialize the parameters' object.""" self.mech_agent_address: str = self._ensure("mech_agent_address", kwargs, str) - self.mech_tool: str = self._ensure("mech_tool", kwargs, str) # this is a mapping from the confidence of a bet's choice to the amount we are willing to bet self.bet_amount_per_threshold: Dict[float, int] = self._ensure( "bet_amount_per_threshold", kwargs, Dict[float, int] diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 830b7ecba..b3f99c667 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -157,7 +157,6 @@ models: tx_timeout: 10.0 use_termination: false mech_agent_address: '0xff82123dfb52ab75c417195c5fdb87630145ae81' - mech_tool: prediction-online bet_amount_per_threshold: 0.0: 0 0.1: 0 diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 124fdf2a0..5aa766e5f 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -144,7 +144,6 @@ models: average_block_time: 5 abt_error_mult: 5 mech_agent_address: '0xff82123dfb52ab75c417195c5fdb87630145ae81' - mech_tool: prediction-online bet_amount_per_threshold: 0.0: 0 0.1: 0 From 96a4abb7451b640b0d0ea15431bbe23cfe83f603 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:08:16 +0300 Subject: [PATCH 05/57] feat: implement an encoder for dataclasses --- .../valory/skills/decision_maker_abci/models.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 28f948b32..bba5afcb9 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -20,10 +20,11 @@ """This module contains the models for the skill.""" import json +import random import re -from dataclasses import dataclass +from dataclasses import asdict, dataclass, is_dataclass from string import Template -from typing import Any, Dict, Optional, Set +from typing import Any, Dict, List, Optional, Set from aea.exceptions import enforce from hexbytes import HexBytes @@ -225,3 +226,13 @@ def incorrect_format(cls, res: Any) -> "MechInteractionResponse": response = cls() response.error = f"The response's format was unexpected: {res}" return response + + +class DataclassEncoder(json.JSONEncoder): + """A custom JSON encoder for dataclasses.""" + + def default(self, o: Any) -> Any: + """The default JSON encoder.""" + if is_dataclass(o): + return asdict(o) + return super().default(o) From 67b0f2cf9a0f2796b8c8cf176a30499e91807ce0 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:08:46 +0300 Subject: [PATCH 06/57] feat: implement an `argmax` function --- packages/valory/skills/decision_maker_abci/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index bba5afcb9..75776d1fc 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -236,3 +236,8 @@ def default(self, o: Any) -> Any: if is_dataclass(o): return asdict(o) return super().default(o) + + +def argmax(li: List) -> int: + """Get the index of the max value within the provided list.""" + return li.index((max(li))) From 26cea4629ebe4908422376000556aad04a4c2b0c Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:09:18 +0300 Subject: [PATCH 07/57] feat: implement an Epsilon Greedy Policy [no ci] --- .../skills/decision_maker_abci/models.py | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 75776d1fc..55513aeef 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -241,3 +241,73 @@ def default(self, o: Any) -> Any: def argmax(li: List) -> int: """Get the index of the max value within the provided list.""" return li.index((max(li))) + + +@dataclass +class EGreedyPolicy: + """An e-Greedy policy for the tool selection.""" + + eps: float + n_tools: int + counts: List[int] + rewards: List[float] + + @classmethod + def initial_state(cls, eps: float, n_tools: int) -> "EGreedyPolicy": + """Return an instance on its initial state.""" + if n_tools == 0: + error = f"Cannot initialize an e Greedy Policy with {n_tools=}" + raise ValueError(error) + + return EGreedyPolicy(eps, n_tools, [0] * n_tools, [0.0] * n_tools) + + @classmethod + def deserialize(cls, policy: str) -> "EGreedyPolicy": + """Deserialize a string to an `EGreedyPolicy` object.""" + return EGreedyPolicy(**json.loads(policy)) + + @property + def random_tool(self) -> int: + """Get the index of a tool randomly.""" + return random.randrange(self.n_tools) + + @property + def reward_rates(self) -> List[float]: + """Get the reward rates.""" + return [reward / count for reward, count in zip(self.rewards, self.counts)] + + def add_new_tools(self, n_new: int) -> None: + """Add new tools to the current policy.""" + self.n_tools += n_new + self.counts.extend([0] * n_new) + self.rewards.extend([0.0] * n_new) + + def remove_tools(self, indexes: List[int]) -> None: + """Remove the knowledge for the tools corresponding to the given indexes.""" + self.n_tools -= len(indexes) + for i in indexes: + try: + del self.counts[i] + del self.rewards[i] + except IndexError as exc: + error = "Attempted to remove tools using incorrect indexes!" + raise ValueError(error) from exc + + def select_tool(self) -> Optional[int]: + """Select a Mech tool and return its index.""" + if self.n_tools == 0: + return None + + if sum(self.counts) == 0 or random.random() < self.eps: + return self.random_tool + + return argmax(self.reward_rates) + + def add_reward(self, index: int, reward: float) -> None: + """Add a reward for the tool corresponding to the given index.""" + self.counts[index] += 1 + self.rewards[index] += reward + + def serialize(self) -> str: + """Return the policy serialized.""" + return json.dumps(self, cls=DataclassEncoder, sort_keys=True) From 1e6037b02bb9886561cd74fa7f8e82a85df6eab4 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:13:41 +0300 Subject: [PATCH 08/57] feat: add properties to the synced data of decision maker --- .../skills/decision_maker_abci/states/base.py | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index bb7d3a87f..c6f884650 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -19,14 +19,16 @@ """This module contains the base functionality for the rounds of the decision-making abci app.""" +import json from enum import Enum -from typing import Optional, Tuple +from typing import Dict, List, Optional, Tuple from packages.valory.skills.abstract_round_abci.base import ( CollectSameUntilThresholdRound, DeserializedCollection, get_name, ) +from packages.valory.skills.decision_maker_abci.models import EGreedyPolicy from packages.valory.skills.decision_maker_abci.payloads import MultisigTxPayload from packages.valory.skills.market_manager_abci.bets import Bet from packages.valory.skills.market_manager_abci.rounds import ( @@ -75,6 +77,38 @@ def mech_price(self) -> int: """Get the mech's request price.""" return int(self.db.get_strict("mech_price")) + @property + def available_mech_tools(self) -> List[str]: + """Get all the available mech tools.""" + tools = self.db.get_strict("available_mech_tools") + return json.loads(tools) + + @property + def policy(self) -> EGreedyPolicy: + """Get the policy.""" + policy = self.db.get_strict("policy") + return EGreedyPolicy.deserialize(policy) + + @property + def mech_tool_idx(self) -> int: + """Get the mech tool's index.""" + return int(self.db.get_strict("mech_tool_idx")) + + @property + def mech_tool(self) -> str: + """Get the selected mech tool.""" + try: + return self.available_mech_tools[self.mech_tool_idx] + except IndexError as exc: + error = f"{self.mech_tool_idx=} is not available in {self.available_mech_tools=}." + raise IndexError(error) from exc + + @property + def utilized_tools(self) -> Dict[str, int]: + """Get a mapping of the utilized tools' indexes for each transaction.""" + tools = str(self.db.get("utilized_tools", "{}")) + return json.loads(tools) + @property def vote(self) -> Optional[int]: """Get the bet's vote index.""" From 54d165b86aad59c1109029f8a72a2aeb71ffbef8 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:16:34 +0300 Subject: [PATCH 09/57] fix: use the synchronized mech tool --- .../skills/decision_maker_abci/behaviours/decision_request.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py index 456702efe..13d006308 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py @@ -120,7 +120,8 @@ def setup(self) -> None: question=sampled_bet.title, yes=sampled_bet.yes, no=sampled_bet.no ) prompt = self.params.prompt_template.substitute(prompt_params) - self._metadata = MechMetadata(prompt=prompt, tool=self.params.mech_tool) + tool = self.synchronized_data.mech_tool + self._metadata = MechMetadata(prompt, tool) msg = f"Prepared metadata {self.metadata!r} for the request." self.context.logger.info(msg) From c787272874b51b77a41c6477437ffc75064cc8f2 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:17:58 +0300 Subject: [PATCH 10/57] feat: add policy attribute and property --- .../skills/decision_maker_abci/behaviours/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index 889a40483..a066e46ba 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -40,6 +40,7 @@ ) from packages.valory.skills.decision_maker_abci.models import ( DecisionMakerParams, + EGreedyPolicy, MultisendBatch, ) from packages.valory.skills.decision_maker_abci.states.base import SynchronizedData @@ -75,6 +76,7 @@ def __init__(self, **kwargs: Any) -> None: self.multisend_batches: List[MultisendBatch] = [] self.multisend_data = b"" self._safe_tx_hash = "" + self._policy: Optional[EGreedyPolicy] = None @property def params(self) -> DecisionMakerParams: @@ -129,6 +131,15 @@ def tx_hex(self) -> Optional[str]: SafeOperation.DELEGATE_CALL.value, ) + @property + def policy(self) -> EGreedyPolicy: + """Get the policy.""" + if self._policy is None: + raise ValueError( + "Attempting to retrieve the policy before it has been established." + ) + return self._policy + @staticmethod def wei_to_native(wei: int) -> float: """Convert WEI to native token.""" From 702bf6d9d81f0bb212db6d2d0a055692506898dd Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:18:37 +0300 Subject: [PATCH 11/57] refactor: move prefix to base --- packages/valory/skills/decision_maker_abci/behaviours/base.py | 1 + .../skills/decision_maker_abci/behaviours/decision_receive.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index a066e46ba..94fba6acf 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -57,6 +57,7 @@ # which is what we want in most cases # more info here: https://safe-docs.dev.gnosisdev.com/safe/docs/contracts_tx_execution/ SAFE_GAS = 0 +CID_PREFIX = "f01701220" def remove_fraction_wei(amount: int, fraction: float) -> int: diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py index 342537407..a889acef4 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -26,6 +26,7 @@ from packages.valory.protocols.contract_api import ContractApiMessage from packages.valory.skills.abstract_round_abci.base import get_name from packages.valory.skills.decision_maker_abci.behaviours.base import ( + CID_PREFIX, DecisionMakerBaseBehaviour, WaitableConditionType, remove_fraction_wei, @@ -41,7 +42,6 @@ from packages.valory.skills.market_manager_abci.bets import BINARY_N_SLOTS -IPFS_HASH_PREFIX = "f01701220" ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" @@ -103,7 +103,7 @@ def mech_response_api(self) -> MechResponseSpecs: def set_mech_response_specs(self) -> None: """Set the mech's response specs.""" - full_ipfs_hash = IPFS_HASH_PREFIX + self.response_hex + full_ipfs_hash = CID_PREFIX + self.response_hex ipfs_link = self.params.ipfs_address + full_ipfs_hash + f"/{self.request_id}" # The url must be dynamically generated as it depends on the ipfs hash self.mech_response_api.__dict__["_frozen"] = False From 22c67e1d24dc0b756e92c17e44ace1af3ecf8c76 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:18:59 +0300 Subject: [PATCH 12/57] docs: correct docstring [no ci] --- .../skills/decision_maker_abci/behaviours/decision_receive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py index a889acef4..fd3506eef 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -112,7 +112,7 @@ def set_mech_response_specs(self) -> None: @property def mech_response(self) -> MechInteractionResponse: - """Get the mech response api specs.""" + """Get the mech's response.""" if self._mech_response is None: error = "The mech's response has not been set!" return MechInteractionResponse(error=error) From edf70a22e61b9c3c1e1e4494546d20f8ce60a9b3 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:21:33 +0300 Subject: [PATCH 13/57] feat: get the transaction hashes of the trades --- packages/valory/skills/decision_maker_abci/redeem_info.py | 1 + .../skills/market_manager_abci/graph_tooling/queries/omen.py | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/redeem_info.py b/packages/valory/skills/decision_maker_abci/redeem_info.py index 6e4a2a940..868cc844b 100644 --- a/packages/valory/skills/decision_maker_abci/redeem_info.py +++ b/packages/valory/skills/decision_maker_abci/redeem_info.py @@ -101,6 +101,7 @@ class Trade: outcomeIndex: int outcomeTokenMarginalPrice: float outcomeTokensTraded: int + transactionHash: str def __post_init__(self) -> None: """Post initialization to adjust the values.""" diff --git a/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py b/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py index 65b9cccb0..974bb5910 100644 --- a/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py +++ b/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py @@ -94,6 +94,7 @@ outcomeIndex outcomeTokenMarginalPrice outcomeTokensTraded + transactionHash } } """ From e7d6373aa8d9627df22164077414257ecce4218d Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:24:58 +0300 Subject: [PATCH 14/57] feat: update the hashes to tool ids mapping --- .../valory/skills/tx_settlement_multiplexer_abci/rounds.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py index ca274730a..637dd3b29 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py @@ -74,6 +74,13 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]: synced_data = SynchronizedData(self.synchronized_data.db) event = submitter_to_event.get(synced_data.tx_submitter, Event.UNRECOGNIZED) + + # if a bet was just placed, edit the utilized tools mapping + if event == Event.BET_PLACEMENT_DONE: + utilized_tools = synced_data.utilized_tools + utilized_tools[synced_data.final_tx_hash] = synced_data.mech_tool_idx + self.synchronized_data.update(utilized_tools=utilized_tools) + return synced_data, event From f8540d2147a549c9c9fab27fe46aebad3ae599fe Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:22:32 +0300 Subject: [PATCH 15/57] fix: return negative amounts for non-winning positions --- .../skills/decision_maker_abci/redeem_info.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/redeem_info.py b/packages/valory/skills/decision_maker_abci/redeem_info.py index 868cc844b..33e4d5e51 100644 --- a/packages/valory/skills/decision_maker_abci/redeem_info.py +++ b/packages/valory/skills/decision_maker_abci/redeem_info.py @@ -125,14 +125,17 @@ def __hash__(self) -> int: """Custom hashing operator.""" return hash(self.fpmm.condition.id) + hash(self.fpmm.question.id) - @property - def claimable_amount(self) -> int: - """Get the claimable amount of the current market.""" - return int(self.outcomeTokenMarginalPrice * self.outcomeTokensTraded) - @property def is_winning(self) -> bool: """Return whether the current position is winning.""" our_answer = self.outcomeIndex correct_answer = self.fpmm.current_answer_index return our_answer == correct_answer + + @property + def claimable_amount(self) -> int: + """Get the claimable amount of the current market.""" + amount = int(self.outcomeTokenMarginalPrice * self.outcomeTokensTraded) + if self.is_winning: + return amount + return -amount From 1132cac39f4006efa09ac16bc8a87a376a9ab9cf Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:26:36 +0300 Subject: [PATCH 16/57] feat: create a payload for redeeming --- packages/valory/skills/decision_maker_abci/payloads.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/payloads.py b/packages/valory/skills/decision_maker_abci/payloads.py index 1aea905b7..d148d77e7 100644 --- a/packages/valory/skills/decision_maker_abci/payloads.py +++ b/packages/valory/skills/decision_maker_abci/payloads.py @@ -50,6 +50,13 @@ class MultisigTxPayload(BaseTxPayload): tx_hash: Optional[str] +@dataclass(frozen=True) +class RedeemPayload(MultisigTxPayload): + """Represents a transaction payload for preparing an on-chain transaction for redeeming.""" + + policy: Optional[str] + + @dataclass(frozen=True) class RequestPayload(MultisigTxPayload): """Represents a transaction payload for preparing an on-chain transaction for a mech request.""" From af5a79453513d2123e5ca89b9687fd75e4abdb95 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:27:09 +0300 Subject: [PATCH 17/57] feat: update the redeeming round to account for the policy --- .../skills/decision_maker_abci/states/redeem.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/states/redeem.py b/packages/valory/skills/decision_maker_abci/states/redeem.py index 3d7e0e651..7c40aeb73 100644 --- a/packages/valory/skills/decision_maker_abci/states/redeem.py +++ b/packages/valory/skills/decision_maker_abci/states/redeem.py @@ -19,8 +19,16 @@ """This module contains the redeem state of the decision-making abci app.""" +from typing import Type + +from packages.valory.skills.abstract_round_abci.base import get_name +from packages.valory.skills.decision_maker_abci.payloads import ( + MultisigTxPayload, + RedeemPayload, +) from packages.valory.skills.decision_maker_abci.states.base import ( Event, + SynchronizedData, TxPreparationRound, ) @@ -28,4 +36,8 @@ class RedeemRound(TxPreparationRound): """A round in which the agents prepare a tx to redeem the winnings.""" + payload_class: Type[MultisigTxPayload] = RedeemPayload + selection_key = TxPreparationRound.selection_key + ( + get_name(SynchronizedData.policy), + ) none_event = Event.NO_REDEEMING From c88ba6d182433ba4bc1c98d0b66c209780fcf5ec Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:28:02 +0300 Subject: [PATCH 18/57] feat: initialize the policy using the synced data on setup --- .../valory/skills/decision_maker_abci/behaviours/reedem.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index 595083910..2342d3431 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -86,6 +86,10 @@ def synced_timestamp(self) -> int: """Return the synchronized timestamp across the agents.""" return int(self.round_sequence.last_round_transition_timestamp.timestamp()) + def setup(self) -> None: + """Setup the behaviour""" + self._policy = self.synchronized_data.policy + def _set_block_number(self, trade: Trade) -> Generator: """Set the block number of the given trade's market.""" timestamp = trade.fpmm.creationTimestamp From b7168e12871c3e4802f9c0d98a206e99f6bf7c09 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:29:02 +0300 Subject: [PATCH 19/57] feat: update the policy and report statistics --- .../decision_maker_abci/behaviours/reedem.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index 2342d3431..9ddaef8f1 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -109,6 +109,24 @@ def _set_block_number(self, trade: Trade) -> Generator: f"Chose block number {self.from_block_mapping[condition_id]!r} as closest to timestamp {timestamp!r}" ) + def _update_policy(self, update: Trade) -> None: + """Update the policy.""" + claimable_xdai = self.wei_to_native(update.claimable_amount) + tool_index = self.synchronized_data.utilized_tools[update.transactionHash] + self.policy.add_reward(tool_index, claimable_xdai) + + def _stats_report(self) -> None: + """Report policy statistics.""" + stats_report = "Policy statistics so far:\n" + for i, tool in enumerate(self.synchronized_data.available_mech_tools): + stats_report += ( + f"{tool} tool:\n" + f"\tTimes used: {self.policy.counts[i]}\n" + f"\tReward rate: {self.policy.reward_rates[i]}\n" + ) + stats_report += f"Best tool so far is {self.policy.select_tool()}." + self.context.logger.info(stats_report) + def update_redeem_info(self, chunk: list) -> Generator: """Update the redeeming information using the given chunk.""" trades_updates: Iterator[Trade] = ( @@ -119,6 +137,8 @@ def update_redeem_info(self, chunk: list) -> Generator: ) for update in trades_updates: + self._update_policy(update) + # do not use the information if position is not winning if not update.is_winning: continue @@ -136,6 +156,8 @@ def update_redeem_info(self, chunk: list) -> Generator: if update == unique_obj: self.claimable_amounts[condition_id] += update.claimable_amount + self._stats_report() + class RedeemBehaviour(RedeemInfoBehaviour): """Redeem the winnings.""" From c50326b4aba7549dc292e4da4330bea811f0e299 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:30:17 +0300 Subject: [PATCH 20/57] feat: use the new redeem payload and include updated policy [no ci] --- .../decision_maker_abci/behaviours/reedem.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index 9ddaef8f1..9df1e737c 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -39,7 +39,7 @@ WaitableConditionType, ) from packages.valory.skills.decision_maker_abci.models import MultisendBatch -from packages.valory.skills.decision_maker_abci.payloads import MultisigTxPayload +from packages.valory.skills.decision_maker_abci.payloads import RedeemPayload from packages.valory.skills.decision_maker_abci.redeem_info import ( Condition, FPMM, @@ -549,11 +549,11 @@ def async_act(self) -> Generator: yield from self._clean_redeem_info() agent = self.context.agent_address redeem_tx_hex = yield from self._prepare_safe_tx() - tx_submitter = ( - self.matching_round.auto_round_id() - if redeem_tx_hex is not None - else None - ) - payload = MultisigTxPayload(agent, tx_submitter, redeem_tx_hex) + tx_submitter = policy = None + if redeem_tx_hex is not None: + tx_submitter = self.matching_round.auto_round_id() + policy = self.policy.serialize() + + payload = RedeemPayload(agent, tx_submitter, redeem_tx_hex, policy) yield from self.finish_behaviour(payload) From 95f39a696fcfd380c166276e0c8d20c79a69a9c0 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:32:56 +0300 Subject: [PATCH 21/57] feat: implement a behaviour for tool selection --- .../behaviours/tool_selection.py | 200 ++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py new file mode 100644 index 000000000..61613f90f --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -0,0 +1,200 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 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 behaviour of the skill which is responsible for selecting a mech tool.""" + +import json +from typing import Any, Generator, List, Optional + +from packages.valory.contracts.agent_registry.contract import AgentRegistryContract +from packages.valory.protocols.contract_api import ContractApiMessage +from packages.valory.skills.abstract_round_abci.base import get_name +from packages.valory.skills.decision_maker_abci.behaviours.base import ( + CID_PREFIX, + DecisionMakerBaseBehaviour, + WaitableConditionType, +) +from packages.valory.skills.decision_maker_abci.models import ( + AgentToolsSpecs, + EGreedyPolicy, +) +from packages.valory.skills.decision_maker_abci.payloads import ToolSelectionPayload +from packages.valory.skills.decision_maker_abci.states.tool_selection import ( + ToolSelectionRound, +) + + +class ToolSelectionBehaviour(DecisionMakerBaseBehaviour): + """A behaviour in which the agents select a mech tool.""" + + matching_round = ToolSelectionRound + + def __init__(self, **kwargs: Any) -> None: + """Initialize Behaviour.""" + super().__init__(**kwargs) + self._mech_id: int = 0 + self._mech_hash: str = "" + self.mech_tools: Optional[List[str]] = None + + @property + def mech_id(self) -> int: + """Get the mech's id.""" + return self._mech_id + + @mech_id.setter + def mech_id(self, mech_id: int) -> None: + """Set the mech's id.""" + self._mech_id = mech_id + + @property + def mech_hash(self) -> str: + """Get the hash of the mech agent.""" + return self._mech_hash + + @mech_hash.setter + def mech_hash(self, mech_hash: str) -> None: + """Set the hash of the mech agent.""" + self._mech_hash = mech_hash + + @property + def mech_tools_api(self) -> AgentToolsSpecs: + """Get the mech agent api specs.""" + return self.context.agent_tools + + def set_mech_agent_specs(self) -> None: + """Set the mech's agent specs.""" + full_ipfs_hash = CID_PREFIX + self.mech_hash + ipfs_link = self.params.ipfs_address + full_ipfs_hash + # The url needs to be dynamically generated as it depends on the ipfs hash + self.mech_tools_api.__dict__["_frozen"] = False + self.mech_tools_api.url = ipfs_link + self.mech_tools_api.__dict__["_frozen"] = True + + def _get_mech_id(self) -> WaitableConditionType: + """Get the mech's id.""" + result = yield from self._mech_contract_interact( + contract_callable="get_mech_id", + data_key="id", + placeholder=get_name(ToolSelectionBehaviour.mech_id), + ) + + return result + + def _get_mech_hash(self) -> WaitableConditionType: + """Get the mech's hash.""" + result = yield from self.contract_interact( + performative=ContractApiMessage.Performative.GET_RAW_TRANSACTION, # type: ignore + contract_address=self.params.agent_registry_address, + contract_public_id=AgentRegistryContract.contract_id, + contract_callable="get_hash", + data_key="hash", + placeholder=get_name(ToolSelectionBehaviour.mech_hash), + agent_id=self.mech_id, + ) + return result + + def _get_mech_tools(self) -> WaitableConditionType: + """Get the mech agent's tools from IPFS.""" + specs = self.mech_tools_api.get_spec() + res_raw = yield from self.get_http_response(**specs) + res = self.mech_tools_api.process_response(res_raw) + + if self.mech_tools_api.is_retries_exceeded(): + error = "Retries were exceeded while trying to get the mech agent's data." + self.context.logger.error(error) + return True + + if res is None: + msg = f"Could not get the mech agent's tools from {self.mech_tools_api.api_id}" + self.context.logger.error(msg) + self.mech_tools_api.increment_retries() + return False + + self.context.logger.info(f"Retrieved the mech agent's tools: {res}.") + if len(res) == 0: + res = None + self.context.logger.error("The mech agent's tools are empty!") + self.mech_tools = res + self.mech_tools_api.reset_retries() + return True + + def _get_tools( + self, + ) -> Generator[None, None, None]: + """Get the Mech's tools.""" + for step in ( + self._get_mech_id, + self._get_mech_hash, + self._get_mech_tools, + ): + yield from self.wait_for_condition_with_sleep(step) + + def _adjust_policy_tools(self, tools: List[str]) -> None: + """Add or remove tools from the policy to match the remote tools.""" + # remove tools if they are not available anymore + local = set(self.synchronized_data.available_mech_tools) + remote = set(tools) + relevant_remote = remote - self.params.irrelevant_tools + removed_tools_idx = [ + idx for idx, tool in enumerate(local) if tool not in relevant_remote + ] + if len(removed_tools_idx) > 0: + self.policy.remove_tools(removed_tools_idx) + + # add tools if there are new ones available + new_tools = remote - local + n_new_tools = len(new_tools) + if n_new_tools > 0: + self.policy.add_new_tools(n_new_tools) + + def _set_policy(self, tools: List[str]) -> None: + """Set the E Greedy Policy.""" + if self.synchronized_data.period_count == 0: + self._policy = EGreedyPolicy.initial_state(self.params.epsilon, len(tools)) + else: + self._policy = self.synchronized_data.policy + self._adjust_policy_tools(tools) + + def _select_tool(self) -> Generator[None, None, Optional[int]]: + """Select a Mech tool based on an e-greedy policy and return its index.""" + yield from self._get_tools() + if self.mech_tools is None: + return None + + self._set_policy(self.mech_tools) + return self.policy.select_tool() + + def async_act(self) -> Generator: + """Do the action.""" + + with self.context.benchmark_tool.measure(self.behaviour_id).local(): + mech_tools = policy = None + selected_tool = yield from self._select_tool() + if selected_tool is not None: + mech_tools = json.dumps(self.mech_tools) + policy = self.policy.serialize() + + payload = ToolSelectionPayload( + self.context.agent_address, + mech_tools, + policy, + selected_tool, + ) + + yield from self.finish_behaviour(payload) From 9908d03ed667cd79a7c3d9d6bdcad49927290e05 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:33:22 +0300 Subject: [PATCH 22/57] feat: implement payload for tool selection --- packages/valory/skills/decision_maker_abci/payloads.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/payloads.py b/packages/valory/skills/decision_maker_abci/payloads.py index d148d77e7..b393544d1 100644 --- a/packages/valory/skills/decision_maker_abci/payloads.py +++ b/packages/valory/skills/decision_maker_abci/payloads.py @@ -69,3 +69,12 @@ class VotingPayload(BaseTxPayload): """Represents a transaction payload for voting.""" vote: bool + + +@dataclass(frozen=True) +class ToolSelectionPayload(BaseTxPayload): + """Represents a transaction payload for selecting a mech tool.""" + + mech_tools: Optional[str] + policy: Optional[str] + index: Optional[int] From 4fda0e2fd3d7d3c81ecff035c787610e53522825 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:33:31 +0300 Subject: [PATCH 23/57] feat: implement round for tool selection --- .../states/tool_selection.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 packages/valory/skills/decision_maker_abci/states/tool_selection.py diff --git a/packages/valory/skills/decision_maker_abci/states/tool_selection.py b/packages/valory/skills/decision_maker_abci/states/tool_selection.py new file mode 100644 index 000000000..982d281de --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/states/tool_selection.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 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 tool selection state of the decision-making abci app.""" + +from packages.valory.skills.abstract_round_abci.base import ( + CollectSameUntilThresholdRound, + get_name, +) +from packages.valory.skills.decision_maker_abci.payloads import ToolSelectionPayload +from packages.valory.skills.decision_maker_abci.states.base import ( + Event, + SynchronizedData, +) + + +class ToolSelectionRound(CollectSameUntilThresholdRound): + """A round for selecting a Mech tool.""" + + payload_class = ToolSelectionPayload + synchronized_data_class = SynchronizedData + done_event = Event.DONE + none_event = Event.NONE + no_majority_event = Event.NO_MAJORITY + selection_key = ( + get_name(SynchronizedData.available_mech_tools), + get_name(SynchronizedData.policy), + get_name(SynchronizedData.mech_tool_idx), + ) + collection_key = get_name(SynchronizedData.participant_to_selection) From dcb3c0d3507b9e3ef91b39c1682866098ca413ad Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:34:24 +0300 Subject: [PATCH 24/57] feat: add tool selection behaviour to the set of behaviours --- .../skills/decision_maker_abci/behaviours/round_behaviour.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/round_behaviour.py b/packages/valory/skills/decision_maker_abci/behaviours/round_behaviour.py index 49be37e88..af7643e54 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/round_behaviour.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/round_behaviour.py @@ -44,6 +44,9 @@ from packages.valory.skills.decision_maker_abci.behaviours.sampling import ( SamplingBehaviour, ) +from packages.valory.skills.decision_maker_abci.behaviours.tool_selection import ( + ToolSelectionBehaviour, +) from packages.valory.skills.decision_maker_abci.rounds import DecisionMakerAbciApp @@ -60,4 +63,5 @@ class AgentDecisionMakerRoundBehaviour(AbstractRoundBehaviour): BetPlacementBehaviour, # type: ignore RedeemBehaviour, # type: ignore HandleFailedTxBehaviour, # type: ignore + ToolSelectionBehaviour, # type: ignore } From 3eac849f00155af1f5947b217b4b3458acd3bfa8 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:34:49 +0300 Subject: [PATCH 25/57] feat: wire the tool selection round to the FSM [no ci] --- packages/valory/skills/decision_maker_abci/rounds.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/rounds.py b/packages/valory/skills/decision_maker_abci/rounds.py index ba22eace7..996634d0f 100644 --- a/packages/valory/skills/decision_maker_abci/rounds.py +++ b/packages/valory/skills/decision_maker_abci/rounds.py @@ -55,6 +55,9 @@ ) from packages.valory.skills.decision_maker_abci.states.redeem import RedeemRound from packages.valory.skills.decision_maker_abci.states.sampling import SamplingRound +from packages.valory.skills.decision_maker_abci.states.tool_selection import ( + ToolSelectionRound, +) from packages.valory.skills.market_manager_abci.rounds import ( Event as MarketManagerEvent, ) @@ -129,11 +132,17 @@ class DecisionMakerAbciApp(AbciApp[Event]): } transition_function: AbciAppTransitionFunction = { SamplingRound: { - Event.DONE: DecisionRequestRound, + Event.DONE: ToolSelectionRound, Event.NONE: FinishedWithoutDecisionRound, Event.NO_MAJORITY: SamplingRound, Event.ROUND_TIMEOUT: SamplingRound, }, + ToolSelectionRound: { + Event.DONE: DecisionRequestRound, + Event.NONE: ToolSelectionRound, + Event.NO_MAJORITY: ToolSelectionRound, + Event.ROUND_TIMEOUT: ToolSelectionRound, + }, DecisionRequestRound: { Event.DONE: FinishedDecisionMakerRound, Event.SLOTS_UNSUPPORTED_ERROR: BlacklistingRound, From 9bd8226169eb8aa1d128943a8fce8800a0498ca5 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:39:15 +0300 Subject: [PATCH 26/57] chore: we do not care about the safety of randomness here --- packages/valory/skills/decision_maker_abci/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 55513aeef..6a8b1e7cc 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -269,7 +269,7 @@ def deserialize(cls, policy: str) -> "EGreedyPolicy": @property def random_tool(self) -> int: """Get the index of a tool randomly.""" - return random.randrange(self.n_tools) + return random.randrange(self.n_tools) # nosec @property def reward_rates(self) -> List[float]: @@ -298,7 +298,7 @@ def select_tool(self) -> Optional[int]: if self.n_tools == 0: return None - if sum(self.counts) == 0 or random.random() < self.eps: + if sum(self.counts) == 0 or random.random() < self.eps: # nosec return self.random_tool return argmax(self.reward_rates) From 127eab8b35af27b562c407f3b4f82aea128de2df Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 17:57:11 +0300 Subject: [PATCH 27/57] fix: circular import [no ci] --- .../decision_maker_abci/behaviours/base.py | 2 +- .../behaviours/tool_selection.py | 2 +- .../skills/decision_maker_abci/models.py | 90 +------------- .../skills/decision_maker_abci/policy.py | 110 ++++++++++++++++++ .../skills/decision_maker_abci/states/base.py | 2 +- 5 files changed, 115 insertions(+), 91 deletions(-) create mode 100644 packages/valory/skills/decision_maker_abci/policy.py diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index 94fba6acf..9ba4cf446 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -40,9 +40,9 @@ ) from packages.valory.skills.decision_maker_abci.models import ( DecisionMakerParams, - EGreedyPolicy, MultisendBatch, ) +from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy from packages.valory.skills.decision_maker_abci.states.base import SynchronizedData from packages.valory.skills.transaction_settlement_abci.payload_tools import ( hash_payload_to_hex, diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index 61613f90f..f7ea16b3c 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -32,8 +32,8 @@ ) from packages.valory.skills.decision_maker_abci.models import ( AgentToolsSpecs, - EGreedyPolicy, ) +from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy from packages.valory.skills.decision_maker_abci.payloads import ToolSelectionPayload from packages.valory.skills.decision_maker_abci.states.tool_selection import ( ToolSelectionRound, diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 6a8b1e7cc..28f948b32 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -20,11 +20,10 @@ """This module contains the models for the skill.""" import json -import random import re -from dataclasses import asdict, dataclass, is_dataclass +from dataclasses import dataclass from string import Template -from typing import Any, Dict, List, Optional, Set +from typing import Any, Dict, Optional, Set from aea.exceptions import enforce from hexbytes import HexBytes @@ -226,88 +225,3 @@ def incorrect_format(cls, res: Any) -> "MechInteractionResponse": response = cls() response.error = f"The response's format was unexpected: {res}" return response - - -class DataclassEncoder(json.JSONEncoder): - """A custom JSON encoder for dataclasses.""" - - def default(self, o: Any) -> Any: - """The default JSON encoder.""" - if is_dataclass(o): - return asdict(o) - return super().default(o) - - -def argmax(li: List) -> int: - """Get the index of the max value within the provided list.""" - return li.index((max(li))) - - -@dataclass -class EGreedyPolicy: - """An e-Greedy policy for the tool selection.""" - - eps: float - n_tools: int - counts: List[int] - rewards: List[float] - - @classmethod - def initial_state(cls, eps: float, n_tools: int) -> "EGreedyPolicy": - """Return an instance on its initial state.""" - if n_tools == 0: - error = f"Cannot initialize an e Greedy Policy with {n_tools=}" - raise ValueError(error) - - return EGreedyPolicy(eps, n_tools, [0] * n_tools, [0.0] * n_tools) - - @classmethod - def deserialize(cls, policy: str) -> "EGreedyPolicy": - """Deserialize a string to an `EGreedyPolicy` object.""" - return EGreedyPolicy(**json.loads(policy)) - - @property - def random_tool(self) -> int: - """Get the index of a tool randomly.""" - return random.randrange(self.n_tools) # nosec - - @property - def reward_rates(self) -> List[float]: - """Get the reward rates.""" - return [reward / count for reward, count in zip(self.rewards, self.counts)] - - def add_new_tools(self, n_new: int) -> None: - """Add new tools to the current policy.""" - self.n_tools += n_new - self.counts.extend([0] * n_new) - self.rewards.extend([0.0] * n_new) - - def remove_tools(self, indexes: List[int]) -> None: - """Remove the knowledge for the tools corresponding to the given indexes.""" - self.n_tools -= len(indexes) - for i in indexes: - try: - del self.counts[i] - del self.rewards[i] - except IndexError as exc: - error = "Attempted to remove tools using incorrect indexes!" - raise ValueError(error) from exc - - def select_tool(self) -> Optional[int]: - """Select a Mech tool and return its index.""" - if self.n_tools == 0: - return None - - if sum(self.counts) == 0 or random.random() < self.eps: # nosec - return self.random_tool - - return argmax(self.reward_rates) - - def add_reward(self, index: int, reward: float) -> None: - """Add a reward for the tool corresponding to the given index.""" - self.counts[index] += 1 - self.rewards[index] += reward - - def serialize(self) -> str: - """Return the policy serialized.""" - return json.dumps(self, cls=DataclassEncoder, sort_keys=True) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py new file mode 100644 index 000000000..a3d082e2d --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 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 an Epsilon Greedy Policy implementation.""" + +import json +import random +from dataclasses import is_dataclass, asdict, dataclass +from typing import Any, List, Optional + + +class DataclassEncoder(json.JSONEncoder): + """A custom JSON encoder for dataclasses.""" + + def default(self, o: Any) -> Any: + """The default JSON encoder.""" + if is_dataclass(o): + return asdict(o) + return super().default(o) + + +def argmax(li: List) -> int: + """Get the index of the max value within the provided list.""" + return li.index((max(li))) + + +@dataclass +class EGreedyPolicy: + """An e-Greedy policy for the tool selection.""" + + eps: float + n_tools: int + counts: List[int] + rewards: List[float] + + @classmethod + def initial_state(cls, eps: float, n_tools: int) -> "EGreedyPolicy": + """Return an instance on its initial state.""" + if n_tools == 0: + error = f"Cannot initialize an e Greedy Policy with {n_tools=}" + raise ValueError(error) + + return EGreedyPolicy(eps, n_tools, [0] * n_tools, [0.0] * n_tools) + + @classmethod + def deserialize(cls, policy: str) -> "EGreedyPolicy": + """Deserialize a string to an `EGreedyPolicy` object.""" + return EGreedyPolicy(**json.loads(policy)) + + @property + def random_tool(self) -> int: + """Get the index of a tool randomly.""" + return random.randrange(self.n_tools) # nosec + + @property + def reward_rates(self) -> List[float]: + """Get the reward rates.""" + return [reward / count for reward, count in zip(self.rewards, self.counts)] + + def add_new_tools(self, n_new: int) -> None: + """Add new tools to the current policy.""" + self.n_tools += n_new + self.counts.extend([0] * n_new) + self.rewards.extend([0.0] * n_new) + + def remove_tools(self, indexes: List[int]) -> None: + """Remove the knowledge for the tools corresponding to the given indexes.""" + self.n_tools -= len(indexes) + for i in indexes: + try: + del self.counts[i] + del self.rewards[i] + except IndexError as exc: + error = "Attempted to remove tools using incorrect indexes!" + raise ValueError(error) from exc + + def select_tool(self) -> Optional[int]: + """Select a Mech tool and return its index.""" + if self.n_tools == 0: + return None + + if sum(self.counts) == 0 or random.random() < self.eps: # nosec + return self.random_tool + + return argmax(self.reward_rates) + + def add_reward(self, index: int, reward: float) -> None: + """Add a reward for the tool corresponding to the given index.""" + self.counts[index] += 1 + self.rewards[index] += reward + + def serialize(self) -> str: + """Return the policy serialized.""" + return json.dumps(self, cls=DataclassEncoder, sort_keys=True) diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index c6f884650..c37034f19 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -28,7 +28,7 @@ DeserializedCollection, get_name, ) -from packages.valory.skills.decision_maker_abci.models import EGreedyPolicy +from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy from packages.valory.skills.decision_maker_abci.payloads import MultisigTxPayload from packages.valory.skills.market_manager_abci.bets import Bet from packages.valory.skills.market_manager_abci.rounds import ( From f9907a23ff189e7e93fb883e1886bda5da10e6e7 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 18:11:40 +0300 Subject: [PATCH 28/57] fix: add missing contract dependency --- packages/valory/skills/decision_maker_abci/skill.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index b3f99c667..57c88ddf5 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -49,6 +49,7 @@ contracts: - valory/conditional_tokens:0.1.0:bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa - valory/realitio:0.1.0:bafybeigb722aznqhc5lsbt3dn4bpyaqe5hnl5onmnestqmzliwtvl3eaom - valory/realitio_proxy:0.1.0:bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy +- valory/agent_registry:0.1.0:bafybeiunknownnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn protocols: - valory/contract_api:1.0.0:bafybeiasywsvax45qmugus5kxogejj66c5taen27h4voriodz7rgushtqa skills: From d9535dfbc0efc1429a297428e71060452bfeee6f Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 18:15:47 +0300 Subject: [PATCH 29/57] fix: add missing `set` tag --- packages/valory/skills/decision_maker_abci/skill.yaml | 2 +- packages/valory/skills/trader_abci/skill.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 57c88ddf5..bd6dc5c9c 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -183,7 +183,7 @@ models: redeeming_batch_size: 5 slippage: 0.01 epsilon: 0.1 - irrelevant_tools: + irrelevant_tools: !!set ? openai-text-davinci-002 ? openai-text-davinci-003 ? openai-gpt-3.5-turbo diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 5aa766e5f..ec50ccb21 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -170,7 +170,7 @@ models: slippage: 0.01 redeem_margin_days: 15 epsilon: 0.1 - irrelevant_tools: + irrelevant_tools: !!set ? openai-text-davinci-002 ? openai-text-davinci-003 ? openai-gpt-3.5-turbo From 86879d1ec2ab18929ee7e3c2c3d6cba73afcc8da Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 18:28:24 +0300 Subject: [PATCH 30/57] fix: use lists as sets are not supported by the framework --- packages/valory/agents/trader/aea-config.yaml | 4 ++-- packages/valory/services/trader/service.yaml | 16 ++++++++-------- .../skills/decision_maker_abci/models.py | 2 +- .../skills/decision_maker_abci/skill.yaml | 18 +++++++++--------- packages/valory/skills/trader_abci/skill.yaml | 18 +++++++++--------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 2e771fc1d..9fa8f9e32 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -188,9 +188,9 @@ models: slippage: ${float:0.01} redeem_margin_days: ${int:15} epsilon: ${float:0.1} - irrelevant_tools: ${set:{"openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", + irrelevant_tools: ${list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", - "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"}} + "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"]} --- public_id: valory/p2p_libp2p_client:0.1.0 type: connection diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 4081035b4..90de19f58 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -105,10 +105,10 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", - "stabilityai-stable-diffusion-768-v2-1"}} + "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: &id005 args: log_dir: ${LOG_DIR:str:/benchmarks} @@ -174,10 +174,10 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", - "stabilityai-stable-diffusion-768-v2-1"}} + "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: *id005 2: models: @@ -241,10 +241,10 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", - "stabilityai-stable-diffusion-768-v2-1"}} + "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: *id005 3: models: @@ -308,10 +308,10 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:set:{"openai-text-davinci-002", "openai-text-davinci-003", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", - "stabilityai-stable-diffusion-768-v2-1"}} + "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: *id005 --- public_id: valory/ledger:0.19.0 diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 28f948b32..145b82cca 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -126,7 +126,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.agent_registry_address: str = self._ensure( "agent_registry_address", kwargs, str ) - self.irrelevant_tools: set = self._ensure("irrelevant_tools", kwargs, set) + self.irrelevant_tools: set = set(self._ensure("irrelevant_tools", kwargs, list)) super().__init__(*args, **kwargs) @property diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index bd6dc5c9c..06f50f1c2 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -183,15 +183,15 @@ models: redeeming_batch_size: 5 slippage: 0.01 epsilon: 0.1 - irrelevant_tools: !!set - ? openai-text-davinci-002 - ? openai-text-davinci-003 - ? openai-gpt-3.5-turbo - ? openai-gpt-4 - ? stabilityai-stable-diffusion-v1-5 - ? stabilityai-stable-diffusion-xl-beta-v2-2-2 - ? stabilityai-stable-diffusion-512-v2-1 - ? stabilityai-stable-diffusion-768-v2-1 + irrelevant_tools: + - openai-text-davinci-002 + - openai-text-davinci-003 + - openai-gpt-3.5-turbo + - openai-gpt-4 + - stabilityai-stable-diffusion-v1-5 + - stabilityai-stable-diffusion-xl-beta-v2-2-2 + - stabilityai-stable-diffusion-512-v2-1 + - stabilityai-stable-diffusion-768-v2-1 class_name: DecisionMakerParams mech_response: args: diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index ec50ccb21..eab5ea890 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -170,15 +170,15 @@ models: slippage: 0.01 redeem_margin_days: 15 epsilon: 0.1 - irrelevant_tools: !!set - ? openai-text-davinci-002 - ? openai-text-davinci-003 - ? openai-gpt-3.5-turbo - ? openai-gpt-4 - ? stabilityai-stable-diffusion-v1-5 - ? stabilityai-stable-diffusion-xl-beta-v2-2-2 - ? stabilityai-stable-diffusion-512-v2-1 - ? stabilityai-stable-diffusion-768-v2-1 + irrelevant_tools: + - openai-text-davinci-002 + - openai-text-davinci-003 + - openai-gpt-3.5-turbo + - openai-gpt-4 + - stabilityai-stable-diffusion-v1-5 + - stabilityai-stable-diffusion-xl-beta-v2-2-2 + - stabilityai-stable-diffusion-512-v2-1 + - stabilityai-stable-diffusion-768-v2-1 class_name: TraderParams network_subgraph: args: From 381b8dcb1e5dd5b27a38eb48f72826a04d7b303b Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 20 Sep 2023 18:39:14 +0300 Subject: [PATCH 31/57] chore: run generators [no ci] --- packages/packages.json | 17 ++--- packages/valory/agents/trader/aea-config.yaml | 17 ++--- .../contracts/agent_registry/contract.yaml | 9 +-- packages/valory/contracts/mech/contract.yaml | 2 +- packages/valory/services/trader/service.yaml | 26 ++++---- .../behaviours/tool_selection.py | 6 +- .../fsm_specification.yaml | 7 +- .../skills/decision_maker_abci/policy.py | 2 +- .../skills/decision_maker_abci/rounds.py | 65 +++++++++--------- .../skills/decision_maker_abci/skill.yaml | 35 +++++----- .../skills/decision_maker_abci/states/base.py | 2 +- .../skills/market_manager_abci/skill.yaml | 2 +- .../skills/trader_abci/fsm_specification.yaml | 7 +- packages/valory/skills/trader_abci/models.py | 6 +- packages/valory/skills/trader_abci/skill.yaml | 12 ++-- .../tx_settlement_multiplexer_abci/skill.yaml | 4 +- poetry.lock | 66 +++++++++---------- 17 files changed, 150 insertions(+), 135 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index e17d14a30..c5a6e8f13 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,17 +1,18 @@ { "dev": { - "skill/valory/market_manager_abci/0.1.0": "bafybeicjqkzen2gvpnc3syojcf6ibr4kjaorcwktikqp2zzxec6vs64oky", - "skill/valory/decision_maker_abci/0.1.0": "bafybeic77zhxf5a53ngfzacklmm3nag4t4jeufdhoeg3ykrmvknojtwipi", - "skill/valory/trader_abci/0.1.0": "bafybeibi3rt3rdk4bvng3tlmwdxal3mk3bflq4cgq3fxyjwzpmhj3y6pmy", + "skill/valory/market_manager_abci/0.1.0": "bafybeigvw5tqei5xb272jb7retxiryhuhxxzupddmbdixgsmxzco3n2dde", + "skill/valory/decision_maker_abci/0.1.0": "bafybeihm77vt53vu3xt6x7istsvaw75juptlynpriebgeltbil5evvhtue", + "skill/valory/trader_abci/0.1.0": "bafybeiea2r67bzi5gkymu2pu2m3sg3lflke5m2finonak4uprqpbdcp2ru", "contract/valory/market_maker/0.1.0": "bafybeif6hivvhxqv4a3uqo2v3yszluzrmngsp624utdi466xwo5qbz5bsi", - "agent/valory/trader/0.1.0": "bafybeigoojaxpc7sz7vuswkxvpa5lp37lipuwc4qycztqk4hxdesmxqcda", - "service/valory/trader/0.1.0": "bafybeidyuzdmwrt66w32oppopviesvhinmwd76q73zv3dex2th7nldpbyi", + "agent/valory/trader/0.1.0": "bafybeiba5eqawktwkpziiazxm5u6ftm7o3zytcbafqsjwt7zrr63o2yis4", + "service/valory/trader/0.1.0": "bafybeifqi4yprf6ajureyqn45aa3mo7vezwsx63skc4n56grlormdzoz5i", "contract/valory/erc20/0.1.0": "bafybeiggo4u56drxusvcdruqrr7mlfzqbieg4hajalh4tkctxhh3c5lpdi", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeidtrigrfjikl7tkbtowbp6mrdzxulayxnxcmviwy3gag557vnymlq", - "contract/valory/mech/0.1.0": "bafybeibfikekaruskx6ui7u4qnls57i2namfxi45zhqslziqyxg4npjzxu", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiey57caacd6d3ow25i6a2zuiinkx6kjtckdktannk7kijpd3p2zb4", + "contract/valory/mech/0.1.0": "bafybeidtezc4ubsyqdltiojvqe5eeh77ejte7vqbojspiej5quivgap3ae", "contract/valory/realitio/0.1.0": "bafybeigb722aznqhc5lsbt3dn4bpyaqe5hnl5onmnestqmzliwtvl3eaom", "contract/valory/realitio_proxy/0.1.0": "bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy", - "contract/valory/conditional_tokens/0.1.0": "bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa" + "contract/valory/conditional_tokens/0.1.0": "bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa", + "contract/valory/agent_registry/0.1.0": "bafybeib6odummk6qqietjekpljkmhqfxk7kv56kv6pyfsnnanews625ncy" }, "third_party": { "protocol/open_aea/signing/1.0.0": "bafybeifuxs7gdg2okbn7uofymenjlmnih2wxwkym44lsgwmklgwuckxm2m", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 9fa8f9e32..fe3922d6c 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -21,7 +21,7 @@ contracts: - valory/market_maker:0.1.0:bafybeif6hivvhxqv4a3uqo2v3yszluzrmngsp624utdi466xwo5qbz5bsi - valory/erc20:0.1.0:bafybeiggo4u56drxusvcdruqrr7mlfzqbieg4hajalh4tkctxhh3c5lpdi - valory/multisend:0.1.0:bafybeidfktuprydtmi4umolfles5qaf7s3t26puvvs44hvkq6uwwr3ia3a -- valory/mech:0.1.0:bafybeibfikekaruskx6ui7u4qnls57i2namfxi45zhqslziqyxg4npjzxu +- valory/mech:0.1.0:bafybeidtezc4ubsyqdltiojvqe5eeh77ejte7vqbojspiej5quivgap3ae - valory/conditional_tokens:0.1.0:bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa - valory/realitio:0.1.0:bafybeigb722aznqhc5lsbt3dn4bpyaqe5hnl5onmnestqmzliwtvl3eaom - valory/realitio_proxy:0.1.0:bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy @@ -41,10 +41,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeiblayblhp5wuirfomwcpgydg35ve5tfq3xxetlosjn47wva5ucmzy - valory/termination_abci:0.1.0:bafybeieqfhvk6klnvxak3vo2ibslkrnnk2bfsn5l3gbaelcprd6cjngxki - valory/transaction_settlement_abci:0.1.0:bafybeicisazpyvnnzlqso3txiucxr5qhsa4ac7ius6b4mhouxr2wkadwfy -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidtrigrfjikl7tkbtowbp6mrdzxulayxnxcmviwy3gag557vnymlq -- valory/market_manager_abci:0.1.0:bafybeicjqkzen2gvpnc3syojcf6ibr4kjaorcwktikqp2zzxec6vs64oky -- valory/decision_maker_abci:0.1.0:bafybeic77zhxf5a53ngfzacklmm3nag4t4jeufdhoeg3ykrmvknojtwipi -- valory/trader_abci:0.1.0:bafybeibi3rt3rdk4bvng3tlmwdxal3mk3bflq4cgq3fxyjwzpmhj3y6pmy +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiey57caacd6d3ow25i6a2zuiinkx6kjtckdktannk7kijpd3p2zb4 +- valory/market_manager_abci:0.1.0:bafybeigvw5tqei5xb272jb7retxiryhuhxxzupddmbdixgsmxzco3n2dde +- valory/decision_maker_abci:0.1.0:bafybeihm77vt53vu3xt6x7istsvaw75juptlynpriebgeltbil5evvhtue +- valory/trader_abci:0.1.0:bafybeiea2r67bzi5gkymu2pu2m3sg3lflke5m2finonak4uprqpbdcp2ru default_ledger: ethereum required_ledgers: - ethereum @@ -188,9 +188,10 @@ models: slippage: ${float:0.01} redeem_margin_days: ${int:15} epsilon: ${float:0.1} - irrelevant_tools: ${list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", - "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", - "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"]} + irrelevant_tools: ${list:["openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + "stabilityai-stable-diffusion-768-v2-1"]} --- public_id: valory/p2p_libp2p_client:0.1.0 type: connection diff --git a/packages/valory/contracts/agent_registry/contract.yaml b/packages/valory/contracts/agent_registry/contract.yaml index dc9566f46..c9713347c 100644 --- a/packages/valory/contracts/agent_registry/contract.yaml +++ b/packages/valory/contracts/agent_registry/contract.yaml @@ -6,12 +6,9 @@ description: Agent Registry contract license: Apache-2.0 aea_version: '>=1.0.0, <2.0.0' fingerprint: - __init__.py: bafybeidey4syohls5hxmso6qsp5p4uhtzle5txv2mlbym6ktjzknich6oa - build/AgentRegistry.json: bafybeia4qi2vstrutejzrxfpbb6eift7va5cjs7bparaal2fafiiczuiyy - build/AgentRegistryL2.json: bafybeic2jylwfod4nmdtbs4izyxyi246pd3f35aoqyahnmyrvzn7j3sv4e - contract.py: bafybeibqwl52cnz64cysjd2jnjijuakdvyrffapxq65cdzx6g65gu42deq - tests/__init__.py: bafybeicl2oklx774jomlt6wwwegfdzrxh6iazjxwcyc7h4gepjljkpl4ji - tests/test_contract.py: bafybeicj535veqf35zb3ycu5iqjvqgj4a2kdmogmx5ba7fiolt5chah42a + __init__.py: bafybeid3wfzglolebuo6jrrsopswzu4lk77bm76mvw3euizlsjtnt3wmgu + build/AgentRegistry.json: bafybeicoe5elvvsv2neiirsdn4uddrilizmyib3x4mvpklr7olhj2kh4ue + contract.py: bafybeihrv6blme3v6diwci6zxxn72qbg5sanzmfq5tobhs4375ebcuyday fingerprint_ignore_patterns: [] contracts: [] class_name: AgentRegistryContract diff --git a/packages/valory/contracts/mech/contract.yaml b/packages/valory/contracts/mech/contract.yaml index 429716ec0..3e87738ff 100644 --- a/packages/valory/contracts/mech/contract.yaml +++ b/packages/valory/contracts/mech/contract.yaml @@ -9,7 +9,7 @@ fingerprint: README.md: bafybeibl4uw7rs6mwh7zuvdnqmj2o2xyr7nx5qk3w7torwx3jg6farn6ca __init__.py: bafybeicx5pxh3cxnml2biuuoebvafvu5tvy6mgkzyjzuubuoeebb5yzjsm build/mech.json: bafybeihsfz7rdnf6cpa3c4eagvs4pw6jhr6pcsikstakejrlkuwvwzhw7m - contract.py: bafybeigypn3frcjr7mcmdoe5ubgoy57owm4bfcgtrcytiu76u7khthlvei + contract.py: bafybeifbfa6p3jcwn6j7s5aiiqxb3ne4vbmvoggr5zpptmd727gpsjqjpe fingerprint_ignore_patterns: [] contracts: [] class_name: Mech diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 90de19f58..d7036fbde 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeigoojaxpc7sz7vuswkxvpa5lp37lipuwc4qycztqk4hxdesmxqcda +agent: valory/trader:0.1.0:bafybeiba5eqawktwkpziiazxm5u6ftm7o3zytcbafqsjwt7zrr63o2yis4 number_of_agents: 4 deployment: {} --- @@ -105,9 +105,9 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", - "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", - "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: &id005 args: @@ -174,9 +174,9 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", - "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", - "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: *id005 2: @@ -241,9 +241,9 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", - "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", - "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: *id005 3: @@ -308,9 +308,9 @@ type: skill slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} epsilon: ${EPSILON:float:0.1} - irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", - "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", - "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", + irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", + "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", + "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1"]} benchmark_tool: *id005 --- diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index f7ea16b3c..b5a46b609 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -30,11 +30,9 @@ DecisionMakerBaseBehaviour, WaitableConditionType, ) -from packages.valory.skills.decision_maker_abci.models import ( - AgentToolsSpecs, -) -from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy +from packages.valory.skills.decision_maker_abci.models import AgentToolsSpecs from packages.valory.skills.decision_maker_abci.payloads import ToolSelectionPayload +from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy from packages.valory.skills.decision_maker_abci.states.tool_selection import ( ToolSelectionRound, ) diff --git a/packages/valory/skills/decision_maker_abci/fsm_specification.yaml b/packages/valory/skills/decision_maker_abci/fsm_specification.yaml index 9fb83b998..28ae210b7 100644 --- a/packages/valory/skills/decision_maker_abci/fsm_specification.yaml +++ b/packages/valory/skills/decision_maker_abci/fsm_specification.yaml @@ -38,6 +38,7 @@ states: - RedeemRound - RefillRequiredRound - SamplingRound +- ToolSelectionRound transition_func: (BetPlacementRound, DONE): FinishedDecisionMakerRound (BetPlacementRound, INSUFFICIENT_BALANCE): RefillRequiredRound @@ -68,7 +69,11 @@ transition_func: (RedeemRound, NO_MAJORITY): RedeemRound (RedeemRound, NO_REDEEMING): FinishedWithoutRedeemingRound (RedeemRound, ROUND_TIMEOUT): RedeemRound - (SamplingRound, DONE): DecisionRequestRound + (SamplingRound, DONE): ToolSelectionRound (SamplingRound, NONE): FinishedWithoutDecisionRound (SamplingRound, NO_MAJORITY): SamplingRound (SamplingRound, ROUND_TIMEOUT): SamplingRound + (ToolSelectionRound, DONE): DecisionRequestRound + (ToolSelectionRound, NONE): ToolSelectionRound + (ToolSelectionRound, NO_MAJORITY): ToolSelectionRound + (ToolSelectionRound, ROUND_TIMEOUT): ToolSelectionRound diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index a3d082e2d..fc83e1959 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -21,7 +21,7 @@ import json import random -from dataclasses import is_dataclass, asdict, dataclass +from dataclasses import asdict, dataclass, is_dataclass from typing import Any, List, Optional diff --git a/packages/valory/skills/decision_maker_abci/rounds.py b/packages/valory/skills/decision_maker_abci/rounds.py index 996634d0f..6d46ff17d 100644 --- a/packages/valory/skills/decision_maker_abci/rounds.py +++ b/packages/valory/skills/decision_maker_abci/rounds.py @@ -73,49 +73,54 @@ class DecisionMakerAbciApp(AbciApp[Event]): Transition states: 0. SamplingRound - done: 1. - - none: 8. + - none: 9. - no majority: 0. - round timeout: 0. - 1. DecisionRequestRound - - done: 7. - - slots unsupported error: 3. + 1. ToolSelectionRound + - done: 2. + - none: 1. - no majority: 1. - round timeout: 1. - - none: 11. - 2. DecisionReceiveRound - - done: 4. - - mech response error: 3. + 2. DecisionRequestRound + - done: 8. + - slots unsupported error: 4. - no majority: 2. - - tie: 3. - - unprofitable: 3. - round timeout: 2. - 3. BlacklistingRound - - done: 8. - - none: 11. + - none: 12. + 3. DecisionReceiveRound + - done: 5. + - mech response error: 4. - no majority: 3. + - tie: 4. + - unprofitable: 4. - round timeout: 3. - - fetch error: 11. - 4. BetPlacementRound - - done: 7. - - insufficient balance: 10. + 4. BlacklistingRound + - done: 9. + - none: 12. - no majority: 4. - round timeout: 4. - - none: 11. - 5. RedeemRound - - done: 7. - - no redeeming: 9. + - fetch error: 12. + 5. BetPlacementRound + - done: 8. + - insufficient balance: 11. - no majority: 5. - round timeout: 5. - - none: 11. - 6. HandleFailedTxRound - - blacklist: 3. - - no op: 5. + - none: 12. + 6. RedeemRound + - done: 8. + - no redeeming: 10. - no majority: 6. - 7. FinishedDecisionMakerRound - 8. FinishedWithoutDecisionRound - 9. FinishedWithoutRedeemingRound - 10. RefillRequiredRound - 11. ImpossibleRound + - round timeout: 6. + - none: 12. + 7. HandleFailedTxRound + - blacklist: 4. + - no op: 6. + - no majority: 7. + 8. FinishedDecisionMakerRound + 9. FinishedWithoutDecisionRound + 10. FinishedWithoutRedeemingRound + 11. RefillRequiredRound + 12. ImpossibleRound Final states: {FinishedDecisionMakerRound, FinishedWithoutDecisionRound, FinishedWithoutRedeemingRound, ImpossibleRound, RefillRequiredRound} diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 06f50f1c2..512c61e56 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -12,32 +12,35 @@ fingerprint: README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i __init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky - behaviours/base.py: bafybeiaxgbkrrskfod55lhynd4ttkwrn6qwzugfmmwikzod4ar6pmjmcu4 + behaviours/base.py: bafybeicvex6q2murzsr7dnkueg2zsbdkcufbtarlojjuactsxnlu5eg3ii behaviours/bet_placement.py: bafybeifwwvvwh4qgf3jkyvza4wfvjv63il2xewsklsjtpyanp23y6hg2aa behaviours/blacklisting.py: bafybeicvespraci44y2dtddy4wi7cdhjuyk6crjs7ztnssm2rcrovha3hm - behaviours/decision_receive.py: bafybeifn4xuv2z3niyhgd35ufncrdpaisw7pd4qkw2vv3cte5koqe2mxqy - behaviours/decision_request.py: bafybeifjlh5cfitjd6wjcvcgoji2bhsi4r5nzpqocotwprmn26eiphlmqq + behaviours/decision_receive.py: bafybeid54jwjs4lulcl2n2w7taxne3wqgsey6ppaidwr2up6bztyf35ghm + behaviours/decision_request.py: bafybeidlyl2ojmpfs2zkewoacraya2cbampo4ynqbqaocsoq7v2nif3ahi behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm - behaviours/reedem.py: bafybeib25frcafu6iikppidwqqovwjkzkxif6m3f4crmklohpj6yixprsq - behaviours/round_behaviour.py: bafybeifk5utwuaneima4rdeow7tcpbe6hcc2utlzxcw3w7vsm5zw7zpamm + behaviours/reedem.py: bafybeif2sby2nfvvecpynbaek452pqhkl7gexno4max6wzw7ofuopfg4iu + behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm behaviours/sampling.py: bafybeiadikynvkaofbko72jc45xthhmmjfmlkpgramormhxwk5u47rnwdu + behaviours/tool_selection.py: bafybeib3vzj25c5hzpitznpe6jkbgbh7cdfmt3aa3zxyuftutikd67eniq dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm - fsm_specification.yaml: bafybeigrljw66oxyvn5wqecfgkcx7ozkjg7xuv75zcjmo25fft37qyed6y + fsm_specification.yaml: bafybeifnob3ceim2mj7lqagtnpwqjqqxs5eg3oiwc73gwm6x5i2dvvlcya handlers.py: bafybeihj33szgrcxnpd73s4nvluyxwwsvhjum2cuq3ilhhe6vfola3k7vy - models.py: bafybeibqou3ryuszu2vbwdp5b7fkj5oxmflgh3z3a7tuajbdxgzdolgmee - payloads.py: bafybeifbnyviargcj5w5kbuuvc3o4y5sdogtuynd2b4ca4xsfbi3cqcwlm - redeem_info.py: bafybeic7de4hrsgjmxbjht5ihasm5t7bykuonei5xxhpf3lpzq35fuxy74 - rounds.py: bafybeihpstybessozkb3hjxhf3gvf323zw4d575ihmxrsuzcyhqtbsruoq + models.py: bafybeicnnzyzdwdtedw3ihahugve6725ckkgt5po6qzxwljs67x5dzhwq4 + payloads.py: bafybeifpwwkikmsr7abxbin7jup6i4by7nzhpqfwlk4knm25z4mznpqj5u + policy.py: bafybeieu7yhgyuwexytpbmhuo2r5ky3sy7btoyw43bqhfcr3oj76e6dmb4 + redeem_info.py: bafybeigtxdyzs5gxfxadudg4n6ua5zpdijuzpm7x6732exxa6hpsczmyzy + rounds.py: bafybeieagkqbsy2da3soieelzvqnj4xkkpttfbhysfsfrb3geckqiejbx4 states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy - states/base.py: bafybeif42mqu6wu55iyjyqxto3poyta22gdsswgtus55lo4qpmv74wvlmm + states/base.py: bafybeieuw57xtki2dsrvr5hfx6iedxjmosr6kywphdzfukjejwv52iawcu states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda states/blacklisting.py: bafybeiao747i4z7owk6dmwfuzdijag55m3ryj3nowfoggvczpgk3koza44 states/decision_receive.py: bafybeifm3oyq2aji7f5yag6wpe4vr3ivi74pybdsk2jvmziiidx5nt7t4a states/decision_request.py: bafybeic7otc3hjb753svbmur3yyk6szahc25yii3x4w4vcnpfz6jwvacuu states/final_states.py: bafybeidiwhuyd5zm2cq7vhv2owcrxdpm7fnvn3db6p6tql4jz5hgpalflu states/handle_failed_tx.py: bafybeihewm2vernvhktuorljdupjqcg2p5vs6wvsira2d62wkoyo5xlzjm - states/redeem.py: bafybeifl7qgs2xvm4nykloec5tq47sriqah3dzahv3gppvgtrrxzw5yyyq + states/redeem.py: bafybeiebofn2pg32iprvwuglclq6hm4x3hvx7neqqad4b77zej67vozjye states/sampling.py: bafybeidnvdogjlthjfe7jpaiuezm3xydrbxxukyoss4gx6t5fdin52rsta + states/tool_selection.py: bafybeihc7pmwxijc5tcsl2yt5n3rbwumqksa3oxjjcrj6vkesinhu5f7im fingerprint_ignore_patterns: [] connections: [] contracts: @@ -45,16 +48,16 @@ contracts: - valory/market_maker:0.1.0:bafybeif6hivvhxqv4a3uqo2v3yszluzrmngsp624utdi466xwo5qbz5bsi - valory/erc20:0.1.0:bafybeiggo4u56drxusvcdruqrr7mlfzqbieg4hajalh4tkctxhh3c5lpdi - valory/multisend:0.1.0:bafybeidfktuprydtmi4umolfles5qaf7s3t26puvvs44hvkq6uwwr3ia3a -- valory/mech:0.1.0:bafybeibfikekaruskx6ui7u4qnls57i2namfxi45zhqslziqyxg4npjzxu +- valory/mech:0.1.0:bafybeidtezc4ubsyqdltiojvqe5eeh77ejte7vqbojspiej5quivgap3ae - valory/conditional_tokens:0.1.0:bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa - valory/realitio:0.1.0:bafybeigb722aznqhc5lsbt3dn4bpyaqe5hnl5onmnestqmzliwtvl3eaom - valory/realitio_proxy:0.1.0:bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy -- valory/agent_registry:0.1.0:bafybeiunknownnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn +- valory/agent_registry:0.1.0:bafybeib6odummk6qqietjekpljkmhqfxk7kv56kv6pyfsnnanews625ncy protocols: - valory/contract_api:1.0.0:bafybeiasywsvax45qmugus5kxogejj66c5taen27h4voriodz7rgushtqa skills: - valory/abstract_round_abci:0.1.0:bafybeicqwr73cs3vndzafrjrjpw63vvqbbjsur7ptek77hsw3lurnood5y -- valory/market_manager_abci:0.1.0:bafybeicjqkzen2gvpnc3syojcf6ibr4kjaorcwktikqp2zzxec6vs64oky +- valory/market_manager_abci:0.1.0:bafybeigvw5tqei5xb272jb7retxiryhuhxxzupddmbdixgsmxzco3n2dde - valory/transaction_settlement_abci:0.1.0:bafybeicisazpyvnnzlqso3txiucxr5qhsa4ac7ius6b4mhouxr2wkadwfy behaviours: main: @@ -211,7 +214,7 @@ models: headers: Content-Type: application/json method: GET - parameters: { } + parameters: {} response_key: tools response_type: list retries: 5 diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index c37034f19..b29c24e2e 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -28,8 +28,8 @@ DeserializedCollection, get_name, ) -from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy from packages.valory.skills.decision_maker_abci.payloads import MultisigTxPayload +from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy from packages.valory.skills.market_manager_abci.bets import Bet from packages.valory.skills.market_manager_abci.rounds import ( SynchronizedData as MarketManagerSyncedData, diff --git a/packages/valory/skills/market_manager_abci/skill.yaml b/packages/valory/skills/market_manager_abci/skill.yaml index f6640d746..95802d874 100644 --- a/packages/valory/skills/market_manager_abci/skill.yaml +++ b/packages/valory/skills/market_manager_abci/skill.yaml @@ -15,7 +15,7 @@ fingerprint: graph_tooling/__init__.py: bafybeigzo7nhbzafyq3fuhrlewksjvmzttiuk4vonrggtjtph4rw4ncpk4 graph_tooling/queries/__init__.py: bafybeihbybnl53i7k57ql5ujt5ru5n2eg324jfndh4lcnm4fk52mwbkjda graph_tooling/queries/network.py: bafybeigeq72ys2nrjqspj2uacaudrgljrne5a3o5jvzsktldxdq6m2xmeu - graph_tooling/queries/omen.py: bafybeiajk65gvqkxvxekywqqy2kob3vobjsealqlyxis3z6mpwhyng7hh4 + graph_tooling/queries/omen.py: bafybeigybmwaz3e33ug756v7k4lrwy5tlwimii5qywapaiww6qgslvfywi graph_tooling/requests.py: bafybeics4oueh3nemdvl366vqgnf3ltea2ab443qtfaoqgl63tmct227qa handlers.py: bafybeihot2i2yvfkz2gcowvt66wdu6tkjbmv7hsmc4jzt4reqeaiuphbtu models.py: bafybeiaplszooak63fo3i6agaoyol4tpof4q4tvoj4j6f2cr2corajnl3a diff --git a/packages/valory/skills/trader_abci/fsm_specification.yaml b/packages/valory/skills/trader_abci/fsm_specification.yaml index a9e12a68c..d550e79ea 100644 --- a/packages/valory/skills/trader_abci/fsm_specification.yaml +++ b/packages/valory/skills/trader_abci/fsm_specification.yaml @@ -60,6 +60,7 @@ states: - SelectKeeperTransactionSubmissionBAfterTimeoutRound - SelectKeeperTransactionSubmissionBRound - SynchronizeLateMessagesRound +- ToolSelectionRound - UpdateBetsRound - ValidateTransactionRound transition_func: @@ -130,7 +131,7 @@ transition_func: (ResetRound, DONE): RandomnessTransactionSubmissionRound (ResetRound, NO_MAJORITY): HandleFailedTxRound (ResetRound, RESET_TIMEOUT): HandleFailedTxRound - (SamplingRound, DONE): DecisionRequestRound + (SamplingRound, DONE): ToolSelectionRound (SamplingRound, NONE): RedeemRound (SamplingRound, NO_MAJORITY): SamplingRound (SamplingRound, ROUND_TIMEOUT): SamplingRound @@ -152,6 +153,10 @@ transition_func: (SynchronizeLateMessagesRound, NONE): SelectKeeperTransactionSubmissionBRound (SynchronizeLateMessagesRound, ROUND_TIMEOUT): SynchronizeLateMessagesRound (SynchronizeLateMessagesRound, SUSPICIOUS_ACTIVITY): HandleFailedTxRound + (ToolSelectionRound, DONE): DecisionRequestRound + (ToolSelectionRound, NONE): ToolSelectionRound + (ToolSelectionRound, NO_MAJORITY): ToolSelectionRound + (ToolSelectionRound, ROUND_TIMEOUT): ToolSelectionRound (UpdateBetsRound, DONE): SamplingRound (UpdateBetsRound, FETCH_ERROR): ResetAndPauseRound (UpdateBetsRound, NO_MAJORITY): UpdateBetsRound diff --git a/packages/valory/skills/trader_abci/models.py b/packages/valory/skills/trader_abci/models.py index 60f0405cc..373113b77 100644 --- a/packages/valory/skills/trader_abci/models.py +++ b/packages/valory/skills/trader_abci/models.py @@ -29,12 +29,12 @@ from packages.valory.skills.abstract_round_abci.models import ( SharedState as BaseSharedState, ) -from packages.valory.skills.decision_maker_abci.models import DecisionMakerParams from packages.valory.skills.decision_maker_abci.models import ( - MechResponseSpecs as DecisionMakerMechResponseSpecs, + AgentToolsSpecs as DecisionMakerAgentToolsSpecs, ) +from packages.valory.skills.decision_maker_abci.models import DecisionMakerParams from packages.valory.skills.decision_maker_abci.models import ( - AgentToolsSpecs as DecisionMakerAgentToolsSpecs, + MechResponseSpecs as DecisionMakerMechResponseSpecs, ) from packages.valory.skills.decision_maker_abci.rounds import ( Event as DecisionMakerEvent, diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index eab5ea890..d7fd07207 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -11,9 +11,9 @@ fingerprint: behaviours.py: bafybeigwadq27e4cnklboorhitwzzve4xkcgjdu2upplbbweuqyl52fj3q composition.py: bafybeie45dgneoggyavgdtswcygvz5o3klmtqf57zoxqnxrtneruutqevi dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm - fsm_specification.yaml: bafybeiasu522aq3xthvuyvajpvzxy33nu6l4esuyl2xmkslckldcomwfzu + fsm_specification.yaml: bafybeiaomt3gscv4pvxczc4scu6q6laza6bqhpvfi2bfiq37vksuchhqiy handlers.py: bafybeicamc6vmozij5dwvkxmbxjazsgf3sacojhstbjtq7vfggszxugvey - models.py: bafybeih26gyqv24lc2mlz3kbdsifip3zlac3owcpqlyi7hg6du6y6ojdda + models.py: bafybeifj5y7qcoac72woe53zaz2lopkqir2472bbey3ypsqmprjmljms7i fingerprint_ignore_patterns: [] connections: [] contracts: [] @@ -24,9 +24,9 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeiblayblhp5wuirfomwcpgydg35ve5tfq3xxetlosjn47wva5ucmzy - valory/transaction_settlement_abci:0.1.0:bafybeicisazpyvnnzlqso3txiucxr5qhsa4ac7ius6b4mhouxr2wkadwfy - valory/termination_abci:0.1.0:bafybeieqfhvk6klnvxak3vo2ibslkrnnk2bfsn5l3gbaelcprd6cjngxki -- valory/market_manager_abci:0.1.0:bafybeicjqkzen2gvpnc3syojcf6ibr4kjaorcwktikqp2zzxec6vs64oky -- valory/decision_maker_abci:0.1.0:bafybeic77zhxf5a53ngfzacklmm3nag4t4jeufdhoeg3ykrmvknojtwipi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidtrigrfjikl7tkbtowbp6mrdzxulayxnxcmviwy3gag557vnymlq +- valory/market_manager_abci:0.1.0:bafybeigvw5tqei5xb272jb7retxiryhuhxxzupddmbdixgsmxzco3n2dde +- valory/decision_maker_abci:0.1.0:bafybeihm77vt53vu3xt6x7istsvaw75juptlynpriebgeltbil5evvhtue +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiey57caacd6d3ow25i6a2zuiinkx6kjtckdktannk7kijpd3p2zb4 behaviours: main: args: {} @@ -234,7 +234,7 @@ models: headers: Content-Type: application/json method: GET - parameters: { } + parameters: {} response_key: tools response_type: list retries: 5 diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 1e4557ff1..e80f4946e 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -13,14 +13,14 @@ fingerprint: fsm_specification.yaml: bafybeibeas5ovngfhfox4dkkwdvhogpuzkmwj6r33ez2xxvvmvmesa3xvm handlers.py: bafybeiafbqr7ojfcbwohvee7x4zzswad3ymfrrbjlfz7uuuttmn3qdfs6q models.py: bafybeiahojnn52s762zitwx6k5s4ef5qw7hwjf3orlklqwuz3zi7k2o7bi - rounds.py: bafybeifotgp5zr6vrgfhursm7dwkju74qdrruw7ui7zmbl5t34om4fnapa + rounds.py: bafybeifcqo6t7vhkclwj6lncfirglvayd7oqdwinca2ipndizgin7alm5q fingerprint_ignore_patterns: [] connections: [] contracts: [] protocols: [] skills: - valory/abstract_round_abci:0.1.0:bafybeicqwr73cs3vndzafrjrjpw63vvqbbjsur7ptek77hsw3lurnood5y -- valory/decision_maker_abci:0.1.0:bafybeic77zhxf5a53ngfzacklmm3nag4t4jeufdhoeg3ykrmvknojtwipi +- valory/decision_maker_abci:0.1.0:bafybeihm77vt53vu3xt6x7istsvaw75juptlynpriebgeltbil5evvhtue behaviours: main: args: {} diff --git a/poetry.lock b/poetry.lock index fa4f7b8ac..3b19fb7d2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -737,35 +737,35 @@ files = [ [[package]] name = "cryptography" -version = "41.0.3" +version = "41.0.4" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "cryptography-41.0.3-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:652627a055cb52a84f8c448185922241dd5217443ca194d5739b44612c5e6507"}, - {file = "cryptography-41.0.3-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:8f09daa483aedea50d249ef98ed500569841d6498aa9c9f4b0531b9964658922"}, - {file = "cryptography-41.0.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4fd871184321100fb400d759ad0cddddf284c4b696568204d281c902fc7b0d81"}, - {file = "cryptography-41.0.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:84537453d57f55a50a5b6835622ee405816999a7113267739a1b4581f83535bd"}, - {file = "cryptography-41.0.3-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:3fb248989b6363906827284cd20cca63bb1a757e0a2864d4c1682a985e3dca47"}, - {file = "cryptography-41.0.3-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:42cb413e01a5d36da9929baa9d70ca90d90b969269e5a12d39c1e0d475010116"}, - {file = "cryptography-41.0.3-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:aeb57c421b34af8f9fe830e1955bf493a86a7996cc1338fe41b30047d16e962c"}, - {file = "cryptography-41.0.3-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:6af1c6387c531cd364b72c28daa29232162010d952ceb7e5ca8e2827526aceae"}, - {file = "cryptography-41.0.3-cp37-abi3-win32.whl", hash = "sha256:0d09fb5356f975974dbcb595ad2d178305e5050656affb7890a1583f5e02a306"}, - {file = "cryptography-41.0.3-cp37-abi3-win_amd64.whl", hash = "sha256:a983e441a00a9d57a4d7c91b3116a37ae602907a7618b882c8013b5762e80574"}, - {file = "cryptography-41.0.3-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:5259cb659aa43005eb55a0e4ff2c825ca111a0da1814202c64d28a985d33b087"}, - {file = "cryptography-41.0.3-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:67e120e9a577c64fe1f611e53b30b3e69744e5910ff3b6e97e935aeb96005858"}, - {file = "cryptography-41.0.3-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:7efe8041897fe7a50863e51b77789b657a133c75c3b094e51b5e4b5cec7bf906"}, - {file = "cryptography-41.0.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ce785cf81a7bdade534297ef9e490ddff800d956625020ab2ec2780a556c313e"}, - {file = "cryptography-41.0.3-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:57a51b89f954f216a81c9d057bf1a24e2f36e764a1ca9a501a6964eb4a6800dd"}, - {file = "cryptography-41.0.3-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:4c2f0d35703d61002a2bbdcf15548ebb701cfdd83cdc12471d2bae80878a4207"}, - {file = "cryptography-41.0.3-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:23c2d778cf829f7d0ae180600b17e9fceea3c2ef8b31a99e3c694cbbf3a24b84"}, - {file = "cryptography-41.0.3-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:95dd7f261bb76948b52a5330ba5202b91a26fbac13ad0e9fc8a3ac04752058c7"}, - {file = "cryptography-41.0.3-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:41d7aa7cdfded09b3d73a47f429c298e80796c8e825ddfadc84c8a7f12df212d"}, - {file = "cryptography-41.0.3-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:d0d651aa754ef58d75cec6edfbd21259d93810b73f6ec246436a21b7841908de"}, - {file = "cryptography-41.0.3-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:ab8de0d091acbf778f74286f4989cf3d1528336af1b59f3e5d2ebca8b5fe49e1"}, - {file = "cryptography-41.0.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a74fbcdb2a0d46fe00504f571a2a540532f4c188e6ccf26f1f178480117b33c4"}, - {file = "cryptography-41.0.3.tar.gz", hash = "sha256:6d192741113ef5e30d89dcb5b956ef4e1578f304708701b8b73d38e3e1461f34"}, + {file = "cryptography-41.0.4-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:80907d3faa55dc5434a16579952ac6da800935cd98d14dbd62f6f042c7f5e839"}, + {file = "cryptography-41.0.4-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:35c00f637cd0b9d5b6c6bd11b6c3359194a8eba9c46d4e875a3660e3b400005f"}, + {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cecfefa17042941f94ab54f769c8ce0fe14beff2694e9ac684176a2535bf9714"}, + {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e40211b4923ba5a6dc9769eab704bdb3fbb58d56c5b336d30996c24fcf12aadb"}, + {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:23a25c09dfd0d9f28da2352503b23e086f8e78096b9fd585d1d14eca01613e13"}, + {file = "cryptography-41.0.4-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:2ed09183922d66c4ec5fdaa59b4d14e105c084dd0febd27452de8f6f74704143"}, + {file = "cryptography-41.0.4-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:5a0f09cefded00e648a127048119f77bc2b2ec61e736660b5789e638f43cc397"}, + {file = "cryptography-41.0.4-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:9eeb77214afae972a00dee47382d2591abe77bdae166bda672fb1e24702a3860"}, + {file = "cryptography-41.0.4-cp37-abi3-win32.whl", hash = "sha256:3b224890962a2d7b57cf5eeb16ccaafba6083f7b811829f00476309bce2fe0fd"}, + {file = "cryptography-41.0.4-cp37-abi3-win_amd64.whl", hash = "sha256:c880eba5175f4307129784eca96f4e70b88e57aa3f680aeba3bab0e980b0f37d"}, + {file = "cryptography-41.0.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:004b6ccc95943f6a9ad3142cfabcc769d7ee38a3f60fb0dddbfb431f818c3a67"}, + {file = "cryptography-41.0.4-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:86defa8d248c3fa029da68ce61fe735432b047e32179883bdb1e79ed9bb8195e"}, + {file = "cryptography-41.0.4-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:37480760ae08065437e6573d14be973112c9e6dcaf5f11d00147ee74f37a3829"}, + {file = "cryptography-41.0.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:b5f4dfe950ff0479f1f00eda09c18798d4f49b98f4e2006d644b3301682ebdca"}, + {file = "cryptography-41.0.4-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:7e53db173370dea832190870e975a1e09c86a879b613948f09eb49324218c14d"}, + {file = "cryptography-41.0.4-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:5b72205a360f3b6176485a333256b9bcd48700fc755fef51c8e7e67c4b63e3ac"}, + {file = "cryptography-41.0.4-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:93530900d14c37a46ce3d6c9e6fd35dbe5f5601bf6b3a5c325c7bffc030344d9"}, + {file = "cryptography-41.0.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:efc8ad4e6fc4f1752ebfb58aefece8b4e3c4cae940b0994d43649bdfce8d0d4f"}, + {file = "cryptography-41.0.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c3391bd8e6de35f6f1140e50aaeb3e2b3d6a9012536ca23ab0d9c35ec18c8a91"}, + {file = "cryptography-41.0.4-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:0d9409894f495d465fe6fda92cb70e8323e9648af912d5b9141d616df40a87b8"}, + {file = "cryptography-41.0.4-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:8ac4f9ead4bbd0bc8ab2d318f97d85147167a488be0e08814a37eb2f439d5cf6"}, + {file = "cryptography-41.0.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:047c4603aeb4bbd8db2756e38f5b8bd7e94318c047cfe4efeb5d715e08b49311"}, + {file = "cryptography-41.0.4.tar.gz", hash = "sha256:7febc3094125fc126a7f6fb1f420d0da639f3f32cb15c8ff0dc3997c4549f51a"}, ] [package.dependencies] @@ -1257,14 +1257,14 @@ grpcio-gcp = ["grpcio-gcp (>=0.2.2,<1.0.dev0)"] [[package]] name = "google-api-python-client" -version = "2.99.0" +version = "2.100.0" description = "Google API Client Library for Python" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "google-api-python-client-2.99.0.tar.gz", hash = "sha256:e733fd0f2c8793b1a000d5e69ac81b1b9ec0665b445b7ed83bdbbb0038973306"}, - {file = "google_api_python_client-2.99.0-py2.py3-none-any.whl", hash = "sha256:40272131d3a4a7aecab840ebcf3df51c54d49560156f3b9d54a4ef82c795985d"}, + {file = "google-api-python-client-2.100.0.tar.gz", hash = "sha256:eaed50efc2f8a4027dcca8fd0037f4b1b03b8093efc84ce3cb6c75bfc79a7e31"}, + {file = "google_api_python_client-2.100.0-py2.py3-none-any.whl", hash = "sha256:226ca35355993d6182506c51745ab5149405cdf6a92975b2725ab3e0d757dbe9"}, ] [package.dependencies] @@ -1528,14 +1528,14 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "jsonschema" -version = "4.19.0" +version = "4.19.1" description = "An implementation of JSON Schema validation for Python" category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "jsonschema-4.19.0-py3-none-any.whl", hash = "sha256:043dc26a3845ff09d20e4420d6012a9c91c9aa8999fa184e7efcfeccb41e32cb"}, - {file = "jsonschema-4.19.0.tar.gz", hash = "sha256:6e1e7569ac13be8139b2dd2c21a55d350066ee3f80df06c608b398cdc6f30e8f"}, + {file = "jsonschema-4.19.1-py3-none-any.whl", hash = "sha256:cd5f1f9ed9444e554b38ba003af06c0a8c2868131e56bfbef0550fb450c0330e"}, + {file = "jsonschema-4.19.1.tar.gz", hash = "sha256:ec84cc37cfa703ef7cd4928db24f9cb31428a5d0fa77747b8b51a847458e0bbf"}, ] [package.dependencies] @@ -1845,14 +1845,14 @@ files = [ [[package]] name = "netaddr" -version = "0.8.0" +version = "0.9.0" description = "A network address manipulation library for Python" category = "main" optional = false python-versions = "*" files = [ - {file = "netaddr-0.8.0-py2.py3-none-any.whl", hash = "sha256:9666d0232c32d2656e5e5f8d735f58fd6c7457ce52fc21c98d45f2af78f990ac"}, - {file = "netaddr-0.8.0.tar.gz", hash = "sha256:d6cc57c7a07b1d9d2e917aa8b36ae8ce61c35ba3fcd1b83ca31c5a0ee2b5a243"}, + {file = "netaddr-0.9.0-py3-none-any.whl", hash = "sha256:5148b1055679d2a1ec070c521b7db82137887fabd6d7e37f5199b44f775c3bb1"}, + {file = "netaddr-0.9.0.tar.gz", hash = "sha256:7b46fa9b1a2d71fd5de9e4a3784ef339700a53a08c8040f08baf5f1194da0128"}, ] [[package]] From c500c252e1b147b3bcc65041294e9acae77418bf Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 09:52:13 +0300 Subject: [PATCH 32/57] fix: pin `jsonschema` --- poetry.lock | 54 ++++++++++++++++++++++++++++---------------------- pyproject.toml | 1 + tox.ini | 6 +++++- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/poetry.lock b/poetry.lock index 3b19fb7d2..cf5e327f3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1528,14 +1528,14 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "jsonschema" -version = "4.19.1" +version = "4.19.0" description = "An implementation of JSON Schema validation for Python" category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "jsonschema-4.19.1-py3-none-any.whl", hash = "sha256:cd5f1f9ed9444e554b38ba003af06c0a8c2868131e56bfbef0550fb450c0330e"}, - {file = "jsonschema-4.19.1.tar.gz", hash = "sha256:ec84cc37cfa703ef7cd4928db24f9cb31428a5d0fa77747b8b51a847458e0bbf"}, + {file = "jsonschema-4.19.0-py3-none-any.whl", hash = "sha256:043dc26a3845ff09d20e4420d6012a9c91c9aa8999fa184e7efcfeccb41e32cb"}, + {file = "jsonschema-4.19.0.tar.gz", hash = "sha256:6e1e7569ac13be8139b2dd2c21a55d350066ee3f80df06c608b398cdc6f30e8f"}, ] [package.dependencies] @@ -2136,31 +2136,37 @@ files = [ [[package]] name = "pandas" -version = "2.1.0" +version = "2.1.1" description = "Powerful data structures for data analysis, time series, and statistics" category = "main" optional = false python-versions = ">=3.9" files = [ - {file = "pandas-2.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:40dd20439ff94f1b2ed55b393ecee9cb6f3b08104c2c40b0cb7186a2f0046242"}, - {file = "pandas-2.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d4f38e4fedeba580285eaac7ede4f686c6701a9e618d8a857b138a126d067f2f"}, - {file = "pandas-2.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6e6a0fe052cf27ceb29be9429428b4918f3740e37ff185658f40d8702f0b3e09"}, - {file = "pandas-2.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d81e1813191070440d4c7a413cb673052b3b4a984ffd86b8dd468c45742d3cc"}, - {file = "pandas-2.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:eb20252720b1cc1b7d0b2879ffc7e0542dd568f24d7c4b2347cb035206936421"}, - {file = "pandas-2.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:38f74ef7ebc0ffb43b3d633e23d74882bce7e27bfa09607f3c5d3e03ffd9a4a5"}, - {file = "pandas-2.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cda72cc8c4761c8f1d97b169661f23a86b16fdb240bdc341173aee17e4d6cedd"}, - {file = "pandas-2.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d97daeac0db8c993420b10da4f5f5b39b01fc9ca689a17844e07c0a35ac96b4b"}, - {file = "pandas-2.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8c58b1113892e0c8078f006a167cc210a92bdae23322bb4614f2f0b7a4b510f"}, - {file = "pandas-2.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:629124923bcf798965b054a540f9ccdfd60f71361255c81fa1ecd94a904b9dd3"}, - {file = "pandas-2.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:70cf866af3ab346a10debba8ea78077cf3a8cd14bd5e4bed3d41555a3280041c"}, - {file = "pandas-2.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:d53c8c1001f6a192ff1de1efe03b31a423d0eee2e9e855e69d004308e046e694"}, - {file = "pandas-2.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:86f100b3876b8c6d1a2c66207288ead435dc71041ee4aea789e55ef0e06408cb"}, - {file = "pandas-2.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:28f330845ad21c11db51e02d8d69acc9035edfd1116926ff7245c7215db57957"}, - {file = "pandas-2.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b9a6ccf0963db88f9b12df6720e55f337447aea217f426a22d71f4213a3099a6"}, - {file = "pandas-2.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d99e678180bc59b0c9443314297bddce4ad35727a1a2656dbe585fd78710b3b9"}, - {file = "pandas-2.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b31da36d376d50a1a492efb18097b9101bdbd8b3fbb3f49006e02d4495d4c644"}, - {file = "pandas-2.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:0164b85937707ec7f70b34a6c3a578dbf0f50787f910f21ca3b26a7fd3363437"}, - {file = "pandas-2.1.0.tar.gz", hash = "sha256:62c24c7fc59e42b775ce0679cfa7b14a5f9bfb7643cfbe708c960699e05fb918"}, + {file = "pandas-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:58d997dbee0d4b64f3cb881a24f918b5f25dd64ddf31f467bb9b67ae4c63a1e4"}, + {file = "pandas-2.1.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:02304e11582c5d090e5a52aec726f31fe3f42895d6bfc1f28738f9b64b6f0614"}, + {file = "pandas-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffa8f0966de2c22de408d0e322db2faed6f6e74265aa0856f3824813cf124363"}, + {file = "pandas-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c1f84c144dee086fe4f04a472b5cd51e680f061adf75c1ae4fc3a9275560f8f4"}, + {file = "pandas-2.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:75ce97667d06d69396d72be074f0556698c7f662029322027c226fd7a26965cb"}, + {file = "pandas-2.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:4c3f32fd7c4dccd035f71734df39231ac1a6ff95e8bdab8d891167197b7018d2"}, + {file = "pandas-2.1.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9e2959720b70e106bb1d8b6eadd8ecd7c8e99ccdbe03ee03260877184bb2877d"}, + {file = "pandas-2.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:25e8474a8eb258e391e30c288eecec565bfed3e026f312b0cbd709a63906b6f8"}, + {file = "pandas-2.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b8bd1685556f3374520466998929bade3076aeae77c3e67ada5ed2b90b4de7f0"}, + {file = "pandas-2.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dc3657869c7902810f32bd072f0740487f9e030c1a3ab03e0af093db35a9d14e"}, + {file = "pandas-2.1.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:05674536bd477af36aa2effd4ec8f71b92234ce0cc174de34fd21e2ee99adbc2"}, + {file = "pandas-2.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:b407381258a667df49d58a1b637be33e514b07f9285feb27769cedb3ab3d0b3a"}, + {file = "pandas-2.1.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c747793c4e9dcece7bb20156179529898abf505fe32cb40c4052107a3c620b49"}, + {file = "pandas-2.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3bcad1e6fb34b727b016775bea407311f7721db87e5b409e6542f4546a4951ea"}, + {file = "pandas-2.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f5ec7740f9ccb90aec64edd71434711f58ee0ea7f5ed4ac48be11cfa9abf7317"}, + {file = "pandas-2.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:29deb61de5a8a93bdd033df328441a79fcf8dd3c12d5ed0b41a395eef9cd76f0"}, + {file = "pandas-2.1.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4f99bebf19b7e03cf80a4e770a3e65eee9dd4e2679039f542d7c1ace7b7b1daa"}, + {file = "pandas-2.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:84e7e910096416adec68075dc87b986ff202920fb8704e6d9c8c9897fe7332d6"}, + {file = "pandas-2.1.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:366da7b0e540d1b908886d4feb3d951f2f1e572e655c1160f5fde28ad4abb750"}, + {file = "pandas-2.1.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9e50e72b667415a816ac27dfcfe686dc5a0b02202e06196b943d54c4f9c7693e"}, + {file = "pandas-2.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc1ab6a25da197f03ebe6d8fa17273126120874386b4ac11c1d687df288542dd"}, + {file = "pandas-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0dbfea0dd3901ad4ce2306575c54348d98499c95be01b8d885a2737fe4d7a98"}, + {file = "pandas-2.1.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:0489b0e6aa3d907e909aef92975edae89b1ee1654db5eafb9be633b0124abe97"}, + {file = "pandas-2.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:4cdb0fab0400c2cb46dafcf1a0fe084c8bb2480a1fa8d81e19d15e12e6d4ded2"}, + {file = "pandas-2.1.1.tar.gz", hash = "sha256:fecb198dc389429be557cde50a2d46da8434a17fe37d7d41ff102e3987fd947b"}, ] [package.dependencies] @@ -3613,4 +3619,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = ">=3.10, <3.11" -content-hash = "1e75c7f45ac002b83c442190a952e0dc501c50ffe1241a65f94f7ff5c3c11a3e" +content-hash = "c1b74b7e0b7c776fdfe5381a4a4711920acc18b5f4c60b1c4c54b65b549b439e" diff --git a/pyproject.toml b/pyproject.toml index 94fa959ff..1f39cb7f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ eth-abi = "==4.0.0" pycryptodome = "==3.18.0" pytest = "==7.2.1" urllib3 = "==1.26.16" +jsonschema = "<=4.19.0,>=4.16.0" [tool.poetry.group.dev.dependencies.tomte] version = "==0.2.12" diff --git a/tox.ini b/tox.ini index 6ca031d3d..2564cb5de 100644 --- a/tox.ini +++ b/tox.ini @@ -51,6 +51,7 @@ deps = pycryptodome==3.18.0 pytest==7.2.1 urllib3==1.26.16 + jsonschema<=4.19.0,>=4.16.0 [testenv] basepython = python3 @@ -120,7 +121,7 @@ commands = [testenv:check-dependencies] skipsdist = True usedevelop = True -commands = +commands = autonomy packages sync {toxinidir}/scripts/check_dependencies.py @@ -363,6 +364,9 @@ ignore_missing_imports = True [mypy-hexbytes.*] ignore_missing_imports = True +[mypy-autonomy.*] +ignore_missing_imports = True + [darglint] docstring_style=sphinx strictness=short From 70799f06019cd5d6c067058b7edf8666b068f228 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 15:37:21 +0300 Subject: [PATCH 33/57] refactor: use predefined value during the initialization --- packages/valory/skills/decision_maker_abci/policy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index fc83e1959..9504f4d84 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -48,6 +48,7 @@ class EGreedyPolicy: n_tools: int counts: List[int] rewards: List[float] + initial_value = 0 @classmethod def initial_state(cls, eps: float, n_tools: int) -> "EGreedyPolicy": @@ -56,7 +57,12 @@ def initial_state(cls, eps: float, n_tools: int) -> "EGreedyPolicy": error = f"Cannot initialize an e Greedy Policy with {n_tools=}" raise ValueError(error) - return EGreedyPolicy(eps, n_tools, [0] * n_tools, [0.0] * n_tools) + return EGreedyPolicy( + eps, + n_tools, + [cls.initial_value] * n_tools, + [float(cls.initial_value)] * n_tools, + ) @classmethod def deserialize(cls, policy: str) -> "EGreedyPolicy": From caed3fd7b21a609cc340c8091d1251f6784e35c6 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 18:22:55 +0300 Subject: [PATCH 34/57] fix: zero division --- packages/valory/skills/decision_maker_abci/policy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index 9504f4d84..50934dd88 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -77,7 +77,10 @@ def random_tool(self) -> int: @property def reward_rates(self) -> List[float]: """Get the reward rates.""" - return [reward / count for reward, count in zip(self.rewards, self.counts)] + return [ + reward / count if count > 0 else 0 + for reward, count in zip(self.rewards, self.counts) + ] def add_new_tools(self, n_new: int) -> None: """Add new tools to the current policy.""" From efe694f3098cfb0797db5ee7b97cb5c60575a4d3 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 18:24:21 +0300 Subject: [PATCH 35/57] feat: add an option to avoid shifting when removing tools --- packages/valory/skills/decision_maker_abci/policy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index 50934dd88..f29984b4f 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -88,9 +88,11 @@ def add_new_tools(self, n_new: int) -> None: self.counts.extend([0] * n_new) self.rewards.extend([0.0] * n_new) - def remove_tools(self, indexes: List[int]) -> None: + def remove_tools(self, indexes: List[int], avoid_shift: bool = False) -> None: """Remove the knowledge for the tools corresponding to the given indexes.""" - self.n_tools -= len(indexes) + if avoid_shift: + indexes = sorted(indexes, reverse=True) + for i in indexes: try: del self.counts[i] From dfa16916ecece69d4c6c97e5add7bb24fe972a36 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 18:22:31 +0300 Subject: [PATCH 36/57] refactor: convert number of tools to a property --- packages/valory/skills/decision_maker_abci/policy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index f29984b4f..e967c8d79 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -45,7 +45,6 @@ class EGreedyPolicy: """An e-Greedy policy for the tool selection.""" eps: float - n_tools: int counts: List[int] rewards: List[float] initial_value = 0 @@ -59,7 +58,6 @@ def initial_state(cls, eps: float, n_tools: int) -> "EGreedyPolicy": return EGreedyPolicy( eps, - n_tools, [cls.initial_value] * n_tools, [float(cls.initial_value)] * n_tools, ) @@ -69,6 +67,11 @@ def deserialize(cls, policy: str) -> "EGreedyPolicy": """Deserialize a string to an `EGreedyPolicy` object.""" return EGreedyPolicy(**json.loads(policy)) + @property + def n_tools(self) -> int: + """Get the number of the policy's tools.""" + return len(self.counts) + @property def random_tool(self) -> int: """Get the index of a tool randomly.""" @@ -84,7 +87,6 @@ def reward_rates(self) -> List[float]: def add_new_tools(self, n_new: int) -> None: """Add new tools to the current policy.""" - self.n_tools += n_new self.counts.extend([0] * n_new) self.rewards.extend([0.0] * n_new) From 8049af9c978ab1c008a3924697087839f28d5655 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 18:27:38 +0300 Subject: [PATCH 37/57] fix: add new tools index based --- packages/valory/skills/decision_maker_abci/policy.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index e967c8d79..f87de1011 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -85,10 +85,14 @@ def reward_rates(self) -> List[float]: for reward, count in zip(self.rewards, self.counts) ] - def add_new_tools(self, n_new: int) -> None: + def add_new_tools(self, indexes: List[int], avoid_shift: bool = False) -> None: """Add new tools to the current policy.""" - self.counts.extend([0] * n_new) - self.rewards.extend([0.0] * n_new) + if avoid_shift: + indexes = sorted(indexes, reverse=True) + + for i in indexes: + self.counts.insert(i, self.initial_value) + self.rewards.insert(i, float(self.initial_value)) def remove_tools(self, indexes: List[int], avoid_shift: bool = False) -> None: """Remove the knowledge for the tools corresponding to the given indexes.""" From d28d5a9366cf1f13e32cb3a6ee7c5af22f94cb67 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 18:28:33 +0300 Subject: [PATCH 38/57] refactor: create a method to get the best tool The best tool is chosen based on the maximum reward rate. --- .../valory/skills/decision_maker_abci/behaviours/reedem.py | 2 +- packages/valory/skills/decision_maker_abci/policy.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index cc1d5233d..efd4f7bfe 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -124,7 +124,7 @@ def _stats_report(self) -> None: f"\tTimes used: {self.policy.counts[i]}\n" f"\tReward rate: {self.policy.reward_rates[i]}\n" ) - stats_report += f"Best tool so far is {self.policy.select_tool()}." + stats_report += f"Best tool so far is {self.policy.best_tool}." self.context.logger.info(stats_report) def update_redeem_info(self, chunk: list) -> Generator: diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index f87de1011..0600d4f72 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -85,6 +85,11 @@ def reward_rates(self) -> List[float]: for reward, count in zip(self.rewards, self.counts) ] + @property + def best_tool(self) -> int: + """Get the best tool.""" + return argmax(self.reward_rates) + def add_new_tools(self, indexes: List[int], avoid_shift: bool = False) -> None: """Add new tools to the current policy.""" if avoid_shift: @@ -115,7 +120,7 @@ def select_tool(self) -> Optional[int]: if sum(self.counts) == 0 or random.random() < self.eps: # nosec return self.random_tool - return argmax(self.reward_rates) + return self.best_tool def add_reward(self, index: int, reward: float) -> None: """Add a reward for the tool corresponding to the given index.""" From f9f8cbe3e871d66fcf673b2ec0bcca82783387ad Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 18:43:04 +0300 Subject: [PATCH 39/57] refactor: remove unused answers --- packages/valory/skills/decision_maker_abci/redeem_info.py | 1 - .../skills/market_manager_abci/graph_tooling/queries/omen.py | 5 ----- 2 files changed, 6 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/redeem_info.py b/packages/valory/skills/decision_maker_abci/redeem_info.py index 33e4d5e51..082c0c9b1 100644 --- a/packages/valory/skills/decision_maker_abci/redeem_info.py +++ b/packages/valory/skills/decision_maker_abci/redeem_info.py @@ -52,7 +52,6 @@ class Question: id: bytes data: str - answers: List def __post_init__(self) -> None: """Post initialization to adjust the values.""" diff --git a/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py b/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py index 974bb5910..3f18fc881 100644 --- a/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py +++ b/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py @@ -83,11 +83,6 @@ question { id data - answers { - id - answer - bondAggregate - } } templateId } From 751a0bf82aaba6a768768ea6eedda9e2ee6f3493 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 18:49:14 +0300 Subject: [PATCH 40/57] refactor: update utilized tools on redeeming [no ci] --- .../decision_maker_abci/behaviours/reedem.py | 18 ++++++++++++++---- .../skills/decision_maker_abci/payloads.py | 1 + .../decision_maker_abci/states/redeem.py | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index efd4f7bfe..c271a15ae 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -19,6 +19,7 @@ """This module contains the redeeming state of the decision-making abci app.""" +import json from abc import ABC from collections import defaultdict from sys import maxsize @@ -66,6 +67,7 @@ class RedeemInfoBehaviour(DecisionMakerBaseBehaviour, QueryingBehaviour, ABC): def __init__(self, **kwargs: Any) -> None: """Initialize a `RedeemInfo` object.""" super().__init__(**kwargs) + self.utilized_tools: Dict[str, int] = {} self.trades: Set[Trade] = set() # blocks in which the markets were created mapped to the corresponding condition ids @@ -89,6 +91,7 @@ def synced_timestamp(self) -> int: def setup(self) -> None: """Setup the behaviour""" self._policy = self.synchronized_data.policy + self.utilized_tools = self.synchronized_data.utilized_tools def _set_block_number(self, trade: Trade) -> Generator: """Set the block number of the given trade's market.""" @@ -112,8 +115,12 @@ def _set_block_number(self, trade: Trade) -> Generator: def _update_policy(self, update: Trade) -> None: """Update the policy.""" claimable_xdai = self.wei_to_native(update.claimable_amount) - tool_index = self.synchronized_data.utilized_tools[update.transactionHash] - self.policy.add_reward(tool_index, claimable_xdai) + # the mapping might not contain a tool for a bet placement because it might have happened on a previous run + tool_index = self.utilized_tools.get(update.transactionHash, None) + if tool_index is not None: + # we try to avoid an ever-increasing dictionary of utilized tools by removing a tool when not needed anymore + del self.utilized_tools[update.transactionHash] + self.policy.add_reward(tool_index, claimable_xdai) def _stats_report(self) -> None: """Report policy statistics.""" @@ -580,11 +587,14 @@ def async_act(self) -> Generator: yield from self._clean_redeem_info() agent = self.context.agent_address redeem_tx_hex = yield from self._prepare_safe_tx() - tx_submitter = policy = None + tx_submitter = policy = utilized_tools = None if redeem_tx_hex is not None: tx_submitter = self.matching_round.auto_round_id() policy = self.policy.serialize() + utilized_tools = json.dumps(self.utilized_tools) - payload = RedeemPayload(agent, tx_submitter, redeem_tx_hex, policy) + payload = RedeemPayload( + agent, tx_submitter, redeem_tx_hex, policy, utilized_tools + ) yield from self.finish_behaviour(payload) diff --git a/packages/valory/skills/decision_maker_abci/payloads.py b/packages/valory/skills/decision_maker_abci/payloads.py index b393544d1..f07b08617 100644 --- a/packages/valory/skills/decision_maker_abci/payloads.py +++ b/packages/valory/skills/decision_maker_abci/payloads.py @@ -55,6 +55,7 @@ class RedeemPayload(MultisigTxPayload): """Represents a transaction payload for preparing an on-chain transaction for redeeming.""" policy: Optional[str] + utilized_tools: Optional[str] @dataclass(frozen=True) diff --git a/packages/valory/skills/decision_maker_abci/states/redeem.py b/packages/valory/skills/decision_maker_abci/states/redeem.py index 7c40aeb73..d222a2249 100644 --- a/packages/valory/skills/decision_maker_abci/states/redeem.py +++ b/packages/valory/skills/decision_maker_abci/states/redeem.py @@ -39,5 +39,6 @@ class RedeemRound(TxPreparationRound): payload_class: Type[MultisigTxPayload] = RedeemPayload selection_key = TxPreparationRound.selection_key + ( get_name(SynchronizedData.policy), + get_name(SynchronizedData.utilized_tools), ) none_event = Event.NO_REDEEMING From aafdd88f905e10d1a95aaa4d51df7bd570f8643f Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 19:29:35 +0300 Subject: [PATCH 41/57] refactor: create property for the mech tools --- .../behaviours/tool_selection.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index b5a46b609..822bfa053 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -48,7 +48,7 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self._mech_id: int = 0 self._mech_hash: str = "" - self.mech_tools: Optional[List[str]] = None + self._mech_tools: Optional[List[str]] = None @property def mech_id(self) -> int: @@ -70,6 +70,18 @@ def mech_hash(self, mech_hash: str) -> None: """Set the hash of the mech agent.""" self._mech_hash = mech_hash + @property + def mech_tools(self) -> List[str]: + """Get the mech agent's tools.""" + if self._mech_tools is None: + raise ValueError("The mech's tools have not been set.") + return self._mech_tools + + @mech_tools.setter + def mech_tools(self, mech_tools: List[str]) -> None: + """Set the mech agent's tools.""" + self._mech_tools = mech_tools + @property def mech_tools_api(self) -> AgentToolsSpecs: """Get the mech agent api specs.""" @@ -126,8 +138,8 @@ def _get_mech_tools(self) -> WaitableConditionType: self.context.logger.info(f"Retrieved the mech agent's tools: {res}.") if len(res) == 0: - res = None self.context.logger.error("The mech agent's tools are empty!") + return False self.mech_tools = res self.mech_tools_api.reset_retries() return True @@ -161,7 +173,7 @@ def _adjust_policy_tools(self, tools: List[str]) -> None: if n_new_tools > 0: self.policy.add_new_tools(n_new_tools) - def _set_policy(self, tools: List[str]) -> None: + def _set_policy(self) -> None: """Set the E Greedy Policy.""" if self.synchronized_data.period_count == 0: self._policy = EGreedyPolicy.initial_state(self.params.epsilon, len(tools)) @@ -172,11 +184,10 @@ def _set_policy(self, tools: List[str]) -> None: def _select_tool(self) -> Generator[None, None, Optional[int]]: """Select a Mech tool based on an e-greedy policy and return its index.""" yield from self._get_tools() - if self.mech_tools is None: - return None - - self._set_policy(self.mech_tools) - return self.policy.select_tool() + self._set_policy() + selected = self.policy.select_tool() + self.context.logger.info(f"Selected the mech tool {selected!r}.") + return selected def async_act(self) -> Generator: """Do the action.""" From 738b565fa1f71b94c39576a5f3f8754aa45b0011 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 19:30:42 +0300 Subject: [PATCH 42/57] fix: keep only the relevant mech tools --- .../decision_maker_abci/behaviours/tool_selection.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index 822bfa053..4d3e3c126 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -137,8 +137,14 @@ def _get_mech_tools(self) -> WaitableConditionType: return False self.context.logger.info(f"Retrieved the mech agent's tools: {res}.") + # keep only the relevant mech tools, sorted + # we sort the tools to avoid using dictionaries in the policy implementation, + # so that we can easily assess which index corresponds to which tool + res = sorted(set(res) - self.params.irrelevant_tools) + self.context.logger.info(f"Relevant tools to the prediction task: {res}.") + if len(res) == 0: - self.context.logger.error("The mech agent's tools are empty!") + self.context.logger.error("The relevant mech agent's tools are empty!") return False self.mech_tools = res self.mech_tools_api.reset_retries() @@ -176,7 +182,8 @@ def _adjust_policy_tools(self, tools: List[str]) -> None: def _set_policy(self) -> None: """Set the E Greedy Policy.""" if self.synchronized_data.period_count == 0: - self._policy = EGreedyPolicy.initial_state(self.params.epsilon, len(tools)) + n_relevant = len(self.mech_tools) + self._policy = EGreedyPolicy.initial_state(self.params.epsilon, n_relevant) else: self._policy = self.synchronized_data.policy self._adjust_policy_tools(tools) From b8d3ef6920bbd02ebd61d038d9faf27d2915058e Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 19:31:07 +0300 Subject: [PATCH 43/57] fix: set specs before http request --- .../skills/decision_maker_abci/behaviours/tool_selection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index 4d3e3c126..773ac5362 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -121,6 +121,7 @@ def _get_mech_hash(self) -> WaitableConditionType: def _get_mech_tools(self) -> WaitableConditionType: """Get the mech agent's tools from IPFS.""" + self.set_mech_agent_specs() specs = self.mech_tools_api.get_spec() res_raw = yield from self.get_http_response(**specs) res = self.mech_tools_api.process_response(res_raw) From da4c08f567603441a4ab3645cf6033bdea2b6935 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 19:31:43 +0300 Subject: [PATCH 44/57] fix: the tools' adjustment logic [no ci] --- .../behaviours/tool_selection.py | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index 773ac5362..a2b5376ed 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -162,23 +162,21 @@ def _get_tools( ): yield from self.wait_for_condition_with_sleep(step) - def _adjust_policy_tools(self, tools: List[str]) -> None: + def _adjust_policy_tools(self) -> None: """Add or remove tools from the policy to match the remote tools.""" + local = self.synchronized_data.available_mech_tools + # remove tools if they are not available anymore - local = set(self.synchronized_data.available_mech_tools) - remote = set(tools) - relevant_remote = remote - self.params.irrelevant_tools - removed_tools_idx = [ - idx for idx, tool in enumerate(local) if tool not in relevant_remote - ] - if len(removed_tools_idx) > 0: - self.policy.remove_tools(removed_tools_idx) + # process the indices in reverse order to avoid index shifting when removing the unavailable tools later + reversed_idx = range(len(local) - 1, -1, -1) + removed_idx = [idx for idx in reversed_idx if local[idx] not in self.mech_tools] + self.policy.remove_tools(removed_idx) # add tools if there are new ones available - new_tools = remote - local - n_new_tools = len(new_tools) - if n_new_tools > 0: - self.policy.add_new_tools(n_new_tools) + # process the indices in reverse order to avoid index shifting when adding the new tools later + reversed_idx = range(len(self.mech_tools) - 1, -1, -1) + new_idx = [idx for idx in reversed_idx if self.mech_tools[idx] not in local] + self.policy.add_new_tools(new_idx) def _set_policy(self) -> None: """Set the E Greedy Policy.""" @@ -187,7 +185,7 @@ def _set_policy(self) -> None: self._policy = EGreedyPolicy.initial_state(self.params.epsilon, n_relevant) else: self._policy = self.synchronized_data.policy - self._adjust_policy_tools(tools) + self._adjust_policy_tools() def _select_tool(self) -> Generator[None, None, Optional[int]]: """Select a Mech tool based on an e-greedy policy and return its index.""" From ac2c027eb488be8b03b35849366760e4f05d33f6 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 19:47:29 +0300 Subject: [PATCH 45/57] refactor: utilize existing third-party package for registry https://github.com/valory-xyz/trader/pull/94#discussion_r1332825595 --- .gitignore | 1 + packages/packages.json | 4 +- packages/valory/agents/trader/aea-config.yaml | 1 + .../contracts/agent_registry/__init__.py | 20 - .../agent_registry/build/AgentRegistry.json | 1046 ----------------- .../contracts/agent_registry/contract.py | 64 - .../contracts/agent_registry/contract.yaml | 23 - .../behaviours/tool_selection.py | 46 +- 8 files changed, 28 insertions(+), 1177 deletions(-) delete mode 100644 packages/valory/contracts/agent_registry/__init__.py delete mode 100644 packages/valory/contracts/agent_registry/build/AgentRegistry.json delete mode 100644 packages/valory/contracts/agent_registry/contract.py delete mode 100644 packages/valory/contracts/agent_registry/contract.yaml diff --git a/.gitignore b/.gitignore index f2695e299..7393faa15 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ packages/valory/skills/termination_abci/ packages/valory/contracts/gnosis_safe_proxy_factory/ packages/valory/contracts/multisend/ +packages/valory/contracts/agent_registry/ packages/valory/contracts/service_registry/ packages/valory/contracts/gnosis_safe/ diff --git a/packages/packages.json b/packages/packages.json index c9703f36b..633aef3de 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -11,8 +11,7 @@ "contract/valory/mech/0.1.0": "bafybeiehjnwd63xp6ttfsskhxsphnvpjpwrfqzfltjvqn6mjqkemoo2qge", "contract/valory/realitio/0.1.0": "bafybeicdgm2a7evjw6szcpo3uaam5mzd6axtevtzwvejr6uaeymbg437da", "contract/valory/realitio_proxy/0.1.0": "bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy", - "contract/valory/conditional_tokens/0.1.0": "bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa", - "contract/valory/agent_registry/0.1.0": "bafybeid3knh7d7uzvtkbdg7xxdjajjb3lhusxju46iydkt5p4wklc4gz5e" + "contract/valory/conditional_tokens/0.1.0": "bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa" }, "third_party": { "protocol/open_aea/signing/1.0.0": "bafybeifuxs7gdg2okbn7uofymenjlmnih2wxwkym44lsgwmklgwuckxm2m", @@ -35,6 +34,7 @@ "contract/valory/gnosis_safe_proxy_factory/0.1.0": "bafybeiaylgywx2qtoaddokexql3d4iqfz5l7rlm5q24lzbn36we3ovfjmi", "contract/valory/gnosis_safe/0.1.0": "bafybeih7gkbdtnhkc3i53mbsj7bcihqa7xau6ewsnew4kkul7phwb4ucjm", "contract/valory/service_registry/0.1.0": "bafybeihtsj4dpoi4iaml2jctlth2y26diam3npkfe736vpg67tgb6th53a", + "contract/valory/agent_registry/0.1.0": "bafybeielrs5qih3r6qhnily6x4h4j4j6kux6eqr546homow4c5ljgfyljq", "skill/valory/transaction_settlement_abci/0.1.0": "bafybeiglsnh2hvfau5gab7requh34k4sbqwbjvrhhqjpes4hakcwq46cpi", "contract/valory/multisend/0.1.0": "bafybeie7m7pjbnw7cccpbvmbgkut24dtlt4cgvug3tbac7gej37xvwbv3a", "skill/valory/termination_abci/0.1.0": "bafybeigcsls72uosoui2y5ppmnvsljjhnxakkeh3fdohklcg66aqq4g7xu" diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 67b927d95..61570c81a 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -25,6 +25,7 @@ contracts: - valory/conditional_tokens:0.1.0:bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa - valory/realitio:0.1.0:bafybeicdgm2a7evjw6szcpo3uaam5mzd6axtevtzwvejr6uaeymbg437da - valory/realitio_proxy:0.1.0:bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy +- valory/agent_registry:0.1.0:bafybeib6odummk6qqietjekpljkmhqfxk7kv56kv6pyfsnnanews625ncy protocols: - open_aea/signing:1.0.0:bafybeifuxs7gdg2okbn7uofymenjlmnih2wxwkym44lsgwmklgwuckxm2m - valory/abci:0.1.0:bafybeigootsvqpk6th5xpdtzanxum3earifrrezfyhylfrit7yvqdrtgpe diff --git a/packages/valory/contracts/agent_registry/__init__.py b/packages/valory/contracts/agent_registry/__init__.py deleted file mode 100644 index cf1e8467e..000000000 --- a/packages/valory/contracts/agent_registry/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 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 support resources for the agent registry contract.""" diff --git a/packages/valory/contracts/agent_registry/build/AgentRegistry.json b/packages/valory/contracts/agent_registry/build/AgentRegistry.json deleted file mode 100644 index 79a56dba2..000000000 --- a/packages/valory/contracts/agent_registry/build/AgentRegistry.json +++ /dev/null @@ -1,1046 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "AgentRegistry", - "sourceName": "contracts/AgentRegistry.sol", - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "_name", - "type": "string" - }, - { - "internalType": "string", - "name": "_symbol", - "type": "string" - }, - { - "internalType": "string", - "name": "_baseURI", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "AgentInstanceRegistered", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "AgentInstancesSlotsFilled", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - } - ], - "name": "AgentNotFound", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "AgentNotInService", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "componentId", - "type": "uint256" - } - ], - "name": "ComponentNotFound", - "type": "error" - }, - { - "inputs": [], - "name": "HashExists", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "sent", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expected", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "IncorrectAgentBondingValue", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "sent", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expected", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "IncorrectRegistrationDepositValue", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "manager", - "type": "address" - } - ], - "name": "ManagerOnly", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "provided", - "type": "address" - }, - { - "internalType": "address", - "name": "expected", - "type": "address" - }, - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "OnlyOwnServiceMultisig", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "OperatorHasNoInstances", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - } - ], - "name": "OperatorOnly", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "provided", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "max", - "type": "uint256" - } - ], - "name": "Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnerOnly", - "type": "error" - }, - { - "inputs": [], - "name": "Paused", - "type": "error" - }, - { - "inputs": [], - "name": "ReentrancyGuard", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "ServiceMustBeInactive", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "TransferFailed", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "multisig", - "type": "address" - } - ], - "name": "UnauthorizedMultisig", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - } - ], - "name": "WrongAgentId", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "numValues1", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "numValues2", - "type": "uint256" - } - ], - "name": "WrongArrayLength", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "WrongOperator", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "state", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "serviceId", - "type": "uint256" - } - ], - "name": "WrongServiceState", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "currentThreshold", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minThreshold", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "maxThreshold", - "type": "uint256" - } - ], - "name": "WrongThreshold", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAddress", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroValue", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "approved", - "type": "bool" - } - ], - "name": "ApprovalForAll", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "baseURI", - "type": "string" - } - ], - "name": "BaseURIChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "agentHash", - "type": "bytes32" - } - ], - "name": "CreateAgent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "manager", - "type": "address" - } - ], - "name": "ManagerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "agentHash", - "type": "bytes32" - } - ], - "name": "UpdateAgentHash", - "type": "event" - }, - { - "inputs": [], - "name": "CID_PREFIX", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "VERSION", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "baseURI", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newManager", - "type": "address" - } - ], - "name": "changeManager", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "changeOwner", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "agentOwner", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "agentHash", - "type": "bytes32" - } - ], - "name": "create", - "outputs": [ - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "unitId", - "type": "uint256" - } - ], - "name": "exists", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "getApproved", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - } - ], - "name": "getHashes", - "outputs": [ - { - "internalType": "uint256", - "name": "numHashes", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "agentHashes", - "type": "bytes32[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "isApprovedForAll", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "manager", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "mapAgentIdHashes", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "internalType": "bool", - "name": "approved", - "type": "bool" - } - ], - "name": "setApprovalForAll", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "bURI", - "type": "string" - } - ], - "name": "setBaseURI", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "tokenByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "unitId", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "unitId", - "type": "uint256" - } - ], - "name": "tokenURI", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "agentId", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "agentHash", - "type": "bytes32" - } - ], - "name": "updateHash", - "outputs": [ - { - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bytecode": "", - "deployedBytecode": "", - "linkReferences": {}, - "deployedLinkReferences": {} -} \ No newline at end of file diff --git a/packages/valory/contracts/agent_registry/contract.py b/packages/valory/contracts/agent_registry/contract.py deleted file mode 100644 index 9acf29aad..000000000 --- a/packages/valory/contracts/agent_registry/contract.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 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 class to connect to the Agent Registry contract.""" - -from aea.common import JSONLike -from aea.configurations.base import PublicId -from aea.contracts.base import Contract -from aea.crypto.base import LedgerApi - - -class AgentRegistryContract(Contract): - """The Agent Registry contract.""" - - contract_id = PublicId.from_str("valory/agent_registry:0.1.0") - - @classmethod - def get_hash( - cls, - ledger_api: LedgerApi, - contract_address: str, - agent_id: int, - ) -> JSONLike: - """Retrieve an operator given its agent instance.""" - - contract_instance = cls.get_instance(ledger_api, contract_address) - res = contract_instance.functions.getHashes(agent_id).call() - # ensure that the returned object has the expected format - if len(res) != 2: - msg = f"The `getHashes` method for {contract_address=} returned data in an unexpected format: {res}" - return dict(error=msg) - - # get the agent hashes - hashes = res.pop(-1) - # ensure that there are hashes returned for the agent - if len(hashes) == 0: - msg = f"The `getHashes` method for {contract_address=} returned no hashes for {agent_id=}: {res}" - return dict(error=msg) - - # get the most recent agent hash - hash_ = hashes.pop(-1) - # ensure that the hash is in bytes - if not isinstance(hash_, bytes): - msg = f"The `getHashes` method for {contract_address=} returned non-bytes {hash_=} for {agent_id=}: {res}" - return dict(error=msg) - - # return the hash in hex - return dict(hash=hash_.hex()) diff --git a/packages/valory/contracts/agent_registry/contract.yaml b/packages/valory/contracts/agent_registry/contract.yaml deleted file mode 100644 index 9e40c0f3e..000000000 --- a/packages/valory/contracts/agent_registry/contract.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: agent_registry -author: valory -version: 0.1.0 -type: contract -description: Agent Registry contract -license: Apache-2.0 -aea_version: '>=1.0.0, <2.0.0' -fingerprint: - __init__.py: bafybeid3wfzglolebuo6jrrsopswzu4lk77bm76mvw3euizlsjtnt3wmgu - build/AgentRegistry.json: bafybeicoe5elvvsv2neiirsdn4uddrilizmyib3x4mvpklr7olhj2kh4ue - contract.py: bafybeihrv6blme3v6diwci6zxxn72qbg5sanzmfq5tobhs4375ebcuyday -fingerprint_ignore_patterns: [] -contracts: [] -class_name: AgentRegistryContract -contract_interface_paths: - ethereum: build/AgentRegistry.json -dependencies: - open-aea-ledger-ethereum: - version: ==1.38.0 - open-aea-test-autonomy: - version: ==0.12.0 - open-aea-web3: - version: ==6.0.1 diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index a2b5376ed..92e1e07fb 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -26,7 +26,6 @@ from packages.valory.protocols.contract_api import ContractApiMessage from packages.valory.skills.abstract_round_abci.base import get_name from packages.valory.skills.decision_maker_abci.behaviours.base import ( - CID_PREFIX, DecisionMakerBaseBehaviour, WaitableConditionType, ) @@ -47,7 +46,7 @@ def __init__(self, **kwargs: Any) -> None: """Initialize Behaviour.""" super().__init__(**kwargs) self._mech_id: int = 0 - self._mech_hash: str = "" + self._mech_token_uri: str = "" self._mech_tools: Optional[List[str]] = None @property @@ -61,14 +60,14 @@ def mech_id(self, mech_id: int) -> None: self._mech_id = mech_id @property - def mech_hash(self) -> str: - """Get the hash of the mech agent.""" - return self._mech_hash + def mech_token_uri(self) -> str: + """Get the token URI of the mech agent.""" + return self._mech_token_uri - @mech_hash.setter - def mech_hash(self, mech_hash: str) -> None: - """Set the hash of the mech agent.""" - self._mech_hash = mech_hash + @mech_token_uri.setter + def mech_token_uri(self, mech_hash: str) -> None: + """Set the token URI of the mech agent.""" + self._mech_token_uri = mech_hash @property def mech_tools(self) -> List[str]: @@ -89,11 +88,9 @@ def mech_tools_api(self) -> AgentToolsSpecs: def set_mech_agent_specs(self) -> None: """Set the mech's agent specs.""" - full_ipfs_hash = CID_PREFIX + self.mech_hash - ipfs_link = self.params.ipfs_address + full_ipfs_hash # The url needs to be dynamically generated as it depends on the ipfs hash self.mech_tools_api.__dict__["_frozen"] = False - self.mech_tools_api.url = ipfs_link + self.mech_tools_api.url = self.mech_token_uri self.mech_tools_api.__dict__["_frozen"] = True def _get_mech_id(self) -> WaitableConditionType: @@ -106,18 +103,23 @@ def _get_mech_id(self) -> WaitableConditionType: return result - def _get_mech_hash(self) -> WaitableConditionType: - """Get the mech's hash.""" - result = yield from self.contract_interact( + def _get_mech_uri(self) -> WaitableConditionType: + """Get the mech's token URI.""" + contract_id = str(AgentRegistryContract.contract_id) + contract_callable = "get_token_uri" + response_msg = yield from self.get_contract_api_response( performative=ContractApiMessage.Performative.GET_RAW_TRANSACTION, # type: ignore contract_address=self.params.agent_registry_address, - contract_public_id=AgentRegistryContract.contract_id, - contract_callable="get_hash", - data_key="hash", - placeholder=get_name(ToolSelectionBehaviour.mech_hash), - agent_id=self.mech_id, + contract_id=contract_id, + contract_callable=contract_callable, + token_id=self.mech_id, ) - return result + if response_msg.performative != ContractApiMessage.Performative.RAW_TRANSACTION: + self.default_error(contract_id, contract_callable, response_msg) + return False + + self.mech_token_uri = response_msg.raw_transaction.body + return True def _get_mech_tools(self) -> WaitableConditionType: """Get the mech agent's tools from IPFS.""" @@ -157,7 +159,7 @@ def _get_tools( """Get the Mech's tools.""" for step in ( self._get_mech_id, - self._get_mech_hash, + self._get_mech_uri, self._get_mech_tools, ): yield from self.wait_for_condition_with_sleep(step) From 8451f3a50dc59b4f520f273aacbce699283a8913 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 20:12:09 +0300 Subject: [PATCH 46/57] revert: existing third-party registry package utilization This reverts commit 22875b1061f6792767b69a562314602b1746a845. --- .gitignore | 1 - packages/packages.json | 4 +- packages/valory/agents/trader/aea-config.yaml | 1 - .../contracts/agent_registry/__init__.py | 20 + .../agent_registry/build/AgentRegistry.json | 1046 +++++++++++++++++ .../contracts/agent_registry/contract.py | 64 + .../contracts/agent_registry/contract.yaml | 23 + .../behaviours/tool_selection.py | 46 +- 8 files changed, 1177 insertions(+), 28 deletions(-) create mode 100644 packages/valory/contracts/agent_registry/__init__.py create mode 100644 packages/valory/contracts/agent_registry/build/AgentRegistry.json create mode 100644 packages/valory/contracts/agent_registry/contract.py create mode 100644 packages/valory/contracts/agent_registry/contract.yaml diff --git a/.gitignore b/.gitignore index 7393faa15..f2695e299 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ packages/valory/skills/termination_abci/ packages/valory/contracts/gnosis_safe_proxy_factory/ packages/valory/contracts/multisend/ -packages/valory/contracts/agent_registry/ packages/valory/contracts/service_registry/ packages/valory/contracts/gnosis_safe/ diff --git a/packages/packages.json b/packages/packages.json index 633aef3de..c9703f36b 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -11,7 +11,8 @@ "contract/valory/mech/0.1.0": "bafybeiehjnwd63xp6ttfsskhxsphnvpjpwrfqzfltjvqn6mjqkemoo2qge", "contract/valory/realitio/0.1.0": "bafybeicdgm2a7evjw6szcpo3uaam5mzd6axtevtzwvejr6uaeymbg437da", "contract/valory/realitio_proxy/0.1.0": "bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy", - "contract/valory/conditional_tokens/0.1.0": "bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa" + "contract/valory/conditional_tokens/0.1.0": "bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa", + "contract/valory/agent_registry/0.1.0": "bafybeid3knh7d7uzvtkbdg7xxdjajjb3lhusxju46iydkt5p4wklc4gz5e" }, "third_party": { "protocol/open_aea/signing/1.0.0": "bafybeifuxs7gdg2okbn7uofymenjlmnih2wxwkym44lsgwmklgwuckxm2m", @@ -34,7 +35,6 @@ "contract/valory/gnosis_safe_proxy_factory/0.1.0": "bafybeiaylgywx2qtoaddokexql3d4iqfz5l7rlm5q24lzbn36we3ovfjmi", "contract/valory/gnosis_safe/0.1.0": "bafybeih7gkbdtnhkc3i53mbsj7bcihqa7xau6ewsnew4kkul7phwb4ucjm", "contract/valory/service_registry/0.1.0": "bafybeihtsj4dpoi4iaml2jctlth2y26diam3npkfe736vpg67tgb6th53a", - "contract/valory/agent_registry/0.1.0": "bafybeielrs5qih3r6qhnily6x4h4j4j6kux6eqr546homow4c5ljgfyljq", "skill/valory/transaction_settlement_abci/0.1.0": "bafybeiglsnh2hvfau5gab7requh34k4sbqwbjvrhhqjpes4hakcwq46cpi", "contract/valory/multisend/0.1.0": "bafybeie7m7pjbnw7cccpbvmbgkut24dtlt4cgvug3tbac7gej37xvwbv3a", "skill/valory/termination_abci/0.1.0": "bafybeigcsls72uosoui2y5ppmnvsljjhnxakkeh3fdohklcg66aqq4g7xu" diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 61570c81a..67b927d95 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -25,7 +25,6 @@ contracts: - valory/conditional_tokens:0.1.0:bafybeicxwjdbmjajgr5rsmadtkxxwmcm42r2htef3tvng73uzib4hmb6qa - valory/realitio:0.1.0:bafybeicdgm2a7evjw6szcpo3uaam5mzd6axtevtzwvejr6uaeymbg437da - valory/realitio_proxy:0.1.0:bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy -- valory/agent_registry:0.1.0:bafybeib6odummk6qqietjekpljkmhqfxk7kv56kv6pyfsnnanews625ncy protocols: - open_aea/signing:1.0.0:bafybeifuxs7gdg2okbn7uofymenjlmnih2wxwkym44lsgwmklgwuckxm2m - valory/abci:0.1.0:bafybeigootsvqpk6th5xpdtzanxum3earifrrezfyhylfrit7yvqdrtgpe diff --git a/packages/valory/contracts/agent_registry/__init__.py b/packages/valory/contracts/agent_registry/__init__.py new file mode 100644 index 000000000..cf1e8467e --- /dev/null +++ b/packages/valory/contracts/agent_registry/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 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 support resources for the agent registry contract.""" diff --git a/packages/valory/contracts/agent_registry/build/AgentRegistry.json b/packages/valory/contracts/agent_registry/build/AgentRegistry.json new file mode 100644 index 000000000..79a56dba2 --- /dev/null +++ b/packages/valory/contracts/agent_registry/build/AgentRegistry.json @@ -0,0 +1,1046 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "AgentRegistry", + "sourceName": "contracts/AgentRegistry.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "_baseURI", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "AgentInstanceRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "AgentInstancesSlotsFilled", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "AgentNotFound", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "AgentNotInService", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "componentId", + "type": "uint256" + } + ], + "name": "ComponentNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "HashExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expected", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "IncorrectAgentBondingValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expected", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "IncorrectRegistrationDepositValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "ManagerOnly", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "provided", + "type": "address" + }, + { + "internalType": "address", + "name": "expected", + "type": "address" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "OnlyOwnServiceMultisig", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "OperatorHasNoInstances", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "OperatorOnly", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "provided", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "Overflow", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnerOnly", + "type": "error" + }, + { + "inputs": [], + "name": "Paused", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuard", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "ServiceMustBeInactive", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "TransferFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "multisig", + "type": "address" + } + ], + "name": "UnauthorizedMultisig", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "WrongAgentId", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "numValues1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "numValues2", + "type": "uint256" + } + ], + "name": "WrongArrayLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "WrongOperator", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "state", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "serviceId", + "type": "uint256" + } + ], + "name": "WrongServiceState", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "currentThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxThreshold", + "type": "uint256" + } + ], + "name": "WrongThreshold", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroValue", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "baseURI", + "type": "string" + } + ], + "name": "BaseURIChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "CreateAgent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "ManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "UpdateAgentHash", + "type": "event" + }, + { + "inputs": [], + "name": "CID_PREFIX", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newManager", + "type": "address" + } + ], + "name": "changeManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "changeOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "agentOwner", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "create", + "outputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "unitId", + "type": "uint256" + } + ], + "name": "exists", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + } + ], + "name": "getHashes", + "outputs": [ + { + "internalType": "uint256", + "name": "numHashes", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "agentHashes", + "type": "bytes32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "manager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "mapAgentIdHashes", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "bURI", + "type": "string" + } + ], + "name": "setBaseURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "tokenByIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "unitId", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "unitId", + "type": "uint256" + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "agentHash", + "type": "bytes32" + } + ], + "name": "updateHash", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "", + "deployedBytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} \ No newline at end of file diff --git a/packages/valory/contracts/agent_registry/contract.py b/packages/valory/contracts/agent_registry/contract.py new file mode 100644 index 000000000..9acf29aad --- /dev/null +++ b/packages/valory/contracts/agent_registry/contract.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 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 class to connect to the Agent Registry contract.""" + +from aea.common import JSONLike +from aea.configurations.base import PublicId +from aea.contracts.base import Contract +from aea.crypto.base import LedgerApi + + +class AgentRegistryContract(Contract): + """The Agent Registry contract.""" + + contract_id = PublicId.from_str("valory/agent_registry:0.1.0") + + @classmethod + def get_hash( + cls, + ledger_api: LedgerApi, + contract_address: str, + agent_id: int, + ) -> JSONLike: + """Retrieve an operator given its agent instance.""" + + contract_instance = cls.get_instance(ledger_api, contract_address) + res = contract_instance.functions.getHashes(agent_id).call() + # ensure that the returned object has the expected format + if len(res) != 2: + msg = f"The `getHashes` method for {contract_address=} returned data in an unexpected format: {res}" + return dict(error=msg) + + # get the agent hashes + hashes = res.pop(-1) + # ensure that there are hashes returned for the agent + if len(hashes) == 0: + msg = f"The `getHashes` method for {contract_address=} returned no hashes for {agent_id=}: {res}" + return dict(error=msg) + + # get the most recent agent hash + hash_ = hashes.pop(-1) + # ensure that the hash is in bytes + if not isinstance(hash_, bytes): + msg = f"The `getHashes` method for {contract_address=} returned non-bytes {hash_=} for {agent_id=}: {res}" + return dict(error=msg) + + # return the hash in hex + return dict(hash=hash_.hex()) diff --git a/packages/valory/contracts/agent_registry/contract.yaml b/packages/valory/contracts/agent_registry/contract.yaml new file mode 100644 index 000000000..9e40c0f3e --- /dev/null +++ b/packages/valory/contracts/agent_registry/contract.yaml @@ -0,0 +1,23 @@ +name: agent_registry +author: valory +version: 0.1.0 +type: contract +description: Agent Registry contract +license: Apache-2.0 +aea_version: '>=1.0.0, <2.0.0' +fingerprint: + __init__.py: bafybeid3wfzglolebuo6jrrsopswzu4lk77bm76mvw3euizlsjtnt3wmgu + build/AgentRegistry.json: bafybeicoe5elvvsv2neiirsdn4uddrilizmyib3x4mvpklr7olhj2kh4ue + contract.py: bafybeihrv6blme3v6diwci6zxxn72qbg5sanzmfq5tobhs4375ebcuyday +fingerprint_ignore_patterns: [] +contracts: [] +class_name: AgentRegistryContract +contract_interface_paths: + ethereum: build/AgentRegistry.json +dependencies: + open-aea-ledger-ethereum: + version: ==1.38.0 + open-aea-test-autonomy: + version: ==0.12.0 + open-aea-web3: + version: ==6.0.1 diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index 92e1e07fb..a2b5376ed 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -26,6 +26,7 @@ from packages.valory.protocols.contract_api import ContractApiMessage from packages.valory.skills.abstract_round_abci.base import get_name from packages.valory.skills.decision_maker_abci.behaviours.base import ( + CID_PREFIX, DecisionMakerBaseBehaviour, WaitableConditionType, ) @@ -46,7 +47,7 @@ def __init__(self, **kwargs: Any) -> None: """Initialize Behaviour.""" super().__init__(**kwargs) self._mech_id: int = 0 - self._mech_token_uri: str = "" + self._mech_hash: str = "" self._mech_tools: Optional[List[str]] = None @property @@ -60,14 +61,14 @@ def mech_id(self, mech_id: int) -> None: self._mech_id = mech_id @property - def mech_token_uri(self) -> str: - """Get the token URI of the mech agent.""" - return self._mech_token_uri + def mech_hash(self) -> str: + """Get the hash of the mech agent.""" + return self._mech_hash - @mech_token_uri.setter - def mech_token_uri(self, mech_hash: str) -> None: - """Set the token URI of the mech agent.""" - self._mech_token_uri = mech_hash + @mech_hash.setter + def mech_hash(self, mech_hash: str) -> None: + """Set the hash of the mech agent.""" + self._mech_hash = mech_hash @property def mech_tools(self) -> List[str]: @@ -88,9 +89,11 @@ def mech_tools_api(self) -> AgentToolsSpecs: def set_mech_agent_specs(self) -> None: """Set the mech's agent specs.""" + full_ipfs_hash = CID_PREFIX + self.mech_hash + ipfs_link = self.params.ipfs_address + full_ipfs_hash # The url needs to be dynamically generated as it depends on the ipfs hash self.mech_tools_api.__dict__["_frozen"] = False - self.mech_tools_api.url = self.mech_token_uri + self.mech_tools_api.url = ipfs_link self.mech_tools_api.__dict__["_frozen"] = True def _get_mech_id(self) -> WaitableConditionType: @@ -103,23 +106,18 @@ def _get_mech_id(self) -> WaitableConditionType: return result - def _get_mech_uri(self) -> WaitableConditionType: - """Get the mech's token URI.""" - contract_id = str(AgentRegistryContract.contract_id) - contract_callable = "get_token_uri" - response_msg = yield from self.get_contract_api_response( + def _get_mech_hash(self) -> WaitableConditionType: + """Get the mech's hash.""" + result = yield from self.contract_interact( performative=ContractApiMessage.Performative.GET_RAW_TRANSACTION, # type: ignore contract_address=self.params.agent_registry_address, - contract_id=contract_id, - contract_callable=contract_callable, - token_id=self.mech_id, + contract_public_id=AgentRegistryContract.contract_id, + contract_callable="get_hash", + data_key="hash", + placeholder=get_name(ToolSelectionBehaviour.mech_hash), + agent_id=self.mech_id, ) - if response_msg.performative != ContractApiMessage.Performative.RAW_TRANSACTION: - self.default_error(contract_id, contract_callable, response_msg) - return False - - self.mech_token_uri = response_msg.raw_transaction.body - return True + return result def _get_mech_tools(self) -> WaitableConditionType: """Get the mech agent's tools from IPFS.""" @@ -159,7 +157,7 @@ def _get_tools( """Get the Mech's tools.""" for step in ( self._get_mech_id, - self._get_mech_uri, + self._get_mech_hash, self._get_mech_tools, ): yield from self.wait_for_condition_with_sleep(step) From 1c03a51efa3a431bb166745dcfd8aaaa22f1308e Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 21:33:37 +0300 Subject: [PATCH 47/57] fix: serialize tools before updating the db --- .../valory/skills/tx_settlement_multiplexer_abci/rounds.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py index 637dd3b29..e5e63835a 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py @@ -19,6 +19,7 @@ """This package contains the rounds of `TxSettlementMultiplexerAbciApp`.""" +import json from enum import Enum from typing import Any, Dict, Optional, Set, Tuple @@ -79,7 +80,8 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]: if event == Event.BET_PLACEMENT_DONE: utilized_tools = synced_data.utilized_tools utilized_tools[synced_data.final_tx_hash] = synced_data.mech_tool_idx - self.synchronized_data.update(utilized_tools=utilized_tools) + tools_update = json.dumps(utilized_tools) + self.synchronized_data.update(utilized_tools=tools_update) return synced_data, event From 531a8bfb38519323c9fc8e642af0e884493c6790 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 22:18:11 +0300 Subject: [PATCH 48/57] fix: add missing cross period persisted keys --- packages/valory/skills/decision_maker_abci/rounds.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/rounds.py b/packages/valory/skills/decision_maker_abci/rounds.py index 6d46ff17d..ad80a1ffe 100644 --- a/packages/valory/skills/decision_maker_abci/rounds.py +++ b/packages/valory/skills/decision_maker_abci/rounds.py @@ -199,6 +199,13 @@ class DecisionMakerAbciApp(AbciApp[Event]): RefillRequiredRound: {}, ImpossibleRound: {}, } + cross_period_persisted_keys = frozenset( + { + get_name(SynchronizedData.available_mech_tools), + get_name(SynchronizedData.policy), + get_name(SynchronizedData.utilized_tools), + } + ) final_states: Set[AppState] = { FinishedDecisionMakerRound, FinishedWithoutDecisionRound, From 8308183525fe9693adc51b2b826999851afb8bfc Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 22:18:54 +0300 Subject: [PATCH 49/57] refactor: clarify that statistics are for resolved markets --- packages/valory/skills/decision_maker_abci/behaviours/reedem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index c271a15ae..1487b9971 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -124,7 +124,7 @@ def _update_policy(self, update: Trade) -> None: def _stats_report(self) -> None: """Report policy statistics.""" - stats_report = "Policy statistics so far:\n" + stats_report = "Policy statistics so far (only for resolved markets):\n" for i, tool in enumerate(self.synchronized_data.available_mech_tools): stats_report += ( f"{tool} tool:\n" From fb597753a6657296a20048dd42e831b4e6d9b781 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 22:40:13 +0300 Subject: [PATCH 50/57] refactor: rename to a more descriptive name https://github.com/valory-xyz/trader/pull/94#discussion_r1332940569 --- packages/valory/agents/trader/aea-config.yaml | 2 +- packages/valory/services/trader/service.yaml | 8 ++++---- packages/valory/skills/decision_maker_abci/models.py | 2 +- packages/valory/skills/decision_maker_abci/skill.yaml | 2 +- packages/valory/skills/trader_abci/skill.yaml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 67b927d95..2cc5a97ae 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -187,7 +187,7 @@ models: redeeming_batch_size: ${int:5} slippage: ${float:0.01} redeem_margin_days: ${int:15} - epsilon: ${float:0.1} + policy_epsilon: ${float:0.1} irrelevant_tools: ${list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 306ae0ee5..d4fb84b85 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -104,7 +104,7 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} - epsilon: ${EPSILON:float:0.1} + policy_epsilon: ${POLICY_EPSILON:float:0.1} irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", @@ -173,7 +173,7 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} - epsilon: ${EPSILON:float:0.1} + policy_epsilon: ${POLICY_EPSILON:float:0.1} irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", @@ -240,7 +240,7 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} - epsilon: ${EPSILON:float:0.1} + policy_epsilon: ${POLICY_EPSILON:float:0.1} irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", @@ -307,7 +307,7 @@ type: skill redeeming_batch_size: ${REDEEMING_BATCH_SIZE:int:1} slippage: ${SLIPPAGE:float:0.01} redeem_margin_days: ${REDEEM_MARGIN_DAYS:int:15} - epsilon: ${EPSILON:float:0.1} + policy_epsilon: ${POLICY_EPSILON:float:0.1} irrelevant_tools: ${IRRELEVANT_TOOLS:list:["openai-text-davinci-002", "openai-text-davinci-003", "openai-gpt-3.5-turbo", "openai-gpt-4", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2", "stabilityai-stable-diffusion-512-v2-1", diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 145b82cca..b440f6678 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -122,7 +122,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # a slippage in the range of [0, 1] to apply to the `minOutcomeTokensToBuy` when buying shares on a fpmm self._slippage = 0.0 self.slippage: float = self._ensure("slippage", kwargs, float) - self.epsilon: float = self._ensure("epsilon", kwargs, float) + self.epsilon: float = self._ensure("policy_epsilon", kwargs, float) self.agent_registry_address: str = self._ensure( "agent_registry_address", kwargs, str ) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index a5b6e58bd..6369b4cd3 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -185,7 +185,7 @@ models: realitio_address: '0x79e32aE03fb27B07C89c0c568F80287C01ca2E57' redeeming_batch_size: 5 slippage: 0.01 - epsilon: 0.1 + policy_epsilon: 0.1 irrelevant_tools: - openai-text-davinci-002 - openai-text-davinci-003 diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index f8618730e..ccb9f2d06 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -169,7 +169,7 @@ models: redeeming_batch_size: 5 slippage: 0.01 redeem_margin_days: 15 - epsilon: 0.1 + policy_epsilon: 0.1 irrelevant_tools: - openai-text-davinci-002 - openai-text-davinci-003 From 20bc58ad6b6b54119f9f0dabff44e767ef7554f7 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 21 Sep 2023 22:43:00 +0300 Subject: [PATCH 51/57] refactor: extend check https://github.com/valory-xyz/trader/pull/94#discussion_r1333061333 --- packages/valory/skills/decision_maker_abci/policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index 0600d4f72..467893c43 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -52,8 +52,8 @@ class EGreedyPolicy: @classmethod def initial_state(cls, eps: float, n_tools: int) -> "EGreedyPolicy": """Return an instance on its initial state.""" - if n_tools == 0: - error = f"Cannot initialize an e Greedy Policy with {n_tools=}" + if n_tools <= 0 or eps > 1 or eps < 0: + error = f"Cannot initialize an e Greedy Policy with {eps=} and {n_tools=}" raise ValueError(error) return EGreedyPolicy( From 8854375a5862ff3cdca45922494987fedecd8d08 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 22 Sep 2023 10:30:37 +0300 Subject: [PATCH 52/57] refactor: create property to determine if it is first period --- .../valory/skills/decision_maker_abci/behaviours/base.py | 5 +++++ .../skills/decision_maker_abci/behaviours/tool_selection.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index 9ba4cf446..01a159fe9 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -141,6 +141,11 @@ def policy(self) -> EGreedyPolicy: ) return self._policy + @property + def is_first_period(self) -> bool: + """Return whether it is the first period of the service.""" + return self.synchronized_data.period_count == 0 + @staticmethod def wei_to_native(wei: int) -> float: """Convert WEI to native token.""" diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index a2b5376ed..65918ab32 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -180,7 +180,7 @@ def _adjust_policy_tools(self) -> None: def _set_policy(self) -> None: """Set the E Greedy Policy.""" - if self.synchronized_data.period_count == 0: + if self.is_first_period: n_relevant = len(self.mech_tools) self._policy = EGreedyPolicy.initial_state(self.params.epsilon, n_relevant) else: From 9a7b7c9129799e7b9226ddf037879a17e83bbf3b Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 22 Sep 2023 10:33:03 +0300 Subject: [PATCH 53/57] fix: initialize the utilized tools Otherwise, the cross-period key for the utilized tools may not exist if, for example, the bet placement round exits with a `TIE` event. --- .../behaviours/tool_selection.py | 13 +++++++++++-- .../valory/skills/decision_maker_abci/payloads.py | 1 + .../skills/decision_maker_abci/states/base.py | 2 +- .../decision_maker_abci/states/tool_selection.py | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index 65918ab32..6d9e94de3 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -20,7 +20,7 @@ """This module contains the behaviour of the skill which is responsible for selecting a mech tool.""" import json -from typing import Any, Generator, List, Optional +from typing import Any, Dict, Generator, List, Optional from packages.valory.contracts.agent_registry.contract import AgentRegistryContract from packages.valory.protocols.contract_api import ContractApiMessage @@ -82,6 +82,13 @@ def mech_tools(self, mech_tools: List[str]) -> None: """Set the mech agent's tools.""" self._mech_tools = mech_tools + @property + def utilized_tools(self) -> Dict[str, int]: + """Get the utilized tools.""" + if self.is_first_period: + return {} + return self.synchronized_data.utilized_tools + @property def mech_tools_api(self) -> AgentToolsSpecs: """Get the mech agent api specs.""" @@ -199,16 +206,18 @@ def async_act(self) -> Generator: """Do the action.""" with self.context.benchmark_tool.measure(self.behaviour_id).local(): - mech_tools = policy = None + mech_tools = policy = utilized_tools = None selected_tool = yield from self._select_tool() if selected_tool is not None: mech_tools = json.dumps(self.mech_tools) policy = self.policy.serialize() + utilized_tools = json.dumps(self.utilized_tools, sort_keys=True) payload = ToolSelectionPayload( self.context.agent_address, mech_tools, policy, + utilized_tools, selected_tool, ) diff --git a/packages/valory/skills/decision_maker_abci/payloads.py b/packages/valory/skills/decision_maker_abci/payloads.py index f07b08617..7d03ac0d3 100644 --- a/packages/valory/skills/decision_maker_abci/payloads.py +++ b/packages/valory/skills/decision_maker_abci/payloads.py @@ -78,4 +78,5 @@ class ToolSelectionPayload(BaseTxPayload): mech_tools: Optional[str] policy: Optional[str] + utilized_tools: Optional[str] index: Optional[int] diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index b29c24e2e..b84092b7d 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -106,7 +106,7 @@ def mech_tool(self) -> str: @property def utilized_tools(self) -> Dict[str, int]: """Get a mapping of the utilized tools' indexes for each transaction.""" - tools = str(self.db.get("utilized_tools", "{}")) + tools = str(self.db.get_strict("utilized_tools")) return json.loads(tools) @property diff --git a/packages/valory/skills/decision_maker_abci/states/tool_selection.py b/packages/valory/skills/decision_maker_abci/states/tool_selection.py index 982d281de..ff65aa3ff 100644 --- a/packages/valory/skills/decision_maker_abci/states/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/states/tool_selection.py @@ -41,6 +41,7 @@ class ToolSelectionRound(CollectSameUntilThresholdRound): selection_key = ( get_name(SynchronizedData.available_mech_tools), get_name(SynchronizedData.policy), + get_name(SynchronizedData.utilized_tools), get_name(SynchronizedData.mech_tool_idx), ) collection_key = get_name(SynchronizedData.participant_to_selection) From b05b7033130ae8e59a8f54296c43221bce529260 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 22 Sep 2023 10:34:25 +0300 Subject: [PATCH 54/57] refactor: sort the keys of the tools to ensure determinism --- packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py index e5e63835a..a7303fbc6 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/rounds.py @@ -80,7 +80,7 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]: if event == Event.BET_PLACEMENT_DONE: utilized_tools = synced_data.utilized_tools utilized_tools[synced_data.final_tx_hash] = synced_data.mech_tool_idx - tools_update = json.dumps(utilized_tools) + tools_update = json.dumps(utilized_tools, sort_keys=True) self.synchronized_data.update(utilized_tools=tools_update) return synced_data, event From 848234791a4baaa94fdb3b7617e77d91b573ca7f Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 22 Sep 2023 10:34:59 +0300 Subject: [PATCH 55/57] refactor: log the tool's name instead of its index --- .../valory/skills/decision_maker_abci/behaviours/reedem.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index 1487b9971..96c1c9a1c 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -125,13 +125,15 @@ def _update_policy(self, update: Trade) -> None: def _stats_report(self) -> None: """Report policy statistics.""" stats_report = "Policy statistics so far (only for resolved markets):\n" - for i, tool in enumerate(self.synchronized_data.available_mech_tools): + available_tools = self.synchronized_data.available_mech_tools + for i, tool in enumerate(available_tools): stats_report += ( f"{tool} tool:\n" f"\tTimes used: {self.policy.counts[i]}\n" f"\tReward rate: {self.policy.reward_rates[i]}\n" ) - stats_report += f"Best tool so far is {self.policy.best_tool}." + best_tool = available_tools[self.policy.best_tool] + stats_report += f"Best tool so far is {best_tool!r}." self.context.logger.info(stats_report) def update_redeem_info(self, chunk: list) -> Generator: From e075ac6ecbcf532a4fabbbc84d4879fd7652a470 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 22 Sep 2023 11:31:22 +0300 Subject: [PATCH 56/57] refactor: do not report stats if policy is in genesis state --- .../valory/skills/decision_maker_abci/behaviours/reedem.py | 3 ++- packages/valory/skills/decision_maker_abci/policy.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index 96c1c9a1c..4f257b8db 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -165,7 +165,8 @@ def update_redeem_info(self, chunk: list) -> Generator: if update == unique_obj: self.claimable_amounts[condition_id] += update.claimable_amount - self._stats_report() + if self.policy.has_updated: + self._stats_report() class RedeemBehaviour(RedeemInfoBehaviour): diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index 467893c43..96b9afa2b 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -77,6 +77,11 @@ def random_tool(self) -> int: """Get the index of a tool randomly.""" return random.randrange(self.n_tools) # nosec + @property + def has_updated(self) -> bool: + """Whether the policy has ever been updated since its genesis or not.""" + return sum(self.counts) > 0 + @property def reward_rates(self) -> List[float]: """Get the reward rates.""" From d831052c5eaaa3897f1c01487fa725c30ed88ec3 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 22 Sep 2023 11:40:45 +0300 Subject: [PATCH 57/57] chore: run generators --- packages/packages.json | 12 +++++----- packages/valory/agents/trader/aea-config.yaml | 8 +++---- packages/valory/services/trader/service.yaml | 2 +- .../skills/decision_maker_abci/skill.yaml | 24 +++++++++---------- .../skills/market_manager_abci/skill.yaml | 2 +- packages/valory/skills/trader_abci/skill.yaml | 6 ++--- .../tx_settlement_multiplexer_abci/skill.yaml | 4 ++-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index c9703f36b..4e30c4652 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { - "skill/valory/market_manager_abci/0.1.0": "bafybeibwe3tmsonkej2v5cnclsyfi4bfd5ievxzkrpc4lg6fqqk6s7hcny", - "skill/valory/decision_maker_abci/0.1.0": "bafybeifssrmowov77evtvevc7qophahlcskuxik573y2y4nmf64xz7oinm", - "skill/valory/trader_abci/0.1.0": "bafybeidm3awh7qul7ojgb2mthlhskymddd27fw2ojicvqkgsrpr2vmlhki", + "skill/valory/market_manager_abci/0.1.0": "bafybeig223xrxbtfx5adwhc7m6rpdbevsqm5osfq66oijucs2gzn4hehsm", + "skill/valory/decision_maker_abci/0.1.0": "bafybeieqyd5jek55q57lg77hey3oapppoosaphhyxxlulx52gg2ahkqdba", + "skill/valory/trader_abci/0.1.0": "bafybeighllbhqgeryjaew2heequ4iyaghevr3vnvvpx2pl3foqopk4k4zi", "contract/valory/market_maker/0.1.0": "bafybeiftimqgvrbval2lxp7au6y72amioo4gtcdth2dflrbwa47i6opyb4", - "agent/valory/trader/0.1.0": "bafybeiep2ccmexjgeqiijonjwggjrymdtss3otvx5jyf555yo2d43w346e", - "service/valory/trader/0.1.0": "bafybeia5hy7yuxm7hl5xtx57vc4x3ri6o4mfhaoeqrnwpjhlaucswcnrki", + "agent/valory/trader/0.1.0": "bafybeibabgxao6ljhmwiztsquug3v6i6jo4s3izlk4zs4so4jfnvfqbxnm", + "service/valory/trader/0.1.0": "bafybeiaq5frvxzehiqyifdvvs35tspv7a32wp7ve7u7o6nflrkvbza6yhu", "contract/valory/erc20/0.1.0": "bafybeifjwr6rwklgg2uk2zkfysn55qqy7dfi4jx7sek6lzdup37fynhpxe", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeib4up7sqeptbuyawjkn6zwucxdknk3c4ah7o3q5iwdkebz4y5fxmq", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeidel3rxm55y2qqewhmwroybs5j7t6ma6awmxbo7xjv3jvhmb6dv7m", "contract/valory/mech/0.1.0": "bafybeiehjnwd63xp6ttfsskhxsphnvpjpwrfqzfltjvqn6mjqkemoo2qge", "contract/valory/realitio/0.1.0": "bafybeicdgm2a7evjw6szcpo3uaam5mzd6axtevtzwvejr6uaeymbg437da", "contract/valory/realitio_proxy/0.1.0": "bafybeibvndq6756qck7forgeavhdbn6ykgqs2ufyg7n5g6qdfpveatxuwy", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 2cc5a97ae..4f3f43392 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -41,10 +41,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeifoihgilpfr76hc5skzspm6qehkwivx7ld2cy3veipcsi4gr2c7na - valory/termination_abci:0.1.0:bafybeigcsls72uosoui2y5ppmnvsljjhnxakkeh3fdohklcg66aqq4g7xu - valory/transaction_settlement_abci:0.1.0:bafybeiglsnh2hvfau5gab7requh34k4sbqwbjvrhhqjpes4hakcwq46cpi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeib4up7sqeptbuyawjkn6zwucxdknk3c4ah7o3q5iwdkebz4y5fxmq -- valory/market_manager_abci:0.1.0:bafybeibwe3tmsonkej2v5cnclsyfi4bfd5ievxzkrpc4lg6fqqk6s7hcny -- valory/decision_maker_abci:0.1.0:bafybeifssrmowov77evtvevc7qophahlcskuxik573y2y4nmf64xz7oinm -- valory/trader_abci:0.1.0:bafybeidm3awh7qul7ojgb2mthlhskymddd27fw2ojicvqkgsrpr2vmlhki +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidel3rxm55y2qqewhmwroybs5j7t6ma6awmxbo7xjv3jvhmb6dv7m +- valory/market_manager_abci:0.1.0:bafybeig223xrxbtfx5adwhc7m6rpdbevsqm5osfq66oijucs2gzn4hehsm +- valory/decision_maker_abci:0.1.0:bafybeieqyd5jek55q57lg77hey3oapppoosaphhyxxlulx52gg2ahkqdba +- valory/trader_abci:0.1.0:bafybeighllbhqgeryjaew2heequ4iyaghevr3vnvvpx2pl3foqopk4k4zi default_ledger: ethereum required_ledgers: - ethereum diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index d4fb84b85..cc2765eb0 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeiep2ccmexjgeqiijonjwggjrymdtss3otvx5jyf555yo2d43w346e +agent: valory/trader:0.1.0:bafybeibabgxao6ljhmwiztsquug3v6i6jo4s3izlk4zs4so4jfnvfqbxnm number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 6369b4cd3..e2a327c9d 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -12,35 +12,35 @@ fingerprint: README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i __init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky - behaviours/base.py: bafybeicvex6q2murzsr7dnkueg2zsbdkcufbtarlojjuactsxnlu5eg3ii + behaviours/base.py: bafybeiato4qxnc2kjjdtttvqdna7dp4c5evlb6cus7h6eci7tj73tqnpey behaviours/bet_placement.py: bafybeifwwvvwh4qgf3jkyvza4wfvjv63il2xewsklsjtpyanp23y6hg2aa behaviours/blacklisting.py: bafybeicvespraci44y2dtddy4wi7cdhjuyk6crjs7ztnssm2rcrovha3hm behaviours/decision_receive.py: bafybeid54jwjs4lulcl2n2w7taxne3wqgsey6ppaidwr2up6bztyf35ghm behaviours/decision_request.py: bafybeidlyl2ojmpfs2zkewoacraya2cbampo4ynqbqaocsoq7v2nif3ahi behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm - behaviours/reedem.py: bafybeig3ikits3r5ldjhfqyyn74t3osmnm72htbuibmo5syfc7url2qtaq + behaviours/reedem.py: bafybeigzsx4wyov3ehfvdjmo2d7yimss4p7mbkopkqyr4gryxpa5rpv6ku behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm behaviours/sampling.py: bafybeiadikynvkaofbko72jc45xthhmmjfmlkpgramormhxwk5u47rnwdu - behaviours/tool_selection.py: bafybeib3vzj25c5hzpitznpe6jkbgbh7cdfmt3aa3zxyuftutikd67eniq + behaviours/tool_selection.py: bafybeidd7jmauc6edgt7caxylanfdz3ucb2qzsndszlxv7an4lohe2waja dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm fsm_specification.yaml: bafybeifnob3ceim2mj7lqagtnpwqjqqxs5eg3oiwc73gwm6x5i2dvvlcya handlers.py: bafybeihj33szgrcxnpd73s4nvluyxwwsvhjum2cuq3ilhhe6vfola3k7vy - models.py: bafybeicnnzyzdwdtedw3ihahugve6725ckkgt5po6qzxwljs67x5dzhwq4 - payloads.py: bafybeifpwwkikmsr7abxbin7jup6i4by7nzhpqfwlk4knm25z4mznpqj5u - policy.py: bafybeieu7yhgyuwexytpbmhuo2r5ky3sy7btoyw43bqhfcr3oj76e6dmb4 - redeem_info.py: bafybeigtxdyzs5gxfxadudg4n6ua5zpdijuzpm7x6732exxa6hpsczmyzy - rounds.py: bafybeieagkqbsy2da3soieelzvqnj4xkkpttfbhysfsfrb3geckqiejbx4 + models.py: bafybeie6ynq37isn4itspkj2eka6r2wwsok3ofdve6iipw5nwjimmzblzu + payloads.py: bafybeic4iz6uxinqpaxnefkadnzaox23y7k57zawnnkeovplih36v5cchy + policy.py: bafybeiftviqwq6lapfxj6ykxyh64z72vauqrgmsoho7zo2lvsdvu32kw3m + redeem_info.py: bafybeihtbundd75a4wdk2d23smvdjlh7fsv42ff2cwwuwgkyyxjciobwca + rounds.py: bafybeihopxmhzrpipc6r5x2vqf2tcixzuf5xdpqfsr7gr3n756n3ssft5q states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy - states/base.py: bafybeieuw57xtki2dsrvr5hfx6iedxjmosr6kywphdzfukjejwv52iawcu + states/base.py: bafybeibx3kn2b3rovyiowjzpwhspjdbzyfroequg7zsjqsbdh5cyowu72a states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda states/blacklisting.py: bafybeiao747i4z7owk6dmwfuzdijag55m3ryj3nowfoggvczpgk3koza44 states/decision_receive.py: bafybeifm3oyq2aji7f5yag6wpe4vr3ivi74pybdsk2jvmziiidx5nt7t4a states/decision_request.py: bafybeic7otc3hjb753svbmur3yyk6szahc25yii3x4w4vcnpfz6jwvacuu states/final_states.py: bafybeidiwhuyd5zm2cq7vhv2owcrxdpm7fnvn3db6p6tql4jz5hgpalflu states/handle_failed_tx.py: bafybeihewm2vernvhktuorljdupjqcg2p5vs6wvsira2d62wkoyo5xlzjm - states/redeem.py: bafybeiebofn2pg32iprvwuglclq6hm4x3hvx7neqqad4b77zej67vozjye + states/redeem.py: bafybeib2y6v3vuvw3upjz75ie7j2bkhclwzp7j77esunabjatdtmdvzqlm states/sampling.py: bafybeidnvdogjlthjfe7jpaiuezm3xydrbxxukyoss4gx6t5fdin52rsta - states/tool_selection.py: bafybeihc7pmwxijc5tcsl2yt5n3rbwumqksa3oxjjcrj6vkesinhu5f7im + states/tool_selection.py: bafybeiaaijv6dukp3bmsptcwkcmumc6wu6ztzkvaqzsqqjbfn4ozgyuykq fingerprint_ignore_patterns: [] connections: [] contracts: @@ -57,7 +57,7 @@ protocols: - valory/contract_api:1.0.0:bafybeiasywsvax45qmugus5kxogejj66c5taen27h4voriodz7rgushtqa skills: - valory/abstract_round_abci:0.1.0:bafybeif3cqkks5qx3lqi6nwwhebcirhazt2vidw3sueeqsyxvjeszjt3om -- valory/market_manager_abci:0.1.0:bafybeibwe3tmsonkej2v5cnclsyfi4bfd5ievxzkrpc4lg6fqqk6s7hcny +- valory/market_manager_abci:0.1.0:bafybeig223xrxbtfx5adwhc7m6rpdbevsqm5osfq66oijucs2gzn4hehsm - valory/transaction_settlement_abci:0.1.0:bafybeiglsnh2hvfau5gab7requh34k4sbqwbjvrhhqjpes4hakcwq46cpi behaviours: main: diff --git a/packages/valory/skills/market_manager_abci/skill.yaml b/packages/valory/skills/market_manager_abci/skill.yaml index ad428ccd4..d160e53ca 100644 --- a/packages/valory/skills/market_manager_abci/skill.yaml +++ b/packages/valory/skills/market_manager_abci/skill.yaml @@ -15,7 +15,7 @@ fingerprint: graph_tooling/__init__.py: bafybeigzo7nhbzafyq3fuhrlewksjvmzttiuk4vonrggtjtph4rw4ncpk4 graph_tooling/queries/__init__.py: bafybeihbybnl53i7k57ql5ujt5ru5n2eg324jfndh4lcnm4fk52mwbkjda graph_tooling/queries/network.py: bafybeigeq72ys2nrjqspj2uacaudrgljrne5a3o5jvzsktldxdq6m2xmeu - graph_tooling/queries/omen.py: bafybeigybmwaz3e33ug756v7k4lrwy5tlwimii5qywapaiww6qgslvfywi + graph_tooling/queries/omen.py: bafybeicatte7cinlzcmubkoyne7fgvuedimvotf4pvhacozsy7ndftmmdy graph_tooling/requests.py: bafybeicv7hdo4a56pqteaxoxi5tskfbb34u2ajmhu7canoco3mi3jv6fmy handlers.py: bafybeihot2i2yvfkz2gcowvt66wdu6tkjbmv7hsmc4jzt4reqeaiuphbtu models.py: bafybeiaplszooak63fo3i6agaoyol4tpof4q4tvoj4j6f2cr2corajnl3a diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index ccb9f2d06..805759eaf 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -24,9 +24,9 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeifoihgilpfr76hc5skzspm6qehkwivx7ld2cy3veipcsi4gr2c7na - valory/transaction_settlement_abci:0.1.0:bafybeiglsnh2hvfau5gab7requh34k4sbqwbjvrhhqjpes4hakcwq46cpi - valory/termination_abci:0.1.0:bafybeigcsls72uosoui2y5ppmnvsljjhnxakkeh3fdohklcg66aqq4g7xu -- valory/market_manager_abci:0.1.0:bafybeibwe3tmsonkej2v5cnclsyfi4bfd5ievxzkrpc4lg6fqqk6s7hcny -- valory/decision_maker_abci:0.1.0:bafybeifssrmowov77evtvevc7qophahlcskuxik573y2y4nmf64xz7oinm -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeib4up7sqeptbuyawjkn6zwucxdknk3c4ah7o3q5iwdkebz4y5fxmq +- valory/market_manager_abci:0.1.0:bafybeig223xrxbtfx5adwhc7m6rpdbevsqm5osfq66oijucs2gzn4hehsm +- valory/decision_maker_abci:0.1.0:bafybeieqyd5jek55q57lg77hey3oapppoosaphhyxxlulx52gg2ahkqdba +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidel3rxm55y2qqewhmwroybs5j7t6ma6awmxbo7xjv3jvhmb6dv7m behaviours: main: args: {} diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 2238a2396..9d2c0043d 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -13,14 +13,14 @@ fingerprint: fsm_specification.yaml: bafybeibeas5ovngfhfox4dkkwdvhogpuzkmwj6r33ez2xxvvmvmesa3xvm handlers.py: bafybeiafbqr7ojfcbwohvee7x4zzswad3ymfrrbjlfz7uuuttmn3qdfs6q models.py: bafybeiahojnn52s762zitwx6k5s4ef5qw7hwjf3orlklqwuz3zi7k2o7bi - rounds.py: bafybeifcqo6t7vhkclwj6lncfirglvayd7oqdwinca2ipndizgin7alm5q + rounds.py: bafybeigyok6qh5firjs5osarsmtcugqhcibishulr6zzdfsnesm6jcxqqa fingerprint_ignore_patterns: [] connections: [] contracts: [] protocols: [] skills: - valory/abstract_round_abci:0.1.0:bafybeif3cqkks5qx3lqi6nwwhebcirhazt2vidw3sueeqsyxvjeszjt3om -- valory/decision_maker_abci:0.1.0:bafybeifssrmowov77evtvevc7qophahlcskuxik573y2y4nmf64xz7oinm +- valory/decision_maker_abci:0.1.0:bafybeieqyd5jek55q57lg77hey3oapppoosaphhyxxlulx52gg2ahkqdba behaviours: main: args: {}