feat: solana
Introduces Solana blockchain integration into THORNode, enabling THORChain to process transactions and interact with the Solana network. The implementation leverages the previously merged EDDSA (Ed25519) signing support, ensuring secure transaction signing and validation for Solana.
Key Features
- Solana Scanner (SOLScanner):
- Implements scanning for Solana, tracking transactions for THORChain vaults using Solana's slot-based system. This does NOT use the block scanner, as it has severe performance issues and cannot keep up. It instead uses the approach of monitoring vault accounts from the last scanned transaction, which is very lightweight.
- Monitors network fees by analyzing recent blocks and calculating median fee rates (lamports per signature).
- Supports vault address scanning with configurable start heights and maintains scan positions for resilience.
- Integrates with the thorchain bridge to report transactions and solvency
- Solana Client (SOLClient):
- Provides functionality for transaction creation, signing, and broadcasting on Solana.
- Utilizes the new EDDSA signing mechanism for secure transaction signing, supporting both local and TSS-based signing via the ThorchainKeyManager.
- Handles SOL transfers with memo instructions, adhering to Solana's transaction specification.
- Manages account balances and solvency reporting, with configurable solvency checks to detect insolvent vaults.
- Network Fee Management:
- Dynamically calculates and updates network fees every 100 slots, using a median fee rate from recent transactions.
- Ensures fee accuracy by caching and rounding fees based on configured resolution.
- Error Handling and Metrics:
- Robust error handling with detailed logging for debugging and monitoring.
- Integrates with Prometheus metrics to track block scanning and errors.
Implementation Details
- Package Structure:
- The solana package includes
SOLScanner(replacesBlockScannerfor Solana impl) for transaction scanning and SOLClient for transaction assembly, sign, and broadcast. - Reuses existing THORChain components like thorclient, pubkeymanager, and signercache
- The solana package includes
- Transaction Processing:
- Supports SOL transfers with memo instructions, validated against THORChain's memo parsing.
- Converts THORChain amounts (1e8) to Solana lamports (1e9) for accurate transaction construction.
- Solvency and Health Checks:
- Implements solvency reporting with configurable block intervals, ensuring timely detection of vault issues.
- Monitors scanner health and pauses scanning if the chain is halted via Mimir checks.
- Longer Memos
- Solana transaction signatures are 64 bytes, which are ~88 chars when bech58 encoded for the TX ID. As a result, outbound txs with memo
OUT:$TXIDare ~92 bytes. This goes over the 80 byte OP_RETURN limit for doge, ltc, btc. This takes advantage of the longer memo format enabled by !4073 (merged) for bifrost transactions.
- Solana transaction signatures are 64 bytes, which are ~88 chars when bech58 encoded for the TX ID. As a result, outbound txs with memo
Integrator Notes
- Only transactions with a single transfer instruction to the vault address are supported.
Edited by Andrew Gouin