
Discover more from Web3 Bits and Bytes
Web3 Glossary - OPQ of Web3
Understand PoW, PoS, on chain vs off chain and reason why your crypto txns are queued
Somebody today was explaining me how the cryptocurrency market was changing, even though I already knew, it was a bit coin descending ๐
Jokes apart, itโs been a week since I started this newsletter. Thankyou for reading and supporting ๐๐
It has been quite a journey so far. Loved all the feedback yaโll sent across and itโs been a great leaning journey in making web3 simpler for everyone.
Let's get to learning some web3 terms. Shall we?๐
Hereโs what I got for you today๐
๐O: On chain, Off chain
๐P: PoS, PoW
๐Q: Queued transactions
Blockchains process numerous transactions every minute. Do all transactions happen on chain? Do we have off chain transactions? Todayโs all about transactions dynamics!๐คฉ
Think of a blockchain as a cloud storage facility, which has two parts - private and public. ๐
On-chain transactions are like the public cloud - visible to all
Off-chain transactions are like the private cloud- the data is not publicly accessible.
Letโs take this analogy and delve deeper.๐๐
On-chain = any transaction or data that is available on the blockchain and visible to all nodes on the network such as mempool data, historical transactions, and account information
Therefore, every time an on-chain transaction occurs, it leads to an update of the overall blockchain network
Ideally these transaction should happen in real time
BUT
It takes time for miners to validate the transactions & add to the blockchain ledger.
Itโs a time consuming process & as the transaction volume increases, networks gets congested & hence the time taken to add the transaction to ledger also increases
๐คฏ๐ค
Subsequently, the transaction fees also increases.
Thats where Off chain txns come in
Off-chain is any transaction or data that exists outside the blockchain.
Committing every transaction on-chain can be expensive and inefficient!
What do we do?๐ค
Leverage third-party tools like oracles that handle pricing data, or layer 2 solutions that execute a higher throughput of transactions, handle the bulk of the processing work off-chain, and submit information on-chain at less frequent intervals.๐๐ฏ
eg Chainlink , Lightning
๐The Lightning Network is a layer-2 protocol - it speeds up the transaction and reduces the fees. Hereโs how it works:๐
It creates a channel between two transacting parties. Once this channel is established, both parties can instantly send crypto to one another at minimal costs
These transactions aren't transmitted to the chain. Once the parties conclude their transactions, the channel is closed. Final amounts are sent to the participating parties as per the transfer history recorded on the channel - this is the only transaction stored on the blockchain
This data consolidation bundles many small transactions into one single set & makes it easier for the nodes to process. If payment channels are removed, these small transactions could hold back high-value transactions & congest the network.
hence layer-2 solutions are the future
In such a dynamically changing status of the blockchain, we need an efficient,fair, real-time & secure mechanism to ensure that all the txns on the network are genuine and all participants agree on a consensus on the status of the ledger. Weโve learnt quite a lot of new things about blockchains, but have you thought how a decentralised network ensures this?
Consensus mechanism does that job for us
Itโs a set of rules that decides on the legitimacy of contributions made by the various participants of the blockchain.
There are 2 kinds of consensus mechanisms
๐PoW: Proof of Work
๐PoS: Proof of Stake
PoW requires a participant node to prove that the work done and submitted by them, qualifies them to receive the right to add new transactions to the blockchain.
Think of it as submitting those assignments and giving end semester exams in college as a proof of your work that you have learnt the subject and can be promoted to next year.
PoW ensures the integrity of new data as it requires members of network to expend effort in solving an arbitrary mathematical puzzle to prevent anybody from gaming the system.
In PoW systems, the probability of mining a block is directly proportional to how much work the miner does
Bitcoin and Litecoin use PoW consensus mechanism.
However, itโs not that simple. This computation leads to high energy consumption and a longer processing time.๐ง
But, where thereโs a problem, thereโs a solution๐ฏ
PoS evolved as a low-cost & low-energy consuming alternative to the PoW model
It delegates control of the network to owners of the token and allocates responsibility of maintaining the public ledger to participant node in proportion to the no of virtual currency tokens held by it.
Letโs scratch the surface๐ง
In the PoS model, stakers (same as miners in PoW) lock up funds in a special smart contract. Every time a new block is needed by the network, an algorithm grants a specific staker the opportunity to publish the next block. ๐๐
The algorithm selects the staker via lottery, depending on each stakerโs percentage of total staked funds.
For e.g., if a single staker controls 25% of all funds staked on a given network, they have a 25% chance of mining the next block.
Do you see a problem here?๐ง
PoS has a stronger tendency to centralize and concentrate token ownership to large holders & hence its security guarantees are weaker than PoW. PoS model has governance problems and is more vulnerability to attacks
Let me break it down with another example
Say we have a PoS network worth $50 bn where 10% of tokens are staked. The $100 bn network can be taken over by any party that is able to allocate $5 bn
All the attacker would have to do is send $5 bn in tokens to a staking contract. While the same would be fairly difficult for PoW models.
Why?๐ค๐ค
Coz it would require purchasing ASICs, acquiring space and energy contracts to mine at a scale larger than the entire network and if such an attack were underway entire network would likely be made aware beforehand by the immense demand for ASICs and electricity.
Essentially, both PoS and PoW have their fair share of pros and cons. We also have other consensus mechanisms like PoH (by Solana ), PoC, PoA and PoB.
Let me know in the comments if youโd like to know more about these๐๐
Now coming to the impounding question
Why is my transaction queued? ๐ค
If youโve found yourself pulling your hair out when a transaction seemingly pauses forever, read on ๐คฏ
Is it pending or queued? Letโs get some clarity, shall we?๐๐
Transactions submitted to a network through an EVM node can have one
of the two following statuses before they are sent through to the network
and included in a block:
๐Pending
๐Queued
Whatโs really the difference though?
๐Pending transactions are the ones in the transaction pool that are ready to be included in a block.
๐Queued transactions are the ones waiting to become the pending transactions.
Where does this queue put up though?
The queued pool๐๐
Itโs a pool of txns in the mempool that are not yet ready to be processed because they are out of order
Out of order? What does it imply?
Every txn has an account nonce (not block nonce). Every time an account does a txn, the account nonce of the transaction is incremented by 1
If a txn is sent with a nonce that is higher than the current txn count for the senderโs account (creating a gap in the nonces), then the txn will be added to the nodeโs local transaction pool with a queued state.
An example would help๐๐
๐Say an account 0x463.. creates a txn for the first time. The txn gets the account nonce 0. The transaction goes directly into the pending pool and is eventually added to the block.
๐The next transaction from account 0x463... is automatically incremented by 1 and gets the acct nonce 1. The transaction goes directly into the pending pool and is eventually processed. Say account 0x463... creates a 3rd txn & manually sets the transaction's account nonce to 3, the txn will get the status queued coz thereโs no txn with the account nonce 2. ๐๐
๐The queued txn will not be propagated to the network until there is a txn with the account nonce in sequence.
How to fix it?๐ค
๐Fill the gap
Once account 0x463... creates a valid txn with account nonce 2, the queued transaction gets unclogged and is added to a block.
๐Send a rescue transaction
To effectively cancel a queued transaction, send another txn from the same acct with the same nonce, but a gasPrice that is at least 10% higher than the gasPrice of the original txn.
You could send 0ETH with fromAccount=toAccount so that the only cost of the transaction is its gas. Nonce ordering is only one of the reasons why your transaction is pending, there could be other reasons like, sending a very small amount with insufficient fees, high n/w volume to count a few.
Thatโs a wrap for today!
Stay tuned for more on the new vocabulary of the web for next 30 days.๐ฏ
Itโs a free crash course on the jargons and terminologies in Web3 direct to your email
As ever, thank you for subscribing and reading. It matters. Itโs a big deal to me.
And, remember, half-true compliments and feedbacks are always welcome at:
laisha.wadh [at] gmail [dot] com
WAGMI ๐๐