Solana Walkthrough - Preamble
Walkthrough - @paulx has a walkthrough time to dive in... so let's try it out
Let's start off with installing everything locally
- Installing the CLI tools - the rest of the documentation is more geared towards specific topics, so let's find something a little easier to digest;
Take a look at CLI options... interesting, looks very thorough... Like they learned from all the Btc and Eth troubles.
| => solana --help
solana-cli 1.6.9 (src:9e42883d; feat:2960423209)
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
-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:
/Users/prakashnarayanan/.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
airdrop Request lamports
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
cluster-date Get current cluster date, computed from genesis creation time and network time
cluster-version Get the version of the cluster entrypoint
config Solana command-line tool configuration settings
confirm Confirm transaction by signature
create-address-with-seed Generate a derived account address with a seed
create-nonce-account Create a nonce account
create-stake-account Create a stake account
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
deploy Deploy a program
epoch Get current epoch
epoch-info Get information about the current epoch
feature Runtime feature management
fees Display current cluster fees
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
rent Calculate per-epoch and rent-exempt-minimum values for a given account data
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
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-history Show the stake history
stake-set-lockup Set Lockup for the stake account
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
validator-info Publish/get Validator info on Solana
validators Show summary information about the current validators
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-withdrawer Authorize a new withdraw signing keypair for the given vote account
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
That looks like a great list of command line options to be explored later.
Moving on to the walkthrough itself, theory is a little dense.
Basically Solana uses something called the Berkeley Packet Filter, or BPF described as provides a raw interface to data link layers, permitting raw link-layer packets to be sent and received
- I surmise that basically, the big challenge in developing Solana was to figure out a way to transmit and sync small packets of data across a large distributed system. And basically lots of middleware ends up getting stripped out and coders have to move down layer.. closer to the metal in order to get more efficient
- This is funnily enough a reversion to the historical byte level optimization of computing, and will probably come as a rude shock to mostly mobile and front end devs who are relatively resource insensitive
- Anyway, looks like BPF is one of the technologies Solana is using to achieve this
Continuing the walkthrough
- each program is processed by its BPF Loader and has an entrypoint whose structure depends on which BPF Loader is used
- accounts are used to store state
- accounts are owned by programs
- only the account owner may debit an account and adjust its data
- all accounts to be written to or read must be passed into the entrypoint
- accounts hold:
- programs, in executable accounts
- data
- SOL
- The NativeLoader program owns
- the System Program, which handles SOL transactions
- the BPF Loader, which owns
- all other Solana programs, stored in executable accounts