How Blockchain works

in #blockchain8 years ago

IMG_2871.PNG

The Blockchain

The blockchain is the Bitcoin transaction log. This register consists of a series of chapters (blocks) that are linked together, each grouping the transactions carried out over a certain period.

Gérard Dréan explains the formation of this chain of blocks:

  • The blockchain is a set of blocks, protected from modification, each of which contains the identifier of its predecessor [...]. It can be in the form of a tree with several branches. The longest of these branches, called the main branch, is identified by the identifier of its terminal block. From this identifier, it is possible to trace this main branch back to the original block "Genesis", created by "Satoshi Nakamoto" on January 3, 2009, and to find all the transactions registered since.
    IMG_2872.PNG

  • Each node of the network constantly receives all sorts of messages, some of which propose new blocks to be added to the blockchain. A fundamental security principle is to make the assumption that the other nodes of the system can be defective or fraudulent. Each node must therefore consider everything it receives from the other nodes as suspect on principle, determine its nature and validate it independently before using it.

  • If a message contains a block, it is submitted to a protocol that will add it to the local blockchain and whose complexity is due to the fact that it has to deal with all the particular cases, even those that appear a prior to the blockchain. More unlikely.

IMG_2873.PNG

  • In addition to transactions, each block contains a checksum ("hash") that protects it from changes, and also serves as an identifier. It also contains the identifier of the block that precedes it in the blockchain of the minor who created it, as well as a measure of the amount of work that was used to produce it. The first step is to eliminate the new block if it is badly formed (incorrect syntax) or if it has already been received, and thus has already been processed.

  • A basic objective of the Blockchain construction protocol is that all its copies are identical, although constructed independently. It aims to achieve consensus on the same version of the transaction log for all computers on the network. The principle chosen is to choose, among the possible versions of the blockchain, the one whose construction has requested the greatest amount of work, which is aimed in particular at deterring potential fraudsters by requiring them to work superior to that of the nodes " Honest ".

IMG_2877[1].PNG

If the new entrant is retained, the sequence depends on the block it indicates as its predecessor. If this is not indicated, the new block is kept among the "orphan" blocks. If it is specified but does not exist in the local blockchain, the new block is also ranked among the "orphan" blocks, but its predecessor is also claimed at neighboring nodes. This step allows, for example, the reconstruction of the blockchain of a node which has been stopped for a certain time. In either case, the program will revert to a new block. Indeed, all received blocks are treated in the same way regardless of their origin.

  • If the specified predecessor is the current end of the main branch, the program tries to add the new block. For this purpose, it verifies that each transaction of the block is valid syntactically, is not already present in the blockchain and satisfies the validity condition indicated by its version code. As soon as a transaction is invalid, the process is aborted. Otherwise, the identifier of the new block replaces the identifier of the end of the blockchain, all transactions of that block are eliminated from the pool of pending transactions and this block is sent to the neighboring nodes, which will execute the same process.

  • If the predecessor indicated is a block other than the terminal block of the current blockchain, two cases may arise depending on whether the sequence of blocks that results in the new block has requested more or less work than the current main branch. If it has requested less work, the current blockchain is not changed, and the new block is simply stored in memory, forming the primer of a secondary branch. If this new branch has asked for more work, it must become the reference blockchain. To do this, the program goes back to the bifurcation, and from there, tries to successively add each of the blocks of the new branch that have been put on hold without being validated, checking as above the validity and the legitimacy of the Transactions it contains.

  • If it succeeds without encountering a block or an illegitimate transaction, it updates the pool of pending transactions (by removing the transactions that are now in the new main branch and putting back those that were in the old stretch
    He main and are not in the new), it replaces the identifier of the end of the blockchain and diffuses the block to neighboring nodes. Otherwise, it leaves the blockchain as it is, while keeping the new block waiting as before. Finally, if the new block is indicated by one or more orphaned blocks like their predecessor, the protocol tries to reattach through it the blocks Orphan to the blockchain by recursively applying it to the above protocol. Protocol in normal operation In normal operation, the blockchain is identical on all nodes, and the new block designates as the predecessor the terminal block of the existing blockchain. Each node will therefore add to the end of its main branch the first valid block it receives.

  • However, miners work in parallel and there is no general rule regarding the selection of transactions to be incorporated into a block. From the same pool of raw transactions, miners can therefore propose different blocks, which each node will continue to receive after the one it has added to its blockchain copy, which will designate the same predecessor and contain in part The same transactions. If all the nodes of the network receive the blocks of the minors in the same order, the blockchain remains the same on all the nodes, although each one has it Built its own version independently. But it may happen that two or more minors transmit different blocks in a time less than the propagation time of the blocks in the network. These blocks then arrive in a different order according to the receiver nodes, each of which will retain the first one in its main branch, the following blocks being grafted as is to the side. The nodes then separate into two (or more) populations and there is a fork of the blockchain.

  • In particular, the minors of each population are now working from different blockchains. This situation is usually resolved by the following blocks. Indeed, the situation that gave rise to this bifurcation is very unlikely, and it is less and less likely that it will be renewed in the next stage. There will come a time when the first block received will be the same for all, and the application of the protocol described above will make him and his predecessors then become the main branch for all. At that time, transactions that appeared in the old main branch, and which were therefore considered to be definitive, may no longer be included in the new branch.

  • For this reason, it is recommended to consider a transaction as final only if the block in which it appears is at a certain distance from the current block (6 blocks for large normal transactions, 100 for mining transactions creating new Bitcoins) .Cases of fraud Normally all the actors in this process have the same objective: to ensure the proper functioning of the system. But anyone can freely issue transactions, become a minor or system node, including with intent to harm or with non-standard versions of the software.

  • No participant can therefore dismiss the assumption that what he or she receives is erroneous or even downright fraudulent or dangerous, and everyone must verify its validity at all stages. Transactions or erroneous or fraudulent blocks have virtually no chance of escaping these checks and reaching the blockchain, and the fraudster finds themselves very quickly isolated. A node can create fraudulent transactions. But the only possible way to introduce them into the multiple copies of the blockchain is to incorporate them into a block and submit this new block to the other nodes of the network by the normal way. In the absence of equally fraudulent changes in block building protocols and transaction validation processes, these transactions will not be validated and embedded in legitimate blocks or accepted by other nodes. The blockchains of the "honest" nodes will therefore not be affected and the fraud will have no consequences other than local to the fraudster node. To modify an existing block in the register, the only way is to create a new block containing possibly a part of the transactions of The old one, and try to graft it in its place.

  • This new block will be grafted (without checking) next to the block it is trying to replace, but the main branch will remain unchanged. To become part of the main branch, it would have to graft new blocks to it faster than To the true main branch so that this new branch will eventually overtake it. However, during this time, the rest of the network continues to lengthen the main branch. Each of the new blocksS to be recalculated ex nihilo including its checksum, the fraudster (s) should mobilize a total power of validation greater than that of all the rest of the network. In addition, each of these blocks, as well as the validity and legitimacy of the transactions contained therein, would be checked with respect to that part of the blockchain situated upstream of the bifurcation. It is difficult to see which fraudulent changes could escape these checks, knowing moreover that all the transactions must be signed cryptographically by the user debited.

  • Finally, even if a fraudster succeeded in introducing modifications of this type in certain nodes, Thus creating a small group of users who are isolated from the rest of the network and who could exchange only among themselves, which is hard to see. The rest of the network would not be affected. Moreover, the maneuver would necessarily be visible, especially since the replaced block is older, since it would consist in the abnormally rapid creation of blocks grafted upstream of the current end. The fraudster would be likely to be eliminated, and blockchains would be repaired from those that remained intact.

IMG_2875.PNG

Sort:  

Got a basic concept.. and will study for more.
Thank you!

your welcome buddy

Do you mind if I use this to show to work mates? This will be perfect.

Now explained in the simple language
Learnt a lot
Thanks a ton mate
Upvoted

This is an impressive work Varun! Very nice buddy.

Thank you very much Gabreil.

This post received a 91% upvote from @randowhale thanks to @varunsangwan! For more information on @randowhale click here!

thank you Man. it's highly appreciated

@varunsangwan a good start of my day learning blockchain :) thank you.

Great explanation man!
Yet another great post from you, resteemed!

Thank you Brother.

That was very enlightening