Skip to content

Commit

Permalink
Merge pull request #290 from EpicsDAO/feature
Browse files Browse the repository at this point in the history
Add Geyser/Firedancer Setup Option
  • Loading branch information
POPPIN-FUMI authored Oct 3, 2024
2 parents 1f6d4a6 + 20728ed commit 38273fe
Show file tree
Hide file tree
Showing 34 changed files with 693 additions and 188 deletions.
17 changes: 17 additions & 0 deletions .changeset/sharp-stingrays-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@epics-dao/solv': minor
---

Add Geyser/Firedancer Setup Option

## Setup Geyser Yellowstone

```
solv setup --geyser
```

## Setup Firedancer (Frankendancer)

```
solv setup --firedancer
```
8 changes: 7 additions & 1 deletion packages/solv/src/cli/balance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const balanceCommands = (config: DefaultConfigType) => {

const showKeypairsInfo = async (config: DefaultConfigType) => {
const keyInfo = getKeypairsInfo(config)
const output = `Validator Key: ${keyInfo.validatorKey}
let output = `Validator Key: ${keyInfo.validatorKey}
Address: ${keyInfo.validatorKeyAddress}
Balance: ${keyInfo.validatorKeyBalance}
Vote Key: ${keyInfo.voteKey}
Expand All @@ -45,6 +45,12 @@ Authority Key: ${keyInfo.authorityKey}
Address: ${keyInfo.authorityKeyAddress}
Balance: ${keyInfo.authorityKeyBalance}
Active Identity:`
if (config.NODE_TYPE === NodeType.RPC) {
output = `Validator Key: ${keyInfo.validatorKey}
Address: ${keyInfo.validatorKeyAddress}
Balance: ${keyInfo.validatorKeyBalance}
Active Identity:`
}
console.log(chalk.white(output))
spawnSync(`solana-keygen pubkey ${IDENTITY_KEY_PATH}`, {
stdio: 'inherit',
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/get/solanaCatchup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawnSync } from 'child_process'
import { spawnSync } from 'node:child_process'

export const solanaCatchup = () => {
const cmd = `solana catchup --our-localhost`
Expand Down
5 changes: 0 additions & 5 deletions packages/solv/src/cli/setup/client/setupFiredancer.ts

This file was deleted.

57 changes: 57 additions & 0 deletions packages/solv/src/cli/setup/firedancer/setupFiredancer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { VERSION_FIREDANCER } from '@/config/versionConfig'
import { spawnSync } from 'child_process'
import startFiredancerScript from './startFiredancerScript'
import firedancerService from '../template/firedancer/firedancerService'
import configToml from '../template/firedancer/configToml'

const setupFiredancer = async () => {
spawnSync(
`git clone --recurse-submodules https://github.com/firedancer-io/firedancer.git`,
{ shell: true, stdio: 'inherit' },
)
spawnSync(`git checkout v${VERSION_FIREDANCER}`, {
shell: true,
stdio: 'inherit',
cwd: '/home/solv/firedancer',
})
spawnSync(`./deps.sh`, {
shell: true,
stdio: 'inherit',
cwd: '/home/solv/firedancer',
})
spawnSync(`make -j fdctl solana`, {
shell: true,
stdio: 'inherit',
cwd: '/home/solv/firedancer',
})
spawnSync(
`sudo ln -s /home/solv/firedancer/build/native/gcc/bin/fdctl /usr/local/bin/fdctl`,
{
shell: true,
stdio: 'inherit',
},
)
const { filePath, body } = startFiredancerScript()
spawnSync(`echo "${body}" | sudo tee ${filePath} > /dev/null`, {
shell: true,
stdio: 'inherit',
})
spawnSync(`chmod +x ${filePath}`, { shell: true, stdio: 'inherit' })
const fdService = firedancerService()
spawnSync(
`echo "${fdService.body}" | sudo tee ${fdService.filePath} > /dev/null`,
{
shell: true,
stdio: 'inherit',
},
)

spawnSync(`sudo systemctl daemon-reload`, { shell: true })
const toml = configToml()
spawnSync(`echo "${toml.body}" | sudo tee ${toml.filePath} > /dev/null`, {
shell: true,
stdio: 'inherit',
})
}

export default setupFiredancer
12 changes: 12 additions & 0 deletions packages/solv/src/cli/setup/firedancer/startFiredancerScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const startFiredancerScript = () => {
const filePath = '/home/solv/start-firedancer.sh'
const body = `#!/usr/bin/env bash
sudo fdctl configure init all --config /home/solv/firedancer/config.toml
sudo fdctl run --config /home/solv/firedancer/config.toml`
return {
filePath,
body,
}
}

export default startFiredancerScript
22 changes: 18 additions & 4 deletions packages/solv/src/cli/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import { daemonReload } from '@/lib/daemonReload'
import { setupV2 } from './setupV2'
import { jitoRelayerSetup } from './jitoRelayerSetup'
import rpcLog from '@/utils/rpcLog'
import { yellowstoneGeyser } from './template/geyser/yellowstoneGeyser'
import setupFiredancer from './firedancer/setupFiredancer'

type SetupOptions = {
vote: boolean
key: boolean
relayer: boolean
jupiter: boolean
geyser: boolean
firedancer: boolean
skipInitConfig: boolean
skipMount: boolean
}
Expand All @@ -27,20 +31,22 @@ export const setupCommands = (config: DefaultConfigType) => {
.option('--key', 'Setup Validator Keypairs', false)
.option('--relayer', 'Setup Jito Relayer', false)
.option('--jupiter', 'Setup Jupiter Swap API', false)
.option('--geyser', 'Setup Geyser', false)
.option('--firedancer', 'Setup Firedancer', false)
.option('--skip-init-config', 'Skip Initial Config', false)
.option('--skip-mount', 'Skip Mount', false)
.action(async (options: SetupOptions) => {
try {
if (options.vote) {
console.log(chalk.white('Setting up Vote Account ...'))
console.log(chalk.white('🗳️ Setting up Vote Account ...'))
setupVoteAccount(config)
process.exit(0)
} else if (options.key) {
console.log(chalk.white('Setting up Validator Keypairs ...'))
console.log(chalk.white('🔑 Setting up Validator Keypairs ...'))
createSolvKeyPairs(config)
process.exit(0)
} else if (options.relayer) {
console.log(chalk.white('Setting up Jito Relayer ...'))
console.log(chalk.white('🛰️ Setting up Jito Relayer ...'))
const jitoConfig = await readOrCreateJitoConfig()
const blockEngineUrl = jitoConfig.blockEngineUrl
const isCoHost = false
Expand All @@ -54,11 +60,19 @@ export const setupCommands = (config: DefaultConfigType) => {
rpcLog()
process.exit(0)
} else if (options.jupiter) {
console.log(chalk.white('Setting up Jupiter Swap API ...'))
console.log(chalk.white('🌏 Setting up Jupiter Swap API ...'))
await jupiterAPISetup()
daemonReload()
rpcLog()
process.exit(0)
} else if (options.geyser) {
console.log(chalk.white('⚡️ Setting up Geyser ...'))
await yellowstoneGeyser()
return
} else if (options.firedancer) {
console.log(chalk.white('🔥 Setting up Firedancer ...'))
await setupFiredancer()
return
}
await setupV2(options.skipInitConfig, options.skipMount)
} catch (error: any) {
Expand Down
6 changes: 5 additions & 1 deletion packages/solv/src/cli/setup/question/initialConfigSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const initialConfigSetup = async () => {
const validatorChoices =
answer.network === Network.MAINNET
? [ValidatorType.JITO, ValidatorType.SOLANA]
: [ValidatorType.AGAVE, ValidatorType.JITO]
: [
ValidatorType.AGAVE,
ValidatorType.JITO,
ValidatorType.FRANKENDANCER,
]
validatorType = await inquirer
.prompt<{ validatorType: ValidatorType }>({
name: 'validatorType',
Expand Down
9 changes: 5 additions & 4 deletions packages/solv/src/cli/setup/setupCpuGovernor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ const setupCpuGovernor = () => {
const cmd = `echo "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor`
execSync(cmd)
} catch (error) {
console.error(
'Error setting up CPU Governor\nPlease Check your cpu governor yourself',
error,
)
// ppl complain if they see error messages
// console.error(
// 'Error setting up CPU Governor\nPlease Check your cpu governor yourself',
// error,
// )
}
}

Expand Down
19 changes: 13 additions & 6 deletions packages/solv/src/cli/setup/setupV2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import readConfig from '@/config/readConfig'
import initialConfigSetup from './question/initialConfigSetup'
import { Network, NodeType } from '@/config/enums'
import { Network, NodeType, ValidatorType } from '@/config/enums'
import setupRpcNode from './rpc'
import setupValidatorNode from './validator'
import chalk from 'chalk'
Expand All @@ -18,6 +18,7 @@ import { restartLogrotate } from '@/lib/restartLogrotate'
import { enableSolv } from '@/lib/enableSolv'
import { createSymLink } from './createSymLink'
import rpcLog from '@/utils/rpcLog'
import setupFiredancer from './firedancer/setupFiredancer'

export const setupV2 = async (skipInitConfig = false, skipMount = false) => {
try {
Expand Down Expand Up @@ -56,6 +57,10 @@ export const setupV2 = async (skipInitConfig = false, skipMount = false) => {
break
case NodeType.VALIDATOR:
await setupValidatorNode(latestConfig)
// Setup Firedancer if needed
if (latestConfig.VALIDATOR_TYPE === ValidatorType.FRANKENDANCER) {
await setupFiredancer()
}
break
default:
throw new Error('Unknown Node Type')
Expand All @@ -64,12 +69,14 @@ export const setupV2 = async (skipInitConfig = false, skipMount = false) => {
setupPermissions()
// Reload Daemon
daemonReload()
// Enable Solv Service
enableSolv()
// Download Snapshot
getSnapshot(isTest)
if (latestConfig.VALIDATOR_TYPE !== ValidatorType.FRANKENDANCER) {
// Enable Solv Service
enableSolv()
// Download Snapshot
getSnapshot(isTest)
}
// Start Solana
startSolana()
startSolana(latestConfig)
console.log(chalk.white(`🟢 Setup Completed`))
rpcLog()
} catch (error: any) {
Expand Down
73 changes: 47 additions & 26 deletions packages/solv/src/cli/setup/template/firedancer/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "solv1"
name = "solv"
user = "solv"
scratch_directory = "/home/{user}/.firedancer/{name}"
scratch_directory = "/home/{user}"
dynamic_port_range = "8900-9000"

[log]
Expand All @@ -11,7 +11,7 @@ dynamic_port_range = "8900-9000"
level_flush = "WARNING"

[reporting]
solana_metrics_config = "https://metrics.solana.com:8086,db=tds,u=testnet_write,p=c4fa841aa918bf8274e3e2a44d77568d9861b3ea"
solana_metrics_config = "host=https://metrics.solana.com:8086,db=mainnet-beta,u=mainnet-beta_write,p=password"

[ledger]
path = "/mnt/ledger"
Expand All @@ -22,44 +22,65 @@ dynamic_port_range = "8900-9000"
snapshot_archive_format = "zstd"
require_tower = false

[gossip]
entrypoints = [
'entrypoint.mainnet-beta.solana.com:8001',
'entrypoint2.mainnet-beta.solana.com:8001',
'entrypoint3.mainnet-beta.solana.com:8001',
'entrypoint4.mainnet-beta.solana.com:8001',
'entrypoint5.mainnet-beta.solana.com:8001',
]
port_check = true
port = 8001
host = ""

[rpc]
port = 0
full_api = false
private = false
transaction_history = false
extended_tx_metadata_storage = false
full_api = true
private = true
transaction_history = true
extended_tx_metadata_storage = true
only_known = true
pubsub_enable_block_subscription = false
pubsub_enable_vote_subscription = false
bigtable_ledger_storage = false
pubsub_enable_block_subscription = true
pubsub_enable_vote_subscription = true
bigtable_ledger_storage = true

[snapshots]
incremental_snapshots = true
full_snapshot_interval_slots = 25000
incremental_snapshot_interval_slots = 100
use-snapshot-archives-at-startup = "when-newest"
path = ""

[gossip]
entrypoints = [
"entrypoint.testnet.solana.com:8001",
"entrypoint2.testnet.solana.com:8001",
"entrypoint3.testnet.solana.com:8001",
]

[consensus]
identity_path = "/home/solv/identity.json"
vote_account_path = "/home/solv/testnet-vote-account-keypair.json"
identity_path = "/home/solv/mainnet-validator-keypair.json"
vote_account_path = "/home/solv/mainnet-vote-account-keypair.json"
authorized_voter_paths = [
"/home/solv/testnet-validator-keypair.json"
"/home/solv/mainnet-validator-keypair.json"
]
snapshot_fetch = true
genesis_fetch = true
poh_speed_test = true
expected_genesis_hash = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY"
wait_for_supermajority_at_slot = 289624982
expected_bank_hash = "4rWEDhTyQVgTw6sPoCthXmUNmjeiwsdKQ5ZNvpEi3uvk"
expected_shred_version = 35459
wait_for_vote_to_start_leader = true
expected_genesis_hash = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
expected_shred_version = 50093
os_network_limits_test = true
hard_fork_at_slots = []
known_validators = ["5D1fNXzvv5NjV1ysLjirC4WY92RNsVH18vjmcszZd8on"]
known_validators = [
"Certusm1sa411sMpV9FPqU5dXAYhmmhygvxJ23S6hJ24",
"7Np41oeYqPefeNQEHSv1UDhYrehxin3NStELsSKCT4K2",
"GdnSyH3YtwcxFvQrVVJMm1JhTS4QVX7MFsX56uJLUfiZ",
"CakcnaRDHka2gXyfbEd2d3xsvkJkqsLw2akB3zsN1D2S"
]

[layout]
affinity = "1-16"
agave_affinity = ""
solana_labs_affinity = "17-31"
net_tile_count = 1
quic_tile_count = 1
verify_tile_count = 4
bank_tile_count = 2
shred_tile_count = 2

[hugetlbfs]
mount_path = "/mnt/.fd"
Loading

0 comments on commit 38273fe

Please sign in to comment.