Day 15 of RareSkills Solana Course.
- Configure Solana to run on localhost:
solana config set --url localhost
- Run the test validator node on another terminal:
solana-test-validator
- Run Solana logs on another terminal:
solana logs
- Build Anchor program:
anchor build
- Sync program_id with Anchor key:
anchor keys sync
- Run tests:
anchor test --skip-local-validator
- Solana opcodes/instructions consume
compute units
. - Each Solana transaction is soft-capped at
200,000 compute units
.- If the transaction costs
more than 200,000 compute units
, itreverts
. - The limit can be increased up to
1,400,000 compute units
with an extra cost.
- If the transaction costs
- Each Solana opcode costs
one compute unit
. - Smaller integers save compute units.
i32
would use less compute units thani64
, vice versa.
- Compute units used in a transaction does not affect transaction fees.
- Currently, Solana transaction fees are determined by the
number of signatures that need to be verified
in a transaction.- Theoretically, a single transaction could contain as many as 12 signatures.
- A Solana transaction with a single signature would cost
5000 lamports
or0.000005 SOL
.
- Solana programs written in
Rust
orC
are compiled down toeBPF
for theSolana VM
. eBPF
allows execution of arbitraryeBPF bytecode
within the kernel (sandbox environment) when the kernel emits an event the eBPF bytecode subscribes to, like:- network: open/close a socket
- disk: write/read
- creation of a process
- creation of a thread
- cpu instruction invocation
- supports up to 64 bits (that’s why solana has a max uint type of u64)
- The program is only executed when an event is emmited in the kernel.
Solana Bytecode Format (SBF)
is a variant ofeBPF
.- Solana Bytecode Format removed the
bytecode verifier
, whicheBPF
uses to ensure that all possible execution paths are finite and safe to execute. - Solana Bytecode Format have safety checks in the runtime and limits computational resources spent with a
compute unit limit
. - While looking for references, I've encountered this pull request to "Rename Soalan Bytecode Format(SBF) toolchain" (lol).