Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix on chain checks #173

Merged
merged 83 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
974d8d4
chore: Refactor electron/update.js for better readability
mohandast52 May 29, 2024
af77fba
chore: Update package.json with new ordering
mohandast52 May 29, 2024
b8a978e
chore: Update .env.example and build.js for IS_STAGING variables
mohandast52 May 29, 2024
b582f3f
Merge pull request #152 from valory-xyz/mohan/staging-setup
mohandast52 May 29, 2024
a7e6f48
Merge pull request #155 from valory-xyz/staging
mohandast52 May 29, 2024
a052cca
feat: Add IS_STAGING variable to production environment configuration
mohandast52 May 29, 2024
657a7c3
chore: Fix typo in electron/install.js and add a comment for 'Version'
mohandast52 May 29, 2024
38cbeb6
feat: Add appVersion to electron store and display it in TopBar
mohandast52 May 29, 2024
0660815
feat: Update electron updater to automatically update to all channels
mohandast52 May 29, 2024
c6897f8
chore: Update electron/install.js and TopBar.tsx for app version disp…
mohandast52 May 30, 2024
92e4046
chore: Update releaseType in publishOptions and store schema
mohandast52 May 30, 2024
afe5407
chore: Update releaseType in publishOptions and store schema
mohandast52 May 30, 2024
b2f8808
chore: Update IS_STAGING variable in production environment configura…
mohandast52 May 31, 2024
3d3b70e
chore: Update IS_STAGING variable in production environment configura…
mohandast52 May 31, 2024
9f7aaf2
chore: Update publishOptions releaseType to 'draft' in electron/const…
mohandast52 Jun 3, 2024
b9cbf28
chore: Update environmentName in store schema and TopBar component
mohandast52 Jun 3, 2024
b12aed4
Merge pull request #159 from valory-xyz/mohan/rename-app-name-on-stag…
mohandast52 Jun 3, 2024
50f6609
conflicts fixed
mohandast52 Jun 3, 2024
f5a98ba
chore: Remove private flag from package.json
mohandast52 Jun 3, 2024
3d877e9
fix: disable brew updates when installing a package
angrybayblade Jun 4, 2024
675c74a
Merge pull request #165 from valory-xyz/mohan/staging-release-setup
mohandast52 Jun 4, 2024
0f6900f
lint & bump for release
Jun 4, 2024
c1232c6
chore: Update version to "0.1.0-rc34.1" in package.json
truemiller Jun 4, 2024
9b9c573
chore: Update IS_STAGING environment variable in release.yml workflow
mohandast52 Jun 4, 2024
c1dfe33
fix: unstaking logic
angrybayblade Jun 5, 2024
a247d64
Merge pull request #167 from valory-xyz/fix/brew-instal
angrybayblade Jun 5, 2024
6cb4e9e
test: operate installation e2e
angrybayblade Jun 5, 2024
97a3142
chore: add e2e test workflow
angrybayblade Jun 5, 2024
812f872
fix: test job
angrybayblade Jun 5, 2024
8a2fe9a
feat: add macos arm runner
angrybayblade Jun 5, 2024
aa6dddd
feat: add IPC channel mock
angrybayblade Jun 5, 2024
cc67cd1
fix: macos arm version
angrybayblade Jun 5, 2024
6d236e1
fix: uninstall brew
angrybayblade Jun 5, 2024
23e3c99
fix: use sudo for uninstalling brew
angrybayblade Jun 5, 2024
2187725
chore: add brew installation logging
angrybayblade Jun 5, 2024
d6256b9
feat: add brew installation script and fix tendermint installation
angrybayblade Jun 5, 2024
c037b3e
fix: __dirname typo
angrybayblade Jun 5, 2024
1abb697
fix: raise condition for command exec result
angrybayblade Jun 5, 2024
0f6803c
fix: skip tendermint installation in CI
angrybayblade Jun 5, 2024
3c42801
feat: extend e2e tests
angrybayblade Jun 5, 2024
91b980d
chore: ignore jinja safety warning
angrybayblade Jun 5, 2024
734b967
chore: ignore gitleaks warnings
angrybayblade Jun 5, 2024
e67e092
chore: remove debug statement
angrybayblade Jun 5, 2024
e879153
feat: bump to rc37
angrybayblade Jun 5, 2024
0611257
Merge pull request #171 from valory-xyz/mohan/update-is-staging-check
mohandast52 Jun 5, 2024
527b05f
conflict fixes
mohandast52 Jun 5, 2024
5f3095e
fix: write script to temporary file for installing brew
angrybayblade Jun 5, 2024
4de8070
feat: bump to v0.1.0-rc38
angrybayblade Jun 5, 2024
0473825
Merge pull request #168 from valory-xyz/staging
mohandast52 Jun 5, 2024
14615fe
fix: use js strings to store brew installation script
angrybayblade Jun 5, 2024
27c1508
Merge branch 'main' into fix/brew-installation
angrybayblade Jun 5, 2024
879862f
fix: script multiline
angrybayblade Jun 5, 2024
8783c07
feat: bump to v0.1.0-rc39
angrybayblade Jun 5, 2024
579fd78
fix: store the temporary brew script in homedir instead of tempdir
angrybayblade Jun 6, 2024
47d4ab2
feat: install brew from source
angrybayblade Jun 6, 2024
5d7333b
fix: homebrew source extraction and sudo cmd exec
angrybayblade Jun 6, 2024
259ef3c
fix: env name typo
angrybayblade Jun 6, 2024
5237df7
fix: remove unwanted code
angrybayblade Jun 6, 2024
3962a76
fix: tendermint installation
angrybayblade Jun 6, 2024
b7bb6c6
fix: remove homebrew leftovers from uninstall
angrybayblade Jun 6, 2024
c848a8f
feat: bump to v0.1.0-rc40
angrybayblade Jun 6, 2024
01084f7
fix: use rmDirSync instead of rmSync
angrybayblade Jun 6, 2024
2d5c23b
fix: on-chain status check
jmoreira-valory Jun 6, 2024
d4be55e
chore: disable on-chain update
jmoreira-valory Jun 6, 2024
65fc08c
chore: fix
jmoreira-valory Jun 7, 2024
1f867e4
chore: update gitleaksignore
jmoreira-valory Jun 7, 2024
aaf6b88
fix: temporary fix for env variables
jmoreira-valory Jun 7, 2024
7017417
chore: service hash
jmoreira-valory Jun 10, 2024
1b8b806
chore: spacing
jmoreira-valory Jun 10, 2024
f38655f
chore: update service hash
jmoreira-valory Jun 10, 2024
590a80f
chore: update version to 0.1.0rc42
truemiller Jun 11, 2024
9dd5654
chore: update hash
jmoreira-valory Jun 11, 2024
ec9699d
chore: update version to 0.1.0rc43
jmoreira-valory Jun 11, 2024
f9332cd
Merge pull request #172 from valory-xyz/fix/brew-installation
truemiller Jun 12, 2024
f07b44e
fix: restake after eviction
jmoreira-valory Jun 13, 2024
5584693
fix: linters
jmoreira-valory Jun 13, 2024
925aa30
chore: tag rc45
jmoreira-valory Jun 13, 2024
d3f0f01
Merge remote-tracking branch 'origin/main' into fix/on_chain_checks
jmoreira-valory Jun 14, 2024
3f431ed
chore: update gitignore
jmoreira-valory Jun 14, 2024
4627dbc
fix: linters
jmoreira-valory Jun 14, 2024
61ac9da
Apply suggestions from code review
jmoreira-valory Jun 14, 2024
edd073b
fix: package.json
jmoreira-valory Jun 14, 2024
b455ab5
fix: linters
jmoreira-valory Jun 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FORK_URL=
NODE_ENV=
DEV_RPC=
STAKING_TEST_KEYS_PATH=
DEV_RPC=
IS_STAGING=
29 changes: 29 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Test Operate Installation E2E"
on:
push:
branches:
- develop
- main
pull_request:
jobs:
test:
continue-on-error: False
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-12, macos-14]
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.11"
- name: Setup
run: |
yarn
# Uninstall brew
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
- name: Run Test
run: |
node electron/test.js
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
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/
- run: rm -rf /dist
- name: "Build, notarize, publish"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ frontend/build
# python
.tox/
.operate/
.operate*/
__pycache__/
data/
backend/temp/
Expand Down
8 changes: 7 additions & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ 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
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:455
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:45591ec07457f69e9a29f63693ac8ef887e4b5f49f0: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
91ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454
8 changes: 4 additions & 4 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const dotenv = require('dotenv');
const build = require('electron-builder').build;
const {publishOptions} = require('./electron/constants/publishOptions');
const { publishOptions } = require('./electron/constants/publishOptions');

dotenv.config();

Expand All @@ -24,7 +24,7 @@ const main = async () => {
target: [
{
target: 'default',
arch: ['x64','arm64'],
arch: ['x64', 'arm64'],
},
],
publish: publishOptions,
Expand All @@ -35,11 +35,11 @@ const main = async () => {
entitlements: 'electron/entitlements.mac.plist',
entitlementsInherit: 'electron/entitlements.mac.plist',
notarize: {
teamId: process.env.APPLETEAMID
teamId: process.env.APPLETEAMID,
},
},
},
});
};

main().then((response) => { console.log('Build & Notarize complete'); }).catch((e) => console.error(e));
main().then((response) => { console.log('Build & Notarize complete'); }).catch((e) => console.error(e));
138 changes: 91 additions & 47 deletions electron/install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Installation helpers.

const https = require('https');
const path = require('path');
const nfs = require('node:fs')
const fs = require('fs');
const os = require('os');
const sudo = require('sudo-prompt');
Expand All @@ -10,8 +9,14 @@ const axios = require('axios');

const Docker = require('dockerode');
const { spawnSync } = require('child_process');

const Version = '0.1.0rc41';
const { BrewScript } = require("./scripts")

/**
* 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.0rc46';
const OperateDirectory = `${os.homedir()}/.operate`;
const VenvDir = `${OperateDirectory}/venv`;
const TempDir = `${OperateDirectory}/temp`;
Expand All @@ -22,6 +27,7 @@ const OperateCmd = `${os.homedir()}/.operate/venv/bin/operate`;
const Env = {
...process.env,
PATH: `${process.env.PATH}:/opt/homebrew/bin:/usr/local/bin`,
HOMEBREW_NO_AUTO_UPDATE: '1',
};
const SudoOptions = {
name: 'Pearl',
Expand Down Expand Up @@ -66,50 +72,50 @@ function appendLog(log) {
}

function runCmdUnix(command, options) {
fs.appendFileSync(
OperateInstallationLog,
`Runninng ${command} with options ${JSON.stringify(options)}`,
{ encoding: 'utf-8' },
console.log(
appendLog(`Running ${command} with options ${JSON.stringify(options)}`),
);
let bin = getBinPath(command);
if (!bin) {
throw new Error(`Command ${command} not found; Path : ${Env.PATH}`);
}
let output = spawnSync(bin, options);
if (output.stdout) {
appendLog(output.stdout.toString());
}
if (output.stderr) {
appendLog(output.stdout.toString());
}
if (output.error) {
throw new Error(
`Error running ${command} with options ${options};
Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`,
);
}
return {
error: output.error,
stdout: output.stdout?.toString(),
stderr: output.stderr?.toString(),
};
console.log(appendLog(`Executed ${command} ${options} with`))
console.log(appendLog(`===== stdout ===== \n${output.stdout}`))
console.log(appendLog(`===== stderr ===== \n${output.stderr}`))
}

function runSudoUnix(command, options) {
let bin = getBinPath(command);
if (!bin) {
throw new Error(`Command ${command} not found`);
}
return new Promise(function (resolve, reject) {
return new Promise(function (resolve, _reject) {
sudo.exec(
`${bin} ${options}`,
SudoOptions,
function (error, stdout, stderr) {
resolve({
let output = {
error: error,
stdout: stdout,
stderr: stderr,
});
};
if (output.error) {
throw new Error(
`Error running ${command} with options ${options};
Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`,
);
}
console.log(appendLog(`Executed ${command} ${options} with`))
console.log(appendLog(`===== stdout ===== \n${output.stdout}`))
console.log(appendLog(`===== stderr ===== \n${output.stderr}`))
resolve()
},
);
});
Expand All @@ -119,11 +125,38 @@ function isBrewInstalled() {
return Boolean(getBinPath(getBinPath('brew')));
}

function installBrew() {
return runCmdUnix('bash', [
'-c',
'$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)',
]);
async function installBrew() {
console.log(appendLog("Fetching homebrew source"))
let outdir = `${os.homedir()}/homebrew`
let outfile = `${os.homedir()}/homebrew.tar`

// Make temporary source dir
fs.mkdirSync(outdir)

// Fetch brew source
runCmdUnix("curl", ["-L", "https://github.com/Homebrew/brew/tarball/master", "--output", outfile])
runCmdUnix("tar", ["-xvf", outfile, "--strip-components", "1", "-C", outdir])

// Check for cache and uninstall leftovers
if (fs.existsSync("/opt/homebrew")) {
console.log(appendLog("Removing homebrew leftovers"))
if (!Env.CI) {
await runSudoUnix("rm", `-rf /opt/homebrew`)
} else {
fs.rmdirSync("/opt/homebrew")
}
}

console.log(appendLog("Installing homebrew"))
if (!Env.CI) {
await runSudoUnix("mv", `${outdir} /opt/homebrew`)
await runSudoUnix("chown", `-R ${os.userInfo().username} /opt/homebrew`)
} else {
runCmdUnix("mv", [outdir, "/opt/homebrew"])
runCmdUnix("chown", ["-R", os.userInfo().username, "/opt/homebrew"])
}
runCmdUnix("brew", ["doctor"])
fs.rmSync(outfile)
}

function isTendermintInstalledUnix() {
Expand Down Expand Up @@ -162,8 +195,15 @@ async function installTendermintUnix() {
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');
runCmdUnix('tar', ['-xvf', 'tendermint.tar.gz']);

// TOFIX: Install tendermint in .operate instead of globally
if (!Env.CI) {
if (!fs.existsSync("/usr/local/bin")) {
await runSudoUnix('mkdir', '/usr/local/bin')
}
await runSudoUnix('install', 'tendermint /usr/local/bin/tendermint');
}
process.chdir(cwd);
}

Expand All @@ -172,7 +212,7 @@ function isDockerInstalledDarwin() {
}

function installDockerDarwin() {
return runCmdUnix('brew', ['install', 'docker']);
runCmdUnix('brew', ['install', 'docker']);
}

function isDockerInstalledUbuntu() {
Expand All @@ -188,11 +228,11 @@ function isPythonInstalledDarwin() {
}

function installPythonDarwin() {
return runCmdUnix('brew', ['install', '[email protected]']);
runCmdUnix('brew', ['install', '[email protected]']);
}

function createVirtualEnvUnix(path) {
return runCmdUnix('python3.10', ['-m', 'venv', path]);
runCmdUnix('python3.10', ['-m', 'venv', path]);
}

function isPythonInstalledUbuntu() {
Expand All @@ -212,25 +252,25 @@ function installGitUbuntu() {
}

function createVirtualEnvUbuntu(path) {
return runCmdUnix('python3.10', ['-m', 'venv', path]);
runCmdUnix('python3.10', ['-m', 'venv', path]);
}

function installOperatePackageUnix(path) {
return runCmdUnix(`${path}/venv/bin/python3.10`, [
runCmdUnix(`${path}/venv/bin/python3.10`, [
'-m',
'pip',
'install',
`olas-operate-middleware==${Version}`,
`olas-operate-middleware==${OlasMiddlewareVersion}`,
]);
}

function reInstallOperatePackageUnix(path) {
console.log(appendLog('Reinstalling pearl CLI'));
return runCmdUnix(`${path}/venv/bin/python3.10`, [
runCmdUnix(`${path}/venv/bin/python3.10`, [
'-m',
'pip',
'install',
`olas-operate-middleware==${Version}`,
`olas-operate-middleware==${OlasMiddlewareVersion}`,
'--force-reinstall',
]);
}
Expand All @@ -240,11 +280,11 @@ function installOperateCli(path) {
if (fs.existsSync(installPath)) {
fs.rmSync(installPath);
}
return new Promise((resolve, reject) => {
return new Promise((resolve, _reject) => {
fs.copyFile(
`${OperateDirectory}/venv/bin/operate`,
installPath,
function (error, stdout, stderr) {
function (error, _stdout, _stderr) {
resolve(!error);
},
);
Expand All @@ -255,23 +295,23 @@ function createDirectory(path) {
if (fs.existsSync(path)) {
return;
}
return new Promise((resolve, reject) => {
return new Promise((resolve, _reject) => {
fs.mkdir(path, { recursive: true }, (error) => {
resolve(!error);
});
});
}

function writeVersion() {
fs.writeFileSync(VersionFile, Version);
fs.writeFileSync(VersionFile, OlasMiddlewareVersion);
}

function versionBumpRequired() {
if (!fs.existsSync(VersionFile)) {
return true;
}
const version = fs.readFileSync(VersionFile).toString();
return version != Version;
const olasMiddlewareVersionInFile = fs.readFileSync(VersionFile).toString();
return olasMiddlewareVersionInFile != OlasMiddlewareVersion;
}

function removeLogFile() {
Expand All @@ -296,7 +336,7 @@ async function setupDarwin(ipcChannel) {
if (!isBrewInstalled()) {
ipcChannel.send('response', 'Installing Pearl Daemon');
console.log(appendLog('Installing brew'));
installBrew();
await installBrew();
}

console.log(appendLog('Checking python installation'));
Expand Down Expand Up @@ -328,7 +368,9 @@ async function setupDarwin(ipcChannel) {

console.log(appendLog('Checking if upgrade is required'));
if (versionBumpRequired()) {
console.log(appendLog(`Upgrading pearl daemon to ${Version}`));
console.log(
appendLog(`Upgrading pearl daemon to ${OlasMiddlewareVersion}`),
);
reInstallOperatePackageUnix(OperateDirectory);
writeVersion();
removeLogFile();
Expand Down Expand Up @@ -382,7 +424,9 @@ async function setupUbuntu(ipcChannel) {

console.log(appendLog('Checking if upgrade is required'));
if (versionBumpRequired()) {
console.log(appendLog(`Upgrading pearl daemon to ${Version}`));
console.log(
appendLog(`Upgrading pearl daemon to ${OlasMiddlewareVersion}`),
);
reInstallOperatePackageUnix(OperateDirectory);
writeVersion();
removeLogFile();
Expand Down Expand Up @@ -435,4 +479,4 @@ module.exports = {
LogFile,
OperateInstallationLog,
},
};
};
Loading
Loading