Knowledge / Computer Science and Engineering / Solana: architecture, Rust programs and applications

Solana: architecture, Rust programs and applications

Computer Science and Engineering (B.E./B.Tech) · Blockchain · free study notes for exams, placements and interviews

In short

Solana is a single-shard, high-throughput public blockchain whose design goal is to scale with hardware (bandwidth, cores, SSDs) rather than by sharding or rollups, targeting 400 ms slots and tens of thousands of transactions per second with sub-rupee fees. Its distinguishing ideas are Proof of History (a verifiable clock), stake-weighted Tower BFT voting, and a strict separation of *code* (stateless programs) from *state* (accounts), which lets the Sealevel runtime execute non-conflicting transactions in parallel. On-chain programs are written mainly in Rust (compiled to SBF bytecode), usually through the Anchor framework, and power DEXs, stablecoin payments, NFTs, depins and consumer apps. In Indian university syllabi it appears in Blockchain Technology electives as the leading non-EVM / "high-performance chain" case study, contrasted with Ethereum and Solidity; in placements it is asked by Web3 and exchange employers (CoinDCX/Okto, CoinSwitch, Mudrex, ZebPay, Coinbase India, Polygon, and the many startups in the Superteam India network). Indian students meet it most often through Solana Foundation and Superteam hackathons, where Rust/Anchor is the expected skill.

Explained

1. Why a new architecture: the eight core components

2. The account model (the thing most students get wrong)

3. Rust programs: toolchain, limits, Anchor

use solana_program::{account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey, msg};

entrypoint!(process_instruction);
pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {
    msg!("counter program invoked");
    Ok(())
}
use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod counter {
    use super::*;
    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
        ctx.accounts.counter.authority = ctx.accounts.user.key();
        ctx.accounts.counter.count = 0;
        Ok(())
    }
    pub fn increment(ctx: Context<Increment>) -> Result<()> {
        let c = &mut ctx.accounts.counter;
        c.count = c.count.checked_add(1).ok_or(ErrorCode::Overflow)?;
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(init, payer = user, space = 8 + 32 + 8,
              seeds = [b"counter", user.key().as_ref()], bump)]
    pub counter: Account<'info, Counter>,
    #[account(mut)] pub user: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
pub struct Increment<'info> {
    #[account(mut, seeds = [b"counter", authority.key().as_ref()], bump,
              has_one = authority)]
    pub counter: Account<'info, Counter>,
    pub authority: Signer<'info>,
}

#[account]
pub struct Counter { pub authority: Pubkey, pub count: u64 }

#[error_code] pub enum ErrorCode { #[msg("overflow")] Overflow }

4. Fees, staking and economics

5. The SPL layer and application patterns

6. Advantages and limitations (exam-style)

Key points

Formulas and examples

Lamports: 1 SOL = 10⁹ lamports; amount_in_SOL = lamports / 10⁹
Rent-exempt minimum (lamports) = (data_len + 128) × 3,480 × 2 = (data_len + 128) × 6,960
data_len = account data size in bytes; 128 = per-account storage overhead; 3,480 = lamports per byte-year; 2 = exemption threshold in years. Parameters are cluster constants and can be changed by governance.
Base fee (lamports) = 5,000 × (number of signatures)
Priority fee (lamports) = CU_limit × price(micro-lamports per CU) / 10⁶
Total fee = base fee + priority fee
Epoch duration = 432,000 slots × slot time; slot time = ticks_per_slot × hashes_per_tick / hash_rate (target 0.4 s)
Inflation in year n = 8% × (0.85)ⁿ, floored at 1.5%
Gross staking yield ≈ inflation rate × (total supply / staked supply); net yield ≈ gross × (1 − validator commission)
Token raw amount = display amount × 10decimals
Theoretical TPS = block CU limit / CU per transaction ÷ slot time (seconds)

Example 1 - rent for an Anchor account. A Counter account stores an 8-byte discriminator, a 32-byte Pubkey and a u64.

Example 2 - standard SPL accounts.

Example 3 - fee with priority. A swap transaction has 2 signatures, requests a 300,000 CU limit and sets a CU price of 20,000 micro-lamports.

Example 4 - epoch timing and throughput.

Example 5 - staking yield. Inflation 4.5%, 65% of supply staked, validator commission 7%.

FeatureSolanaEthereum (EVM)
ConsensusPoH + Tower BFT (PoS), Alpenglow approvedGasper: Casper FFG + LMD-GHOST
Block/slot time~0.4 s~12 s
ExecutionParallel (Sealevel), accounts declaredSequential, single-threaded
State modelSeparate accounts; stateless programsContract-internal storage
Language / toolchainRust (also C, Zig) → SBF; Anchor, IDLSolidity/Vyper → EVM bytecode; Hardhat/Foundry, ABI
MeteringCompute units, 1.4 M per txGas, block gas limit
Fees5,000 lamports/signature + local priority feeEIP-1559 base fee + tip, global market
Mapping patternPDA derived from seedsmapping in storage
UpgradesNative program upgrade authorityProxy patterns (UUPS, transparent)
Scaling routeScale the single chain (hardware)L2 rollups + danksharding
Re-entrancyNarrow: CPI depth 4, restricted self-recursionClassic risk; needs guards

Where it is used

Interview questions

Common mistakes

Related topics

Smart contracts and Solidity · Blockchain security and smart-contract audits · Consensus algorithms: PoW, PoS and BFT · Enterprise blockchains: Hyperledger Fabric and Corda · Rust systems programming and memory safety · Blockchain in finance and supply chain

Open in the Knowledge reader →Find jobs →