Skip to content

1. Solana配置文件

1.1 获取配置文件

bash
$ mkdir -p ~/solana-config && cd ~/solana-config
$ solana-install init v1.18.26
⚠️  solana-install is deprecated and will be discontinued when v1.18 is no longer supported. Please switch to Agave: https://github.com/anza-xyz/agave/wiki/Agave-Transition

   1.18.26 initialized
Adding
export PATH="/root/.local/share/solana/install/active_release/bin:$PATH" to /root/.bash_profile

$ls /root/.local/share/solana/install -l
total 8
lrwxrwxrwx 1 root root   65 Jan  9 08:59 active_release -> /root/.local/share/solana/install/releases/1.18.26/solana-release
drwxr-xr-x 3 root root 4096 Jan  9 08:59 releases

#这个命令回安装solana,安装位置在/root/.local/share/solana/install/releases/下

#解释
v1.18.26 ---> 指定版本号
$ mkdir -p ~/solana-config && cd ~/solana-config
$ solana-install init v1.18.26
⚠️  solana-install is deprecated and will be discontinued when v1.18 is no longer supported. Please switch to Agave: https://github.com/anza-xyz/agave/wiki/Agave-Transition

   1.18.26 initialized
Adding
export PATH="/root/.local/share/solana/install/active_release/bin:$PATH" to /root/.bash_profile

$ls /root/.local/share/solana/install -l
total 8
lrwxrwxrwx 1 root root   65 Jan  9 08:59 active_release -> /root/.local/share/solana/install/releases/1.18.26/solana-release
drwxr-xr-x 3 root root 4096 Jan  9 08:59 releases

#这个命令回安装solana,安装位置在/root/.local/share/solana/install/releases/下

#解释
v1.18.26 ---> 指定版本号

1.2 端口

  • 8899 TCP - JSONRPC over HTTP. Change with --rpc-port RPC_PORT
  • 8900 TCP - JSONRPC over Websockets. Derived. Uses RPC_PORT + 1

2. Solana命令

官当

2.1 查看帮助

bash
$solana --help
solana-cli 1.18.26 (src:d9f20e95; feat:3241752014, client:SolanaLabs)
Blockchain, Rebuilt for Scale

USAGE:
    solana [FLAGS] [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help                           Prints help information
        --no-address-labels              Do not use address labels in the output
        --skip-seed-phrase-validation    Skip validation of seed phrases. Use this if your phrase does not use the BIP39
                                         official English word list
        --use-quic                       Use QUIC when sending transactions.
        --use-udp                        Use UDP when sending transactions.
    -V, --version                        Prints version information
    -v, --verbose                        Show additional information

OPTIONS:
        --commitment <COMMITMENT_LEVEL>    Return information at the selected commitment level [possible values:
                                           processed, confirmed, finalized]
    -C, --config <FILEPATH>                Configuration file to use [default: /root/.config/solana/cli/config.yml]
    -u, --url <URL_OR_MONIKER>             URL for Solana's JSON RPC or moniker (or their first letter): [mainnet-beta,
                                           testnet, devnet, localhost]
    -k, --keypair <KEYPAIR>                Filepath or URL to a keypair
        --output <FORMAT>                  Return information in specified output format [possible values: json, json-
                                           compact]
        --ws <URL>                         WebSocket URL for the solana cluster

SUBCOMMANDS:
    account                              Show the contents of an account
    address                              Get your public key
    address-lookup-table                 Address lookup table management
    airdrop                              Request SOL from a faucet
    authorize-nonce-account              Assign account authority to a new entity
    balance                              Get your balance
    block                                Get a confirmed block
    block-height                         Get current block height
    block-production                     Show information about block production
    block-time                           Get estimated production time of a block
    catchup                              Wait for a validator to catch up to the cluster
    close-vote-account                   Close a vote account and withdraw all funds remaining
    cluster-date                         Get current cluster date, computed from genesis creation time and network
                                         time
    cluster-version                      Get the version of the cluster entrypoint
    completion                           Generate completion scripts for various shells
    config                               Solana command-line tool configuration settings
    confirm                              Confirm transaction by signature
    create-address-with-seed             Generate a derived account address with a seed. For program derived
                                         addresses (PDAs), use the find-program-derived-address command instead
    create-nonce-account                 Create a nonce account
    create-stake-account                 Create a stake account
    create-stake-account-checked         Create a stake account, checking the withdraw authority as a signer
    create-vote-account                  Create a vote account
    deactivate-stake                     Deactivate the delegated stake from the stake account
    decode-transaction                   Decode a serialized transaction
    delegate-stake                       Delegate stake to a vote account
    epoch                                Get current epoch
    epoch-info                           Get information about the current epoch
    feature                              Runtime feature management
    fees                                 Display current cluster fees (Deprecated in v1.8.0)
    find-program-derived-address         Generate a program derived account address with a seed
    first-available-block                Get the first available block in the storage
    genesis-hash                         Get the genesis hash
    gossip                               Show the current gossip network nodes
    help                                 Prints this message or the help of the given subcommand(s)
    inflation                            Show inflation information
    largest-accounts                     Get addresses of largest cluster accounts
    leader-schedule                      Display leader schedule
    live-slots                           Show information about the current slot progression
    logs                                 Stream transaction logs
    merge-stake                          Merges one stake account into another
    new-nonce                            Generate a new nonce, rendering the existing nonce useless
    nonce                                Get the current nonce value
    nonce-account                        Show the contents of a nonce account
    ping                                 Submit transactions sequentially
    program                              Program management
    program-v4                           Program V4 management
    redelegate-stake                     Redelegate active stake to another vote account
    rent                                 Calculate rent-exempt-minimum value for a given account data field length.
    resolve-signer                       Checks that a signer is valid, and returns its specific path; useful for
                                         signers that may be specified generally, eg. usb://ledger
    sign-offchain-message                Sign off-chain message
    slot                                 Get current slot
    split-stake                          Duplicate a stake account, splitting the tokens between the two
    stake-account                        Show the contents of a stake account
    stake-authorize                      Authorize a new signing keypair for the given stake account
    stake-authorize-checked              Authorize a new signing keypair for the given stake account, checking the
                                         authority as a signer
    stake-history                        Show the stake history
    stake-minimum-delegation             Get the stake minimum delegation amount
    stake-set-lockup                     Set Lockup for the stake account
    stake-set-lockup-checked             Set Lockup for the stake account, checking the new authority as a signer
    stakes                               Show stake account information
    supply                               Get information about the cluster supply of SOL
    transaction-count                    Get current transaction count
    transaction-history                  Show historical transactions affecting the given address from newest to
                                         oldest
    transfer                             Transfer funds between system accounts
    upgrade-nonce-account                One-time idempotent upgrade of legacy nonce versions in order to bump them
                                         out of chain blockhash domain.
    validator-info                       Publish/get Validator info on Solana
    validators                           Show summary information about the current validators
    verify-offchain-signature            Verify off-chain message signature
    vote-account                         Show the contents of a vote account
    vote-authorize-voter                 Authorize a new vote signing keypair for the given vote account
    vote-authorize-voter-checked         Authorize a new vote signing keypair for the given vote account, checking
                                         the new authority as a signer
    vote-authorize-withdrawer            Authorize a new withdraw signing keypair for the given vote account
    vote-authorize-withdrawer-checked    Authorize a new withdraw signing keypair for the given vote account,
                                         checking the new authority as a signer
    vote-update-commission               Update the vote account's commission
    vote-update-validator                Update the vote account's validator identity
    wait-for-max-stake                   Wait for the max stake of any one node to drop below a percentage of total.
    withdraw-from-nonce-account          Withdraw SOL from the nonce account
    withdraw-from-vote-account           Withdraw lamports from a vote account into a specified account
    withdraw-stake                       Withdraw the unstaked SOL from the stake account
$solana --help
solana-cli 1.18.26 (src:d9f20e95; feat:3241752014, client:SolanaLabs)
Blockchain, Rebuilt for Scale

USAGE:
    solana [FLAGS] [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help                           Prints help information
        --no-address-labels              Do not use address labels in the output
        --skip-seed-phrase-validation    Skip validation of seed phrases. Use this if your phrase does not use the BIP39
                                         official English word list
        --use-quic                       Use QUIC when sending transactions.
        --use-udp                        Use UDP when sending transactions.
    -V, --version                        Prints version information
    -v, --verbose                        Show additional information

OPTIONS:
        --commitment <COMMITMENT_LEVEL>    Return information at the selected commitment level [possible values:
                                           processed, confirmed, finalized]
    -C, --config <FILEPATH>                Configuration file to use [default: /root/.config/solana/cli/config.yml]
    -u, --url <URL_OR_MONIKER>             URL for Solana's JSON RPC or moniker (or their first letter): [mainnet-beta,
                                           testnet, devnet, localhost]
    -k, --keypair <KEYPAIR>                Filepath or URL to a keypair
        --output <FORMAT>                  Return information in specified output format [possible values: json, json-
                                           compact]
        --ws <URL>                         WebSocket URL for the solana cluster

SUBCOMMANDS:
    account                              Show the contents of an account
    address                              Get your public key
    address-lookup-table                 Address lookup table management
    airdrop                              Request SOL from a faucet
    authorize-nonce-account              Assign account authority to a new entity
    balance                              Get your balance
    block                                Get a confirmed block
    block-height                         Get current block height
    block-production                     Show information about block production
    block-time                           Get estimated production time of a block
    catchup                              Wait for a validator to catch up to the cluster
    close-vote-account                   Close a vote account and withdraw all funds remaining
    cluster-date                         Get current cluster date, computed from genesis creation time and network
                                         time
    cluster-version                      Get the version of the cluster entrypoint
    completion                           Generate completion scripts for various shells
    config                               Solana command-line tool configuration settings
    confirm                              Confirm transaction by signature
    create-address-with-seed             Generate a derived account address with a seed. For program derived
                                         addresses (PDAs), use the find-program-derived-address command instead
    create-nonce-account                 Create a nonce account
    create-stake-account                 Create a stake account
    create-stake-account-checked         Create a stake account, checking the withdraw authority as a signer
    create-vote-account                  Create a vote account
    deactivate-stake                     Deactivate the delegated stake from the stake account
    decode-transaction                   Decode a serialized transaction
    delegate-stake                       Delegate stake to a vote account
    epoch                                Get current epoch
    epoch-info                           Get information about the current epoch
    feature                              Runtime feature management
    fees                                 Display current cluster fees (Deprecated in v1.8.0)
    find-program-derived-address         Generate a program derived account address with a seed
    first-available-block                Get the first available block in the storage
    genesis-hash                         Get the genesis hash
    gossip                               Show the current gossip network nodes
    help                                 Prints this message or the help of the given subcommand(s)
    inflation                            Show inflation information
    largest-accounts                     Get addresses of largest cluster accounts
    leader-schedule                      Display leader schedule
    live-slots                           Show information about the current slot progression
    logs                                 Stream transaction logs
    merge-stake                          Merges one stake account into another
    new-nonce                            Generate a new nonce, rendering the existing nonce useless
    nonce                                Get the current nonce value
    nonce-account                        Show the contents of a nonce account
    ping                                 Submit transactions sequentially
    program                              Program management
    program-v4                           Program V4 management
    redelegate-stake                     Redelegate active stake to another vote account
    rent                                 Calculate rent-exempt-minimum value for a given account data field length.
    resolve-signer                       Checks that a signer is valid, and returns its specific path; useful for
                                         signers that may be specified generally, eg. usb://ledger
    sign-offchain-message                Sign off-chain message
    slot                                 Get current slot
    split-stake                          Duplicate a stake account, splitting the tokens between the two
    stake-account                        Show the contents of a stake account
    stake-authorize                      Authorize a new signing keypair for the given stake account
    stake-authorize-checked              Authorize a new signing keypair for the given stake account, checking the
                                         authority as a signer
    stake-history                        Show the stake history
    stake-minimum-delegation             Get the stake minimum delegation amount
    stake-set-lockup                     Set Lockup for the stake account
    stake-set-lockup-checked             Set Lockup for the stake account, checking the new authority as a signer
    stakes                               Show stake account information
    supply                               Get information about the cluster supply of SOL
    transaction-count                    Get current transaction count
    transaction-history                  Show historical transactions affecting the given address from newest to
                                         oldest
    transfer                             Transfer funds between system accounts
    upgrade-nonce-account                One-time idempotent upgrade of legacy nonce versions in order to bump them
                                         out of chain blockhash domain.
    validator-info                       Publish/get Validator info on Solana
    validators                           Show summary information about the current validators
    verify-offchain-signature            Verify off-chain message signature
    vote-account                         Show the contents of a vote account
    vote-authorize-voter                 Authorize a new vote signing keypair for the given vote account
    vote-authorize-voter-checked         Authorize a new vote signing keypair for the given vote account, checking
                                         the new authority as a signer
    vote-authorize-withdrawer            Authorize a new withdraw signing keypair for the given vote account
    vote-authorize-withdrawer-checked    Authorize a new withdraw signing keypair for the given vote account,
                                         checking the new authority as a signer
    vote-update-commission               Update the vote account's commission
    vote-update-validator                Update the vote account's validator identity
    wait-for-max-stake                   Wait for the max stake of any one node to drop below a percentage of total.
    withdraw-from-nonce-account          Withdraw SOL from the nonce account
    withdraw-from-vote-account           Withdraw lamports from a vote account into a specified account
    withdraw-stake                       Withdraw the unstaked SOL from the stake account
  • cmd
bash
$solana <cmd> --help
$solana <cmd> --help

2.2 cmd

1.gossip

查看公网上面有多少个solana节点,目前有5352节点

bash
$ solana gossip
IP Address      | Identity                                     | Gossip | TPU   | RPC Address           | Version | Feature Set
----------------+----------------------------------------------+--------+-------+-----------------------+---------+----------------
177.54.154.65   | Dvit3T4kkVbS6cCEybaMVjuDhf7ESsMgJki82FrNZD96 | 8001   | 8004  | none                  | 2.0.21  | 607245837
95.67.10.106    | ECNnK4VjcKTsABiw8FAp3JCE6tCmYyrEJthYVyMazmxi | 8000   | 8003  | none                  | 2.0.19  | 607245837
185.84.247.202  | CBHHTRa6YtuUbNA1v6b18cAXExtbBEDRFshJiEJYjWzC | 8001   | 11222 | none                  | 2.0.21  | 607245837
93.115.25.189   | G3x5eb53kUpp92FWiyqRWJ3Q6e9tH3dEjGDgDWYf6was | 8001   | 8004  | none                  | 2.0.19  | 607245837
205.209.119.110 | 7MuF8X6oRnNDw2q2D66MYDfJ4mEPk4ifiAv9s21duwax | 8000   | 8008  | none                  | 2.0.19  | 607245837
64.176.217.167  | 8WKbFye8HjNa3rBvx5jEd9gYtfLLXwXg3wzVhavvMSva | 8000   | 11222 | none                  | 2.0.19  | 607245837
145.40.126.143  | scb1Z7du8NVSaHFXsafSjRdXr6xBjWR3iugikL739Y1  | 8001   | 8004  | 145.40.126.143:8899   | 2.1.8   | 1793238286
64.130.50.51    | 4JahMMrVRS1gimWoXpD5H6KwKc2MrsoTDFMaStMttL1E | 8001   | 8004  | none                  | 2.0.21  | 607245837
。。。。
$ solana gossip
IP Address      | Identity                                     | Gossip | TPU   | RPC Address           | Version | Feature Set
----------------+----------------------------------------------+--------+-------+-----------------------+---------+----------------
177.54.154.65   | Dvit3T4kkVbS6cCEybaMVjuDhf7ESsMgJki82FrNZD96 | 8001   | 8004  | none                  | 2.0.21  | 607245837
95.67.10.106    | ECNnK4VjcKTsABiw8FAp3JCE6tCmYyrEJthYVyMazmxi | 8000   | 8003  | none                  | 2.0.19  | 607245837
185.84.247.202  | CBHHTRa6YtuUbNA1v6b18cAXExtbBEDRFshJiEJYjWzC | 8001   | 11222 | none                  | 2.0.21  | 607245837
93.115.25.189   | G3x5eb53kUpp92FWiyqRWJ3Q6e9tH3dEjGDgDWYf6was | 8001   | 8004  | none                  | 2.0.19  | 607245837
205.209.119.110 | 7MuF8X6oRnNDw2q2D66MYDfJ4mEPk4ifiAv9s21duwax | 8000   | 8008  | none                  | 2.0.19  | 607245837
64.176.217.167  | 8WKbFye8HjNa3rBvx5jEd9gYtfLLXwXg3wzVhavvMSva | 8000   | 11222 | none                  | 2.0.19  | 607245837
145.40.126.143  | scb1Z7du8NVSaHFXsafSjRdXr6xBjWR3iugikL739Y1  | 8001   | 8004  | 145.40.126.143:8899   | 2.1.8   | 1793238286
64.130.50.51    | 4JahMMrVRS1gimWoXpD5H6KwKc2MrsoTDFMaStMttL1E | 8001   | 8004  | none                  | 2.0.21  | 607245837
。。。。

2.退出服务

bash
$solana-validator exit --help
solana-validator-exit
Send an exit request to the validator

USAGE:
    solana-validator --ledger <DIR> exit [FLAGS] [OPTIONS]

FLAGS:
    -f, --force                      Request the validator exit immediately instead of waiting for a restart window
    -h, --help                       Prints help information
    -m, --monitor                    Monitor the validator after sending the exit request
        --skip-health-check          Skip health check
        --skip-new-snapshot-check    Skip check for a new snapshot

OPTIONS:
        --max-delinquent-stake <PERCENT>    The maximum delinquent stake % permitted for an exit [default: 5]
        --min-idle-time <MINUTES>           Minimum time that the validator should not be leader before restarting
                                            [default: 10]
$solana-validator exit --help
solana-validator-exit
Send an exit request to the validator

USAGE:
    solana-validator --ledger <DIR> exit [FLAGS] [OPTIONS]

FLAGS:
    -f, --force                      Request the validator exit immediately instead of waiting for a restart window
    -h, --help                       Prints help information
    -m, --monitor                    Monitor the validator after sending the exit request
        --skip-health-check          Skip health check
        --skip-new-snapshot-check    Skip check for a new snapshot

OPTIONS:
        --max-delinquent-stake <PERCENT>    The maximum delinquent stake % permitted for an exit [default: 5]
        --min-idle-time <MINUTES>           Minimum time that the validator should not be leader before restarting
                                            [default: 10]

如果是加入到了systemd进程,会自动重启

2.3 集群

bash
# Similar to solana-gossip, you should see your validator in the list of cluster nodes
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getClusterNodes"}' http://api.devnet.solana.com
# If your validator is properly voting, it should appear in the list of `current` vote accounts. If staked, `stake` should be > 0
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getVoteAccounts"}' http://api.devnet.solana.com
# Returns the current leader schedule
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getLeaderSchedule"}' http://api.devnet.solana.com
# Returns info about the current epoch. slotIndex should progress on subsequent calls.
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getEpochInfo"}' http://api.devnet.solana.com
# Similar to solana-gossip, you should see your validator in the list of cluster nodes
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getClusterNodes"}' http://api.devnet.solana.com
# If your validator is properly voting, it should appear in the list of `current` vote accounts. If staked, `stake` should be > 0
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getVoteAccounts"}' http://api.devnet.solana.com
# Returns the current leader schedule
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getLeaderSchedule"}' http://api.devnet.solana.com
# Returns info about the current epoch. slotIndex should progress on subsequent calls.
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getEpochInfo"}' http://api.devnet.solana.com