-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add getSolanaCLI for agave/solana CLI
- Loading branch information
1 parent
1e3e3f0
commit 74afffc
Showing
4 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'@epics-dao/solv': minor | ||
--- | ||
|
||
Now that we have the v2 version of the solv cli, we need to update the solv cli versioin. | ||
So, we are adding a new function `getSolanaCLI` to get the solana cli version for agave/solana. | ||
Also, solv switch incoming for v1 to v2. | ||
|
||
Add - getSolanaCLI to get the solana cli version for agave/solana | ||
Add - solv switch incoming for v1 to v2 | ||
|
||
solana version: 1.x.x will be deprecated soon, so we need to switch to v2. |
146 changes: 146 additions & 0 deletions
146
packages/solv/src/cli/switch/changeIdentityIncomingV1toV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { | ||
AGAVE_VALIDATOR, | ||
IDENTITY_KEY, | ||
IDENTITY_KEY_PATH, | ||
LEDGER_PATH, | ||
MAINNET_VALIDATOR_KEY_PATH, | ||
SOLANA_VALIDATOR, | ||
SOLV_HOME, | ||
TESTNET_VALIDATOR_KEY_PATH, | ||
UNSTAKED_KEY, | ||
} from '@/config/constants' | ||
import { join } from 'path' | ||
import { spawnSync } from 'node:child_process' | ||
import chalk from 'chalk' | ||
import checkValidatorKey from './checkValidatorKey' | ||
import { updateDefaultConfig } from '@/config/updateDefaultConfig' | ||
import { DefaultConfigType } from '@/config/types' | ||
import { Network, NodeType } from '@/config/enums' | ||
|
||
const unstakedKeyPath = join(SOLV_HOME, UNSTAKED_KEY) | ||
const identityKeyPath = join(SOLV_HOME, IDENTITY_KEY) | ||
|
||
export const changeIdentityIncomingV1toV2 = async ( | ||
ip: string, | ||
pubkey: string, | ||
config: DefaultConfigType, | ||
) => { | ||
const isTestnet = config.NETWORK === Network.TESTNET | ||
const isRPC = config.NODE_TYPE === NodeType.RPC | ||
let validatorKeyPath = isTestnet | ||
? TESTNET_VALIDATOR_KEY_PATH | ||
: MAINNET_VALIDATOR_KEY_PATH | ||
if (isRPC) { | ||
validatorKeyPath = TESTNET_VALIDATOR_KEY_PATH | ||
} | ||
|
||
const isKeyOkay = checkValidatorKey(validatorKeyPath, ip) | ||
if (!isKeyOkay) { | ||
return | ||
} | ||
|
||
// old version of solana client | ||
const solanaClient = SOLANA_VALIDATOR | ||
// new version of solana client | ||
const agaveClient = AGAVE_VALIDATOR | ||
|
||
console.log(chalk.white('🟢 Waiting for restart window...')) | ||
const restartWindowCmd = `ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no solv@${ip} -p 22 'cd ~ && source ~/.profile && ${solanaClient} -l ${LEDGER_PATH} wait-for-restart-window --min-idle-time 2 --skip-new-snapshot-check'` | ||
const result1 = spawnSync(restartWindowCmd, { shell: true, stdio: 'inherit' }) | ||
if (result1.status !== 0) { | ||
console.log( | ||
chalk.yellow( | ||
`⚠️ wait-for-restart-window Failed. Please check your Validator\n$ ssh solv@${ip}\n\nFailed Cmd: ${solanaClient} -l ${LEDGER_PATH} wait-for-restart-window --min-idle-time 2 --skip-new-snapshot-check`, | ||
), | ||
) | ||
return | ||
} | ||
|
||
// Set the identity on the unstaked key | ||
console.log(chalk.white('🟢 Setting identity on the new validator...')) | ||
const setIdentityCmd = `ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no solv@${ip} -p 22 'cd ~ && source ~/.profile && ${solanaClient} -l ${LEDGER_PATH} set-identity ${unstakedKeyPath}'` | ||
const result2 = spawnSync(setIdentityCmd, { shell: true, stdio: 'inherit' }) | ||
if (result2.status !== 0) { | ||
console.log( | ||
chalk.yellow( | ||
`⚠️ Set Identity Failed. Please check your Validator\n$ ssh solv@${ip}\n\nFailed Cmd: ${solanaClient} -l ${LEDGER_PATH} set-identity ${unstakedKeyPath}`, | ||
), | ||
) | ||
return | ||
} | ||
|
||
// Change the Symlink to the unstaked keypair | ||
console.log( | ||
chalk.white('🟢 Changing the Symlink to the new validator keypair...'), | ||
) | ||
const result3 = spawnSync( | ||
`ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no solv@${ip} -p 22 'cd ~ && source ~/.profile && ln -sf ${unstakedKeyPath} ${identityKeyPath}'`, | ||
{ | ||
shell: true, | ||
stdio: 'inherit', | ||
}, | ||
) | ||
|
||
if (result3.status !== 0) { | ||
console.log( | ||
chalk.yellow( | ||
`⚠️ Chaning Identity Key Symlink Failed. Please check your Validator\n$ ssh solv@${ip}\n\nFailed Cmd: ln -sf ${unstakedKeyPath} ${identityKeyPath}`, | ||
), | ||
) | ||
return | ||
} | ||
|
||
// Download the tower file to the new validator | ||
console.log( | ||
chalk.white('🟢 Uploading the tower file to the new validator...'), | ||
) | ||
const result4 = spawnSync( | ||
`scp solv@${ip}:${LEDGER_PATH}/tower-1_9-${pubkey}.bin ${LEDGER_PATH}`, | ||
{ shell: true, stdio: 'inherit' }, | ||
) | ||
if (result4.status !== 0) { | ||
console.log( | ||
chalk.yellow( | ||
`⚠️ Upload Tower File Failed. Please check your tower file\n$ ssh solv@${ip}\n\nFailed Cmd: scp solv@${ip}:${LEDGER_PATH}/tower-1_9-${pubkey}.bin ${LEDGER_PATH}`, | ||
), | ||
) | ||
return | ||
} | ||
|
||
// Set the identity on the new validator | ||
console.log(chalk.white('🟢 Setting identity on the new validator...')) | ||
const result5 = spawnSync( | ||
`${agaveClient} -l ${LEDGER_PATH} set-identity --require-tower ${validatorKeyPath}`, | ||
{ | ||
shell: true, | ||
stdio: 'inherit', | ||
}, | ||
) | ||
if (result5.status !== 0) { | ||
console.log( | ||
chalk.yellow( | ||
`⚠️ Set Identity Failed. Please check your Validator\n\nFailed Cmd: ${agaveClient} -l ${LEDGER_PATH} set-identity ${validatorKeyPath}\nln -sf ${validatorKeyPath} ${IDENTITY_KEY_PATH}`, | ||
), | ||
) | ||
return | ||
} | ||
|
||
const result6 = spawnSync(`ln -sf ${validatorKeyPath} ${IDENTITY_KEY_PATH}`, { | ||
shell: true, | ||
stdio: 'inherit', | ||
}) | ||
|
||
if (result6.status !== 0) { | ||
console.log( | ||
chalk.yellow( | ||
`⚠️ Chaning Identity Key Symlink Failed. Please check your Validator\n\nFailed Cmd: ln -sf ${validatorKeyPath} ${IDENTITY_KEY_PATH}`, | ||
), | ||
) | ||
return | ||
} | ||
|
||
console.log(chalk.white('🟢 Identity changed successfully!')) | ||
await updateDefaultConfig({ | ||
IS_DUMMY: false, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters