A blockchain is a globally shared, transactional database. This means that everyone can read entries in the database just by participating in the network. If you want to change something in the database, you have to create a so-called transaction which has to be accepted by all others. The word transaction implies that the change you want to make (assume you want to change two values at the same time) is either not done at all or completely applied. Furthermore, while your transaction is being applied to the database, no other transaction can alter it.
It is based on a data structure that stores transactions in an orderly manner.
One major obstacle to overcome is what (in Bitcoin terms) is called a “double-spend attack”: What happens if two transactions exist in the network that both want to empty an account? Only one of the transactions can be valid, typically the one that is accepted first. The problem is that “first” is not an objective term in a peer-to-peer network.
The abstract answer to this is that you do not have to care. A globally accepted order of the transactions will be selected for you, solving the conflict. The transactions will be bundled into what is called a “block” and then they will be executed and distributed among all participating nodes. If two transactions contradict each other, the one that ends up being second will be rejected and not become part of the block.
These blocks form a linear sequence in time and that is where the word “blockchain” derives from. Blocks are added to the chain in rather regular intervals — for Ethereum this is roughly every 17 seconds.
A genesis block is the first block of a block chain. Modern versions of Bitcoin number it as block 0, though very early versions counted it as block 1. Thegenesis block is almost always hardcoded into the software of the applications that utilize its blockchain.
A node is a device on a blockchain network, that is in essence the foundation of the technology, allowing it to function and survive. Nodes are distributed across a widespread network and carry out a variety of tasks.A node can be any active electronic device, including a computer or phone, as long as it is connected to the internet and as such has an IP address. The role of a node is to support the network by maintaining a copy of a blockchain and, in some cases, to process transactions.
A node can either be a communication endpoint or a point of communication redistribution, linking to other nodes. Every node on the network is considered equal, however certain nodes have different roles in the manner in which they support the network. For example, not all nodes will store a full copy of a blockchain or validate transactions
A full node downloads a complete copy of a blockchain and checks any new transactions coming in based on the consensus protocol utilized by that particular cryptocurrency or utility token. All nodes use the same consensus protocol to remain compatible with each other. It is the nodes on the network that confirm and validate transactions, putting them into blocks. Nodes always come to their own conclusion on whether a transaction is valid and should be added to a block with other transactions, irrespective of how other nodes act.
Blockchain consensus protocols are what keep all the nodes on a network synchronized with each other, while providing an answer to the question: how do we all make sure that we agree on what the truth is?
After all, anyone can submit information to be stored onto a blockchain and therefore it is important that there is review and confirmation, in the form of a consensus about whether to add that information.
As a term, ‘consensus’ means that the nodes on the network agree on the same state of a blockchain, in a sense making it a self-auditing ecosystem. This is an absolutely crucial aspect of the technology, carrying out two key functions. Firstly, consensus protocols allow a blockchain to be updated, while ensuring that every block in the chain is true as well as keeping participants incentivized. Secondly, it prevents any single entity from controlling or derailing the whole blockchain system. The aim of consensus rules is to guarantee a single chain is used and followed.
Proof of Stake
Proof of stake is the consensus algorithm used by cryptocurrencies to validate blocks.
If a set of potential validators was made up of Adam, who is holding 40 tokens, Fil with 30, Tomek with 20 and Daniel with 10, there will be a 40% chance of Adam being chosen to validate the block and Daniel 10%, with Tomek and Fil on 20% and 30% respectively.
The big vulnerability of Proof of Stake, is the fact that the same size stake may be valued differently by different actors.
For example, take Alice, an early adopter of the blockchain technology with a massive portfolio of digital assets, and Bob, a newbie who is just exploring the emerging token economy. Let’s say they both hold the same stake in a hypothetical network, Elixirium, 1,000 ELX each. In isolation, we could assume that Alice and Bob are equally interested in Elixirium’s success. We cannot be as confident, however, when we take their other holdings into consideration. If 1,000 ELX is only 1% of Alice’s total wealth, while for Bob it represents nearly 50%, their incentives are tough to compare. Alice might care about Elixirium much less than Bob does, even though they have the same stake. Consequently, her desire to act in the interest of the network might also not be as strong as Bob’s.
Proof of Authority: consensus model with Identity at Stake.
Proof of Authority, an alternative consensus mechanism in which the nodes validating blocks are the ones explicitly allowed to do so.
Staking identity means voluntarily disclosing who you are in exchange for the right to validate the blocks. This means that the benefits you derive from it are public and so are the nefarious actions you might undertake. Identity placed at stake can serve as a great equalizer, understood and valued the same by all actors. Individuals whose identity (and reputation by extension) is at stake for the securing of a network are incentivized to preserve the network.
For the concept to work in real, live settings, a few conditions need to be satisfied:
Identity must be true: meaning there needs to be a standard and robust process of verifying that validators are indeed who they claim they are.
Eligibility for staking identity should be difficult to obtain: so that the right to be a validator becomes earned, valued, and unpleasant to lose.
The procedure of establishing the authority needs to be the same for all validators: to ensure that the network understands the process and can trust its integrity.
The Ethereum Virtual Machine
The Ethereum Virtual Machine or EVM is the runtime environment for smart contracts in Ethereum. It is not only sandboxed but actually completely isolated, which means that code running inside the EVM has no access to network, filesystem or other processes. Smart contracts even have limited access to other smart contracts.
There are two kinds of accounts in Ethereum which share the same address space: External accounts that are controlled by public-private key pairs (i.e. humans) and contract accounts which are controlled by the code stored together with the account.
The address of an external account is determined from the public key while the address of a contract is determined at the time the contract is created (it is derived from the creator address and the number of transactions sent from that address, the so-called “nonce”).
A transaction is a message that is sent from one account to another account (which might be the same or empty, see below). It can include binary data (which is called “payload”) and Ether.If the target account contains code, that code is executed and the payload is provided as input data.
Upon creation, each transaction is charged with a certain amount of gas, whose purpose is to limit the amount of work that is needed to execute the transaction and to pay for this execution at the same time. While the EVM executes the transaction, the gas is gradually depleted according to specific rules.The gas price is a value set by the creator of the transaction, who has to pay
gas_price * gas up front from the sending account. If some gas is left after the execution, it is refunded to the creator in the same way.
Contracts can call other contracts or send Ether to non-contract accounts by the means of message calls. Message calls are similar to transactions, in that they have a source, a target, data payload, Ether, gas and return data. In fact, every transaction consists of a top-level message call which in turn can create further message calls.
ASICs (Application Specific Integrated Circuits)
It’s now impossible to profitably mine Bitcoin with your computer, you’ll need specialized hardware called ASICs. Nowadays all serious Bitcoin mining is performed on dedicated Bitcoin mining hardware ASICs, usually in thermally-regulated data-centers with low-cost electricity.
ERC-20 is a technical standard used for smart contracts on the Ethereum blockchain for implementing tokens. ERC stands for Ethereum Request for Comment, and 20 is the number that was assigned to this request. The clear majority of tokens issued on the Ethereum blockchain are ERC-20 compliant.
Application Binary Interface — a list of all the functions in the smart contracts along with their parameters and return values.
Solidity Bytecode and Opcode
Solidity is a high level programming language. We understand it but the machine doesn’t. When we install an ethereum client such as geth, it also comes with the Ethereum Virtual Machine, a lightweight operating system that is specially created to run smart contracts.
When we compile the solidity code using the solc compiler, it will translate our code into bytecode, something only the EVM can understand.
The compiled code is:
How is Gas Cost related to Smart Contract Code?
The combining of economic models with computational models is a common theme in ethereum. In the case of storage, users who want to store messages, data or program state on the blockchain have to pay to do so.Each opcode has a gas cost associated with it.Due to this requirement, some opcodes cost more gas than others. If you write a smart contract that stores a lot of useless information on the blockchain, anyone who calls that contract will be forced to pay the higher gas cost associated with executing those useless write operations you have left in your program. This means that smart contract users have an economic incentive to use smart contracts that are well written, store only what they need to on the chain, and thus cost less.
Uncles in Ethereum
These have nothing to do with family ties in the traditional sense. Instead, an uncle is a referred to as a network block which would normally be considered an orphan. Bitcoin users are well aware of how some blocks are orphaned because they were mined just after someone found the correct block header. Uncles work in a similar way, but there is a major difference.
Miners on the Ethereum network are incentivized to include a number of uncles every time a block is mined. This may sound very strange at first, as it allows “orphaned” blocks to still yield a reward for miners. This is another example of how Ethereum is very different from Bitcoin. In Bitcoin mining, an uncle would yield nothing.Some people may wonder why the Ethereum network is set up in such a way they would incentivize miners to include uncles.
Rewarding miners for producing uncles is an interesting incentive. Not everyone wants to mine at a large pool, and this move effectively promotes solo mining to a certain degree. It is also an incentive to join smaller mining pools, as uncles will still yield some form of reward. Any miner who is not part of a big pool often has to deal with slight network delays when new blocks are discovered. In some cases, uncles can be discovered with a split second off the official block being mined.
The second purpose comes in the form of increasing overall Ethereum chain security. Uncles are still subject to the same mining work as conducted to mine the main chain blocks.
As we have seen on the Bitcoin network, mining empty blocks serves no real purpose whatsoever. An empty uncle block would make no real sense either, yet there is a reward associated with it. So far, it does not appear anyone is purposefully mining empty uncle blocks, but that situation may come to change over time.