From c0b6867135241c38996ea5fdb3e3dcf25d054a62 Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Mon, 10 Feb 2025 20:26:46 +0100 Subject: [PATCH] station core -> checker node --- .eslintrc.json | 2 +- .../dependabot-auto-approve-patch.yml | 2 +- .gitignore | 2 +- build/after-pack.js | 4 +- electron-builder.yml | 2 +- main/{core.js => checker-node.js} | 51 ++-- main/index.js | 10 +- main/station-config.js | 2 +- main/tray.js | 6 +- package-lock.json | 241 +++++++++--------- package.json | 4 +- shared/typings.ts | 2 +- 12 files changed, 171 insertions(+), 157 deletions(-) rename main/{core.js => checker-node.js} (78%) diff --git a/.eslintrc.json b/.eslintrc.json index 6af73c306..3a09b554b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -27,7 +27,7 @@ "assets/", "dist/", "@types/", - "core/" + "checker/" ], "overrides": [ { diff --git a/.github/workflows/dependabot-auto-approve-patch.yml b/.github/workflows/dependabot-auto-approve-patch.yml index b3d722359..38d4158a4 100644 --- a/.github/workflows/dependabot-auto-approve-patch.yml +++ b/.github/workflows/dependabot-auto-approve-patch.yml @@ -18,7 +18,7 @@ jobs: - react-helmet-async - tailwindcss - '@glif/' - - '@filecoin-station/core' + - '@checkernetwork/node' - npm - ejs - '@electron/notarize' diff --git a/.gitignore b/.gitignore index 6f5f910b9..c17dae00c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ dev-app-update.yml *.sw? .tool-versions -core +checker diff --git a/build/after-pack.js b/build/after-pack.js index a122ab831..bfd85f687 100644 --- a/build/after-pack.js +++ b/build/after-pack.js @@ -22,7 +22,7 @@ exports.default = async function (context) { : null if (arch === 'universal') return assert(arch, `Unknown architecture id: ${context.arch}`) - console.log(`Rebuild Station Core for arch=${arch}`) + console.log(`Rebuild Checker Node for arch=${arch}`) const ps = spawn( 'node', ['scripts/post-install.js'], @@ -32,7 +32,7 @@ exports.default = async function (context) { 'Filecoin Station.app', 'Contents', 'Resources', - 'core' + 'checker' ), env: { ...process.env, diff --git a/electron-builder.yml b/electron-builder.yml index 3ccf8c83c..1b391fee0 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -13,7 +13,7 @@ files: - package.json extraResources: - - 'core/**' + - 'checker/**' beforePack: './build/before-pack.js' afterPack: './build/after-pack.js' diff --git a/main/core.js b/main/checker-node.js similarity index 78% rename from main/core.js rename to main/checker-node.js index 8fb1e0c7b..24dd05187 100644 --- a/main/core.js +++ b/main/checker-node.js @@ -16,16 +16,16 @@ const { parseEther } = require('ethers/lib/utils') const { once } = require('node:events') const { format } = require('node:util') -const log = require('electron-log').scope('core') +const log = require('electron-log').scope('checker') /** @typedef {import('./typings').Context} Context */ -// Core is installed separately from `node_modules`, since it needs a +// Checker Node is installed separately from `node_modules`, since it needs a // self-contained dependency tree outside the asar archive. -const corePath = app.isPackaged - ? join(process.resourcesPath, 'core', 'bin', 'station.js') - : join(__dirname, '..', 'core', 'bin', 'station.js') -log.info(format('Core binary: %s', corePath)) +const checkerNodePath = app.isPackaged + ? join(process.resourcesPath, 'checker', 'bin', 'checker.js') + : join(__dirname, '..', 'checker', 'bin', 'checker.js') +log.info(format('Checker Node binary: %s', checkerNodePath)) const logs = new Logs() const activities = new Activities() @@ -76,24 +76,24 @@ function maybeReportErrorToSentry (err, scopeFn) { * @param {Context} ctx */ async function start (ctx) { - log.info('Starting Core...') + log.info('Starting Checker...') const childProcess = fork( - corePath, - ['--json', '--recreateStationIdOnError'], + checkerNodePath, + ['--json', '--recreateCheckerIdOnError'], { env: { ...process.env, FIL_WALLET_ADDRESS: await wallet.getAddress(), - PASSPHRASE: await wallet.signMessage('station core passhprase'), + PASSPHRASE: await wallet.signMessage('checker node passhprase'), CACHE_ROOT: consts.CACHE_ROOT, STATE_ROOT: consts.STATE_ROOT, - DEPLOYMENT_TYPE: 'station-desktop' + DEPLOYMENT_TYPE: 'checker-app' }, stdio: ['pipe', 'pipe', 'pipe', 'ipc'] } ) - log.info(format('Core pid:', childProcess.pid)) + log.info(format('Checker Node pid:', childProcess.pid)) assert(childProcess.stdout) childProcess.stdout.setEncoding('utf8') @@ -105,12 +105,12 @@ async function start (ctx) { try { event = JSON.parse(line) } catch (_err) { - const err = new Error(`Failed to parse core event: ${line}`) + const err = new Error(`Failed to parse checker node event: ${line}`) err.cause = _err if (!line.includes('failed to detect network')) { Sentry.captureException(err) } - log.error(format('Cannot parse Core stdout:', err)) + log.error(format('Cannot parse Checker Node stdout:', err)) return } switch (event.type) { @@ -136,7 +136,7 @@ async function start (ctx) { } default: { const err = new Error( - `Unknown Station Core event type "${event.type}": ${line}` + `Unknown Station Checker Node event type "${event.type}": ${line}` ) log.error(format(err)) Sentry.captureException(err) @@ -161,12 +161,14 @@ async function start (ctx) { const reason = exitSignal ? `via signal ${exitSignal}` : `with code: ${exitCode}` - const msg = `Core exited ${reason}` + const msg = `Checker Node exited ${reason}` log.info(msg) const exitReason = exitSignal || exitCode ? reason : null const [closeCode] = await onceClosed - log.info(`Core closed all stdio with code ${closeCode ?? ''}`) + log.info( + `Checker Node closed all stdio with code ${closeCode ?? ''}` + ) if (closeCode === 2) { // FIL_WALLET_ADDRESS did not pass our screening. There is not much @@ -175,12 +177,15 @@ async function start (ctx) { throw new Error('Invalid Filecoin wallet address') } - maybeReportErrorToSentry('Core exited', (/** @type {any} */ scope) => { - // Sentry UI can't show the full 100 lines - scope.setExtra('logs', logs.getLastLines(20)) - scope.setExtra('reason', exitReason) - return scope - }) + maybeReportErrorToSentry( + 'Checker Node exited', + (/** @type {any} */ scope) => { + // Sentry UI can't show the full 100 lines + scope.setExtra('logs', logs.getLastLines(20)) + scope.setExtra('reason', exitReason) + return scope + } + ) } module.exports = { diff --git a/main/index.js b/main/index.js index 32b5480a8..87e5dfd2a 100644 --- a/main/index.js +++ b/main/index.js @@ -28,7 +28,7 @@ const { ipcMainEvents, setupIpcMain } = require('./ipc') const { BUILD_VERSION } = require('./consts') const { ipcMain } = require('electron/main') const os = require('os') -const core = require('./core') +const checkerNode = require('./checker-node') const wallet = require('./wallet') const settings = require('./settings') const serve = require('electron-serve') @@ -99,13 +99,13 @@ app.on('second-instance', () => { /** @type {import('./typings').Context} */ const ctx = { - getActivities: () => core.getActivities(), + getActivities: () => checkerNode.getActivities(), recordActivity: activity => { ipcMain.emit(ipcMainEvents.ACTIVITY_LOGGED, activity) }, - getTotalJobsCompleted: () => core.getTotalJobsCompleted(), + getTotalJobsCompleted: () => checkerNode.getTotalJobsCompleted(), setTotalJobsCompleted: (count) => { ipcMain.emit( ipcMainEvents.JOB_STATS_UPDATED, @@ -179,10 +179,10 @@ async function run () { await wallet.setup(ctx) await telemetry.setup() - await core.setup(ctx) + await checkerNode.setup(ctx) await settings.setup(ctx) - await core.run(ctx) + await checkerNode.run(ctx) } catch (e) { handleError(e) } diff --git a/main/station-config.js b/main/station-config.js index 414e08217..933e5ad17 100644 --- a/main/station-config.js +++ b/main/station-config.js @@ -7,7 +7,7 @@ const log = require('electron-log').scope('config') const ConfigKeys = { OnboardingCompleted: 'station.OnboardingCompleted', TrayOperationExplained: 'station.TrayOperationExplained', - StationID: 'station.StationID', + CheckerID: 'station.CheckerID', FilAddress: 'station.FilAddress', DestinationFilAddress: 'station.DestinationFilAddress' } diff --git a/main/tray.js b/main/tray.js index c95aa27fd..721bc2d21 100644 --- a/main/tray.js +++ b/main/tray.js @@ -5,7 +5,7 @@ const { Menu, Tray, app, ipcMain, nativeImage } = require('electron') const { ipcMainEvents } = require('./ipc') const path = require('path') const assert = require('node:assert') -const core = require('./core') +const checkerNode = require('./checker-node') const { formatTokenValue } = require('./utils') /** @typedef {import('./typings').Context} Context */ @@ -86,7 +86,7 @@ const createContextMenu = (/** @type {Context} */ ctx) => { } module.exports = async function (/** @type {Context} */ ctx) { - tray = new Tray(getTrayIcon(false, core.isOnline())) + tray = new Tray(getTrayIcon(false, checkerNode.isOnline())) const contextMenu = createContextMenu(ctx) tray.setToolTip('Filecoin Station') @@ -108,7 +108,7 @@ function setupIpcEventListeners (ctx) { function updateTray () { assert(tray) tray.setImage( - getTrayIcon(ctx.getUpdaterStatus().readyToUpdate, core.isOnline()) + getTrayIcon(ctx.getUpdaterStatus().readyToUpdate, checkerNode.isOnline()) ) const contextMenu = createContextMenu(ctx) tray.setContextMenu(contextMenu) diff --git a/package-lock.json b/package-lock.json index 71f3245f7..0ba916b71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "license": "(Apache-2.0 AND MIT)", "dependencies": { - "@filecoin-station/core": "^21.2.5", + "@checkernetwork/node": "github:CheckerNetwork/core#update/checker-rebrand", "@filecoin-station/spark-impact-evaluator": "^1.2.4", "@glif/filecoin-address": "3.0.12", "@glif/filecoin-message": "^3.0.5", @@ -2261,6 +2261,126 @@ "resolved": "https://registry.npmjs.org/@chainsafe/filsnap-types/-/filsnap-types-2.1.3.tgz", "integrity": "sha512-6yu04diRSyQD4wwOEMCEG7pqSr7BM1X+LTLQJo2VSVH3yazUsFTY43Fhars1kXn0jhIU241l6bA7hvY34m2otg==" }, + "node_modules/@checkernetwork/node": { + "version": "21.2.5", + "resolved": "git+ssh://git@github.com/CheckerNetwork/core.git#186bfb75ad81408c20c011351b4aedbd06797fdf", + "hasInstallScript": true, + "license": "(Apache-2.0 AND MIT)", + "dependencies": { + "@filecoin-station/spark-impact-evaluator": "^1.1.0", + "@glif/filecoin-address": "^3.0.0", + "@influxdata/influxdb-client": "^1.33.2", + "@ipld/car": "^5.2.6", + "@sentry/node": "^8.2.1", + "@web3-storage/car-block-validator": "^1.2.0", + "ethers": "^6.8.1", + "execa": "^9.0.2", + "ipfs-unixfs-exporter": "^13.4.0", + "p-retry": "^6.1.0", + "tar": "^7.0.0", + "undici": "^7.0.0", + "unzip-stream": "^0.3.1", + "w3name": "^1.0.8", + "yargs": "^17.7.1" + }, + "bin": { + "checker": "bin/checker.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@checkernetwork/node/node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@checkernetwork/node/node_modules/@types/node": { + "version": "22.7.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz", + "integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/@checkernetwork/node/node_modules/aes-js": { + "version": "4.0.0-beta.5", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", + "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==", + "license": "MIT" + }, + "node_modules/@checkernetwork/node/node_modules/ethers": { + "version": "6.13.5", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.5.tgz", + "integrity": "sha512-+knKNieu5EKRThQJWwqaJ10a6HE9sSehGeqWN65//wE7j47ZpFhKAnHB/JJFibwwg61I/koxaPsXbXpD/skNOQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/ethers-io/" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", + "@types/node": "22.7.5", + "aes-js": "4.0.0-beta.5", + "tslib": "2.7.0", + "ws": "8.17.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@checkernetwork/node/node_modules/undici": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.3.0.tgz", + "integrity": "sha512-Qy96NND4Dou5jKoSJ2gm8ax8AJM/Ey9o9mz7KN1bb9GP+G0l20Zw8afxTnY2f4b7hmhn/z8aC2kfArVQlAhFBw==", + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/@checkernetwork/node/node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "license": "MIT" + }, + "node_modules/@checkernetwork/node/node_modules/ws": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/@csstools/color-helpers": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.1.tgz", @@ -3750,109 +3870,6 @@ "@ethersproject/strings": "^5.7.0" } }, - "node_modules/@filecoin-station/core": { - "version": "21.2.5", - "resolved": "https://registry.npmjs.org/@filecoin-station/core/-/core-21.2.5.tgz", - "integrity": "sha512-gUPPcU3i7En2VrGI69hTkmpbnPJyB42fAM8Kjwb3XM+CEDBCujb/tnHutrXFerjTk0JZays6uYjTiQRewj1inQ==", - "hasInstallScript": true, - "license": "(Apache-2.0 AND MIT)", - "dependencies": { - "@filecoin-station/spark-impact-evaluator": "^1.1.0", - "@glif/filecoin-address": "^3.0.0", - "@influxdata/influxdb-client": "^1.33.2", - "@ipld/car": "^5.2.6", - "@sentry/node": "^8.2.1", - "@web3-storage/car-block-validator": "^1.2.0", - "ethers": "^6.8.1", - "execa": "^9.0.2", - "ipfs-unixfs-exporter": "^13.4.0", - "p-retry": "^6.1.0", - "tar": "^7.0.0", - "undici": "^6.14.1", - "unzip-stream": "^0.3.1", - "w3name": "^1.0.8", - "yargs": "^17.7.1" - }, - "bin": { - "station": "bin/station.js" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@filecoin-station/core/node_modules/@noble/hashes": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@filecoin-station/core/node_modules/@types/node": { - "version": "18.15.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", - "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" - }, - "node_modules/@filecoin-station/core/node_modules/aes-js": { - "version": "4.0.0-beta.5", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", - "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==" - }, - "node_modules/@filecoin-station/core/node_modules/ethers": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.0.tgz", - "integrity": "sha512-+yyQQQWEntY5UVbCv++guA14RRVFm1rSnO1GoLFdrK7/XRWMoktNgyG9UjwxrQqGBfGyFKknNZ81YpUS2emCgg==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/ethers-io/" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@adraffy/ens-normalize": "1.10.1", - "@noble/curves": "1.2.0", - "@noble/hashes": "1.3.2", - "@types/node": "18.15.13", - "aes-js": "4.0.0-beta.5", - "tslib": "2.4.0", - "ws": "8.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@filecoin-station/core/node_modules/tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" - }, - "node_modules/@filecoin-station/core/node_modules/ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/@filecoin-station/spark-impact-evaluator": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/@filecoin-station/spark-impact-evaluator/-/spark-impact-evaluator-1.2.4.tgz", @@ -18935,9 +18952,10 @@ } }, "node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "license": "0BSD" }, "node_modules/tsutils": { "version": "3.21.0", @@ -19161,15 +19179,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/undici": { - "version": "6.21.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz", - "integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==", - "license": "MIT", - "engines": { - "node": ">=18.17" - } - }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", diff --git a/package.json b/package.json index 1426b620c..87cbf0165 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "vitest:ui": "vitest --ui", "postinstall": "run-s install-*", "install-app-deps": "electron-builder install-app-deps", - "install-core": "shx rm -rf core && shx cp -R node_modules/@filecoin-station/core core && cd core && npm install --omit=dev", + "install-checker": "shx rm -rf checker && shx cp -R node_modules/@checkernetwork/node checker && cd checker && npm install --omit=dev", "clean": "shx rm -rf dist/", "build": "run-s clean build:*", "build:webui": "vite build", @@ -39,7 +39,7 @@ }, "homepage": "https://github.com/filecoin-station/desktop#readme", "dependencies": { - "@filecoin-station/core": "^21.2.5", + "@checkernetwork/node": "github:CheckerNetwork/core#update/checker-rebrand", "@filecoin-station/spark-impact-evaluator": "^1.2.4", "@glif/filecoin-address": "3.0.12", "@glif/filecoin-message": "^3.0.5", diff --git a/shared/typings.ts b/shared/typings.ts index 12730be29..c9d101db9 100644 --- a/shared/typings.ts +++ b/shared/typings.ts @@ -1,4 +1,4 @@ -import { ActivityEvent } from '@filecoin-station/core/dist/lib/activity' +import { ActivityEvent } from '@checkernetwork/node/dist/lib/activity' export type FILTransactionStatus = 'succeeded' | 'processing' | 'failed'