Shiva Profile picture
Jan 14 11 tweets 6 min read Read on X
Lifecycle of a Solana transaction 🧵

1/11 Image
TRANSACTION CREATION

Solana tx begins when a user connects to an app and intends to do a tx on that app.

For e.g. when you click 'Swap' on Jupiter

The app then verifies the user wallet balance and other metadata, and constructs the tx

Each tx includes:

a) Header: indicating which accounts must sign the tx
b) Instructions: the operations that must be performed during this tx
c) Hash of a Recent Block: to prevent stale txs
d) Access List: the accounts being read from or written to

The app then sends the tx to the user, who signs the tx with their private key (via a wallet), and sends it back to the app

2/11Image
SENDING TO RPC

The signed tx is sent to an RPC node (like @heliuslabs) that sanity checks the tx by verifying that the signatures are valid, tx format is correct, etc.

RPCs can be thought of as gateways to interact with and read data from the network.

They run the same software as full validators but with different settings, allowing them to accurately simulate txs and maintain an up-to-date view of the current state of the chain

3/11
GULFSTREAM & swQOS

The RPC node sends the tx through the Solana network’s gossip layer to the current leader validator (more on this later)

Note that this is different from most other networks like Ethereum where the tx is sent to a public mempool

In Solana, any validator who sees a pending tx, sends it via the gossip layer (called Gulfstream) to the leader validator

To ensure that no single node spams the network and that tx distribution remains fair, the leader prioritizes incoming txs from validators with higher stake (this is called swQOS - stake weighted Quality of Service)

swQOCs are like priority lanes that ensure high "quality of service"

4/11Image
LEADER SCHEDULE

The Solana chain is divided into epochs (lasts ~2 days), and each epoch is divided into 400ms slots.

Based on stake weighting, a leader schedule is produced before every epoch, and a leader is chosen for each slot. The leader is responsible for producing blocks from the incoming txs

Each leader is assigned 4 consecutive slots (1.6 seconds) before rotation to the next leader

5/11
BLOCK PRODUCTION

Upon receiving txs, leaders perform sanity checks (signature verification, validity, etc.) and send the txs to the 'Banking Stage'

This is Solana's block building stage where txs are processed in parallel and packaged into ledger “entries,” which are batches of 64 non-conflicting txs (decided by each tx's access lists)

Conflicting txs go into different entries and are executed sequentially, while non-conflicting txs are executed in parallel

There are 6 threads processing txs in parallel, with 4 dedicated to normal txs and 2 exclusively handling vote txs (more on vote txs later)

6/11Image
JITO CLIENT

Normally, the leader builds a block from a prioritized queue of txs it has collected

However, leaders running the Jito client can rely on MEV searchers to receive optimally ordered bundled of txs

Jito runs out-of-protocol auctions where searchers look at any txs that the leader is ingesting and pack them in profit maximizing bundles

These searchers then send these bundles to the leaders - who choose one or more of the bundles to be included in the block and receive the bids as MEV tips (Jito keeps a 5% cut)

7/11Image
PROOF OF HISTORY (PoH)

Once the txs have been ordered in these entries, the accounts these txs touch are locked, and block txs are ready for execution

Execution happens in the SVM (Sealevel Virtual Machine) which is Solana's runtime environment

The hashes of these entries are also sent to a 'Proof of History (PoH)' service

PoH acts as the time-stamping service for Solana.

For each block, PoH generates a hash using as inputs the previous block's hash + the hashes of the entries in the current block

This acts as a sort of 'proof of work' by the leader and helps maintain the order of events in the Solana blockchain

8/11
TURBINE

When the execution is complete, the locks on the accounts are lifted, and the leader updates the account states in their personal copy of the AccountDB

The leader then broadcasts the block to the rest of the network using Solana's block propogation engine 'Turbine'.

Turbine breaks the block tx data into smaller pieces called 'shreds' (up to 1280 bytes each)

These shreds are then streamed to other validators over Solana’s gossip network. Instead of sending one large file, the leader continuously emits these small shreds.

This allows validators to begin verifying and voting on blocks as they are being built, significantly reducing block propagation times and improving overall network performance.

Turbine implements a tree-based fanout: the leader sends shreds to a few validators, who forward them to more validators, and so on, ensuring fast, efficient block propagation

9/11Image
VOTING

Once a validator receives a new block from the leader via Turbine, they must validate all txs within each entry.

This involves replaying the entire block, validating the PoH hashes in parallel, recreating the txs in the sequence dictated by PoH, and updating they local bank.

Validators are also responsible for retransmitting the block to the downstream validators in the 'Turbine Tree'

If the validators believe the block is valid, they can attest to it by producing a 'vote transaction'.

These vote txs get recorded in subsequent slots in the ledger.

10/11Image
CONSENSUS

Solana’s consensus algorithm, Tower BFT, uses validator votes to lock in blocks.

If a supermajority (at least two-thirds of the total stake) of validators vote on top of a particular slot, that slot (and all its ancestors) becomes finalized.

Wallets and RPC services often report “commitment levels” such as:

• Processed: Included by the leader
• Confirmed: Voted by supermajority of validators
• Finalized: More than 31 blocks have been built on top of the tx's block

Finalized blocks are immutable and cannot be reversed.

11/11Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Shiva

Shiva Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @ShivanshuMadan

Sep 8, 2023
The LST debate around limiting the staking cap to <33% has taken over CT recently

But why is the 33% number significant?

Shouldn't it be okay as long as no one holds >50% of the stake?

Let's dive into the fascinating reasons: 🧵 Image
Consensus systems depend on an honest majority of nodes to ensure trust

In Ethereum, the magic formula is n >= 3f + 1

where, N = number of nodes
f = malicious nodes

Here's why 👇
Blockchains are p2p systems where different nodes exchange messages to come to a 'consensus' on the state of the chain

These nodes can be anonymous and located in completely separate parts of the world
Read 10 tweets
May 7, 2023
Unpacking the lifecycle of a rollup transaction: 🧵

Now (Centralized Sequencers)
vs.
Future (Modular everything) Image
First, Current centralized rollups:

The tx journey begins when you perform an action on a rollup dApp and click "Sign" on your wallet.

The wallet is your interface.

It's how you interact with the blockchain network. Image
Behind the scenes, the wallet interacts with the rollup RPC node to check the state of the rollup.

If blockchains are like a house, RPC nodes are like the doors to that house.

It's how anyone can read the blockchain ledger. Image
Read 23 tweets
Apr 5, 2023
The zkEVM wars are raging, but few truly understand them.

Want to join the fray?

Here are the resources that helped me go from 0-to-100 in less than a month: 🧵 Image
This thread goes from ELI5 levels to really advanced content.

As such, I've divided it into 3 sections-

• Starter Pack: I want everything ELI5
• Semi-Pro: I have basic knowledge, but want to get advanced
• Pro: I wanna hit level 9999
1/ Starter Pack

My first foray into the ZK world began with this beautiful substack from @cmsintern and @MarkMBissell

It covers everything from a basic explanation of zk-proof to zkEVMs.

internbreakdowns.substack.com/p/intern-break…
Read 19 tweets
Mar 28, 2023
You've heard of @zksync

But do you know what makes it truly UNIQUE?

Here are 3 features that could unlock mass adoption and bring MILLIONS of new users to crypto. 🧵
For an average Joe to start using crypto, 3 things need to be true.

dApps should be:
• Super easy to use (crypto hides in background)
• Cheap & Fast
• Interoperable - Users should be able to transfer their assets between any 2 dApps (on any chain) easily

zkSync does all 3:
1. Native Account Abstraction

Let's be honest - we can't expect to take crypto to the masses by asking them to remember 16 words for their wallets.

Creating an account should be as easy as signing up with Gmail.

Native AA enables this.
Read 18 tweets
Mar 19, 2023
Want to make it in crypto?

Find the next 100x narrative before everyone else.

One such narrative is "Rollups-as-a-Service".

Here's everything you need to know:
In this thread I'll cover:

• RaaS 101
• RaaS Ecosystem
• The Major Players

I'll trade you 20+ hrs of research for 5 mins of your time.

Let's dive in!
Rollups are the future of blockchains.

And the next evolution of rollups is - App-Specific Rollups (ASR).

ASRs allow customizability like never before.

The problem?

They are very hard to build:
Read 8 tweets
Mar 10, 2023
Weeks like this are a good reminder of why we are in crypto

Instead of relying on opaque entities, we rely on open code & cryptography to define the bounds of financial systems

As an added bonus, it can save us BILLIONS of $$$ in costs!

Here's one example: 🧵

1/8
Traditional lending is a $14 Trillion market globally

Banks borrow money from lenders at X% and lend it to individuals out at Y%

2/8
The difference (X-Y)% is the profit

This profit is shared amongst a whole series of intermediaries

From auditors to investment banks to custodial agents

3/8
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(