Solana Core

by Buildspace & Solana Bootcamp

I'm J.D. Nicholls 👋

- Open Source Contributor 👨‍💻

- Game developer (Hobby) 🎮

- Developer who loves UX 💫

- Chocolate lover 🍫

- Founding Full-Stack Engineer 👷

AT

BAXUS

Why Solana?

Solana has low gas fees, it's really fast...

- Scales natively with Moore's Law

- Great Nakamoto Coefficient of decentralization

Accounts

Smart contracts on Solana, referred to as "programs", are stateless - meaning they don't store anything except code. Everything happens in accounts, so they're central to Solana, they're used for storage, contracts, and for native blockchain programs.

A close-up illustration of a Solana account, with a smart contract displayed on a computer screen in the background, sleek, modern, high-tech, intricate, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha

The program itself doesn't hold a user's data. The program just talks to "accounts" that hold the user's data.

⬇️

Types of accounts

Data

These accounts store data:

  • System owned accounts.
  • PDA (Program derived address) accounts.

Program

These accounts store executable programs (AKA smart contracts).

Native

These accounts are for core blockchain functions like Stake, Vote, etc.

⬇️

Account Fields

FIELD DESCRIPTION
lamports The # of lamports owned by this account
owner The program owner of this account
executable Whether this account can process instructions (is executable)
data The raw data byte array stored by this account
rent_epoch The next epoch that this account will owe rent

Iamports are the smallest unit of Solana:

1 Iamport = 0.000000001 SOL

Iamports defines how much SOL the account has 💰

⬇️

Account Address

Smart contracts on Solana, referred to as "programs", are stateless - meaning they don't store anything except code. Everything happens in accounts, so they're central to Solana, they're used for storage, contracts, and for native blockchain programs.

Accounts

  • Unique 256-bit address
  • Hold some balance of SOL
  • Can store arbitrary data
  • Data storage is paid with Rent
  • Anyone can credit SOL or read data
  • Only the account’s owner can debit SOL or modify data

{
  key: number,            // The address of the account
  lamports: number,       // Lamports currently held
  data: Uint8Array,       // Data stored in the account
  is_executable: boolean, // Is this data a program?
  owner: PublicKey,       // The program with write access
}

Programs

Smart contracts on Solana are called "programs";

A Solana program is just a piece of code that lives on the blockchain. The blockchain is a place where anyone can run code for a fee. The blockchain is being run by "miners", in the world of Solana we actually call them "validators".

 

Programs are:

- Special kind of account

- Data is eBPF bytecode

- Written in Rust, C/C++, Python

Deep in Programs

  • Programs are stateless, they read & write data to other accounts. This allows programs to be executed in parallel.
  • Must be the owner of an account to modify
  • Programs process instructions
  • Programs can send instructions to other programs

 

 

 

 

Program instructions

{
  program_id: number,           // The program this instruction is for
  keys: Array<{
    key: PublicKey,
    is_mutable: boolean,
    is_signer: boolean,
  }>,
  data: Uint8Array,      // Data stored in the account
}

Transactions

Transactions allows to send an instruction to a Solana program. Transactions send a package of "instructions" to an RPC client, which then forwards it to the network

  • Programs are invoked by instructions.
  • Instructions are sent via transactions.
  • Transactions are atomic.
  • Transactions must be signed.
{
  message: {
    instructions: Array<Instruction>,
    recent_blockhash: number,
    fee_payer: PublicKey,
    ...
  },
  signers: Array<Uint8Array>,
}

NFTs

The Metadata Standard on Solana introduces countless ways to customize NFTs and the user’s experience.

  • Are SPL Tokens
  • Have 0 decimal places
  • Have a total supply of 1
  • Can have highly-customizable metadata
  • A Collection is a NFT as well

Useful commands

# Verify installed versions
solana --version
solana-keygen --version

# Verify current configuration
solana config get

# Change RPC url to connect to different clusters in Solana ecosystem
solana config set --url https://api.devnet.solana.com
solana config set --url https://api.mainnet-beta.solana.com

# devnet: playground for developers and validators to use the same release of mainnet
# testnet: for solana core contributors to test recent releases and features
# tokens from these networks are not real, so you can faucet for free (development)

# Generate a new wallet (key-pair)
solana-keygen new
# saved from $HOME/.config/solana/id.json
# NOTE: save the seed phrase and BIP39 passphrase to recover your new keypair
# Override current key-pair
solana-keygen new --force

$ Get the current pubkey of that wallet
solana-keygen pubkey

# Check the current balance of solana tokens of that wallet
solana balance

# Request new tokens to that wallet (try a lower amount if fails)
solana airdrop 0.5

⬇️

# Transfer tokens to a different wallet with a custom amount
solana transfer "TARGET WALLET ADDRESS" 0.2
# if the target wallet is new, you can use the below command
solana transfer "TARGET WALLET ADDRESS" 0.2 --allow-unfunded-recipients

FAQ

What mechanism does Solana use to synchronize local virtual clocks on all nodes? 

Proof-of-History (PoH)

What's the nature of PoH for production and verification?

PoH is difficult to produce but easy to verify.

When considering TBFT in Solana, what is the approximate time duration for one slot?

Every 400ms, a new potential rollback point occurs in the Solana network due to the slot duration

In the context of Solana's TBFT, what action takes place when a leader seems to have failed?

Another node attempts to take his place by initiating an election process

⬇️

What does Turbine aim to reduce by utilizing a smart block propagation protocol?

Time needed for block propagation

How are nodes in the network organized in the Turbine protocol?

Into neighborhoods; nodes within a particular neighborhood in the Turbine protocol are responsible for sharing received data with other nodes in the same neighborhood.

How is propagation priority determined in Turbine?

Stake-weighted selection algorithm. This algorithm prioritizes propagation based on the amount of stake validators hold in the network. Validators with higher stakes are placed closer to the current leader for efficient data sharing.

⬇️

What does Gulf Stream serve as in Solana?

A mempool-less solution for forwarding and storing transactions before processing.

What is the primary role of the mempool in traditional blockchains?

Store transactions being broadcasted but not yet processed.

Why can Solana execute transactions in parallel?

Each Solana transaction describes all the states required to read and write to, enabling non-overlapping instructions to be executed simultaneously.

Why did the Solana team develop the Transaction Processing Unit (TPU)?

To validate and execute transactions quickly before receiving another block. It ensures efficient processing of transactions to maintain the network's speed and performance.

⬇️

What are the pipeline stages of the TPU?

- Data fetch in kernel space via network card (I/O).

- Signature verification using GPU

- Change of the state using CPU (banking).

- Write to the disk in kernel space and send out via network card (I/O).

What becomes a bottleneck after achieving fast computation in blockchain systems?

The memory becomes a bottleneck due to the limitations of storing everything in RAM

How does Cloudbreak handle data storage?

It makes use of memory-mapped files.

How is data integrity ensured among the specialized network nodes?

By splitting into small pieces and replicating the data multiple times.

Resources

- Solana Developer Guides

- Solana Devnet Faucet

- Solana Whitepaper

Community

- Ackee Solana Handbook 

- Shyft, full-suite Solana Development Experience

Made with Slides.com