Skip to content

Commit

Permalink
Merge pull request #279 from EpicsDAO/feature
Browse files Browse the repository at this point in the history
update - solv update --migrate-config
  • Loading branch information
POPPIN-FUMI authored Sep 10, 2024
2 parents 2295abb + fae8f97 commit 3cf0c9d
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 44 deletions.
33 changes: 33 additions & 0 deletions .changeset/tidy-dogs-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
'@epics-dao/solv': patch
---

Update - solv update --migrate-config

## Summary

This PR adds a new command `solv update --migrate-config` to migrate the old config file to the new config file.

`solv.config.json` to `solv4.config.json`

You can migrate the old config file to the new config file by running the following command:

```bash
solv update --migrate-config
```

## Config Update Command

This command will update the config file to the latest version.

```bash
solv update --config
```

## solv Discord Channel is now migrated to Validators DAO's Discord

Due to the increasing number of users, the solv Discord channel has been migrated to Validators DAO's Discord.

Now this community is more focused on Solana Validators and RPC Operators.

Validators DAO: https://discord.gg/8dhnZnvzuw
3 changes: 3 additions & 0 deletions packages/solv/src/cli/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { readOrCreateJitoConfig } from '@/lib/readOrCreateJitoConfig'
import { daemonReload } from '@/lib/daemonReload'
import { setupV2 } from './setupV2'
import { jitoRelayerSetup } from './jitoRelayerSetup'
import rpcLog from '@/utils/rpcLog'

type SetupOptions = {
vote: boolean
Expand Down Expand Up @@ -50,11 +51,13 @@ export const setupCommands = (config: DefaultConfigType) => {
),
)
daemonReload()
rpcLog()
process.exit(0)
} else if (options.jupiter) {
console.log(chalk.white('Setting up Jupiter Swap API ...'))
await jupiterAPISetup()
daemonReload()
rpcLog()
process.exit(0)
}
await setupV2(options.skipInitConfig, options.skipMount)
Expand Down
34 changes: 2 additions & 32 deletions packages/solv/src/cli/setup/setupV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import updateSysctlConfig from '@/template/updateSysctlConfig'
import { restartLogrotate } from '@/lib/restartLogrotate'
import { enableSolv } from '@/lib/enableSolv'
import { createSymLink } from './createSymLink'
import rpcLog from '@/utils/rpcLog'

export const setupV2 = async (skipInitConfig = false, skipMount = false) => {
try {
Expand Down Expand Up @@ -70,39 +71,8 @@ export const setupV2 = async (skipInitConfig = false, skipMount = false) => {
// Start Solana
startSolana()
console.log(chalk.white(`🟢 Setup Completed`))
lastMsg()
rpcLog()
} catch (error: any) {
throw new Error(`Setup Error: ${error.message}`)
}
}

const lastMsg = () => {
const warning = `===⚠️ Frequently Asked Questions ⚠️===
Q: How long does it take to catch up with the latest slot?
Q: Error: error sending request for url (http://localhost:8899/)
Q: Can't connect to Solana RPC Node
A:
It will take an hour to a several hours to catch up with the latest slot.
This time may vary depending on your network speed and hardware.
Solana Validator requires at least 256GB RAM and 12 CPU cores.
RPC Node requires at least 512GB RAM and 16 CPU cores.
It may not finish catching up if your hardware does not meet the requirements.
You can check current status by running:
$ solv monitor
(Above cmd only works when the snapshot is downloaded and the validator is running.)
If above cmd doesn't work, please check if your node has finished downloading the snapshot by running:
$ solv log
You can only track error logs by running:
$ solv log -e
Validators Solutions: https://validators.solutions
`
console.log(chalk.yellow(warning))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { spawnSync } from 'child_process'
import jupiterAPIService from '@/cli/setup/template/jupiter/jupiterAPIService'
import inquirer from 'inquirer'
import chalk from 'chalk'
import rpcLog from '@/utils/rpcLog'

type JupiterAPISetupOptions = {
rpcUrl: string
Expand Down
44 changes: 37 additions & 7 deletions packages/solv/src/cli/swap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { swap } from './swap'
import { Command } from 'commander'
import { ELSOL_MINT_ADDRESS } from '@/config/config'
import { DefaultConfigType } from '@/config/types'
import { updateDefaultConfig } from '@/config/updateDefaultConfig'
import rpcLog from '@/utils/rpcLog'
dotenv.config()

export const swapCommand = async (
Expand Down Expand Up @@ -63,16 +65,12 @@ const swapCmd = async (
outputMint = '',
inputAmountLamport = 0,
isNeedConfirm = true,
initConfig = false,
) => {
console.log(chalk.white('Solana RPC URL:', solanaRpcUrl))
console.log(chalk.white('KeyfilePath:', keyfilePath))
if (!keyfilePath || keyfilePath === '') {
console.log(
chalk.yellow(
`⚠️ Please set the KEYPAIR_PATH in the solv4.config.json file to use this command ⚠️`,
),
)
return
if (!keyfilePath || keyfilePath === '' || initConfig) {
await askForConfig()
}
const jupiterEndpoint = JUPITER_ENDPOINT
let inputTokenChoice = [...SWAP_TOKENS, 'Other']
Expand Down Expand Up @@ -172,3 +170,35 @@ const swapCmd = async (
}

export default swapCmd

export type SwapConfig = {
RPC_URL: string
KEYPAIR_PATH: string
API_KEY: string
}

const askForConfig = async () => {
const config = await inquirer.prompt<SwapConfig>([
{
type: 'input',
name: 'RPC_URL',
message: 'Enter Solana RPC URL',
default: 'https://api.mainnet-beta.solana.com',
},
{
type: 'input',
name: 'KEYPAIR_PATH',
message: 'Enter Keypair Path',
default: '/home/solv/mainnet-validator-keypair.json',
},
{
type: 'input',
name: 'API_KEY',
message: 'Enter Jupiter API Key(Optional)',
default: '',
},
])
await updateDefaultConfig(config)
console.log(chalk.green('✔︎ Config Updated Successfully!\n'))
rpcLog()
}
13 changes: 8 additions & 5 deletions packages/solv/src/cli/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type UpdateOptions = {
commission: number
firewall: boolean
config: boolean
migrateConfig: boolean
auto: boolean
}

Expand Down Expand Up @@ -64,6 +65,7 @@ export const updateCommands = (config: DefaultConfigType) => {
.option('-b, --background', 'No Monitor Delinquent Stake Update', false)
.option('-c, --commission', 'Update Commission', false)
.option('-f, --firewall', 'Update Firewall', false)
.option('--migrate-config', 'Migrate Solv Config', false)
.option('--config', 'Update Solv Config Default Solana Version', false)
.option('--auto', 'Auto Update', false)
.action(async (options: UpdateOptions) => {
Expand All @@ -78,8 +80,8 @@ export const updateCommands = (config: DefaultConfigType) => {
await autoUpdate(config)
return
}
// Only Update solv.config.json default solana version
if (options.config) {

if (options.migrateConfig) {
// Temporarily!!
// Migrate solv.config.json to solv4.config.json
const oldConfig = readOrCreateDefaultConfig().config
Expand Down Expand Up @@ -121,7 +123,8 @@ export const updateCommands = (config: DefaultConfigType) => {

await updateDefaultConfig(newConfigBody)
// --- End of Temporarily!!

}
if (options.config) {
await updateDefaultConfig({
TESTNET_SOLANA_VERSION: VERSION_TESTNET,
MAINNET_SOLANA_VERSION: VERSION_MAINNET,
Expand Down Expand Up @@ -150,8 +153,8 @@ export const updateCommands = (config: DefaultConfigType) => {
if (options.background) {
let version = options.version
await updateDefaultConfig({
TESTNET_SOLANA_VERSION: config.TESTNET_SOLANA_VERSION,
MAINNET_SOLANA_VERSION: config.MAINNET_SOLANA_VERSION,
TESTNET_SOLANA_VERSION: VERSION_TESTNET,
MAINNET_SOLANA_VERSION: VERSION_MAINNET,
})

if (isJito) {
Expand Down
19 changes: 19 additions & 0 deletions packages/solv/src/utils/rpcLog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import chalk from 'chalk'

const rpcLog = () => {
const lighting = `${chalk.yellow('⚡️⚡️⚡️')}`
const msg = `${chalk.blueBright(`${lighting} Solana Private RPC Connection API Key ${lighting}`)}
We're excited to offer a free API key exclusively for the Validators DAO community 🎉
It's our way of supporting the community and empowering you with fast, reliable connections.
To get your free API key, simply join us through the link below:
Validators DAO: ${chalk.white('`https://discord.gg/X4BgkBHavp`')}
Unlock fast connections and elevate your experience with your very own API key 🚀
`
console.log(chalk.cyan(msg))
}

export default rpcLog

0 comments on commit 3cf0c9d

Please sign in to comment.