From 435f76c37bc6ea899a711fcbdd9ec6e0a8bc9e76 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 31 Oct 2024 10:58:06 +0100 Subject: [PATCH 01/22] chore: update staking contracts backend --- operate/ledger/profiles.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/operate/ledger/profiles.py b/operate/ledger/profiles.py index d0e62b272..5d68ff613 100644 --- a/operate/ledger/profiles.py +++ b/operate/ledger/profiles.py @@ -40,6 +40,9 @@ "pearl_alpha": "0xEE9F19b5DF06c7E8Bfc7B28745dcf944C504198A", "pearl_beta": "0xeF44Fb0842DDeF59D37f85D61A1eF492bbA6135d", "pearl_beta_2": "0x1c2F82413666d2a3fD8bC337b0268e62dDF67434", + "pearl_beta_3": "0xBd59Ff0522aA773cB6074ce83cD1e4a05A457bc1", + "pearl_beta_4": "0x3052451e1eAee78e62E169AfdF6288F8791F2918", + "pearl_beta_5": "0x4Abe376Fda28c2F43b84884E5f822eA775DeA9F4", "pearl_beta_mech_marketplace": "0xDaF34eC46298b53a3d24CBCb431E84eBd23927dA", } } From 44f191922b6f1c181c59b12e84de4811c37766ad Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 31 Oct 2024 11:00:31 +0100 Subject: [PATCH 02/22] chore: revert commit --- operate/ledger/profiles.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/operate/ledger/profiles.py b/operate/ledger/profiles.py index 5d68ff613..d0e62b272 100644 --- a/operate/ledger/profiles.py +++ b/operate/ledger/profiles.py @@ -40,9 +40,6 @@ "pearl_alpha": "0xEE9F19b5DF06c7E8Bfc7B28745dcf944C504198A", "pearl_beta": "0xeF44Fb0842DDeF59D37f85D61A1eF492bbA6135d", "pearl_beta_2": "0x1c2F82413666d2a3fD8bC337b0268e62dDF67434", - "pearl_beta_3": "0xBd59Ff0522aA773cB6074ce83cD1e4a05A457bc1", - "pearl_beta_4": "0x3052451e1eAee78e62E169AfdF6288F8791F2918", - "pearl_beta_5": "0x4Abe376Fda28c2F43b84884E5f822eA775DeA9F4", "pearl_beta_mech_marketplace": "0xDaF34eC46298b53a3d24CBCb431E84eBd23927dA", } } From dbd5c6ed96438cd5a1c1494bf0751b7653c2a8c3 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Thu, 31 Oct 2024 11:03:04 +0100 Subject: [PATCH 03/22] chore: add staking contracts --- operate/ledger/profiles.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/operate/ledger/profiles.py b/operate/ledger/profiles.py index d0e62b272..5d68ff613 100644 --- a/operate/ledger/profiles.py +++ b/operate/ledger/profiles.py @@ -40,6 +40,9 @@ "pearl_alpha": "0xEE9F19b5DF06c7E8Bfc7B28745dcf944C504198A", "pearl_beta": "0xeF44Fb0842DDeF59D37f85D61A1eF492bbA6135d", "pearl_beta_2": "0x1c2F82413666d2a3fD8bC337b0268e62dDF67434", + "pearl_beta_3": "0xBd59Ff0522aA773cB6074ce83cD1e4a05A457bc1", + "pearl_beta_4": "0x3052451e1eAee78e62E169AfdF6288F8791F2918", + "pearl_beta_5": "0x4Abe376Fda28c2F43b84884E5f822eA775DeA9F4", "pearl_beta_mech_marketplace": "0xDaF34eC46298b53a3d24CBCb431E84eBd23927dA", } } From afa37d36ebb16675021ef99fe875dd15940914d8 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:33:41 +0000 Subject: [PATCH 04/22] feat: add new staking contract proxys --- frontend/constants/contractAddresses.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/constants/contractAddresses.ts b/frontend/constants/contractAddresses.ts index 9af8f62e3..41f99a5a3 100644 --- a/frontend/constants/contractAddresses.ts +++ b/frontend/constants/contractAddresses.ts @@ -21,9 +21,14 @@ export const SERVICE_STAKING_TOKEN_MECH_USAGE_CONTRACT_ADDRESSES: Record< Record > = { [Chain.GNOSIS]: { - [StakingProgramId.Beta2]: '0x1c2F82413666d2a3fD8bC337b0268e62dDF67434', - [StakingProgramId.Beta]: '0xeF44Fb0842DDeF59D37f85D61A1eF492bbA6135d', [StakingProgramId.Alpha]: '0xEE9F19b5DF06c7E8Bfc7B28745dcf944C504198A', + + [StakingProgramId.Beta]: '0xeF44Fb0842DDeF59D37f85D61A1eF492bbA6135d', + [StakingProgramId.Beta2]: '0x1c2F82413666d2a3fD8bC337b0268e62dDF67434', + [StakingProgramId.Beta3]: '0xBd59Ff0522aA773cB6074ce83cD1e4a05A457bc1', + [StakingProgramId.Beta4]: '0x3052451e1eAee78e62E169AfdF6288F8791F2918', + [StakingProgramId.Beta5]: '0x4Abe376Fda28c2F43b84884E5f822eA775DeA9F4', + [StakingProgramId.BetaMechMarketplace]: '0xDaF34eC46298b53a3d24CBCb431E84eBd23927dA', }, From 80ecdd641656b05c3108103c7eaa7ab5587a7146 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:34:29 +0000 Subject: [PATCH 05/22] feat: make staking program meta scalable --- frontend/constants/stakingProgramMeta.ts | 42 +++++++++++++++++------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/frontend/constants/stakingProgramMeta.ts b/frontend/constants/stakingProgramMeta.ts index be8911a86..1bdebc46d 100644 --- a/frontend/constants/stakingProgramMeta.ts +++ b/frontend/constants/stakingProgramMeta.ts @@ -6,35 +6,55 @@ export type StakingProgramMeta = { deprecated: boolean; }; +const allStakingProgramIds = Object.values(StakingProgramId); +const deprecatedStakingProgramIds = [StakingProgramId.Alpha]; +const activeStakingProgramIds = allStakingProgramIds.filter( + (id) => !deprecatedStakingProgramIds.includes(id), +); + +const activeStakingProgramsWithout = (stakingProgramId: StakingProgramId) => + activeStakingProgramIds.filter((id) => id !== stakingProgramId); + export const STAKING_PROGRAM_META: Record< StakingProgramId, StakingProgramMeta > = { [StakingProgramId.Alpha]: { name: 'Pearl Alpha', - canMigrateTo: [ - StakingProgramId.Beta, - StakingProgramId.Beta2, - StakingProgramId.BetaMechMarketplace, - ], + canMigrateTo: activeStakingProgramsWithout(StakingProgramId.Alpha), deprecated: true, }, [StakingProgramId.Beta]: { name: 'Pearl Beta', - canMigrateTo: [ - StakingProgramId.Beta2, - StakingProgramId.BetaMechMarketplace, - ], + canMigrateTo: activeStakingProgramsWithout(StakingProgramId.Beta), deprecated: false, }, [StakingProgramId.Beta2]: { name: 'Pearl Beta 2', - canMigrateTo: [StakingProgramId.Beta, StakingProgramId.BetaMechMarketplace], + canMigrateTo: activeStakingProgramsWithout(StakingProgramId.Beta2), + deprecated: false, + }, + [StakingProgramId.Beta3]: { + name: 'Pearl Beta 3', + canMigrateTo: activeStakingProgramsWithout(StakingProgramId.Beta3), deprecated: false, }, + [StakingProgramId.Beta4]: { + name: 'Pearl Beta 4', + canMigrateTo: activeStakingProgramsWithout(StakingProgramId.Beta4), + deprecated: false, + }, + [StakingProgramId.Beta5]: { + name: 'Pearl Beta 5', + canMigrateTo: activeStakingProgramsWithout(StakingProgramId.Beta5), + deprecated: false, + }, + [StakingProgramId.BetaMechMarketplace]: { name: 'Pearl Beta Mech Marketplace', - canMigrateTo: [StakingProgramId.Beta, StakingProgramId.Beta2], + canMigrateTo: activeStakingProgramsWithout( + StakingProgramId.BetaMechMarketplace, + ), deprecated: false, }, }; From 1e908094c555083f96a47277bdc8a2bacd413b85 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:34:51 +0000 Subject: [PATCH 06/22] feat: generate stakingContractInfoRecord instead of manual --- .../context/StakingContractInfoProvider.tsx | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/frontend/context/StakingContractInfoProvider.tsx b/frontend/context/StakingContractInfoProvider.tsx index 115df8d0e..5254a31f6 100644 --- a/frontend/context/StakingContractInfoProvider.tsx +++ b/frontend/context/StakingContractInfoProvider.tsx @@ -84,29 +84,24 @@ export const StakingContractInfoProvider = ({ /** Updates general staking contract information, not user or service specific */ const updateStakingContractInfoRecord = async () => { - const alpha = AutonolasService.getStakingContractInfoByStakingProgram( - StakingProgramId.Alpha, - ); - const beta = AutonolasService.getStakingContractInfoByStakingProgram( - StakingProgramId.Beta, - ); - const beta2 = AutonolasService.getStakingContractInfoByStakingProgram( - StakingProgramId.Beta2, - ); - const betaMechMarketplace = - AutonolasService.getStakingContractInfoByStakingProgram( - StakingProgramId.BetaMechMarketplace, - ); + const stakingPrograms = Object.values(StakingProgramId); try { - const [alphaInfo, betaInfo, beta2Info, betaMechMarketplaceInfo] = - await Promise.all([alpha, beta, beta2, betaMechMarketplace]); - setStakingContractInfoRecord({ - [StakingProgramId.Alpha]: alphaInfo, - [StakingProgramId.Beta]: betaInfo, - [StakingProgramId.Beta2]: beta2Info, - [StakingProgramId.BetaMechMarketplace]: betaMechMarketplaceInfo, - }); + const stakingInfoPromises = stakingPrograms.map((programId) => + AutonolasService.getStakingContractInfoByStakingProgram(programId), + ); + + const stakingInfos = await Promise.all(stakingInfoPromises); + + const stakingContractInfoRecord = stakingPrograms.reduce( + (record, programId, index) => { + record[programId] = stakingInfos[index]; + return record; + }, + {} as Record>, + ); + + setStakingContractInfoRecord(stakingContractInfoRecord); setIsStakingContractInfoLoaded(true); } catch (e) { console.error(e); From a56fe5c3741bf38b5825de34dce9afc0f5ec69cf Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:35:05 +0000 Subject: [PATCH 07/22] feat: export default staking contract to avoid future breaking --- frontend/context/StakingProgramProvider.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/context/StakingProgramProvider.tsx b/frontend/context/StakingProgramProvider.tsx index 39e6ba2ab..c07514fb5 100644 --- a/frontend/context/StakingProgramProvider.tsx +++ b/frontend/context/StakingProgramProvider.tsx @@ -6,13 +6,15 @@ import { StakingProgramId } from '@/enums/StakingProgram'; import { useServices } from '@/hooks/useServices'; import { AutonolasService } from '@/service/Autonolas'; +export const DEFAULT_STAKING_PROGRAM_ID = StakingProgramId.Beta; + export const StakingProgramContext = createContext<{ activeStakingProgramId?: StakingProgramId | null; defaultStakingProgramId: StakingProgramId; updateActiveStakingProgramId: () => Promise; }>({ activeStakingProgramId: undefined, - defaultStakingProgramId: StakingProgramId.Beta, + defaultStakingProgramId: DEFAULT_STAKING_PROGRAM_ID, updateActiveStakingProgramId: async () => {}, }); @@ -50,7 +52,7 @@ export const StakingProgramProvider = ({ children }: PropsWithChildren) => { value={{ activeStakingProgramId, updateActiveStakingProgramId, - defaultStakingProgramId: StakingProgramId.Beta, + defaultStakingProgramId: DEFAULT_STAKING_PROGRAM_ID, }} > {children} From 65041f545cec8f9cb23d6c546e35b2e867884b1c Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:35:16 +0000 Subject: [PATCH 08/22] feat: extend StakingProgramId enum --- frontend/enums/StakingProgram.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/enums/StakingProgram.ts b/frontend/enums/StakingProgram.ts index 1ad892083..2156ff246 100644 --- a/frontend/enums/StakingProgram.ts +++ b/frontend/enums/StakingProgram.ts @@ -2,5 +2,8 @@ export enum StakingProgramId { Alpha = 'pearl_alpha', Beta = 'pearl_beta', Beta2 = 'pearl_beta_2', + Beta3 = 'pearl_beta_3', + Beta4 = 'pearl_beta_4', + Beta5 = 'pearl_beta_5', BetaMechMarketplace = 'pearl_beta_mech_marketplace', } From 80d6c0ea4144220b95f8358861675292a1d92d63 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:35:36 +0000 Subject: [PATCH 09/22] feat: create staking token contract instances dynamically --- frontend/service/Autonolas.ts | 38 +++++++++++------------------------ 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/frontend/service/Autonolas.ts b/frontend/service/Autonolas.ts index ab29d95a3..2ae3f05af 100644 --- a/frontend/service/Autonolas.ts +++ b/frontend/service/Autonolas.ts @@ -35,32 +35,18 @@ const ServiceStakingTokenAbi = SERVICE_STAKING_TOKEN_MECH_USAGE_ABI.filter( const serviceStakingTokenMechUsageContracts: Record< StakingProgramId, MulticallContract -> = { - [StakingProgramId.Alpha]: new MulticallContract( - SERVICE_STAKING_TOKEN_MECH_USAGE_CONTRACT_ADDRESSES[Chain.GNOSIS][ - StakingProgramId.Alpha - ], - ServiceStakingTokenAbi, - ), - [StakingProgramId.Beta]: new MulticallContract( - SERVICE_STAKING_TOKEN_MECH_USAGE_CONTRACT_ADDRESSES[Chain.GNOSIS][ - StakingProgramId.Beta - ], - ServiceStakingTokenAbi, - ), - [StakingProgramId.Beta2]: new MulticallContract( - SERVICE_STAKING_TOKEN_MECH_USAGE_CONTRACT_ADDRESSES[Chain.GNOSIS][ - StakingProgramId.Beta2 - ], - ServiceStakingTokenAbi, - ), - [StakingProgramId.BetaMechMarketplace]: new MulticallContract( - SERVICE_STAKING_TOKEN_MECH_USAGE_CONTRACT_ADDRESSES[Chain.GNOSIS][ - StakingProgramId.BetaMechMarketplace - ], - ServiceStakingTokenAbi, - ), -}; +> = Object.values(StakingProgramId).reduce( + (contracts, programId) => { + contracts[programId] = new MulticallContract( + SERVICE_STAKING_TOKEN_MECH_USAGE_CONTRACT_ADDRESSES[Chain.GNOSIS][ + programId + ], + ServiceStakingTokenAbi, + ); + return contracts; + }, + {} as Record, +); const serviceRegistryTokenUtilityContract = new MulticallContract( SERVICE_REGISTRY_TOKEN_UTILITY_CONTRACT_ADDRESS[Chain.GNOSIS], From 46e43cebbd45b1d6927519caef366cb6316d1dd1 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:35:50 +0000 Subject: [PATCH 10/22] feat: add minimum stake requirements for new contracts --- frontend/utils/service.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/utils/service.ts b/frontend/utils/service.ts index cdecb71f9..53ec7fc7c 100644 --- a/frontend/utils/service.ts +++ b/frontend/utils/service.ts @@ -1,10 +1,11 @@ import { ServiceTemplate } from '@/client'; +import { DEFAULT_STAKING_PROGRAM_ID } from '@/context/StakingProgramProvider'; import { StakingProgramId } from '@/enums/StakingProgram'; /** TODO: update from hardcoded, workaround for quick release */ export const getMinimumStakedAmountRequired = ( serviceTemplate?: ServiceTemplate, //TODO: remove, as unused - stakingProgramId: StakingProgramId = StakingProgramId.Beta, + stakingProgramId: StakingProgramId = DEFAULT_STAKING_PROGRAM_ID, ): number | undefined => { if (stakingProgramId === StakingProgramId.Alpha) { return 20; @@ -18,6 +19,18 @@ export const getMinimumStakedAmountRequired = ( return 100; } + if (stakingProgramId === StakingProgramId.Beta3) { + return 100; + } + + if (stakingProgramId === StakingProgramId.Beta4) { + return 100; + } + + if (stakingProgramId === StakingProgramId.Beta5) { + return 10; + } + if (stakingProgramId === StakingProgramId.BetaMechMarketplace) { return 40; } From f91ec4a05000d42c305efad3c390969e5e8823a7 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:42:02 +0000 Subject: [PATCH 11/22] fix: typo --- .../ManageStakingPage/StakingContractSection/useMigrate.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx b/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx index bdff573c8..ec03692e8 100644 --- a/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx +++ b/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx @@ -17,7 +17,7 @@ export enum CantMigrateReason { InsufficientOlasToMigrate = 'Insufficient OLAS to switch', MigrationNotSupported = 'Switching to this program is not currently supported', NoAvailableRewards = 'This program has no rewards available', - NoAvailableStakingSlots = 'The program has no more avaiable slots', + NoAvailableStakingSlots = 'The program has no more available slots', NotStakedForMinimumDuration = 'Pearl has not been staked for the required minimum duration', PearlCurrentlyRunning = 'Unable to switch while Pearl is running', LoadingServices = 'Loading services...', From 669d526299eef529da6b58aa164e1c67444a0f8e Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 10:42:17 +0000 Subject: [PATCH 12/22] fix: allow singular failures in promise all --- frontend/context/StakingContractInfoProvider.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/context/StakingContractInfoProvider.tsx b/frontend/context/StakingContractInfoProvider.tsx index 5254a31f6..ca41801bb 100644 --- a/frontend/context/StakingContractInfoProvider.tsx +++ b/frontend/context/StakingContractInfoProvider.tsx @@ -91,11 +91,12 @@ export const StakingContractInfoProvider = ({ AutonolasService.getStakingContractInfoByStakingProgram(programId), ); - const stakingInfos = await Promise.all(stakingInfoPromises); + const stakingInfos = await Promise.allSettled(stakingInfoPromises); const stakingContractInfoRecord = stakingPrograms.reduce( (record, programId, index) => { - record[programId] = stakingInfos[index]; + if (stakingInfos[index].status === 'rejected') return record; + record[programId] = stakingInfos[index].value; return record; }, {} as Record>, From 464983e8c2f89db5752c92c7f6ff13bfce1e0472 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 14:01:24 +0000 Subject: [PATCH 13/22] feat: integrate available rewards check --- frontend/context/StakingContractInfoProvider.tsx | 5 ++++- frontend/hooks/useStakingContractInfo.ts | 4 ++-- frontend/service/Autonolas.ts | 13 ++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend/context/StakingContractInfoProvider.tsx b/frontend/context/StakingContractInfoProvider.tsx index ca41801bb..8533046d4 100644 --- a/frontend/context/StakingContractInfoProvider.tsx +++ b/frontend/context/StakingContractInfoProvider.tsx @@ -95,7 +95,10 @@ export const StakingContractInfoProvider = ({ const stakingContractInfoRecord = stakingPrograms.reduce( (record, programId, index) => { - if (stakingInfos[index].status === 'rejected') return record; + if (stakingInfos[index].status === 'rejected') { + console.error(stakingInfos[index].reason); + return record; + } record[programId] = stakingInfos[index].value; return record; }, diff --git a/frontend/hooks/useStakingContractInfo.ts b/frontend/hooks/useStakingContractInfo.ts index 72f24d6b8..96860360d 100644 --- a/frontend/hooks/useStakingContractInfo.ts +++ b/frontend/hooks/useStakingContractInfo.ts @@ -29,13 +29,13 @@ export const useStakingContractInfo = () => { const { serviceStakingState, serviceStakingStartTime, - //availableRewards, // TODO: uncomment when availableRewards is available serviceIds, maxNumServices, minimumStakingDuration, + availableRewards, } = activeStakingContractInfo; - const isRewardsAvailable = true; // availableRewards > 0; + const isRewardsAvailable = availableRewards ?? 0 > 0; const hasEnoughServiceSlots = !isNil(serviceIds) && diff --git a/frontend/service/Autonolas.ts b/frontend/service/Autonolas.ts index 2ae3f05af..094662231 100644 --- a/frontend/service/Autonolas.ts +++ b/frontend/service/Autonolas.ts @@ -292,19 +292,26 @@ const getStakingContractInfoByStakingProgram = async ( const availableRewards = parseFloat( ethers.utils.formatUnits(availableRewardsInBN, 18), ); + const serviceIds = getServiceIdsInBN.map((id: BigNumber) => id.toNumber()); const maxNumServices = maxNumServicesInBN.toNumber(); // APY const rewardsPerYear = rewardsPerSecond.mul(ONE_YEAR); - const apy = - Number(rewardsPerYear.mul(100).div(minStakingDeposit)) / - (1 + numAgentInstances.toNumber()); + + let apy = 0; + + if (rewardsPerSecond.gt(0) && minStakingDeposit.gt(0)) { + apy = + Number(rewardsPerYear.mul(100).div(minStakingDeposit)) / + (1 + numAgentInstances.toNumber()); + } // Amount of OLAS required for Stake const stakeRequiredInWei = minStakingDeposit.add( minStakingDeposit.mul(numAgentInstances), ); + const olasStakeRequired = Number(formatEther(stakeRequiredInWei)); // Rewards per work period From 760683de25b1bb8fb6d393f400565a9ffd1468a0 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 14:02:01 +0000 Subject: [PATCH 14/22] fix: simplify dev script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 748693e90..9265e1a3c 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "install:frontend": "cd frontend && yarn", "lint:frontend": "cd frontend && yarn lint", "start": "yarn electron .", - "dev": "dotenv -e .env -- yarn start", + "dev": "dotenv -e .env -- electron .", "start:frontend": "cd frontend && yarn start", "test:frontend": "cd frontend && yarn test", "download-binaries": "sh download_binaries.sh", From 37c86f43b78fab87afb86e89b5df9bf3149fda7b Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 14:05:07 +0000 Subject: [PATCH 15/22] bump: rc183 --- package.json | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9265e1a3c..9546adada 100644 --- a/package.json +++ b/package.json @@ -63,5 +63,5 @@ "download-binaries": "sh download_binaries.sh", "build:pearl": "sh build_pearl.sh" }, - "version": "0.1.0-rc182" + "version": "0.1.0-rc183" } \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 2f3dd9963..44500eb8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc182" +version = "0.1.0-rc183" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From c5d067a60d38bc5d5164fe9d459d77c47096ba62 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 15:11:00 +0000 Subject: [PATCH 16/22] fix(tiny): available rewards condition update --- .../ManageStakingPage/StakingContractSection/useMigrate.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx b/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx index ec03692e8..624b9288c 100644 --- a/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx +++ b/frontend/components/ManageStakingPage/StakingContractSection/useMigrate.tsx @@ -208,7 +208,7 @@ export const useMigrate = (stakingProgramId: StakingProgramId) => { const stakingContractInfo = stakingContractInfoRecord?.[stakingProgramId]; - if (stakingContractInfo?.availableRewards === 0) { + if ((stakingContractInfo?.availableRewards ?? 0) <= 0) { return { canMigrate: false, reason: CantMigrateReason.NoAvailableRewards, From f0e54d1ebff8ed16a4039a921d8030d82730b442 Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 31 Oct 2024 15:47:41 +0000 Subject: [PATCH 17/22] fix: missing isStaked checks on new contracts --- frontend/service/Autonolas.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/service/Autonolas.ts b/frontend/service/Autonolas.ts index 094662231..f926daab1 100644 --- a/frontend/service/Autonolas.ts +++ b/frontend/service/Autonolas.ts @@ -395,6 +395,9 @@ const getCurrentStakingProgramByServiceId = async ( isAlphaStaked, isBetaStaked, isBeta2Staked, + isBeta3Staked, + isBeta4Staked, + isBeta5Staked, isBetaMechMarketplaceStaked, ] = await gnosisMulticallProvider.all(Object.values(contractCalls)); @@ -410,6 +413,18 @@ const getCurrentStakingProgramByServiceId = async ( return StakingProgramId.Beta2; } + if (isBeta3Staked) { + return StakingProgramId.Beta3; + } + + if (isBeta4Staked) { + return StakingProgramId.Beta4; + } + + if (isBeta5Staked) { + return StakingProgramId.Beta5; + } + if (isBetaMechMarketplaceStaked) { return StakingProgramId.BetaMechMarketplace; } From e7d4e8eeb59eef3c91f91dd5dd93302e7b655a43 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Tue, 29 Oct 2024 15:33:20 +0300 Subject: [PATCH 18/22] num of fails for healthchecker increased to 10 --- operate/cli.py | 2 +- operate/constants.py | 3 +++ operate/services/health_checker.py | 24 ++++++++++++++---------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/operate/cli.py b/operate/cli.py index ce4725d5f..2fcab5fed 100644 --- a/operate/cli.py +++ b/operate/cli.py @@ -145,7 +145,7 @@ def create_app( # pylint: disable=too-many-locals, unused-argument, too-many-st ) -> FastAPI: """Create FastAPI object.""" HEALTH_CHECKER_OFF = os.environ.get("HEALTH_CHECKER_OFF", "0") == "1" - number_of_fails = int(os.environ.get("HEALTH_CHECKER_TRIES", "5")) + number_of_fails = int(os.environ.get("HEALTH_CHECKER_TRIES", str(HealthChecker.NUMBER_OF_FAILS_DEFAULT))) logger = setup_logger(name="operate") if HEALTH_CHECKER_OFF: diff --git a/operate/constants.py b/operate/constants.py index 8af868559..d29aef244 100644 --- a/operate/constants.py +++ b/operate/constants.py @@ -35,3 +35,6 @@ ON_CHAIN_INTERACT_TIMEOUT = 120.0 ON_CHAIN_INTERACT_RETRIES = 40 ON_CHAIN_INTERACT_SLEEP = 3.0 + +#HEALTH_CHECK_URL = "http://localhost:8716/healthcheck" +HEALTH_CHECK_URL = "http://127.0.0.1:8716/healthcheck" # possible DNS issues on windows? \ No newline at end of file diff --git a/operate/services/health_checker.py b/operate/services/health_checker.py index 7a9c27373..13e516a8f 100644 --- a/operate/services/health_checker.py +++ b/operate/services/health_checker.py @@ -19,6 +19,7 @@ # ------------------------------------------------------------------------------ """Source code for checking aea is alive..""" import asyncio +from traceback import print_exc import typing as t from concurrent.futures import ThreadPoolExecutor @@ -26,7 +27,7 @@ from aea.helpers.logging import setup_logger from operate.services.manage import ServiceManager # type: ignore - +from operate.constants import HEALTH_CHECK_URL HTTP_OK = 200 @@ -36,7 +37,8 @@ class HealthChecker: SLEEP_PERIOD_DEFAULT = 30 PORT_UP_TIMEOUT_DEFAULT = 120 # seconds - NUMBER_OF_FAILS_DEFAULT = 5 + NUMBER_OF_FAILS_DEFAULT = 10 + HEALTH_CHECK_URL = HEALTH_CHECK_URL def __init__( self, @@ -79,12 +81,12 @@ def stop_for_service(self, service: str) -> None: f"[HEALTH_CHECKER]: Healthcheck job cancellation for {service} failed" ) - @staticmethod - async def check_service_health(service: str) -> bool: + @classmethod + async def check_service_health(cls, service: str) -> bool: """Check the service health""" del service async with aiohttp.ClientSession() as session: - async with session.get("http://localhost:8716/healthcheck") as resp: + async with session.get(cls.HEALTH_CHECK_URL) as resp: status = resp.status response_json = await resp.json() return status == HTTP_OK and response_json.get( @@ -134,15 +136,16 @@ async def _check_health( try: # Check the service health healthy = await self.check_service_health(service) - except aiohttp.ClientConnectionError: - self.logger.info( - f"[HEALTH_CHECKER] {service} port read failed. restart" + except aiohttp.ClientConnectionError as e: + print_exc() + self.logger.warning( + f"[HEALTH_CHECKER] {service} port read failed. assume not healthy {e}" ) - return + healthy = False if not healthy: fails += 1 - self.logger.info( + self.logger.warning( f"[HEALTH_CHECKER] {service} not healthy for {fails} time in a row" ) else: @@ -156,6 +159,7 @@ async def _check_health( f"[HEALTH_CHECKER] {service} failed {fails} times in a row. restart" ) return + await asyncio.sleep(sleep_period) async def _restart(service_manager: ServiceManager, service: str) -> None: From a7630e6ef3f027d0992f605b603238246ec9d392 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Fri, 1 Nov 2024 08:31:15 +0300 Subject: [PATCH 19/22] utf-8 fix --- operate/cli.py | 3 +++ operate/services/deployment_runner.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/operate/cli.py b/operate/cli.py index 2fcab5fed..c0d9734a0 100644 --- a/operate/cli.py +++ b/operate/cli.py @@ -18,6 +18,9 @@ # ------------------------------------------------------------------------------ """Operate app CLI module.""" +# set encoding! +import sys +sys.setdefaultencoding('utf-8') import asyncio import logging diff --git a/operate/services/deployment_runner.py b/operate/services/deployment_runner.py index ebde6527b..f9616821b 100644 --- a/operate/services/deployment_runner.py +++ b/operate/services/deployment_runner.py @@ -119,7 +119,7 @@ def _prepare_agent_env(self) -> Any: # TODO: Dynamic port allocation, backport to service builder env["CONNECTION_ABCI_CONFIG_HOST"] = "localhost" env["CONNECTION_ABCI_CONFIG_PORT"] = "26658" - + env["PYTHONUTF8"] = "1" for var in env: # Fix tendermint connection params if var.endswith("MODELS_PARAMS_ARGS_TENDERMINT_COM_URL"): @@ -249,6 +249,7 @@ def _start_tendermint(self) -> None: """Start tendermint process.""" working_dir = self._work_directory env = json.loads((working_dir / "tendermint.json").read_text(encoding="utf-8")) + env["PYTHONUTF8"] = "1" env = { **os.environ, **env, @@ -306,6 +307,7 @@ def _start_agent(self) -> None: """Start agent process.""" working_dir = self._work_directory env = json.loads((working_dir / "agent.json").read_text(encoding="utf-8")) + env["PYTHONUTF8"] = "1" process = subprocess.Popen( # pylint: disable=consider-using-with # nosec args=[self._aea_bin, "run"], cwd=str(working_dir / "agent"), @@ -323,6 +325,7 @@ def _start_tendermint(self) -> None: """Start tendermint process.""" working_dir = self._work_directory env = json.loads((working_dir / "tendermint.json").read_text(encoding="utf-8")) + env["PYTHONUTF8"] = "1" process = subprocess.Popen( # pylint: disable=consider-using-with # nosec args=[ str(self._venv_dir / "bin" / "flask"), From f3031d912a726453a008d78d91f7cc63e6f1aa18 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Fri, 1 Nov 2024 15:09:17 +0300 Subject: [PATCH 20/22] linting and fixes --- electron/install.js | 2 ++ operate/cli.py | 10 +++++----- operate/constants.py | 3 +-- operate/services/deployment_runner.py | 8 ++++++++ operate/services/health_checker.py | 5 +++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/electron/install.js b/electron/install.js index 4df11f4ee..b6c22f313 100644 --- a/electron/install.js +++ b/electron/install.js @@ -24,6 +24,8 @@ const Env = { ...process.env, PATH: `${process.env.PATH}:/opt/homebrew/bin:/usr/local/bin`, HOMEBREW_NO_AUTO_UPDATE: '1', + PYTHONUTF8: '1', + PYTHONIOENCODING: 'utf8' }; const SudoOptions = { diff --git a/operate/cli.py b/operate/cli.py index c0d9734a0..c2e425c43 100644 --- a/operate/cli.py +++ b/operate/cli.py @@ -18,10 +18,6 @@ # ------------------------------------------------------------------------------ """Operate app CLI module.""" -# set encoding! -import sys -sys.setdefaultencoding('utf-8') - import asyncio import logging import os @@ -148,7 +144,11 @@ def create_app( # pylint: disable=too-many-locals, unused-argument, too-many-st ) -> FastAPI: """Create FastAPI object.""" HEALTH_CHECKER_OFF = os.environ.get("HEALTH_CHECKER_OFF", "0") == "1" - number_of_fails = int(os.environ.get("HEALTH_CHECKER_TRIES", str(HealthChecker.NUMBER_OF_FAILS_DEFAULT))) + number_of_fails = int( + os.environ.get( + "HEALTH_CHECKER_TRIES", str(HealthChecker.NUMBER_OF_FAILS_DEFAULT) + ) + ) logger = setup_logger(name="operate") if HEALTH_CHECKER_OFF: diff --git a/operate/constants.py b/operate/constants.py index d29aef244..4a2b77f24 100644 --- a/operate/constants.py +++ b/operate/constants.py @@ -36,5 +36,4 @@ ON_CHAIN_INTERACT_RETRIES = 40 ON_CHAIN_INTERACT_SLEEP = 3.0 -#HEALTH_CHECK_URL = "http://localhost:8716/healthcheck" -HEALTH_CHECK_URL = "http://127.0.0.1:8716/healthcheck" # possible DNS issues on windows? \ No newline at end of file +HEALTH_CHECK_URL = "http://127.0.0.1:8716/healthcheck" # possible DNS issues on windows so use IP address diff --git a/operate/services/deployment_runner.py b/operate/services/deployment_runner.py index f9616821b..4f10dae88 100644 --- a/operate/services/deployment_runner.py +++ b/operate/services/deployment_runner.py @@ -229,6 +229,8 @@ def _start_agent(self) -> None: """Start agent process.""" working_dir = self._work_directory env = json.loads((working_dir / "agent.json").read_text(encoding="utf-8")) + env["PYTHONUTF8"] = "1" + env["PYTHONIOENCODING"] = "utf8" env = {**os.environ, **env} process = subprocess.Popen( # pylint: disable=consider-using-with # nosec args=[self._aea_bin, "run"], @@ -250,6 +252,8 @@ def _start_tendermint(self) -> None: working_dir = self._work_directory env = json.loads((working_dir / "tendermint.json").read_text(encoding="utf-8")) env["PYTHONUTF8"] = "1" + env["PYTHONIOENCODING"] = "utf8" + env = { **os.environ, **env, @@ -308,6 +312,8 @@ def _start_agent(self) -> None: working_dir = self._work_directory env = json.loads((working_dir / "agent.json").read_text(encoding="utf-8")) env["PYTHONUTF8"] = "1" + env["PYTHONIOENCODING"] = "utf8" + process = subprocess.Popen( # pylint: disable=consider-using-with # nosec args=[self._aea_bin, "run"], cwd=str(working_dir / "agent"), @@ -326,6 +332,8 @@ def _start_tendermint(self) -> None: working_dir = self._work_directory env = json.loads((working_dir / "tendermint.json").read_text(encoding="utf-8")) env["PYTHONUTF8"] = "1" + env["PYTHONIOENCODING"] = "utf8" + process = subprocess.Popen( # pylint: disable=consider-using-with # nosec args=[ str(self._venv_dir / "bin" / "flask"), diff --git a/operate/services/health_checker.py b/operate/services/health_checker.py index 13e516a8f..4f1d91aa9 100644 --- a/operate/services/health_checker.py +++ b/operate/services/health_checker.py @@ -19,15 +19,16 @@ # ------------------------------------------------------------------------------ """Source code for checking aea is alive..""" import asyncio -from traceback import print_exc import typing as t from concurrent.futures import ThreadPoolExecutor +from traceback import print_exc import aiohttp # type: ignore from aea.helpers.logging import setup_logger -from operate.services.manage import ServiceManager # type: ignore from operate.constants import HEALTH_CHECK_URL +from operate.services.manage import ServiceManager # type: ignore + HTTP_OK = 200 From e8db80a696247f7f18709657449ebcdd6a95258f Mon Sep 17 00:00:00 2001 From: Mohan Date: Fri, 1 Nov 2024 20:21:32 +0530 Subject: [PATCH 21/22] refactor: improve layout and styling of seed phrase display (#419) --- .../SetupPage/Create/SetupSeedPhrase.tsx | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/frontend/components/SetupPage/Create/SetupSeedPhrase.tsx b/frontend/components/SetupPage/Create/SetupSeedPhrase.tsx index f133f35a5..46a8d1bca 100644 --- a/frontend/components/SetupPage/Create/SetupSeedPhrase.tsx +++ b/frontend/components/SetupPage/Create/SetupSeedPhrase.tsx @@ -18,29 +18,36 @@ export const SetupSeedPhrase = () => { Back up seed phrase - - Seed phrase is needed to regain access to your account if you forget the - password. - - - {mnemonic.map((word: string) => ( - {word} - ))} - - - - + + + Seed phrase is needed to regain access to your account if you forget + the password. + + + {mnemonic.map((word: string) => ( + + {word} + + ))} + + + + + ); From 63f6810fd3c0411424c62927c6865091ecd69254 Mon Sep 17 00:00:00 2001 From: truemiller Date: Fri, 1 Nov 2024 15:51:11 +0000 Subject: [PATCH 22/22] bump: rc184 --- package.json | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9546adada..281333811 100644 --- a/package.json +++ b/package.json @@ -63,5 +63,5 @@ "download-binaries": "sh download_binaries.sh", "build:pearl": "sh build_pearl.sh" }, - "version": "0.1.0-rc183" + "version": "0.1.0-rc184" } \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 44500eb8e..0a48a9d4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc183" +version = "0.1.0-rc184" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md"