Skip to content

Commit

Permalink
Merge pull request #99 from EpicsDAO/solv
Browse files Browse the repository at this point in the history
Update Logrotate, RPC NODE firewall
  • Loading branch information
POPPIN-FUMI authored Mar 15, 2024
2 parents fd5d8f0 + e22bf97 commit 6749a9e
Show file tree
Hide file tree
Showing 10 changed files with 731 additions and 457 deletions.
28 changes: 28 additions & 0 deletions .changeset/hot-avocados-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
'@epics-dao/solv': patch
---

Update Logrotate, RPC NODE firewall

## Update Logrotation

Recently, we have updated the logrotate configuration for Solana Validator.
To apply the changes, you need to run the following command.
(We recommend running this command if you are attending to TDS with Edgevana Server.)

```bash
$ solv update --logrotate
```

## Update RPC NODE Firewall

We have noticed that some users are facing issues with the RPC Node's performance.
We have updated the firewall configuration to improve the RPC Node's to prevent the DDoS attack.
Thank you @cryptoo_bear San for reporting the issue to us.
New solv setup command will ask you to enter your IP address to allow access to RPC NODE.
But you can also run the following command to update the firewall configuration.

```bash
$ solv update --firewall
? Enter your IP address to allow access to RPC NODE: (0.0.0.0)
```
24 changes: 12 additions & 12 deletions packages/solv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,45 @@
"ci:version": "npx ts-node -r tsconfig-paths/register --transpile-only src/lib/logVersion.ts"
},
"dependencies": {
"@skeet-framework/utils": "1.2.4",
"@skeet-framework/utils": "1.3.8",
"chalk": "5.3.0",
"chalk-pipe": "6.0.0",
"cli-progress": "3.12.0",
"cli-spinner": "0.2.10",
"cli-table3": "0.6.3",
"commander": "12.0.0",
"dotenv": "16.4.5",
"inquirer": "9.2.15",
"inquirer": "9.2.16",
"node-cron": "3.0.3",
"node-fetch": "3.3.2",
"prompt": "1.3.0"
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.1",
"@skeet-framework/discord-utils": "0.2.14",
"@skeet-framework/discord-utils": "0.4.0",
"@types/cli-progress": "3.11.5",
"@types/cli-spinner": "0.2.3",
"@types/inquirer": "9.0.7",
"@types/node": "20.11.19",
"@types/node": "20.11.28",
"@types/node-cron": "3.0.11",
"@types/node-fetch": "2.6.11",
"@types/prompt": "1.1.8",
"@typescript-eslint/eslint-plugin": "7.0.2",
"@typescript-eslint/parser": "7.0.2",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.2.0",
"babel-loader": "9.1.3",
"esbuild": "0.20.1",
"esbuild": "0.20.2",
"esbuild-plugin-alias-path": "2.0.2",
"eslint": "8.56.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"nodemon": "3.0.3",
"nodemon": "3.1.0",
"prettier": "3.2.5",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "5.3.3",
"vite": "5.1.4",
"vite-tsconfig-paths": "4.3.1",
"typescript": "5.4.2",
"vite": "5.1.6",
"vite-tsconfig-paths": "4.3.2",
"vitest": "1.3.1"
}
}
3 changes: 2 additions & 1 deletion packages/solv/src/cli/cron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { getEpoch } from './getEpoch'
import { Logger } from '@/lib/logger'
import { spawnSync } from 'child_process'
import { stopSolana } from '../stop/stopSolana'
import { dotenv, sendDiscord } from '@skeet-framework/utils'
import { sendDiscord } from '@skeet-framework/utils'
import chalk from 'chalk'
import dotenv from 'dotenv'
import { ConfigParams } from '@/lib/readOrCreateDefaultConfig'

dotenv.config()
Expand Down
5 changes: 4 additions & 1 deletion packages/solv/src/cli/setup/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { enableSolv } from '@/lib/enableSolv'
import { restartLogrotate } from '@/lib/restartLogrotate'
import { askJitoSetting } from './askJitoSetting'
import { readOrCreateJitoConfig } from '@/lib/readOrCreateJitoConfig'
import { updateFirewall } from './updateFirewall'

export const setup = async (solvConfig: ConfigParams) => {
try {
Expand Down Expand Up @@ -102,6 +103,8 @@ export const setup = async (solvConfig: ConfigParams) => {
},
])
commission = Number(question.commission)
} else {
await updateFirewall()
}

// Check if solvType is TESTNET_VALIDATOR
Expand Down Expand Up @@ -159,7 +162,7 @@ export const setup = async (solvConfig: ConfigParams) => {
}
const newSolvConfig = readOrCreateDefaultConfig()
setupPermissions()
await genStartupValidatorScript(true, sType, isJitoMev)
genStartupValidatorScript(true, sType, isJitoMev)
makeServices(isTest)
daemonReload()

Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/setup/testnetSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const testnetSetup = async (solvConfig: ConfigParams) => {
}
}
setupPermissions()
await genStartupValidatorScript(true, sType)
genStartupValidatorScript(true, sType)
makeServices(isTest)
setupKeys(solvConfig)
const cmds = [
Expand Down
20 changes: 20 additions & 0 deletions packages/solv/src/cli/setup/updateFirewall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { execAsync } from '@skeet-framework/utils'
import chalk from 'chalk'
import inquirer from 'inquirer'

export const updateFirewall = async () => {
const answer = await inquirer.prompt<{ ip: string }>([
{
name: 'ip',
type: 'input',
message: 'Enter your IP address to allow access to RPC NODE:',
default: '0.0.0.0',
},
])
await execAsync(`sudo ufw delete allow 8899/udp`)
await execAsync(`sudo ufw delete allow 8899/tcp`)
await execAsync(`sudo ufw allow from ${answer.ip} to any port 8899 proto tcp`)
await execAsync(`sudo ufw allow from ${answer.ip} to any port 8899 proto udp`)
await execAsync(`sudo ufw reload`)
console.log(chalk.white('✔️ Firewall updated!'))
}
22 changes: 21 additions & 1 deletion packages/solv/src/cli/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { Logger } from '@/lib/logger'
import chalk from 'chalk'
import { updateSolv } from './updateSolv'
import { spawnSync } from 'child_process'
import { CONFIG, MAINNET_TYPES, SOLV_TYPES } from '@/config/config'
import {
CONFIG,
MAINNET_TYPES,
SERVICE_PATHS,
SOLV_TYPES,
} from '@/config/config'
import { ConfigParams } from '@/lib/readOrCreateDefaultConfig'
import { updateSolvConfig } from '@/lib/updateSolvConfig'
import { nodeUpdate } from './nodeUpdate'
Expand All @@ -13,6 +18,8 @@ import { jitoUpdate } from './jitoUpdate'
import { updateJitoSolvConfig } from '@/lib/updateJitoSolvConfig'
import { JITO_CONFIG } from '@/config/jitConfig'
import { updateCommission, updateCommissionAsk } from './updateCommission'
import { setupLogrotate } from '../setup/setupLogrotate'
import { updateFirewall } from '../setup/updateFirewall'

export * from './update'

Expand All @@ -22,6 +29,8 @@ export type UpdateOptions = {
background: boolean
node: boolean
commission: number
logrotate: boolean
firewall: boolean
}

export const updateCommands = (solvConfig: ConfigParams) => {
Expand All @@ -39,7 +48,18 @@ export const updateCommands = (solvConfig: ConfigParams) => {
.option('-b, --background', 'No Monitor Delinquent Stake Update', false)
.option('-n, --node', 'Update Node Version', false)
.option('-c, --commission', 'Update Commission', false)
.option('-l, --logrotate', 'Setup Logrotate', false)
.option('-f, --firewall', 'Update Firewall', false)
.action(async (options: UpdateOptions) => {
if (options.logrotate) {
spawnSync(`rm -rf ${SERVICE_PATHS.SOL_LOGROTATE}`, { shell: true })
setupLogrotate()
return
}
if (options.firewall) {
await updateFirewall()
return
}
const isTest =
solvConfig.config.SOLV_TYPE === SOLV_TYPES.TESTNET_VALIDATOR
? true
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/lib/migrate/migrateSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const migrateSetup = async () => {
formatDisk(fileSystem)
ensureFstabEntries(fileSystem)
setupPermissions()
await genStartupValidatorScript(true)
genStartupValidatorScript(true)
makeServices()
const cmds = [
'sudo systemctl daemon-reload',
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/template/logRotates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const logRotates = (username = CONFIG.USERNAME) => {
const body = `${log} {
su ${username} ${username}
daily
rotate 2
rotate 1
size 4G
missingok
compress
Expand Down
Loading

0 comments on commit 6749a9e

Please sign in to comment.