Get started with Casper : An In-Depth Overview of Casper Network Architecture
A guide about Casper Blockchain Architecture and its comparison to Ethereum! To help you make better dapps
Introduction
Hey Everyone, Welcome to another blog where we will be discussing about casper blockchain. Casper was launched in March 2021 and from that day it has been in news. As we know that Ethereum being the biggest player in blockchain market is suffering from multiple issues related to gas fees, computation, etc. Today we will discuss about how casper is different from others and how you can benefit from it.
Casper is a layer 1 public blockchain, meaning its a new blockchain and not a sidechain. The Casper Network is the first live proof-of-stake blockchain built off the Casper CBC specification. Casper is designed to accelerate enterprise and developer adoption of blockchain technology today and evolve to meet user needs in the future. The network is specifically optimised for high throughput, security and decentralisation.
It is also represented as CSPR, same as ethereum is represented as ETH.
Native Token of Casper
The native token of casper is known as CSPR. Same as ETH is native token for Ethereum.
The use of CSPR is to reward validators that participate in the pos consensus mechanism which secures the network.
CSPR is also used to pay network fees for on-chain actions.
The smaller unit of casper is called motes, the unit in which gas is paid on casper, Its same like Ethereum has GWei for gas payments.
In short the use of CSPR is same as ETH which is for securing and doing transactions(gas fee) for blockchain
Consensus algorithm of Casper
Casper uses a type of Proof of stake consensus protocol called Casper CBC(Casper Correct by Construction (CBC)) with many improvements. This improved consensus protocol of casper is named as Highway Protocol. Casper CBC was an idea of Vlad Zamfir, who helped to create Ethereum. Ethereum2.0 is going to use CFFG(Casper Friendly Finality Gadget (CFFG)) protocol and the Ethereum 3.0 is going to use Casper CBC. Because of this casper calls itself the "final evolution" of Ethereum.
How Highway protocol is better
- Highway allows networks to reach higher thresholds of finality, meaning that more blocks are finalized, and validators agree to add them to the blockchain.
- The protocol achieves flexibility by expressing block finality in ways not possible in BFT models
- Unlike Proof-of-Work networks, which need to centralize validators for economies of scale, Casper allows for the geographical decentralization of validators
The virtual Machine of Casper
Casper is turing-complete chain which means it supports smart contracts. Casper doesn't have a EVM like ethereum, Instead it has an WASM interpreter(We can say its a kind of Virtual Machine) which is used for all computation work to be performed. This makes casper useful as any language which can compile down code to wasm can be used to write smart contracts on casper.
Smart Contracts in Casper
Casper blockchain supports smart contracts. You can write your smart contracts in any language which compiles/compiled down to wasm(Web Assembly). The primary language used to write smart contracts in casper is Rust. CaperLabs has also created a code transpiler called caspiler that converts solidity code to Rust. This make solidity another language supported in casper.
There is Javascript SDK which is used to connect to casper and perform calls on the smart contracts that are deployed.
The Model of Casper : Account-Based Model
Same like Ethereum Casper has account based model. It has account hash, public key and private key. There is a global state in casper where all data is stored in Key-value manner. Each block causes a change in global state. The key-value store is implemented using a Merkle trie. Casper implementation of the trie has radix of 256, meaning each branch node can have up to 256 children. A path through the tree can be an array of bytes, and serialization directly links a key with a path through the tree as its associated value.
A trie node is actually one of the following:
- A leaf: which includes a key and a value
- A branch: which has up to 256 blake2b256 hashes, pointing to up to 256 other nodes in the trie (recall each node is labeled by its hash)
- An extension node: which includes a byte array (called the affix) and a blake2b256 hash pointing to another node in the trie
Features of Casper as compared to Ethereum(Why to choose Casper)
Casper is build to solve the problems that existing enterprises is facing with adoption of blockchain. Casper aims to support global enterprise adoption of web3. Existing enterprise blockchains lacks a lot of features which casper has tried to solve.
Lets have a look on some of the great features casper provides:-
Upgradable Smart Contracts: Yes, You have heard it right, Casper support easy upgrade of deployed smart contracts without any complex processes like as it is present in Ethereum where you have to deal with proxy contracts with a lot of mess. Casper smart contracts use a package management model, which allows the direct upgrading of on-chain smart contracts, eliminating the need for complex migration processes .This allows quick patching of smart contracts vulnerabilities, easy logic upgrades with time, etc.
When installing a contract, it's possible to designate a contract as 'not upgradeable', which is suitable for DeFi contracts
Inbuilt Easy and Secure Weighted Keys Management : As you know many blockchanis only allow binary (on or off) smart contract access permissions for users, which restricts larger teams to effectively work together on blockchain and managing complex applications becomes very difficult. The Casper Network offers powerful accounts that are not just public keys. Accounts on casper offer weights for separate key management and transaction signing rights, and the ability to run session code (wasm) in the account context. By running session code in the account, it's possible to delegate transaction signing to multiple keys, revoke lost keys to recover accounts and store data within the account itself. It is also possible to securely share state between accounts and contracts (without expensive cryptographic checks)
Lower and Predictable Gas Cost: The casper PoS consensus mechanism allows less network congestion and high throughput when compared to Ethereum and other blockchains. The network is designed in such a way that it improves price stability during changes in order size or at times of high transaction volume. Casperlabs is also working on predictive gas futures market which would allow us to reserve gas ahead of time at predetermined prices.
CasperLabs- A Non-Profit for casper improvements: The casperLab is a Non Profit org which works on improving the casper blockchain as per the user needs and demand. This makes casper a great choice for enterprises as casper is designed to continually upgrade itself with time which makes the blockchain feature rich with growing demand and needs of business's.
Future Proof : The design of casper is so great that all components in it are pluggable(Network Engine, Execution Engine, Consensys Layer). This makes it easy to upgrade casper in future.
This was all about Casper Blockchain. I hope you understood what Casper is and how it is different from others.