Sei sulla pagina 1di 4

Architecture of Blockchain

Transaction:
Transactions are the things that give a blockchain purpose. They are the smallest building blocks
of a blockchain system.
Transactions generally consist of a recipient address, a sender address, and a value. This is not
too different from a standard transaction that you would find on a credit card statement.
A Bitcoin transaction moves the value of some bitcoin from one address to another address.
A transaction changes the state of the agreed-correct blockchain. A blockchain is a shared,
decentralized, distributed state machine. This means that all nodes (users of the blockchain
system) independently hold their own copy of the blockchain, and the current known "state" is
calculated by processing each transaction in order as it appears in the blockchain.
Transactions are bundled and delivered to each node in the form of a block. As new transactions
are distributed throughout the network, they are independently verified and "processed" by each
node.

Blocks:
Blocks are data structures whose purpose is to bundle sets of transactions and be distributed to all
nodes in the network. Blocks are created by miners. Blocks contain a block header, which is the
metadata that helps verify the validity of a block.
Typical block metadata contains:
Version - the current version of the block structure
Previous block header hash - the reference this block's parent block
Root hash - a cryptographic hash of all of the transactions included in this block
Time - the time that this block was created
nBits - the current difficulty that was used to create this block
nonce ("number used once") - a random value that the creator of a block is allowed to
manipulate.
Blockchains are probabilistic systems, by design. Nodes, or the computers in the network,
independently decide and concur upon which "chain of blocks" is the longest and most valid. As
a block is created and set around the network, each node processes the block and decides where
it fits into the current overarching blockchain ledger.
Within the context of a blockchain, there are a few different types of blocks.
 Most blocks simply extend the current main blockchain. These are called "main branch
blocks".
 Some blocks reference a parent block that is not at the current blockchain tip. These
blocks are called "side branch blocks".
 Some blocks reference a parent block that is not known to the node processing the block.
These are called "orphan blocks."

Side branch blocks are particularly interesting. They might not currently exist in the main
branch, but if more work is done on them (meaning other blocks are mined that reference them
as a parent), there is the possibility that that a particular side branch will be reorganized into the
main branch. This reorganization happens because the "main" branch of the blockchain is the one
that has had the most work done on it. As new blocks are appended to the blockchain, it becomes
increasingly difficult to "overwrite" existing blocks because the most valid chain is the one that
has had the most work done on it.
The primary chain (the blue blocks) is the longest series of blocks. The primary chain starts at
the first created block (the orange block) and continues to the current block. Orphaned blocks
that are not part of the series (the green blocks) exist without being a part of the primary chain.

Mining:

So far, we've danced around the details of "creating a block", or mining. Mining is the process of
putting in real-world work (in the form of electricity) to create a valid block that will be accepted
by the rest of the network.

Miners are the equivalent to the processing network of a credit card company. They take pending
transactions, verify that they are cryptographically accurate, and package them into blocks to be
stored on the blockchain.

At a high level, the process of mining involves hashing a potential block, checking to see if the
hash fits the current difficulty rules, and if not, changing the nonce in the block header and
hashing the block again.

Hashing:

Hashing functions have a few properties that make them desirable for creating proof of work, a
key concept in the Bitcoin network specifically:

Hash functions turn an arbitrarily-large piece of data into a fixed-length hash output
They are one-to-one: the same input will always provide the same hash output
They are one-way functions: it's impossible to "work backwards", and reconstruct the input given
a hash output.

Some common hashing schemes can be found here. For reference, Bitcoin uses the SHA-256
hashing algorithm for proof of work.

Due to hashing, editing even a single bit of the block header will result in a different hash.
Therefore, changing the nonce will create a new hash value to cross-check with the current
difficulty rules. This process must be done over and over for each new potential block, until a
valid hash is found.

When a miner DOES find the right configuration of data within a block template that results in a
valid hash, it's trivially easy for all other nodes to perform the same hashing function on that
block, and verify that it does, in fact, result in a valid hash.
Consensus:

All of these previous concepts of independent nodes checking and verifying the validity of
transactions and blocks is called consensus.

The consensus of a blockchain is realized in a codified set of rules that everyone is playing by.
These rules are entirely self-enforced. As the blockchain network grows larger, and more nodes
and miners participate in it, the overall consensus grows stronger due to the sheer number of
actors that are enforcing their own rules (that everyone else is enforcing, as well).

The entire network independently agrees on what the reward for finding a new block should be.
Trying to play "outside of the rules" is not illegal or even wrong (remember, anyone can do
whatever they want). However, if you want your transaction or block to be accepted by the
network, you must follow the same rules as everyone in the network, otherwise you run the risk
of not matching consensus standards and getting your verification ignored. Thus consensus adds
another layer of security to blockchain transactions.

In general, blockchains contain transactions packaged into blocks that are mined using
significant resources, and new "tokens" are created as a result of this mining.

The network-at-large cryptographically verifies that all transactions are legitimate, and uses
consensus rules to determine what the valid blockchain contains.

Potrebbero piacerti anche