CSC School: Structure #5

zeroxlive
Coinmonks
7 min readDec 27, 2022

--

Now , we know how a transaction created and broadcasted to network.but how nodes store these data and update state? in this part we will look at this process.

in previous part we did create a transaction and broadcast to network.we should know how CSC validate transactions in a block and store them.

POS

Source: Investopedia

Proof-of-stake is a cryptocurrency consensus mechanism for processing transactions and creating new blocks in a blockchain. A consensus mechanism is a method for validating entries into a distributed database and keeping the database secure. In the case of cryptocurrency, the database is called a blockchain — so the consensus mechanism secures the blockchain.

Features

  • With proof-of-stake (POS), cryptocurrency owners validate block transactions based on the number of staked coins.
  • Proof-of-stake (POS) was created as an alternative to Proof-of-work (POW), the original consensus mechanism used to validate a blockchain and add new blocks.
  • While PoW mechanisms require miners to solve cryptographic puzzles, PoS mechanisms require validators to hold and stake tokens for the privilege of earning transaction fees.
  • Proof-of-stake (POS) is seen as less risky regarding the potential for an attack on the network, as it structures compensation in a way that makes an attack less advantageous.
  • The next block writer on the blockchain is selected at random, with higher odds being assigned to nodes with larger stake positions.

Proof-of-stake reduces the amount of computational work needed to verify blocks and transactions. Under proof-of-work, it kept blockchain secure. Proof-of-stake changes the way blocks are verified using the machines of coin owners, so there doesn’t need to be as much computational work done. The owners offer their coins as collateral — staking — for the chance to validate blocks and then become validators.1

Don’t know when to buy and sell, Try Copy trading.

Validators are selected randomly to confirm transactions and validate block information. This system randomizes who gets to collect fees rather than using a competitive rewards-based mechanism like proof-of-work.1

To become a validator, a coin owner must “stake” a specific amount of coins. For instance, CSC requires 1000 CET to be staked before a user can become a validator.1 Blocks are validated by more than one validator, and when a specific number of the validators verify that the block is accurate, it is finalized and closed.

Proof-of-stake is designed to reduce network congestion and environmental sustainability concerns surrounding the proof-of-work (PoW) protocol. Proof-of-work is a competitive approach to verifying transactions, which naturally encourages people to look for ways to gain an advantage, especially since monetary value is involved.

Bitcoin miners earn Bitcoin by verifying transactions and blocks. However, they pay their operating expenses like electricity and rent with fiat currency. What’s really happening then is that miners are exchanging energy for cryptocurrency, which causes PoW mining to use as much energy as some small countries.4

The PoS mechanism seeks to solve these problems by effectively substituting staking for computational power, whereby an individual’s mining ability is randomized by the network. This means there should be a drastic reduction in energy consumption since miners can no longer rely on massive farms of single-purpose hardware to gain an advantage.

Proof-of-Stake Security

Long touted as a threat for cryptocurrency fans, the 51% attack is a concern when PoS is used, but there is doubt it will occur. Under PoW, a 51% attack is when an entity controls more than 50% of the miners in a network and uses that majority to alter the blockchain. In PoS, a group or individual would have to own 51% of the staked cryptocurrency.

It’s very expensive to control 51% of staked cryptocurrency. Under Ethereum’s PoS, if a 51% attack occurred, the honest validators in the network could vote to disregard the altered blockchain and burn the offender(s) staked ETH. This incentivizes validators to act in good faith to benefit the cryptocurrency and the network.

Most other security features of PoS are not advertised, as this might create an opportunity to circumvent security measures. However, most PoS systems have extra security features in place that add to the inherent security behind blockchains and PoS mechanisms

CPOS

Although Proof of Work (PoW) has been proved to be a practical solution for decentralized networks, yet it is not environment-friendly and requires a large number of participants to maintain network security.

On the other hand, Ethereum and some other networks use Proof of Authority (PoA) or its variants in different scenarios, including test network and main network. PoA provides defense for 51% attack and is more effective in preventing evil-doing by some Byzantine nodes. However, PoA protocol is not decentralized enough, for the validators are prone to corruption and security attacks given the extreme powers they possess.

Therefore, some blockchain projects introduce other consensus schemes on the premise of ensuring network security and stability without compromising decentralization, such as DPoS adopted by EOS and Cosmos, which allows token holders to vote for validator nodes and makes the blockchain more decentralized and conducive to community management.

After rigorous investigation and research, CoinEx Team adheres to the principle of decentralization and combines the characteristics of PoS with PoA to realize CPoS, without losing network stability and security. The features of CPoS are as follows:

  1. Blocks are generated with a maximum of 101 validator nodes.
  2. Anyone can become a validator by staking CET without any permitted.
  3. Validators take turns to generate blocks. When the validator node produce blocks normally, the difficulty is 2; when the validator node do not produce blocks in a predetermined order, the difficulty is reduced to 1; when the block forks, the chain with the greatest difficulty will be systematically selected.
  4. Anyone can stake for their trusted validator.

Merkle Tree

Merkle Tree

Merkle tree is a tree in which every “leaf” (node) is labelled with the cryptographic hash of a data block, and every node that is not a leaf (called a branch, inner node, or inode) is labelled with the cryptographic hash of the labels of its child nodes. A hash tree allows efficient and secure verification of the contents of a large data structure. A hash tree is a generalization of a hash list and a hash chain.

Demonstrating that a leaf node is a part of a given binary hash tree requires computing a number of hashes proportional to the logarithm of the number of leaf nodes in the tree. Conversely, in a hash list, the number is proportional to the number of leaf nodes itself. A Merkle tree is therefore an efficient example of a cryptographic commitment scheme, in which the root of the tree is seen as a commitment and leaf nodes may be revealed and proven to be part of the original commitment.

Hash trees can be used to verify any kind of data stored, handled and transferred in and between computers. They can help ensure that data blocks received from other peers in a peer-to-peer network are received undamaged and unaltered, and even to check that the other peers do not lie and send fake blocks.

A hash tree is a tree of hashes in which the leaves (i.e., leaf nodes, sometimes also called “leafs”) are hashes of data blocks in, for instance, a file or set of files. Nodes farther up in the tree are the hashes of their respective children. For example, in the above picture hash 0 is the result of hashing the concatenation of hash 0–0 and hash 0–1. That is, hash 0 = hash( hash 0–0 + hash 0–1 ) where “+” denotes concatenation.

Most hash tree implementations are binary (two child nodes under each node) but they can just as well use many more child nodes under each node.

Usually, a cryptographic hash function such as SHA-2 is used for the hashing. If the hash tree only needs to protect against unintentional damage, unsecured checksums such as CRCs can be used.

In the top of a hash tree there is a top hash (or root hash or master hash). Before downloading a file on a P2P network, in most cases the top hash is acquired from a trusted source, for instance a friend or a web site that is known to have good recommendations of files to download. When the top hash is available, the hash tree can be received from any non-trusted source, like any peer in the P2P network. Then, the received hash tree is checked against the trusted top hash, and if the hash tree is damaged or fake, another hash tree from another source will be tried until the program finds one that matches the top hash.

The main difference from a hash list is that one branch of the hash tree can be downloaded at a time and the integrity of each branch can be checked immediately, even though the whole tree is not available yet. For example, in the picture, the integrity of data block L2 can be verified immediately if the tree already contains hash 0–0 and hash 1 by hashing the data block and iteratively combining the result with hash 0–0 and then hash 1 and finally comparing the result with the top hash. Similarly, the integrity of data block L3 can be verified if the tree already has hash 1–1 and hash 0. This can be an advantage since it is efficient to split files up in very small data blocks so that only small blocks have to be re-downloaded if they get damaged. If the hashed file is big, such a hash list or hash chain becomes fairly big. But if it is a tree, one small branch can be downloaded quickly, the integrity of the branch can be checked, and then the downloading of data blocks can start.

Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing

Also, Read

--

--