Agave Documentation

repository·master·Indexed 23 days ago

https://github.com/anza-xyz/agave

The core implementation of the Solana validator software. Agave provides tools to build, run, and benchmark high-performance blockchain validators, including the Geyser Plugin Interface for real-time event reactions, validator metrics integration via Chronograf and Grafana, and utilities for bootstrapping validator accounts into genesis.

Tokens
57.6K
Snippets
53
Records
414
Agent score
83%

What's inside Agave

  1. Overview of agave-watchtower

    master

    The agave-watchtower program monitors cluster health by periodically polling an RPC API. It performs several sanity checks to ensure the cluster is functioning correctly:

    • Transaction Advancement: Confirms the transaction count is increasing.
    • Blockhash Availability: Ensures new blockhashes are being produced.
    • Validator Delinquency: Checks that no validators are in a delinquent state.
    • Vote Account Balance: Alerts when a monitored validator's vote account balance falls below the bank-side VAT balance threshold (computed from RPC-visible state).

    Note: The vote account balance check only verifies the balance via public RPC and does not verify full VAT eligibility (e.g., BLS pubkey presence, stake, or top validator set inclusion).

  2. Overview of Solana Remote Wallet

    master
    The solana-remote-wallet library is designed for interacting with "remote" wallets. These are wallet implementations where the private key bytes are not directly accessible to the local machine, such as hardware security modules or Ledger devices.
  3. Use the Solana Virtual Machine (SVM) as a standalone library

    master

    The Solana Virtual Machine (SVM) can be used as a standalone library outside of the standard Solana Validator. This allows developers to build applications such as:

    • SVM Rollups: Execute blocks with reduced hardware requirements.
    • SVM Fraud Proofs: Generate succinct proofs of invalid state transitions.
    • Validator Sidecars: Implement JSON-RPC services that require transaction replaying and account data access (e.g., simulateTransaction).
    • Custom Subnets: Run SVM within alternative consensus frameworks like Avalanche.
    • Modified SVM (SVM+): Extend the current functionality with custom instructions.
  4. Overview of the Solana Geyser Plugin Interface

    master

    The Geyser Plugin Interface allows developers to extend the Solana Validator runtime by implementing a plugin that reacts to real-time validator events. Plugins can take actions during account updates, block processing, or transaction processing. A common use case is streaming account state to an external database for indexing or monitoring.

    To create a plugin, you must:

    1. Implement the GeyserPlugin trait defined in geyser_plugin_interface.rs.
    2. Compile the plugin as a cdylib dynamic library.
    3. Expose a C function named _create_plugin() that returns an instance of your GeyserPlugin implementation.
  5. Understand the Solana Virtual Machine (SVM) Functional Model

    master

    The SVM's control flow manages the lifecycle of transaction execution through a series of high-level steps: loading program accounts, verifying them, creating an invocation context, and invoking the Runtime BPF (RBPF) on programs.

    Key components include:

    • Account Database: Provides access to account data.
    • Sysvar Cache: Accessed via traits for system variables.
    • MessageProcessor: Contained in the solana-program-runtime crate, responsible for the actual execution of the transaction message.
    • LogCollector: Defined in solana-program-runtime, used to capture execution logs.

    In a validator context, the primary entry point is load_and_execute_sanitized_transactions, which is called by simulate_transaction (for single transactions) or load_execute_and_commit_transactions (for batches).

  6. Configure BigTable for a production environment

    master

    In production, the project expects a BigTable instance named solana-ledger that has been previously initialized using the ./init-bigtable.sh script.

    To connect, you must provide service account credentials via the GOOGLE_APPLICATION_CREDENTIALS environment variable. The application will request either https://www.googleapis.com/auth/bigtable.data or https://www.googleapis.com/auth/bigtable.data.readonly OAuth scopes depending on the required operation mode.

  7. Implement a Geyser Plugin

    master

    To build a plugin for the Solana Validator, follow these requirements:

    1. Implement the Trait

    Your plugin must implement the GeyserPlugin trait. This trait defines the hooks for interacting with the validator's lifecycle (e.g., account updates, block processing).

    2. Export the Entry Point

    The validator expects a dynamic library (cdylib) with a specific C-compatible entry point. You must export a function named _create_plugin to allow the validator to instantiate your plugin.

    3. Example Implementation

    For a reference implementation that saves account data to a PostgreSQL database, see the solana-accountsdb-plugin-postgres repository.

  8. Grant XDP capabilities on Linux

    master

    On Linux, XDP (eXpress Data Path) transmit is enabled by default but requires specific kernel capabilities. You must grant these to the validator binary after building.

    Standard XDP

    For standard XDP transmit:

    $ sudo setcap 'cap_net_admin,cap_net_raw+eip' <path-to-agave-validator-binary>

    XDP Zero-Copy

    If you are using the --xdp-zero-copy flag, you must grant additional capabilities:

    $ sudo setcap 'cap_net_admin,cap_net_raw,cap_bpf,cap_perfmon+eip' <path-to-agave-validator-binary>
  9. Distribute SPL tokens using `solana-tokens distribute-spl-tokens`

    master

    Distribute SPL tokens to multiple recipients. The tool will automatically create the recipient's Associated Token Account (ATA) if it does not exist, funded by the --fee-payer.

    Important Requirements:

    • CSV Format: The amount in the CSV must be in raw format (no decimals/integers representing the smallest unit).
    • Signing: You must provide an --owner <KEYPAIR> to sign the transactions.
    • Mint: You must know the SPL Token mint address.

    Workflow:

    1. Check status: Use spl-token-balances to see current balances vs expected balances before starting.
    2. Run distribution: Execute distribute-spl-tokens.

    Commands:

    # 1. Check status
    solana-tokens spl-token-balances --mint <ADDRESS> --input-csv <RECIPIENTS_CSV>
    
    # 2. Run distribution
    solana-tokens distribute-spl-tokens --from <ADDRESS> --owner <KEYPAIR> \
        --input-csv <RECIPIENTS_CSV> --fee-payer <KEYPAIR>
  10. Install Rust toolchain and dependencies

    master

    Before building Agave, you must install the Rust toolchain and necessary system dependencies. The project uses a rust-toolchain.toml file to pin a specific version, which cargo will automatically install if missing.

    1. Install Rust

    Install rustc, cargo, and rustfmt using rustup:

    $ curl https://sh.rustup.rs -sSf | sh
    $ source $HOME/.cargo/env
    $ rustup component add rustfmt

    2. Install System Dependencies

    Depending on your Linux distribution, install the required development libraries:

    Ubuntu:

    $ sudo apt-get update
    $ sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler libclang-dev

    Fedora:

    $ sudo dnf install openssl-devel systemd-devel pkg-config zlib-devel llvm clang cmake make protobuf-devel protobuf-compiler perl-core libclang-dev
  11. Filter notifications by validator identity

    master
    If you only want to receive failure notifications for a specific subset of validators, use the --validator-identity command-line argument. This restricts failure alerts to issues that specifically affect the identities provided.
  12. Distribute stake accounts using `solana-tokens distribute-stake`

    master

    This command distributes tokens by splitting existing stake accounts. New stake accounts are created, inheriting any lockup or custodian settings from the original account.

    Behavior: The tool subtracts 1 SOL from each allocation and stores it in the recipient address (to cover future staking operation fees like delegation). The remainder of the allocation is placed into a new stake account.

    Command:

    solana-tokens distribute-stake --stake-account-address <ACCOUNT_ADDRESS> \
        --input-csv <ALLOCATIONS_CSV> \
        --stake-authority <KEYPAIR> --withdraw-authority <KEYPAIR> --fee-payer <KEYPAIR>