diff --git a/.changeset/sour-months-begin.md b/.changeset/sour-months-begin.md new file mode 100644 index 0000000..333c13b --- /dev/null +++ b/.changeset/sour-months-begin.md @@ -0,0 +1,26 @@ +--- +'@epics-dao/solv': patch +--- + +Update - solv restart + +```bash +$ solv restart +``` + +This command will do this command below; + +```bash +solana-validator --ledger /mnt/ledger exit --max-delinquent-stake 5 +``` + +You can change `--max-delinquent-stake` value as you edit the `solv` configuration file. + +`/home/solv/solv.config.json` + +```json +{ + ,... + "maxDelinquentStake": 5 +} +``` diff --git a/packages/solv/src/cli/get/index.ts b/packages/solv/src/cli/get/index.ts index d324d02..c5e8568 100644 --- a/packages/solv/src/cli/get/index.ts +++ b/packages/solv/src/cli/get/index.ts @@ -8,6 +8,7 @@ import { showConfig } from './showConfig' import { ConfigParams } from '@/lib/readOrCreateDefaultConfig' import { getSnapshot } from './snapshot' import { SOLV_TYPES } from '@/config/config' +import { spawnSync } from 'node:child_process' export const getCommands = (solvConfig: ConfigParams) => { const { locale, config } = solvConfig @@ -64,6 +65,14 @@ export const getCommands = (solvConfig: ConfigParams) => { monitorSolana() }) + get + .command('contact') + .description('Show Validator Contact Information') + .action(() => { + const cmd = `solana-validator --ledger /mnt/ledger/ contact-info` + spawnSync(cmd, { shell: true, stdio: 'inherit' }) + }) + get .command('config') .description(locale.cmds.config) diff --git a/packages/solv/src/cli/restart/createSnapshot.ts b/packages/solv/src/cli/restart/createSnapshot.ts deleted file mode 100644 index 027807c..0000000 --- a/packages/solv/src/cli/restart/createSnapshot.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ConfigParams } from '@/lib/readOrCreateDefaultConfig' -import { spawn } from 'child_process' - -export const createSnapshot = (solvConfig: ConfigParams, slot: string) => { - try { - const ledgerPath = solvConfig.config.LEDGER_PATH - const cmd = `solana-ledger-tool -l ${ledgerPath} \ - --snapshot-archive-path ${ledgerPath} \ - --incremental-snapshot-archive-path ${ledgerPath} \ - create-snapshot ${slot} ${ledgerPath} \ - --hard-fork ${slot}\ - --deactivate-feature-gate EJJewYSddEEtSZHiqugnvhQHiWyZKjkFDQASd7oKSagn` - const process = spawn(cmd, { shell: true }) - - process.stdout.on('data', (data) => { - console.log(data.toString()) - }) - - process.stderr.on('data', (data) => { - console.error(data.toString()) - }) - - process.on('exit', (code) => { - if (code === 0) { - console.log(`Snapshot created for slot: ${slot}`) - } else { - throw new Error(`createSnapshot: ${code}`) - } - }) - } catch (error) { - throw new Error(`createSnapshot: ${error}`) - } -} diff --git a/packages/solv/src/cli/restart/deleteSnapshot.ts b/packages/solv/src/cli/restart/deleteSnapshot.ts deleted file mode 100644 index 96fc70e..0000000 --- a/packages/solv/src/cli/restart/deleteSnapshot.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { spawnSync } from 'child_process' - -export const deleteSnapshot = () => { - try { - const ledgerPath = `/mnt/ledger/*snapshot*` - const cmd = `sudo rm -rf ${ledgerPath}` - spawnSync(cmd, { shell: true, stdio: 'inherit' }) - return true - } catch (error) { - throw new Error(`deleteSnapshot: ${error}`) - } -} diff --git a/packages/solv/src/cli/restart/index.ts b/packages/solv/src/cli/restart/index.ts index 37ba023..7306e20 100644 --- a/packages/solv/src/cli/restart/index.ts +++ b/packages/solv/src/cli/restart/index.ts @@ -1,32 +1,16 @@ import { program } from '@/index' import { ConfigParams } from '@/lib/readOrCreateDefaultConfig' -import { restartFetch } from './restartFetch' -import { restartSolv } from './restartSolv' - -type RestartOptions = { - snapshot: boolean -} +import { spawnSync } from 'node:child_process' +import { MT_PATHS } from '@/config/config' export const restartCommand = (solvConfig: ConfigParams) => { const { cmds } = solvConfig.locale program .command('restart') .description(cmds.restart) - .option('--snapshot', 'Restart Solana Validator with fetch snapshot', false) - .action(async (options: RestartOptions) => { - try { - if (options.snapshot) { - await restartFetch(solvConfig) - } else { - // TODO: Uncomment this line and update the createSnapshot function when The Solana team releases the new instructions - // Comment out for the usual restart - // createSnapshot(solvConfig) - await restartSolv(solvConfig) - } - } catch (error) { - console.log( - `If you failed to create a snapshot, please try - $ solv restart --snapshot`, - ) - } + .action(async () => { + const config = solvConfig.config + const cmd = `solana-validator --ledger ${MT_PATHS.LEDGER} exit --max-delinquent-stake ${config.MAINNET_DELINQUENT_STAKE}` + spawnSync(cmd, { shell: true, stdio: 'inherit' }) }) } diff --git a/packages/solv/src/cli/restart/restartFetch.ts b/packages/solv/src/cli/restart/restartFetch.ts deleted file mode 100644 index c57052b..0000000 --- a/packages/solv/src/cli/restart/restartFetch.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { MAINNET_TYPES } from '@/config/config' -import { genStartupValidatorScript } from '@/cli/setup/genStartupValidatorScript' -import { ConfigParams } from '@/lib/readOrCreateDefaultConfig' -import { stopSolana } from '@/cli/stop/stopSolana' -import { startSolana } from '@/cli/start/startSolana' -import inquirer from 'inquirer' - -export const restartFetch = async (solvConfig: ConfigParams) => { - const answer = await inquirer.prompt([ - { - type: 'confirm', - name: 'confirm', - message: - 'This will overwrite start-validator.sh file and restart the validator. Are you sure?', - default: false, - }, - ]) - if (!answer.confirm) { - return - } - const isJitoMev = - solvConfig.config.MAINNET_TYPE === MAINNET_TYPES.JITO_MEV ? true : false - await genStartupValidatorScript(false, solvConfig.config.SOLV_TYPE, isJitoMev) - stopSolana() - startSolana() -} diff --git a/packages/solv/src/cli/scp/executeSCP.ts b/packages/solv/src/cli/scp/executeSCP.ts index dde80cd..89cb596 100644 --- a/packages/solv/src/cli/scp/executeSCP.ts +++ b/packages/solv/src/cli/scp/executeSCP.ts @@ -7,8 +7,8 @@ export function executeSCP( isDownload: boolean, ) { const cmd = isDownload - ? `scp solv@${ip}:${key} ${filePath}` - : `scp ${key} solv@${ip}:${filePath}` + ? `scp -o StrictHostKeyChecking=no solv@${ip}:${key} ${filePath}` + : `scp -o StrictHostKeyChecking=no ${key} solv@${ip}:${filePath}` const result = spawnSync(cmd, { shell: true, stdio: 'inherit' }) return result.status === 0 diff --git a/packages/solv/src/cli/scp/upload.ts b/packages/solv/src/cli/scp/upload.ts index ebec26c..b1b85c1 100644 --- a/packages/solv/src/cli/scp/upload.ts +++ b/packages/solv/src/cli/scp/upload.ts @@ -33,7 +33,7 @@ export const upload = async () => { if (!existsSync(filePath)) { continue } - const cmd = `scp ${filePath} solv@${answer.ip}:${key}` + const cmd = `scp -o StrictHostKeyChecking=no ${filePath} solv@${answer.ip}:${key}` spawnSync(cmd, { shell: true, stdio: 'inherit' }) console.log(`Successfully Uploaded - ${fileName} 🎉`) } diff --git a/packages/solv/src/cli/update/updateSolv.ts b/packages/solv/src/cli/update/updateSolv.ts index 3146362..bd2f015 100644 --- a/packages/solv/src/cli/update/updateSolv.ts +++ b/packages/solv/src/cli/update/updateSolv.ts @@ -1,6 +1,7 @@ import { spawnSync } from 'child_process' export const updateSolv = () => { + spawnSync('pnpm add -g pnpm', { shell: true, stdio: 'inherit' }) const cmd = `pnpm add -g @epics-dao/solv` spawnSync(cmd, { shell: true, stdio: 'inherit' }) }