From 381b82a19942121e0a59670c0e775404da8db29b Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Tue, 4 Jun 2024 19:59:04 +0530 Subject: [PATCH 01/27] feat: update agent hash --- frontend/constants/serviceTemplates.ts | 2 +- templates/trader.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/constants/serviceTemplates.ts b/frontend/constants/serviceTemplates.ts index 6cac3b626..b7cb061c4 100644 --- a/frontend/constants/serviceTemplates.ts +++ b/frontend/constants/serviceTemplates.ts @@ -3,7 +3,7 @@ import { ServiceTemplate } from '@/client'; export const SERVICE_TEMPLATES: ServiceTemplate[] = [ { name: 'Trader Agent', - hash: 'bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq', + hash: 'bafybeic5dkp7n5a6mgomy3vamkcugnmjl7eynlibntucc6hoiazbyiuupq', description: 'Trader agent for omen prediction markets', image: 'https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75', diff --git a/templates/trader.yaml b/templates/trader.yaml index a687f8929..3a99e60f2 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -1,6 +1,6 @@ name: "Trader Agent" description: "Trader agent for omen prediction markets" -hash: bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq +hash: bafybeic5dkp7n5a6mgomy3vamkcugnmjl7eynlibntucc6hoiazbyiuupq image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 configuration: nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq From 993499b4160fa9ace466633f70e36eed5b9a6f5c Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 4 Jun 2024 17:07:21 +0100 Subject: [PATCH 02/27] bump deps for release to rc36 --- electron/install.js | 54 ++++++++++++++++++++++++--------------------- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/electron/install.js b/electron/install.js index 944ceac50..70c670bfe 100644 --- a/electron/install.js +++ b/electron/install.js @@ -6,12 +6,12 @@ const fs = require('fs'); const os = require('os'); const sudo = require('sudo-prompt'); const process = require('process'); -const axios = require("axios") +const axios = require('axios'); const Docker = require('dockerode'); const { spawnSync } = require('child_process'); -const Version = '0.1.0rc34'; +const Version = '0.1.0rc36'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; @@ -29,18 +29,21 @@ const SudoOptions = { }; const TendermintUrls = { darwin: { - x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_amd64.tar.gz", - arm64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_arm64.tar.gz", + x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_amd64.tar.gz', + arm64: + 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_darwin_arm64.tar.gz', }, linux: { - x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_amd64.tar.gz", - arm64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_arm64.tar.gz", + x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_amd64.tar.gz', + arm64: + 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_linux_arm64.tar.gz', }, win32: { - x64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz", - arm64: "https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_arm64.tar.gz" - } -} + x64: 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz', + arm64: + 'https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_arm64.tar.gz', + }, +}; function getBinPath(command) { return spawnSync('/usr/bin/which', [command], { env: Env }) @@ -133,7 +136,7 @@ async function downloadFile(url, dest) { const response = await axios({ url, method: 'GET', - responseType: 'stream' + responseType: 'stream', }); response.data.pipe(writer); return new Promise((resolve, reject) => { @@ -141,28 +144,29 @@ async function downloadFile(url, dest) { writer.on('error', reject); }); } catch (err) { - fs.unlink(dest, () => { }); // Delete the file if there is an error + fs.unlink(dest, () => {}); // Delete the file if there is an error console.error('Error downloading the file:', err.message); } } async function installTendermintUnix() { - const cwd = process.cwd() - process.chdir(TempDir) + const cwd = process.cwd(); + process.chdir(TempDir); - console.log(appendLog(`Installing tendermint for ${os.platform()}-${process.arch}`)) - const url = TendermintUrls[os.platform()][process.arch] + console.log( + appendLog(`Installing tendermint for ${os.platform()}-${process.arch}`), + ); + const url = TendermintUrls[os.platform()][process.arch]; - console.log(appendLog(`Downloading ${url}, might take a while...`)) - await downloadFile(url, `${TempDir}/tendermint.tar.gz`) + console.log(appendLog(`Downloading ${url}, might take a while...`)); + await downloadFile(url, `${TempDir}/tendermint.tar.gz`); - console.log(appendLog(`Installing tendermint binary`)) - await runCmdUnix("tar", ["-xvf", "tendermint.tar.gz"]) - await runSudoUnix("install", "tendermint /usr/local/bin") - process.chdir(cwd) + console.log(appendLog(`Installing tendermint binary`)); + await runCmdUnix('tar', ['-xvf', 'tendermint.tar.gz']); + await runSudoUnix('install', 'tendermint /usr/local/bin'); + process.chdir(cwd); } - function isDockerInstalledDarwin() { return Boolean(getBinPath('docker')); } @@ -310,7 +314,7 @@ async function setupDarwin(ipcChannel) { if (!isTendermintInstalledUnix()) { ipcChannel.send('response', 'Installing Pearl Daemon'); console.log(appendLog('Installing tendermint')); - await installTendermintUnix() + await installTendermintUnix(); } if (!fs.existsSync(VenvDir)) { @@ -364,7 +368,7 @@ async function setupUbuntu(ipcChannel) { if (!isTendermintInstalledUnix()) { ipcChannel.send('response', 'Installing Pearl Daemon'); console.log(appendLog('Installing tendermint')); - await installTendermintUnix() + await installTendermintUnix(); } if (!fs.existsSync(VenvDir)) { diff --git a/package.json b/package.json index d866e9081..e43d4df45 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" }, - "version": "0.1.0-rc34" + "version": "0.1.0-rc36" } diff --git a/pyproject.toml b/pyproject.toml index fe6eee3e6..585c4b99e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc34" +version = "0.1.0-rc36" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 609e3cfbd6528a571851f5b024512d74a6eb2312 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 5 Jun 2024 10:36:47 +0530 Subject: [PATCH 03/27] fix: remove stake tx call from unstaking logic --- operate/services/manage.py | 7 +------ tox.ini | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 803ee8527..cfbda1d96 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -758,13 +758,8 @@ def unstake_service_on_chain_from_safe(self, hash: str) -> None: service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], ) - ).add( - sftxb.get_staking_data( - service_id=service.chain_data.token, - staking_contract=STAKING[service.ledger_config.chain], - ) ).settle() - service.chain_data.staked = True + service.chain_data.staked = False service.store() def fund_service( # pylint: disable=too-many-arguments diff --git a/tox.ini b/tox.ini index ccc7c2890..b7de2caf0 100644 --- a/tox.ini +++ b/tox.ini @@ -75,7 +75,7 @@ skip_install = True deps = tomte[safety]==0.2.15 commands = - safety check -i 37524 -i 38038 -i 37776 -i 38039 -i 39621 -i 40291 -i 39706 -i 41002 -i 51358 -i 51499 -i 67599 + safety check -i 37524 -i 38038 -i 37776 -i 38039 -i 39621 -i 40291 -i 39706 -i 41002 -i 51358 -i 51499 -i 67599 -i 70612 [testenv:vulture] skipsdist = True From 21591edfa041ec267fd931a37a0b3b8cce3b06e4 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 5 Jun 2024 15:12:43 +0530 Subject: [PATCH 04/27] fix: bump to fixed service hash --- frontend/constants/serviceTemplates.ts | 2 +- templates/trader.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/constants/serviceTemplates.ts b/frontend/constants/serviceTemplates.ts index b7cb061c4..da7f614ca 100644 --- a/frontend/constants/serviceTemplates.ts +++ b/frontend/constants/serviceTemplates.ts @@ -3,7 +3,7 @@ import { ServiceTemplate } from '@/client'; export const SERVICE_TEMPLATES: ServiceTemplate[] = [ { name: 'Trader Agent', - hash: 'bafybeic5dkp7n5a6mgomy3vamkcugnmjl7eynlibntucc6hoiazbyiuupq', + hash: 'bafybeibbloa4w33vj4bvdkso7pzk6tr3duvxjpecbx4mur4ix6ehnwb5uu', description: 'Trader agent for omen prediction markets', image: 'https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75', diff --git a/templates/trader.yaml b/templates/trader.yaml index 3a99e60f2..060b37d97 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -1,6 +1,6 @@ name: "Trader Agent" description: "Trader agent for omen prediction markets" -hash: bafybeic5dkp7n5a6mgomy3vamkcugnmjl7eynlibntucc6hoiazbyiuupq +hash: bafybeibbloa4w33vj4bvdkso7pzk6tr3duvxjpecbx4mur4ix6ehnwb5uu image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 configuration: nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq From d3bf7096a4b68830721e72daefbf24e8398f16e0 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 5 Jun 2024 15:19:04 +0530 Subject: [PATCH 05/27] fix: policy store path patch --- operate/services/service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/operate/services/service.py b/operate/services/service.py index ce3d75eaa..1f03d93ab 100644 --- a/operate/services/service.py +++ b/operate/services/service.py @@ -358,10 +358,10 @@ def _setup_agent(working_dir: Path) -> None: """Setup agent.""" env = json.loads((working_dir / "agent.json").read_text(encoding="utf-8")) # Patch for trader agent - if "SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_POLICY_STORE_PATH" in env: + if "SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_STORE_PATH" in env: data_dir = working_dir / "data" data_dir.mkdir(exist_ok=True) - env["SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_POLICY_STORE_PATH"] = str(data_dir) + env["SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_STORE_PATH"] = str(data_dir) # TODO: Dynamic port allocation, backport to service builder env["CONNECTION_ABCI_CONFIG_HOST"] = "localhost" From d8da388c0cc2b2ab4a473c642cd97548dd2c9d78 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 6 Jun 2024 09:28:51 +0100 Subject: [PATCH 06/27] bump to 41 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index 70c670bfe..d19139e37 100644 --- a/electron/install.js +++ b/electron/install.js @@ -11,7 +11,7 @@ const axios = require('axios'); const Docker = require('dockerode'); const { spawnSync } = require('child_process'); -const Version = '0.1.0rc36'; +const Version = '0.1.0rc41'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/package.json b/package.json index e43d4df45..9699d77ec 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" }, - "version": "0.1.0-rc36" + "version": "0.1.0-rc41" } diff --git a/pyproject.toml b/pyproject.toml index 585c4b99e..9fefe6938 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc36" +version = "0.1.0-rc41" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 2d5c23b3233484037186feb39ce2179d36a6e2e5 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 6 Jun 2024 18:15:36 +0200 Subject: [PATCH 07/27] fix: on-chain status check --- operate/services/manage.py | 54 +++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index cfbda1d96..847b6f285 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -216,6 +216,9 @@ def deploy_service_onchain( # pylint: disable=too-many-statements f"required olas: {required_olas}; your balance {balance}" ) + info = ocm.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.NOTMINTED: self.logger.info("Minting service") service.chain_data.token = t.cast( @@ -242,6 +245,9 @@ def deploy_service_onchain( # pylint: disable=too-many-statements service.chain_data.on_chain_state = OnChainState.MINTED service.store() + info = ocm.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.MINTED: self.logger.info("Activating service") ocm.activate( @@ -255,6 +261,9 @@ def deploy_service_onchain( # pylint: disable=too-many-statements service.chain_data.on_chain_state = OnChainState.ACTIVATED service.store() + info = ocm.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.ACTIVATED: self.logger.info("Registering service") ocm.register( @@ -271,6 +280,9 @@ def deploy_service_onchain( # pylint: disable=too-many-statements service.keys = keys service.store() + info = ocm.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.REGISTERED: self.logger.info("Deploying service") ocm.deploy( @@ -360,6 +372,9 @@ def deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,too f"address: {wallet.safe}; required olas: {required_olas}; your balance: {balance}" ) + info = sftxb.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.NOTMINTED: self.logger.info("Minting service") receipt = ( @@ -399,6 +414,9 @@ def deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,too service.chain_data.on_chain_state = OnChainState.MINTED service.store() + info = sftxb.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.MINTED: cost_of_bond = user_params.cost_of_bond if user_params.use_staking: @@ -448,6 +466,9 @@ def deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,too service.chain_data.on_chain_state = OnChainState.ACTIVATED service.store() + info = sftxb.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.ACTIVATED: cost_of_bond = user_params.cost_of_bond if user_params.use_staking: @@ -502,6 +523,9 @@ def deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,too service.keys = keys service.store() + info = sftxb.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state == OnChainState.REGISTERED: self.logger.info("Deploying service") sftxb.new_tx().add( @@ -532,12 +556,15 @@ def terminate_service_on_chain(self, hash: str) -> None: :param hash: Service hash """ service = self.create_or_load(hash=hash) + ocm = self.get_on_chain_manager(service=service) + info = ocm.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state != OnChainState.DEPLOYED: self.logger.info("Cannot terminate service") return self.logger.info("Terminating service") - ocm = self.get_on_chain_manager(service=service) ocm.terminate( service_id=service.chain_data.token, token=( @@ -556,12 +583,15 @@ def terminate_service_on_chain_from_safe(self, hash: str) -> None: :param hash: Service hash """ service = self.create_or_load(hash=hash) + sftxb = self.get_eth_safe_tx_builder(service=service) + info = sftxb.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state != OnChainState.DEPLOYED: self.logger.info("Cannot terminate service") return self.logger.info("Terminating service") - sftxb = self.get_eth_safe_tx_builder(service=service) sftxb.new_tx().add( sftxb.get_terminate_data( service_id=service.chain_data.token, @@ -577,12 +607,15 @@ def unbond_service_on_chain(self, hash: str) -> None: :param hash: Service hash """ service = self.create_or_load(hash=hash) + ocm = self.get_on_chain_manager(service=service) + info = ocm.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state != OnChainState.TERMINATED: self.logger.info("Cannot unbond service") return self.logger.info("Unbonding service") - ocm = self.get_on_chain_manager(service=service) ocm.unbond( service_id=service.chain_data.token, token=( @@ -601,12 +634,15 @@ def unbond_service_on_chain_from_safe(self, hash: str) -> None: :param hash: Service hash """ service = self.create_or_load(hash=hash) + sftxb = self.get_eth_safe_tx_builder(service=service) + info = sftxb.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state != OnChainState.TERMINATED: self.logger.info("Cannot unbond service") return self.logger.info("Unbonding service") - sftxb = self.get_eth_safe_tx_builder(service=service) sftxb.new_tx().add( sftxb.get_unbond_data( service_id=service.chain_data.token, @@ -626,11 +662,14 @@ def stake_service_on_chain(self, hash: str) -> None: self.logger.info("Cannot stake service, `use_staking` is set to false") return + ocm = self.get_on_chain_manager(service=service) + info = ocm.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state != OnChainState.DEPLOYED: self.logger.info("Cannot stake service, it's not in deployed state") return - ocm = self.get_on_chain_manager(service=service) state = ocm.staking_status( service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], @@ -662,11 +701,14 @@ def stake_service_on_chain_from_safe(self, hash: str) -> None: self.logger.info("Cannot stake service, `use_staking` is set to false") return + sftxb = self.get_eth_safe_tx_builder(service=service) + info = sftxb.info(token_id=service.chain_data.token) + service.chain_data.on_chain_state = OnChainState(info["service_state"]) + if service.chain_data.on_chain_state != OnChainState.DEPLOYED: self.logger.info("Cannot stake service, it's not in deployed state") return - sftxb = self.get_eth_safe_tx_builder(service=service) state = sftxb.staking_status( service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], From d4be55e26840c4b210dc4b9143ecd080b6d27ae3 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 6 Jun 2024 21:51:51 +0200 Subject: [PATCH 08/27] chore: disable on-chain update --- operate/services/manage.py | 82 ++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 847b6f285..014de9b74 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -927,45 +927,49 @@ def update_service( old_service = self.create_or_load( hash=old_hash, ) - ( - self.unstake_service_on_chain_from_safe - if from_safe - else self.unstake_service_on_chain - )( - hash=old_hash, - ) - ( - self.terminate_service_on_chain_from_safe - if from_safe - else self.terminate_service_on_chain - )( - hash=old_hash, - ) - ( - self.unbond_service_on_chain_from_safe - if from_safe - else self.unbond_service_on_chain - )( - hash=old_hash, - ) - - owner, *_ = old_service.chain_data.instances - if from_safe: - sftx = self.get_eth_safe_tx_builder(service=old_service) - sftx.new_tx().add( - sftx.get_swap_data( - service_id=old_service.chain_data.token, - multisig=old_service.chain_data.multisig, - owner_key=str(self.keys_manager.get(key=owner).private_key), - ) - ).settle() - else: - ocm = self.get_on_chain_manager(service=old_service) - ocm.swap( - service_id=old_service.chain_data.token, - multisig=old_service.chain_data.multisig, - owner_key=str(self.keys_manager.get(key=owner).private_key), - ) + # TODO code for updating service commented until safe swap transaction is implemented + # This is a temporary fix that will only work for services that have not started the + # update flow. Services having started the update flow must need to manually change + # the Safe owner to the Operator. + # ( + # self.unstake_service_on_chain_from_safe + # if from_safe + # else self.unstake_service_on_chain + # )( + # hash=old_hash, + # ) + # ( + # self.terminate_service_on_chain_from_safe + # if from_safe + # else self.terminate_service_on_chain + # )( + # hash=old_hash, + # ) + # ( + # self.unbond_service_on_chain_from_safe + # if from_safe + # else self.unbond_service_on_chain + # )( + # hash=old_hash, + # ) + + # owner, *_ = old_service.chain_data.instances + # if from_safe: + # sftx = self.get_eth_safe_tx_builder(service=old_service) + # sftx.new_tx().add( + # sftx.get_swap_data( + # service_id=old_service.chain_data.token, + # multisig=old_service.chain_data.multisig, + # owner_key=str(self.keys_manager.get(key=owner).private_key), + # ) + # ).settle() + # else: + # ocm = self.get_on_chain_manager(service=old_service) + # ocm.swap( + # service_id=old_service.chain_data.token, + # multisig=old_service.chain_data.multisig, + # owner_key=str(self.keys_manager.get(key=owner).private_key), + # ) new_service = self.create_or_load( hash=new_hash, From 65fc08ce36a288e86d6c15d7246b52ef6e889a34 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 7 Jun 2024 14:16:03 +0200 Subject: [PATCH 09/27] chore: fix --- operate/services/manage.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 014de9b74..a03b5aafa 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -216,9 +216,6 @@ def deploy_service_onchain( # pylint: disable=too-many-statements f"required olas: {required_olas}; your balance {balance}" ) - info = ocm.info(token_id=service.chain_data.token) - service.chain_data.on_chain_state = OnChainState(info["service_state"]) - if service.chain_data.on_chain_state == OnChainState.NOTMINTED: self.logger.info("Minting service") service.chain_data.token = t.cast( @@ -372,9 +369,6 @@ def deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,too f"address: {wallet.safe}; required olas: {required_olas}; your balance: {balance}" ) - info = sftxb.info(token_id=service.chain_data.token) - service.chain_data.on_chain_state = OnChainState(info["service_state"]) - if service.chain_data.on_chain_state == OnChainState.NOTMINTED: self.logger.info("Minting service") receipt = ( From 1f867e49c20ffb086170730695639173d25a5b8f Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 7 Jun 2024 14:29:33 +0200 Subject: [PATCH 10/27] chore: update gitleaksignore --- .gitleaksignore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitleaksignore b/.gitleaksignore index 402af754e..158702af9 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -21,4 +21,9 @@ e7de9ce0b902ed6d68f8c5b033d044f39b08f5a1:operate/data/contracts/service_staking_ d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:405 d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:406 d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:454 -d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:455 \ No newline at end of file +d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:455 +91ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454 +99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:405 +99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:406 +99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:454 +99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:455 From aaf6b88c47ed9892d3262ee29e024fe866ca4339 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 7 Jun 2024 20:27:19 +0200 Subject: [PATCH 11/27] fix: temporary fix for env variables --- operate/services/service.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/operate/services/service.py b/operate/services/service.py index 1f03d93ab..775e7e05d 100644 --- a/operate/services/service.py +++ b/operate/services/service.py @@ -313,6 +313,13 @@ def generate( """Generate agent and tendermint configurations""" agent = self.service_builder.generate_agent(agent_n=0) agent = {key: f"{value}" for key, value in agent.items()} + + # TODO: This fix prevents the error of environment variables with dots + # It requires that the aea-config.yaml is properly configured + keys_to_delete = [key for key in agent.keys() if key.startswith("SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_STRATEGIES_KWARGS")] + for key in keys_to_delete: + del agent[key] + (self.build_dir / "agent.json").write_text( json.dumps(agent, indent=2), encoding="utf-8", From 7017417ccaa0fb5c636b2c9c3db31bfe9155b691 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Mon, 10 Jun 2024 16:37:05 +0200 Subject: [PATCH 12/27] chore: service hash --- frontend/constants/serviceTemplates.ts | 2 +- operate/services/service.py | 6 ------ templates/trader.yaml | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/frontend/constants/serviceTemplates.ts b/frontend/constants/serviceTemplates.ts index da7f614ca..972819a1e 100644 --- a/frontend/constants/serviceTemplates.ts +++ b/frontend/constants/serviceTemplates.ts @@ -3,7 +3,7 @@ import { ServiceTemplate } from '@/client'; export const SERVICE_TEMPLATES: ServiceTemplate[] = [ { name: 'Trader Agent', - hash: 'bafybeibbloa4w33vj4bvdkso7pzk6tr3duvxjpecbx4mur4ix6ehnwb5uu', + hash: 'bafybeih5woeemgmz2dgez6t335eydw2sftse2alsbkvkxormt55ef7o7e4', description: 'Trader agent for omen prediction markets', image: 'https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75', diff --git a/operate/services/service.py b/operate/services/service.py index 775e7e05d..691c499b3 100644 --- a/operate/services/service.py +++ b/operate/services/service.py @@ -314,12 +314,6 @@ def generate( agent = self.service_builder.generate_agent(agent_n=0) agent = {key: f"{value}" for key, value in agent.items()} - # TODO: This fix prevents the error of environment variables with dots - # It requires that the aea-config.yaml is properly configured - keys_to_delete = [key for key in agent.keys() if key.startswith("SKILL_TRADER_ABCI_MODELS_PARAMS_ARGS_STRATEGIES_KWARGS")] - for key in keys_to_delete: - del agent[key] - (self.build_dir / "agent.json").write_text( json.dumps(agent, indent=2), encoding="utf-8", diff --git a/templates/trader.yaml b/templates/trader.yaml index 060b37d97..eb6b8cf5c 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -1,6 +1,6 @@ name: "Trader Agent" description: "Trader agent for omen prediction markets" -hash: bafybeibbloa4w33vj4bvdkso7pzk6tr3duvxjpecbx4mur4ix6ehnwb5uu +hash: bafybeih5woeemgmz2dgez6t335eydw2sftse2alsbkvkxormt55ef7o7e4 image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 configuration: nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq From 1b8b8063a4124c789a4faaa803b4511fcdf17a02 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Mon, 10 Jun 2024 16:37:29 +0200 Subject: [PATCH 13/27] chore: spacing --- operate/services/service.py | 1 - 1 file changed, 1 deletion(-) diff --git a/operate/services/service.py b/operate/services/service.py index 691c499b3..1f03d93ab 100644 --- a/operate/services/service.py +++ b/operate/services/service.py @@ -313,7 +313,6 @@ def generate( """Generate agent and tendermint configurations""" agent = self.service_builder.generate_agent(agent_n=0) agent = {key: f"{value}" for key, value in agent.items()} - (self.build_dir / "agent.json").write_text( json.dumps(agent, indent=2), encoding="utf-8", From f38655fd1b89ab5fb89e4c2c74456b001fc31e00 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Mon, 10 Jun 2024 17:52:47 +0200 Subject: [PATCH 14/27] chore: update service hash --- frontend/constants/serviceTemplates.ts | 2 +- templates/trader.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/constants/serviceTemplates.ts b/frontend/constants/serviceTemplates.ts index 972819a1e..5371d206b 100644 --- a/frontend/constants/serviceTemplates.ts +++ b/frontend/constants/serviceTemplates.ts @@ -3,7 +3,7 @@ import { ServiceTemplate } from '@/client'; export const SERVICE_TEMPLATES: ServiceTemplate[] = [ { name: 'Trader Agent', - hash: 'bafybeih5woeemgmz2dgez6t335eydw2sftse2alsbkvkxormt55ef7o7e4', + hash: 'bafybeibcel7tvcc3yhqobiro7klrmuv7ues3goaesozybhq6jlrxkjpw3u', description: 'Trader agent for omen prediction markets', image: 'https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75', diff --git a/templates/trader.yaml b/templates/trader.yaml index eb6b8cf5c..df8fe0b6a 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -1,6 +1,6 @@ name: "Trader Agent" description: "Trader agent for omen prediction markets" -hash: bafybeih5woeemgmz2dgez6t335eydw2sftse2alsbkvkxormt55ef7o7e4 +hash: bafybeibcel7tvcc3yhqobiro7klrmuv7ues3goaesozybhq6jlrxkjpw3u image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 configuration: nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq From 590a80f360645f0c749b2becba98ba3c086c3009 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 11 Jun 2024 10:40:08 +0100 Subject: [PATCH 15/27] chore: update version to 0.1.0rc42 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index d19139e37..cdac05fcd 100644 --- a/electron/install.js +++ b/electron/install.js @@ -11,7 +11,7 @@ const axios = require('axios'); const Docker = require('dockerode'); const { spawnSync } = require('child_process'); -const Version = '0.1.0rc41'; +const Version = '0.1.0rc42'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/package.json b/package.json index 9699d77ec..d6c414c93 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" }, - "version": "0.1.0-rc41" + "version": "0.1.0-rc42" } diff --git a/pyproject.toml b/pyproject.toml index 9fefe6938..4cfd604be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc41" +version = "0.1.0-rc42" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 9dd565460f2c4de6f88be93409e298231c25b19b Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 11 Jun 2024 17:55:27 +0200 Subject: [PATCH 16/27] chore: update hash --- frontend/constants/serviceTemplates.ts | 2 +- templates/trader.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/constants/serviceTemplates.ts b/frontend/constants/serviceTemplates.ts index 5371d206b..7d9baf6c5 100644 --- a/frontend/constants/serviceTemplates.ts +++ b/frontend/constants/serviceTemplates.ts @@ -3,7 +3,7 @@ import { ServiceTemplate } from '@/client'; export const SERVICE_TEMPLATES: ServiceTemplate[] = [ { name: 'Trader Agent', - hash: 'bafybeibcel7tvcc3yhqobiro7klrmuv7ues3goaesozybhq6jlrxkjpw3u', + hash: 'bafybeihv3nyh43rim6kcxdscdgsiojhbqfwndhwcrtxhi3gkxbnasdc7ui', description: 'Trader agent for omen prediction markets', image: 'https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75', diff --git a/templates/trader.yaml b/templates/trader.yaml index df8fe0b6a..ab22b8478 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -1,6 +1,6 @@ name: "Trader Agent" description: "Trader agent for omen prediction markets" -hash: bafybeibcel7tvcc3yhqobiro7klrmuv7ues3goaesozybhq6jlrxkjpw3u +hash: bafybeihv3nyh43rim6kcxdscdgsiojhbqfwndhwcrtxhi3gkxbnasdc7ui image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 configuration: nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq From ec9699dcfea7c3a98185cc679e699fe71de0435f Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 11 Jun 2024 17:59:07 +0200 Subject: [PATCH 17/27] chore: update version to 0.1.0rc43 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index cdac05fcd..2e03ded44 100644 --- a/electron/install.js +++ b/electron/install.js @@ -11,7 +11,7 @@ const axios = require('axios'); const Docker = require('dockerode'); const { spawnSync } = require('child_process'); -const Version = '0.1.0rc42'; +const Version = '0.1.0rc43'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/package.json b/package.json index d6c414c93..a8b1069ed 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" }, - "version": "0.1.0-rc42" + "version": "0.1.0-rc43" } diff --git a/pyproject.toml b/pyproject.toml index 4cfd604be..3a207c629 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc42" +version = "0.1.0-rc43" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From f07b44ec4127d4bf2254c3d70c38ef6dd4b230b6 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 13 Jun 2024 16:46:09 +0200 Subject: [PATCH 18/27] fix: restake after eviction --- operate/services/manage.py | 19 ++++++++++++++++--- operate/services/protocol.py | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index a03b5aafa..8f31b916f 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -675,6 +675,12 @@ def stake_service_on_chain(self, hash: str) -> None: service.store() return + if state == StakingState.EVICTED: + self.logger.info(f"{service.chain_data.token} has been evicted") + service.chain_data.staked = True + service.store() + self.unstake_service_on_chain(hash=hash) + self.logger.info(f"Staking service: {service.chain_data.token}") ocm.stake( service_id=service.chain_data.token, @@ -714,6 +720,12 @@ def stake_service_on_chain_from_safe(self, hash: str) -> None: service.store() return + if state == StakingState.EVICTED: + self.logger.info(f"{service.chain_data.token} has been evicted") + service.chain_data.staked = True + service.store() + self.unstake_service_on_chain_from_safe(hash=hash) + self.logger.info(f"Approving staking: {service.chain_data.token}") sftxb.new_tx().add( sftxb.get_staking_approval_data( @@ -751,7 +763,8 @@ def unstake_service_on_chain(self, hash: str) -> None: service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], ) - if state != StakingState.STAKED: + self.logger.info(f"Staking status for service {service.chain_data.token}: {state}") + if state not in {StakingState.STAKED, StakingState.EVICTED}: self.logger.info("Cannot unstake service, it's not staked") service.chain_data.staked = False service.store() @@ -781,8 +794,8 @@ def unstake_service_on_chain_from_safe(self, hash: str) -> None: service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], ) - self.logger.info(f"Checking staking status for: {service.chain_data.token}") - if state != StakingState.STAKED: + self.logger.info(f"Staking status for service {service.chain_data.token}: {state}") + if state not in {StakingState.STAKED, StakingState.EVICTED}: self.logger.info("Cannot unstake service, it's not staked") service.chain_data.staked = False service.store() diff --git a/operate/services/protocol.py b/operate/services/protocol.py index 5853f8516..401afbc1a 100644 --- a/operate/services/protocol.py +++ b/operate/services/protocol.py @@ -248,7 +248,7 @@ def check_staking_compatibility( """Check if service can be staked.""" status = self.status(service_id, staking_contract) if status == StakingState.STAKED: - raise ValueError("Service already stacked") + raise ValueError("Service already staked") if status == StakingState.EVICTED: raise ValueError("Service is evicted") @@ -330,7 +330,7 @@ def check_if_unstaking_possible( """Check unstaking availability""" if ( self.status(service_id=service_id, staking_contract=staking_contract) - != StakingState.STAKED + not in {StakingState.STAKED, StakingState.EVICTED} ): raise ValueError("Service not staked.") From 558469306030af1cc00ba512a7fbcf0ff4d7174a Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 13 Jun 2024 16:48:34 +0200 Subject: [PATCH 19/27] fix: linters --- operate/services/manage.py | 8 ++++++-- operate/services/protocol.py | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 8f31b916f..f95247684 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -763,7 +763,9 @@ def unstake_service_on_chain(self, hash: str) -> None: service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], ) - self.logger.info(f"Staking status for service {service.chain_data.token}: {state}") + self.logger.info( + f"Staking status for service {service.chain_data.token}: {state}" + ) if state not in {StakingState.STAKED, StakingState.EVICTED}: self.logger.info("Cannot unstake service, it's not staked") service.chain_data.staked = False @@ -794,7 +796,9 @@ def unstake_service_on_chain_from_safe(self, hash: str) -> None: service_id=service.chain_data.token, staking_contract=STAKING[service.ledger_config.chain], ) - self.logger.info(f"Staking status for service {service.chain_data.token}: {state}") + self.logger.info( + f"Staking status for service {service.chain_data.token}: {state}" + ) if state not in {StakingState.STAKED, StakingState.EVICTED}: self.logger.info("Cannot unstake service, it's not staked") service.chain_data.staked = False diff --git a/operate/services/protocol.py b/operate/services/protocol.py index 401afbc1a..349b3b7b1 100644 --- a/operate/services/protocol.py +++ b/operate/services/protocol.py @@ -328,10 +328,9 @@ def check_if_unstaking_possible( staking_contract: str, ) -> None: """Check unstaking availability""" - if ( - self.status(service_id=service_id, staking_contract=staking_contract) - not in {StakingState.STAKED, StakingState.EVICTED} - ): + if self.status( + service_id=service_id, staking_contract=staking_contract + ) not in {StakingState.STAKED, StakingState.EVICTED}: raise ValueError("Service not staked.") ts_start = t.cast(int, self.service_info(staking_contract, service_id)[3]) From 925aa308babae961331c00860118b1df2995e6b4 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 13 Jun 2024 16:56:23 +0200 Subject: [PATCH 20/27] chore: tag rc45 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index 2e03ded44..042f5ba28 100644 --- a/electron/install.js +++ b/electron/install.js @@ -11,7 +11,7 @@ const axios = require('axios'); const Docker = require('dockerode'); const { spawnSync } = require('child_process'); -const Version = '0.1.0rc43'; +const Version = '0.1.0rc45'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/package.json b/package.json index a8b1069ed..ac1374b62 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" }, - "version": "0.1.0-rc43" + "version": "0.1.0-rc45" } diff --git a/pyproject.toml b/pyproject.toml index 3a207c629..33c068f49 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc43" +version = "0.1.0-rc45" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 3f431ed76b7c39a3e95facd853e8fe8e2dc2d238 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 14 Jun 2024 11:13:55 +0200 Subject: [PATCH 21/27] chore: update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c7eba5391..7e8161e69 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ frontend/build # python .tox/ .operate/ +.operate*/ __pycache__/ data/ backend/temp/ From 4627dbc21659ec80a3cfda300fa8a733603dab5d Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 14 Jun 2024 11:20:05 +0200 Subject: [PATCH 22/27] fix: linters --- operate/services/manage.py | 78 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index f95247684..a4bb78d78 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -942,45 +942,45 @@ def update_service( # This is a temporary fix that will only work for services that have not started the # update flow. Services having started the update flow must need to manually change # the Safe owner to the Operator. - # ( - # self.unstake_service_on_chain_from_safe - # if from_safe - # else self.unstake_service_on_chain - # )( - # hash=old_hash, - # ) - # ( - # self.terminate_service_on_chain_from_safe - # if from_safe - # else self.terminate_service_on_chain - # )( - # hash=old_hash, - # ) - # ( - # self.unbond_service_on_chain_from_safe - # if from_safe - # else self.unbond_service_on_chain - # )( - # hash=old_hash, - # ) - - # owner, *_ = old_service.chain_data.instances - # if from_safe: - # sftx = self.get_eth_safe_tx_builder(service=old_service) - # sftx.new_tx().add( - # sftx.get_swap_data( - # service_id=old_service.chain_data.token, - # multisig=old_service.chain_data.multisig, - # owner_key=str(self.keys_manager.get(key=owner).private_key), - # ) - # ).settle() - # else: - # ocm = self.get_on_chain_manager(service=old_service) - # ocm.swap( - # service_id=old_service.chain_data.token, - # multisig=old_service.chain_data.multisig, - # owner_key=str(self.keys_manager.get(key=owner).private_key), - # ) + # ( # noqa: E800 + # self.unstake_service_on_chain_from_safe # noqa: E800 + # if from_safe # noqa: E800 + # else self.unstake_service_on_chain # noqa: E800 + # )( # noqa: E800 + # hash=old_hash, # noqa: E800 + # ) # noqa: E800 + # ( # noqa: E800 + # self.terminate_service_on_chain_from_safe # noqa: E800 + # if from_safe # noqa: E800 + # else self.terminate_service_on_chain # noqa: E800 + # )( # noqa: E800 + # hash=old_hash, # noqa: E800 + # ) # noqa: E800 + # ( # noqa: E800 + # self.unbond_service_on_chain_from_safe # noqa: E800 + # if from_safe # noqa: E800 + # else self.unbond_service_on_chain # noqa: E800 + # )( # noqa: E800 + # hash=old_hash, # noqa: E800 + # ) # noqa: E800 + + # owner, *_ = old_service.chain_data.instances # noqa: E800 + # if from_safe: # noqa: E800 + # sftx = self.get_eth_safe_tx_builder(service=old_service) # noqa: E800 + # sftx.new_tx().add( # noqa: E800 + # sftx.get_swap_data( # noqa: E800 + # service_id=old_service.chain_data.token, # noqa: E800 + # multisig=old_service.chain_data.multisig, # noqa: E800 + # owner_key=str(self.keys_manager.get(key=owner).private_key), # noqa: E800 + # ) # noqa: E800 + # ).settle() # noqa: E800 + # else: # noqa: E800 + # ocm = self.get_on_chain_manager(service=old_service) # noqa: E800 + # ocm.swap( # noqa: E800 + # service_id=old_service.chain_data.token, # noqa: E800 + # multisig=old_service.chain_data.multisig, # noqa: E800 + # owner_key=str(self.keys_manager.get(key=owner).private_key), # noqa: E800 + # ) # noqa: E800 new_service = self.create_or_load( hash=new_hash, From 61ac9da75df334a73c9bbbdd90b62621a239e0c8 Mon Sep 17 00:00:00 2001 From: jmoreira-valory <96571377+jmoreira-valory@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:40:16 +0200 Subject: [PATCH 23/27] Apply suggestions from code review Co-authored-by: truemiller <31908788+truemiller@users.noreply.github.com> --- .github/workflows/e2e.yml | 2 +- electron/install.js | 2 +- package.json | 4 ++-- pyproject.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 58691e7b4..9cbd9b7ac 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -21,7 +21,7 @@ jobs: node-version: "20.11" - name: Setup run: | - npm install + yarn # Uninstall brew sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" - name: Run Test diff --git a/electron/install.js b/electron/install.js index 90e19fd99..6e09fe6c8 100644 --- a/electron/install.js +++ b/electron/install.js @@ -16,7 +16,7 @@ const { BrewScript } = require("./scripts") * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc45'; +const OlasMiddlewareVersion = '0.1.0rc46'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/package.json b/package.json index 5c738247b..10b48a9ee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "main": "electron/main.js", "name": "olas-operate-app", "productName": "Pearl", - "version": "0.1.0-rc40", + "version": "0.1.0-rc46", "dependencies": { "@ant-design/cssinjs": "^1.18.4", "@ant-design/icons": "^5.3.0", @@ -56,5 +56,5 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" }, - "version": "0.1.0-rc45" + } diff --git a/pyproject.toml b/pyproject.toml index 33c068f49..61ae8d497 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc45" +version = "0.1.0-rc46" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From edd073b8239b870814664d9e9dd01cf2a0d749a4 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 14 Jun 2024 11:43:08 +0200 Subject: [PATCH 24/27] fix: package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10b48a9ee..486059e47 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,6 @@ "test:frontend": "cd frontend && yarn test", "start": "electron .", "build": "rm -rf dist/ && electron-builder build" - }, + } } From b455ab54a96745c3a2ef55232f108c1e4919ebaf Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 14 Jun 2024 11:49:19 +0200 Subject: [PATCH 25/27] fix: linters --- operate/services/manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index a4bb78d78..e4b67430c 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -932,7 +932,7 @@ def update_service( new_hash: str, rpc: t.Optional[str] = None, on_chain_user_params: t.Optional[OnChainUserParams] = None, - from_safe: bool = True, + from_safe: bool = True, # pylint: disable=unused-argument ) -> Service: """Update a service.""" old_service = self.create_or_load( From a09678534b4cdad10c262ed4b1760e97ddf3750a Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 14 Jun 2024 12:08:57 +0200 Subject: [PATCH 26/27] chore: gitleaksignore --- .gitleaksignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitleaksignore b/.gitleaksignore index d5ebe0a15..446eb5a4b 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -27,4 +27,4 @@ d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api- 99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:406 99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:454 99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:455 -91ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454 +91ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454 \ No newline at end of file From 8ff071f223a7cbcd5e0d18edd2283705d674abd8 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Fri, 14 Jun 2024 12:10:41 +0200 Subject: [PATCH 27/27] chore: tidy files --- electron/install.js | 2 +- package.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/electron/install.js b/electron/install.js index 6e09fe6c8..1869762a7 100644 --- a/electron/install.js +++ b/electron/install.js @@ -177,7 +177,7 @@ async function downloadFile(url, dest) { writer.on('error', reject); }); } catch (err) { - fs.unlink(dest, () => {}); // Delete the file if there is an error + fs.unlink(dest, () => { }); // Delete the file if there is an error console.error('Error downloading the file:', err.message); } } diff --git a/package.json b/package.json index 486059e47..af7a8b634 100644 --- a/package.json +++ b/package.json @@ -56,5 +56,4 @@ "start": "electron .", "build": "rm -rf dist/ && electron-builder build" } - }