Skip to content

Commit

Permalink
feat: staging to main (#335)
Browse files Browse the repository at this point in the history
* initial win support

* win: process kill fixes

* win: tendermint installation automated

* helthchecker env vars to switch it off. small refactoring

* service hash id updated

* use bundled in tendermint.exe, not download it

* lint fixes

* feat: add staking deployment vars

* feat: added pearl beta 2 address & section

* chore: add pearl beta 2 address

* chore: init

* chore: comment env example

* fix: isNil check for low balance

* fix: serviceFundRequirements coalesce

* refactor: order and map staking contracts

* fix: required olas when both staked and not staked

* feat: update StakingContractSection to support multi-contract

* feat: updated STAKING_PROGRAM_META with deprecated and supported migration targets

* fix: isAddress checks to protect against 0xm

* feat: added pearl_beta_2 to StakingContractInfo record

* feat: add pearl_beta_2 Beta2 enum

* chore: comment availableRewards until it's used

* feat: extend serviceStakingMechUsageContracts with pearl_beta_2, protect against -1 serviceId

* fix: protect against -1 serviceId related errors

* feat: add pearl_beta_2 requirement

* bump: rc124 for test release

* add staking contract update button in homepage

* update contract UI

* update

* win release updates

* add loading state

* workflow cleanup

* fix: default contract fallback, instead of "not staked"

* fix: broken import (kebabCase import)

* bump: rc125

* win build poetry version bump

* fix: added minimum staking duration to migration condition

* fix for windows tendermint bundle in

* fix: disable hash update

* fix: migration countdown, and minimum duration fix from staging

* fix: typos

* refactor: popover copy

* fix: typo

* fix for tendermint PATH env vars

* feat: Disable the staking contract button if the balance is low. (#317)

* feat: disable staking contract button if low balance

* feat: update staking contract button popover message

* feat: add useNeedsFunds hook

* feat: integrate useNeedsFunds hook for disable staking contract

* update logic

* refactor: remove OLAS requirement from notification

* fix: commented link to broken site

* feat: Staking info per contract (#325)

* refractor: tiny format document

* feat: add InfoBreakdown component

* feat: replace OlasBalanceSection with BalanceBreakdown

* refactor: Update InfoBreakdown component and add InfoBreakdownList

* feat: add more contract methods for staking info

* move from different function inside the main one (Autonolas.ts)

* feat: add types

* refactor: Update StakingContractSection component and add StakingContractInfo

* other changes

* feat: minor

* feat: address Josh review changes

* feat: Add balance polling pause functionality to StakingContractSection (#330)

* bump: rc126

* hotfix: undefined fixes in useStakingContractInfo hook for build 126

* refactor: simplify logic, remove New tag

* chore: remove redundant "New" objects

* fix: remove commented mistakenly commented code

* feat: Update backup wallet alert copy (#341)

* feat: Add backup wallet warning message

* update text

* refactor: cleanup staking program parse from contract

* chore: update minimum staking duration comment

* feat: add loader to staking contract info provider

* refactor: return loader from hook, rework comments, add service staked check

* refactor: match active staking program type meta with active staking program type

* refactor: rewrite staking contract section to consolidate, clean-up business logic

* chore: delete huge comment block (cantMigrateReason)

* fix: migrate button display logic

* fix: Release 0.1.0-rc126 issues (#342)

* Refactor SetupWelcome component to handle account setup state correctly

* feat: trigger IPC call on app load (with commented code)

* feat: remove all comments from main.js

* Update frontend/components/ManageStakingPage/StakingContractSection/index.tsx

* Update frontend/components/ManageStakingPage/StakingContractSection/index.tsx

* Update frontend/components/ManageStakingPage/StakingContractSection/index.tsx

Co-authored-by: Mohan <[email protected]>

* Update frontend/components/ManageStakingPage/StakingContractSection/index.tsx

* chore: prettier fix

* refactor: seperate CountdownUntilMigration

* hotfix: update actions/upload-artifact to v4

* hotfix: update checkout and download-artifact actions to v4

* fix: add version prefix

* bump: rc127

* refactor: numerous changes

* chore: fix leftover `stakingProgram` references

* chore: comment purpose

* fix: migration and funding button validation

* fix: migrate & funding button condition fixes

* refactor: can't migrate reason copy

* chore: leftover `stakingProgramId` refactor

* fix: experienced bug where alpha showed during migration

* fix: use Text component instead of span

* fix: Badge "Active" status to be displayed only on active staking contract  (#345)

* fix StakingContractTag

* fix

* fix: reinstate #345 changes after overwrite due to merge conflicts

* chore: better comment

* Update frontend/components/ManageStakingPage/StakingContractSection/CountdownUntilMigration.tsx

Co-authored-by: Mohan <[email protected]>

* Update frontend/components/ManageStakingPage/StakingContractSection/CountdownUntilMigration.tsx

---------

Co-authored-by: Yuri (solarw) Turchenkov <[email protected]>
Co-authored-by: jmoreira-valory <[email protected]>
Co-authored-by: truemiller <[email protected]>
Co-authored-by: Josh Miller <[email protected]>
  • Loading branch information
5 people authored Sep 12, 2024
1 parent e6128a4 commit 6e33a9a
Show file tree
Hide file tree
Showing 67 changed files with 2,181 additions and 1,283 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FORK_URL=
NODE_ENV=
FORK_URL=
DEV_RPC=

# TODO: determine if these are needed
STAKING_TEST_KEYS_PATH=
IS_STAGING=
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Node.js (for package scripts)
- uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/common_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
python-version: ["3.10.9"]
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
poetry run pyinstaller --collect-data eth_account --collect-all aea --collect-all autonomy --collect-all operate --collect-all aea_ledger_ethereum --collect-all aea_ledger_cosmos --collect-all aea_ledger_ethereum_flashbots --hidden-import aea_ledger_ethereum --hidden-import aea_ledger_cosmos --hidden-import aea_ledger_ethereum_flashbots operate/pearl.py --add-binary dist/aea_bin:. --add-binary dist/tendermint:. --onefile --name pearl_${{ env.OS_ARCH }}
- name: Upload Release Assets
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: pearl_${{ env.OS_ARCH }}
path: dist/pearl_${{ env.OS_ARCH }}
Expand All @@ -64,20 +64,20 @@ jobs:
needs:
- "build-macos-pyinstaller"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: pearl_x64
path: electron/bins/
- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: pearl_arm64
path: electron/bins/
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/release_win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release for Windows

on:
push:
tags:
- 'v*.*.*'

jobs:
build-windows:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.10'

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: '1.8.3'
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-path: ~/my-custom-path
installer-parallel: true
- name: Install dependencies
run: poetry install

- name: install node deps
run: yarn install-deps

- name: set env vars to prod.env
env:
NODE_ENV: production
DEV_RPC: https://rpc-gate.autonolas.tech/gnosis-rpc/
IS_STAGING: ${{ github.ref != 'refs/heads/main' && 'true' || 'false' }}
FORK_URL: https://rpc-gate.autonolas.tech/gnosis-rpc/
GH_TOKEN: ${{ secrets.github_token}}
run: |
echo NODE_ENV=$NODE_ENV >> prod.env
echo DEV_RPC=$DEV_RPC >> prod.env
echo IS_STAGING=$IS_STAGING >> prod.env
echo FORK_URL=$FORK_URL >> prod.env
cat prod.env
echo GH_TOKEN=$GH_TOKEN >> prod.env
- run: rm -rf /dist
- name: "Build, notarize, publish"
run: make build
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

define setup_env
$(eval ENV_FILE := $(1).env)
@echo " - setup env $(ENV_FILE)"
$(eval include $(1).env)
$(eval export)
endef


./trader/:
pwd
git clone https://github.com/valory-xyz/trader.git

./dist/aea_win.exe: ./trader/
mkdir -p dist
cd trader && poetry install && poetry run pyinstaller --collect-data eth_account --collect-all aea --collect-all autonomy --collect-all operate --collect-all aea_ledger_ethereum --collect-all aea_ledger_cosmos --collect-all aea_ledger_ethereum_flashbots --hidden-import aea_ledger_ethereum --hidden-import aea_ledger_cosmos --hidden-import aea_ledger_ethereum_flashbots --hidden-import grpc --hidden-import openapi_core --collect-all google.protobuf --collect-all openapi_core --collect-all openapi_spec_validator --collect-all asn1crypto --hidden-import py_ecc --hidden-import pytz --onefile pyinstaller/trader_bin.py --name trader_win
cp -f trader/dist/trader_win.exe ./dist/aea_win.exe
pwd


./dist/tendermint_win.exe: ./operate/
pwd
poetry install && poetry run pyinstaller operate/services/utils/tendermint.py --onefile --name tendermint_win


./dist/pearl_win.exe: ./operate/ ./dist/aea_win.exe ./dist/tendermint_win.exe
pwd
poetry install && poetry run pyinstaller --collect-data eth_account --collect-all aea --collect-all coincurve --collect-all autonomy --collect-all operate --collect-all aea_ledger_ethereum --collect-all aea_ledger_cosmos --collect-all aea_ledger_ethereum_flashbots --hidden-import aea_ledger_ethereum --hidden-import aea_ledger_cosmos --hidden-import aea_ledger_ethereum_flashbots operate/pearl.py --add-binary dist/aea_win.exe:. --add-binary dist/tendermint_win.exe:. --onefile --name pearl_win


./electron/bins/:
mkdir -p ./electron/bins/

./electron/bins/tendermint.exe: ./electron/bins/
curl -L https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz -o tendermint.tar.gz
tar -xvf tendermint.tar.gz tendermint.exe
cp ./tendermint.exe ./electron/bins/tendermint.exe

.PHONY: build
build: ./dist/pearl_win.exe ./electron/bins/tendermint.exe
$(call setup_env, prod)
echo ${DEV_RPC}
cp -f dist/pearl_win.exe ./electron/bins/pearl_win.exe
echo ${NODE_ENV}
NODE_ENV=${NODE_ENV} DEV_RPC=${DEV_RPC} FORK_URL=${FORK_URL} yarn build:frontend
NODE_ENV=${NODE_ENV} DEV_RPC=${DEV_RPC} FORK_URL=${FORK_URL} GH_TOKEN=${GH_TOKEN} node build-win.js




.PHONY: build-tenderly
build-tenderly: ./dist/pearl_win.exe
$(call setup_env, dev-tenderly)
echo ${DEV_RPC}
cp -f dist/pearl_win.exe ./electron/bins/pearl_win.exe
echo ${NODE_ENV}
NODE_ENV=${NODE_ENV} DEV_RPC=${DEV_RPC} FORK_URL=${FORK_URL} yarn build:frontend
GH_TOKEN=${GH_TOKEN} node build-win-tenderly.js
38 changes: 38 additions & 0 deletions build-win-tenderly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* This script is used to build the electron app **with notarization**. It is used for the final build and release process.
*/
require('dotenv').config();
const build = require('electron-builder').build;

const { publishOptions } = require('./electron/constants');

const main = async () => {
console.log('Building...');

/** @type import {CliOptions} from "electron-builder" */
await build({
publish: 'onTag',
config: {
appId: 'xyz.valory.olas-operate-app',
artifactName: '${productName}-${version}-${platform}-${arch}-tenderly.${ext}',
productName: 'Pearl',
files: ['electron/**/*', 'package.json'],
directories: {
output: 'dist',
},
nsis: {
oneClick: false,
},
extraResources: [
{
from: 'electron/bins',
to: 'bins',
filter: ['**/*'],
},
],

},
});
};

main().then((response) => { console.log('Build & Notarize complete'); }).catch((e) => console.error(e));
49 changes: 49 additions & 0 deletions build-win.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* This script is used to build the electron app **with notarization**. It is used for the final build and release process.
*/
require('dotenv').config();
const build = require('electron-builder').build;

const { publishOptions } = require('./electron/constants');


function artifactName() {
const env = process.env.NODE_ENV;
const prefix = env === 'production' ? '' : 'dev-';
return prefix + '${productName}-${version}-${platform}-${arch}.${ext}';
}

const main = async () => {
console.log('Building...');

/** @type import {CliOptions} from "electron-builder" */
await build({
publish: 'onTag',
config: {
appId: 'xyz.valory.olas-operate-app',
artifactName: artifactName(),
productName: 'Pearl',
files: ['electron/**/*', 'package.json'],
directories: {
output: 'dist',
},
nsis: {
oneClick: false,
},
win: {
publish: publishOptions,
icon: 'electron/assets/icons/splash-robot-head-dock.png',
},
extraResources: [
{
from: 'electron/bins',
to: 'bins',
filter: ['**/*'],
},
],

},
});
};

main().then((response) => { console.log('Build & Notarize complete'); }).catch((e) => console.error(e));
79 changes: 76 additions & 3 deletions electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ const process = require('process');
const axios = require('axios');
const { spawnSync } = require('child_process');
const { logger } = require('./logger');

const { execSync} = require('child_process');
const { paths } = require('./constants');

const homedir = os.homedir();
/**
* current version of the pearl release
* - 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.0rc120';
const OlasMiddlewareVersion = '0.1.0rc127';

const path = require('path');
const { app } = require('electron');
Expand Down Expand Up @@ -55,6 +55,21 @@ const TendermintUrls = {
},
};


function execSyncExitCode(cmd) {
try {
execSync(cmd);
return 0;
}
catch (error) {
logger.electron(error.status); // Might be 127 in your example.
logger.electron(error.message); // Holds the message you typically want.
logger.electron(error.stderr.toString()); // Holds the stderr output. Use `.toString()`.
logger.electron(error.stdout.toString()); // Holds the stdout output. Use `.toString()`.
return error.status;
}
}

function getBinPath(command) {
return spawnSync('/usr/bin/which', [command], { env: Env })
.stdout?.toString()
Expand All @@ -79,6 +94,7 @@ function runCmdUnix(command, options) {
logger.electron(`===== stderr ===== \n${output.stderr}`);
}


function runSudoUnix(command, options) {
let bin = getBinPath(command);
if (!bin) {
Expand Down Expand Up @@ -113,6 +129,12 @@ function isTendermintInstalledUnix() {
return Boolean(getBinPath('tendermint'));
}

function isTendermintInstalledWindows() {
return true;
//always installed cause bundled in
return execSyncExitCode('tendermint --help') === 0;
}

async function downloadFile(url, dest) {
const writer = fs.createWriteStream(dest);
try {
Expand All @@ -132,6 +154,41 @@ async function downloadFile(url, dest) {
}
}

async function installTendermintWindows() {
return;
// bundled in
logger.electron(`Installing tendermint for ${os.platform()}-${process.arch}`);
const cwd = process.cwd();
process.chdir(paths.tempDir);

const url = TendermintUrls[os.platform()][process.arch];

logger.electron(
`Downloading ${url} to ${paths.tempDir}. This might take a while...`,
);
await downloadFile(url, `${paths.tempDir}/tendermint.tar.gz`);

logger.electron(`Installing tendermint binary`);
try {
execSync('tar -xvf tendermint.tar.gz');
} catch (error){
logger.electron(error.status); // Might be 127 in your example.
logger.electron(error.message); // Holds the message you typically want.
logger.electron(error.stderr.toString()); // Holds the stderr output. Use `.toString()`.
logger.electron(error.stdout.toString()); // Holds the stdout output. Use `.toString()`.
}

const bin_dir = homedir + "//AppData//Local//Microsoft//WindowsApps//"
if (!Env.CI) {
if (!fs.existsSync(bin_dir)) {
fs.mkdirSync(bin_dir, {recursive: true});
}
fs.copyFileSync("tendermint.exe", bin_dir + "tendermint.exe");
}
process.chdir(cwd);
}


async function installTendermintUnix() {
logger.electron(`Installing tendermint for ${os.platform()}-${process.arch}`);
const cwd = process.cwd();
Expand Down Expand Up @@ -202,8 +259,24 @@ async function setupUbuntu(ipcChannel) {
}
}



async function setupWindows(ipcChannel) {
logger.electron('Creating required directories');
await createDirectory(`${paths.dotOperateDirectory}`);
await createDirectory(`${paths.tempDir}`);

logger.electron('Checking tendermint installation: ' + isTendermintInstalledWindows());
if (!isTendermintInstalledWindows()) {
ipcChannel.send('response', 'Installing tendermint');
logger.electron('Installing tendermint');
await installTendermintWindows();
}
}

module.exports = {
setupDarwin,
setupUbuntu,
setupWindows,
Env,
};
Loading

0 comments on commit 6e33a9a

Please sign in to comment.