-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update - testnet restart instruction
- Loading branch information
1 parent
3a3d031
commit a7a0237
Showing
73 changed files
with
1,918 additions
and
705 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { Command } from '@cliffy' | ||
import { init } from '/src/validator/init/init.ts' | ||
import { deployValidatorTestnet } from '/src/validator/deploy/deployValidatorTestnet.ts' | ||
import { prompt, Select } from '@cliffy/prompt' | ||
import { Confirm, prompt, Select } from '@cliffy/prompt' | ||
import { colors } from '@cliffy/colors' | ||
import { listValidators } from '/src/validator/listValidators.ts' | ||
import { getIPByIdentityKey } from '/lib/getIPByIdentityKey.ts' | ||
import { getTemplatePath } from '/lib/getTemplatePath.ts' | ||
import { runAnsilbe } from '/lib/runAnsible.ts' | ||
import type { InventoryType, NetworkType } from '@cmn/types/config.ts' | ||
import { genOrReadInventory } from '/lib/genOrReadInventory.ts' | ||
import { parse } from 'https://deno.land/[email protected]/yaml/parse.ts' | ||
import { addInventory } from '/lib/addInventory.ts' | ||
import type { SSHConnection } from '@cmn/prompt/checkSshConnection.ts' | ||
import { homeDir } from '@cmn/constants/path.ts' | ||
import { updateInventory } from '/lib/updateInventory.ts' | ||
import { VERSION_SOLANA_TESTNET } from '@cmn/constants/version.ts' | ||
|
||
export const validatorCmd = new Command() | ||
.description('Manage Solana Validator Nodes') | ||
|
@@ -73,8 +78,12 @@ validatorCmd.command('set:identity') | |
: 'testnet_validators' | ||
|
||
const templateRoot = getTemplatePath() | ||
const inventory = await genOrReadInventory(inventoryType) | ||
const playbook = | ||
`${templateRoot}/ansible/testnet-validator/change_identity_and_restart.yml` | ||
inventory[inventoryType].hosts[options.pubkey].validator_type === | ||
'firedancer' | ||
? `${templateRoot}/ansible/testnet-validator/change_identity_and_restart.yml` | ||
: `${templateRoot}/ansible/testnet-validator/set_identity_to_active.yml` | ||
const result = await runAnsilbe(playbook, inventoryType, options.pubkey) | ||
if (result) { | ||
console.log(colors.white('✅ Successfully Set Validator Identity')) | ||
|
@@ -141,3 +150,132 @@ validatorCmd.command('restart') | |
return | ||
} | ||
}) | ||
|
||
validatorCmd.command('setup:agave') | ||
.description('Setup Agave Validator') | ||
.option('--pubkey <pubkey>', 'Public Key of Validator') | ||
.action(async (options) => { | ||
if (!options.pubkey) { | ||
console.log(colors.yellow('⚠️ Public Key is required')) | ||
return | ||
} | ||
const inventoryType: InventoryType = 'testnet_validators' | ||
const templateRoot = getTemplatePath() | ||
const playbook = `${templateRoot}/ansible/testnet-validator/setup_agave.yml` | ||
const result = await runAnsilbe(playbook, inventoryType, options.pubkey) | ||
await updateInventory(options.pubkey, inventoryType, { | ||
validator_type: 'agave', | ||
version: VERSION_SOLANA_TESTNET, | ||
}) | ||
if (result) { | ||
console.log(colors.white('✅ Successfully Setup Agave Validator')) | ||
return | ||
} | ||
}) | ||
|
||
// validatorCmd.command('update:version') | ||
// .description('Update Validator Version') | ||
// .option('--pubkey <pubkey>', 'Public Key of Validator') | ||
// .option('-n, --network <network>', 'Network to deploy validators', { | ||
// default: 'testnet', | ||
// }) | ||
// .action(async (options) => { | ||
// if (!options.pubkey) { | ||
// console.log(colors.yellow('⚠️ Public Key is required')) | ||
// return | ||
// } | ||
// const inventoryType: InventoryType = options.network === 'mainnet' | ||
// ? 'mainnet_validators' | ||
// : 'testnet_validators' | ||
// }) | ||
|
||
validatorCmd.command('apply') | ||
.description('Apply Ansiible Playbook') | ||
.option('-y, --yml <yml>', 'Playbook Yml File Path to Apply') | ||
.option('-p, --pubkey <pubkey>', 'Public Key of Validator') | ||
.option('-n, --network <network>', 'Network to deploy validators', { | ||
default: 'testnet', | ||
}) | ||
.action(async (options) => { | ||
if (!options.yml) { | ||
console.log(colors.yellow('⚠️ Yml File is required')) | ||
return | ||
} | ||
if (!options.pubkey) { | ||
console.log(colors.yellow('⚠️ Public Key is required')) | ||
return | ||
} | ||
const inventoryType: InventoryType = options.network === 'mainnet' | ||
? 'mainnet_validators' | ||
: 'testnet_validators' | ||
const result = await runAnsilbe(options.yml, inventoryType, options.pubkey) | ||
if (result) { | ||
console.log(colors.white('✅ Successfully Applied Playbook')) | ||
return | ||
} | ||
}) | ||
|
||
validatorCmd.command('codebot') | ||
.description('CodeBot Validator Config') | ||
.action(async () => { | ||
const confirm = await prompt([{ | ||
type: Confirm, | ||
name: 'continue', | ||
message: 'Do you want to migrate to new inventory?', | ||
default: true, | ||
}]) | ||
if (!confirm.continue) { | ||
console.log(colors.blue('Cancelled...🌝')) | ||
return | ||
} | ||
interface Validator { | ||
identity_account: string | ||
vote_account: string | ||
authority_account: string | ||
username: string | ||
ip: string | ||
rsa_key_path: string | ||
solana_cli: string | ||
solana_version: string | ||
validator_type: string | ||
version: string | ||
} | ||
|
||
interface Config { | ||
validators: Validator[] | ||
} | ||
const inventoryType: InventoryType = 'testnet_validators' | ||
const oldConfigPath = homeDir + '/.slv/config.validator.testnet.yml' | ||
let fileContent = '' | ||
try { | ||
fileContent = await Deno.readTextFile(oldConfigPath) | ||
} catch (_error) { | ||
console.log(`No file found at ${oldConfigPath}`) | ||
console.log(colors.white('Looks good...🌝')) | ||
return | ||
} | ||
const config = parse(fileContent) as Config | ||
for (const validator of config.validators) { | ||
const sshConnection: SSHConnection = { | ||
username: validator.username, | ||
ip: validator.ip, | ||
rsa_key_path: validator.rsa_key_path, | ||
} | ||
await addInventory( | ||
validator.identity_account, | ||
sshConnection, | ||
inventoryType, | ||
) | ||
await updateInventory( | ||
validator.identity_account, | ||
inventoryType, | ||
{ | ||
vote_account: validator.vote_account, | ||
authority_account: validator.authority_account, | ||
validator_type: validator.validator_type, | ||
version: validator.version, | ||
}, | ||
) | ||
} | ||
console.log(colors.white('✅ Successfully Migrated to New Inventory')) | ||
}) |
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
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
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// Description: Version constants for the application. | ||
// e.g.: VERSION + SOLANA CLI NAME + NETWORK = '0.0.1' only numbers and dots | ||
export const VERSION_SOLANA_TESTNET = '2.1.6' | ||
export const VERSION_SOLANA_TESTNET = '2.0.22' | ||
export const VERSION_SOLANA_MAINNET = '2.0.19' | ||
export const VERSION_JITO_TESTNET = '2.1.6' | ||
export const VERSION_JITO_TESTNET = '2.0.22' | ||
export const VERSION_JITO_MAINNET = '2.0.19' | ||
export const VERSION_FIREDANCER_TESTNET = '0.302.20104' | ||
export const VERSION_FIREDANCER_MAINNET = '0.302.20104' | ||
export const VERSION_FIREDANCER_TESTNET = '0.304.20106' | ||
export const VERSION_FIREDANCER_MAINNET = '0.304.20106' |
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
Empty file.
Oops, something went wrong.