A Blockchain is a globally shared, publicly viewable, transactional database; one in which everyone can participate and read entries. Blockchains were first made famous by Bitcoin, and since then they have grown and taken on a large number of different implementations and architectures. BlockApps' STRATO platform is based on the Ethereum blockchain protocol. Ethereum allows for the use of Smart Contracts to store data and perform verified computations on the stored data with the Blockchain.
A Block is an object that contains data. This data is both metadata about a specific block, and information about the state of the blockchain itself. Blocks contain information that can be modified over time, allowing it to act as a ledger. This ledger of information is what makes blockchain useful for maintaining data verifiability and auditability, since all changes to data are recorded and viewable on a block. Instructions on how this data is changed is recorded and is stored in the form of a transaction. A block is the building block on which a blockchain is created - blocks they are stored in a consecutive, ordered list as new information is created and recorded.
Blocks are Chained together by a reference to the hash of the block before it. If any data in a block is changed, consequentially its hash is also changed. Therefore any change to data in one block cannot occur without affecting all the data of the subsequent blocks. By having a network agree on the data within each block, it provides verifiability of the data within each block. A single member cannot modify the data without other members also agreeing on that change. To accomplish this distributed agreement, blockchains use a consensus mechanism. The consensus mechanism used varies based on each Blockchain's implementation.
- Data is visible to all parties.
- History of past data values is visible to all parties.
- Every member contributes to the correctness of data.
- User real-world identities are not traceable from their blockchain address.
- Efficient data storage and hashing allow for scalable applications.
- See Merkle Trees. 1
Ethereum builds on the concept of a blockchain by enabling:
- Easy to understand and use.
- Benefits and usages applicable to everyone.
- Contracts are able to operate discretely.
- Non-discrimination and Non-Censorship
- The Ethereum Platform cannot single out parties from participating in it.
Ethereum integrates programming logic into a blockchain. It allows complex applications to be built using the benefits of a blockchain like auditability and verifiability. All data being stored or new state being computed is universally agreed upon by the entire network. Ethereum uses smart contracts to define the way the application state should be created and modified. The standard Ethereum network uses tokens known as Ether to attach value to running such contracts. The larger or more instructions a contract has, the more Ether it takes to run. While STRATO is built on and fully Ethereum compliant, it does not use tokens as means of value. Furthermore STRATO builds on top of Ethereum to provide a faster, more efficient platform for Enterprise use cases.
We highly recommend reading the Ethereum Whitepaper to learn the basics of Ethereum, and its implementation of blockchain technology.
Below is a excerpt from the Whitepaper explaining its usage of smart contracts.
A Next-Generation Smart Contract and Decentralized Application Platform.
What Ethereum intends to provide is a blockchain with a built-in fully fledged Turing-complete programming language that can be used to create "contracts" that can be used to encode arbitrary state transition functions, allowing users to create any of the systems described above, as well as many others that we have not yet imagined, simply by writing up the logic in a few lines of code.2
Blocks are the fundamental data structure on a blockchain. A Block is created by a node of a blockchain network and broadcast to the other nodes for approval before being inserted into the chain. Blocks are structures which hold transactions, and metadata about the block itself, such as its number, or timestamp. Most importantly it also stores the hash of the data from the previous block in the chain, aptly named the "previous block hash". This fundamentally links blocks together since any change of data in one block will cause every subsequent block to have a different parent hash than what was originally recorded. Since every member of a network must agree that the data within each block is correct, it prevents any one member from proposing a new block with tampered data. The change of the block's hash would be noticed by the network and the block would be discarded. Blocks are further secured from modification since each transaction is cryptographically signed by the account that created the transaction, allowing the identity of the transaction sender to be verified.
The part of a block that contains the most meaningful data is its transactions. Transactions are essentially state transition functions, which allow for data to be created, and modified in a defined method. A block contains a state root field which enables the global state to be verified with a hash of the current state. If a proposed block has a different state root than expected, then this is a "state mismatch", indicating that the node that created block did not run the transactions correctly or as expected.
A STRATO block follows the Ethereum block protocol, and therefore contains the same headers and fields as a block from the Ethereum network.
The first block of a blockchain is known as a Genesis Block. The Genesis Block simply declares what the initial state of the chain should be. Like any block, all nodes within a network must agree on the data within this block. Any new node joining a network must have the same Genesis Block as the one on the network. The Genesis Block therefore is defined before the creation of the chain and is stored in a file on a node. It is usually obtained by new parties through some file sharing process. A node without an identical Genesis Block will not be allowed to join a network. This is a natural consequence of the block's containing the parent hash of the previous block. A different Genesis Block causes an instant mismatch of data.
Unlike Bitcoin, in STRATO there is no competition to create or "mine" the next block, so every node within the network works cooperatively together to form and verify the next block. This can be accomplished since STRATO is a permissioned blockchain where each party is known and trusted.
A Node is a computer that is connected to a blockchain network. A node performs four main functions:
- A node stores blocks, transaction data, account state, and other data related to the blockchain.
- A node participates in the network by creating its own contracts and data.
Validates Data/Creates Blocks
- A node can either be a or a Node. This feature is unique to STRATO and allows for more efficient transaction validation.
- A verifies that the data within a block is correct and subsequently inserts into the Blockchain. It participates in the consensus algorithm with other Validator Nodes to make an agreement on the blockchain state.
- A Node does not participate in the verification or creation of new blocks. It only receives new block data.
- See STRATO PBFT for more information on node types.
Communicates with Peers
- Since a blockchain is a network of many nodes, it both sends and receives information about the blockchain. This includes all the blocks on the blockchain, and any transactions that must be completed.
- A node also sends out information to other nodes regarding relevant data they needs such as a list of peers and their information (public key and IP address), and Private Chain data if another node is a member.
At any given moment, a single Validator Node acts as the Proposer Node of the network. The Proposer Node receives transaction information and creates a block out of that data. Once a full block has been created, it is broadcasted to the rest of the Validator Nodes for validation. STRATO uses the concept of "rounds" to choose new Proposers. A round is recorded by storing the current . The round number is incremented every 10 seconds indicating the next round has begun. In each new round, a new Proposer Node is selected automatically by the network. Like other mechanisms on the blockchain, the round number and new Proposer Node must be agreed upon by at least ⅔ of the network's Validator Nodes.
A Network is a group of nodes communicating with each other to run the same blockchain. Within STRATO, every network has a custom Network ID that allows it to be uniquely identified from any other STRATO network. This prevents communication between two nodes that are not part of the same network.
In STRATO, a Node's number of peers its connected to in the Network is controlled by a configuration option that allows node operators to connect to more or less peers. In general there is a tradeoff between more connections and a Node's communication performance, however more connections allows immediate and direct communication of blocks and private chain data.
The first node (Root Node) creates the blockchain using the Genesis Block. At this point the blockchain network is a single node since there are no other members.
Joining a Network
Within STRATO, any new node may join an existing network by obtaining the network's ID, and the information of another member node. This information is used at STRATO boot time so the node may begin connecting with the network. After the program has started successfully, the nodes in the network will perform a "handshake" confirming their identities. The node is now part of the network on the Main Chain and will begin syncing with the network to obtain all of blocks on the chain. The management of networks is a complex topic, so view the Network Governance Page to learn more about this topic, such as how to start a network or add new member nodes.
One of the most important aspects of a blockchain is group consensus. All network members form an agreement to provide data verifiability and reliability. There is never one party in control of how data gets inserted or modified on the blockchain. Members form an agreement on any new data by attesting to the validity and correctness of the data.
A network arrives at a consensus through a defined Consensus Algorithm. A consensus algorithm is a process through which the members of the network communicate with each other, sharing their vote on the validity of the data. Consensus algorithms vary greatly depending on the use case, and each one has advantages and disadvantages.
There two main categories of consensus algorithms used within blockchains: Proof of Work, and Proof of Stake. Outside of the application of blockchain, there are many other consensus algorithms that exist.
Consensus vs. Block Creation
There is a subtle but important difference between achieving consensus on a block, and the actual creation of a block.
is the process through which a new block is created. A block must contain valid data to be inserted into the chain. The consensus algorithm determines what is "valid data". In theory a block with any arbitrary data could be proposed to the network, however there are only relatively a small number of valid new blocks.
is the method through which the members of a network decide on the validity of a new block. This includes the definition for what qualifies as a valid block. It also defines any other necessary requirements for a new block to be inserted, such as a majority agreement. Think of this as how a group people might decide on what restaurant to eat at: if a majority of people want to eat a restaurant, than that restaurant is chosen. However perhaps it is a someone's birthday, than that person decides and they have final say. These two methods are the group's different consensus algorithms.
The time between block creation to block insertion is called the "Block Time".
Proof of Work
The two popular cryptocurrencies Bitcoin and Ethereum both currently use Proof of Work consensus algorithms. Proof of Work systems operate by having each member compete to create a new valid block containing the necessary transactions. This process is computationally intensive and serves to incentivize members to act cooperatively. Members will not want to waste energy on creating a block which will not accepted. Once a valid block is created, it is proposed to the rest of the network. Usually after some majority of other members agree on the validity of the new block, it is inserted onto the chain. Proof of Work algorithms are designed to make it hard to arrive at the correct solution, but the solution is easy to verify once it has been computed.
There are many downsides to Proof of Work algorithms, most significantly the immense energy consumption and long times for new blocks to be created. Furthermore since there are infinitely many valid next blocks for any given current block, two different members may both propose different blocks for the same block number. This causes a fork in the chain, forks are resolved in blockchains by "following" the first fork to contain six (usually) or more subsequent blocks. This causes an unreliability in transaction finality, since a transaction might end up in a forked chain which does not become the main chain.
Proof-of-Work algorithms are , causing large amounts of power to be consumed, and huge stress to be placed on the energy grid as a whole.3 Similarly, networks with Proof-of-Work enforce long block times which naturally causes a slow network - Ethereum block times are typically around 13s. 4 This means that any transaction sent by a user will not usually be executed until several seconds later. This far from optimal for large scale enterprise applications with large amounts data needing to be processed.
For these reasons, STRATO does not use a Proof of Work algorithm to achieve consensus. STRATO is able to do this since it runs on networks with trusted parties - there is relatively no reason for a member to act out of turn. Furthermore, STRATO transactions can be executed extremely quickly, with average block times < 1s.
Proof of Stake
Proof of Stake operates by enabling members to put a stake on the validity of a block they have created. The stake that is used is some type of token that holds value. The party creating the block has incentive to create a valid block since they will lose their stake if it is invalid. After a new block is proposed, it is validated in a similar way by the other members of a network.
While this method is a great improvement from Proof of Work, it relies on a network having some type of intrinsic token with value. Since STRATO is not designed to be a cryptocurrency or have a token of value, Proof of Stake would not make sense to use in STRATO.
STRATO employs the PBFT (Practical Byzantine Fault Tolerance) consensus algorithm. PBFT requires a ⅔ majority of members to reach consensus on the contents of a proposed block. It also is ideal for synchronous networks or possible failures as it allows up to ⅓ of members to temporarily disconnect, be out of sync with each other, or even attest to bad blocks (the member is said to be "byzantine").
PBFT uses a slightly complex system of communication between nodes to function however the technical details are not necessary for the understanding of how the consensus operates within a STRATO network. If you wish to learn more about PBFT, visit the STRATO Consensus documentation.
- A new block is created and broadcast to the network
- Each validator node verifies that this block is valid.
- If the block is valid, the node broadcasts a message in agreement with this block to the network.
- If the block is invalid, the node broadcasts a message in disagreement with this block to the network.
- If a two-thirds majority are in agreement that a block is valid, each node will send a message indicating this block should be inserted into the chain.
- If a two-thirds majority receive this message, the block is added to the chain.
In any Ethereum-based blockchain, all data is stored in objects called Accounts. An account has a location or that allows it be located on the blockchain. Addresses are simply hexadecimal numbers, for example
0xb10cca445b10cca445b10cca445b10cca445b10cca. STRATO accounts differ from Ethereum addresses because STRATO accounts are represented by both an
address and a
chain ID. Standard Ethereum does not have the concept of a chain ID since there is only one chain. You can think of accounts like a street address - the
address represents the street number and the
chain ID represents the street name. You would not be able to find a house if you only had one, but by having both you can go to exactly the right place. What the house contains is the account data.
- A counter incremented every time this account performs a transaction.
- This is used to ensure that a transaction can only be processed once. Any transaction that is seen with a nonce that is not the expected nonce of the account is discarded.
- The account's current token balance.
- Contract Code
- The account's contract code if it is a contract.
- An external account's contract code is empty.
- The account's storage if it is a contract.
- An external account's storage is empty.
- External (User) Accounts
- Represents an actual human user's data.
- This address is associated with the public-private key pair of a user, as well as their real-world identity.
- Address is generated from a user's
- Must have a Verified Identity in order to perform transactions.
- Contract Accounts
- Represents a smart contract stored at this address.
- Address is generated from the contract creator's
- Behavior defined by its contract code.
- Holds state data and smart contract functions.
Each type of account can perform transactions on/with another account, based on the type of the other account.
A STRATO user is a single user-account of an Identity Provider, such as Google, Auth0, or any other OAuth Provider. A user uses this account to sign-in and interact with STRATO and is associated with a unique blockchain address. A user's account is also associated with a verified real-world identity via an X.509 Certificate. STRATO uses an encrypted key vault to securely store users' keys and related account info so only an authorized user can access this information. This allows STRATO to easily retrieve a user's blockchain identity (address, public/private keys) when an authorized request (request is authorized with the Identity Provider) comes in. Users do not need to worry about manually creating, or signing transactions with keys, or remembering their account address. User's only need to use their normal sign-in credentials they are familiar with using, like an email and password through whatever Identity Provider has been setup on the network.
An Organization is a group of users within a network that are all associated with the same entity, just like a real world organization. Organizations can represent companies, interest groups, or just organizations. In STRATO, organizations are used to permission data within the blockchain network. This allows multiple groups to participate in an industry application while maintaining data privacy and confidentiality. Users are associated with organizations and groups within those organizations via signed X.509 certificates. This ensures the validity of the user's membership to the organization since it is verified by the certificate issuer.
The data contained within an account is referred to as its "state". However normally when we are referring to the state of an Account, we are referring to the values that the variables hold within its contract code. This only pertains to Contract Accounts. State data is stored "locally" in this account, however ultimately data from each contract account contributes to the global state of the blockchain. This global state is represented in the "state root" field of a each block. As a result, any change to local state will affect the state of the blockchain as a whole.
Transactions are cryptographically signed payloads of instructions from a user account that update the state of other accounts on the blockchain. There are three types of transactions on the STRATO platform:
- Contract Creation
- A new contract account is created at a new address.
- The transaction payload contains the contract code to be posted.
- Contract Function Call
- A function of an existing contract account is invoked, causing the code defined in it to run.
- The transaction payload contains the address of contract account, the name of the function, and any arguments that are passed to the function's parameters.
- Token Transfer
- An account of any type sends tokens from its balance to the balance of another account.
- The transaction payload contains the address of the receiving account and the amount of tokens being transferred.
Contract Accounts may perform all the same functions, however, they are only done when a user account creates a transaction to begin those processes. Therefore any functions that contract account performs as a result of a user account transaction are all bundled into the same user account transaction - a transaction is every process that is instigated and terminated from the initial transaction process. Contract Accounts do not create transactions of their own.
In order to maintain integrity, traceability, and accountability of data on STRATO Mercata, STRATO 8.0 requires all users have a Verified Identity in order to make a transaction.
Transactions are simply instructions of how to change the current state of the blockchain data. This change can be direct (token transfer), or a complex (function call). A function call is called complex because it uses predefined logic in the contract code to calculate the next state. An token transfer is simple because it is unconditional and direct. A transaction that creates a new contract is essentially creating a new account, or adding more data to the state. This contract itself holds data that contributes to the state.
Because all transactions have well-defined behavior, transactions are often referred to as "state transition functions". A state transition function is set of instructions that allow a current state to become a new state in a predictable defined way - given the current state of the system and an input, the output and new state can easily be determined. As an example, a contract function governs the rules of how its variables are modified and used. The contract code is defined once and cannot be changed again. Therefore whenever this function is called, the output of the contract's state is known.
While each account has its own state, the combination of all the account states form the state of the entire blockchain. Therefore there are an uncountable number of possible global states for the blockchain to be in at any one time. Each small transaction creates a new global state.
- A transaction is created by a user account by creating a transaction payload, and signing it with their private-key.
- The transaction is broadcasted to every node in the network.
- Each node puts the transaction in a staging queue. The staging queue contains transactions that have been sent, but have yet to been put into blocks.
- The Validator Nodes checks the validity of the transactions in the queue by ensuring that:
- The nonces are consistent with the expected nonces.
- The account balances of each sender meets the transaction's gas requirements (if gas is enabled on your network).
- Once the nodes come to an agreement about the validity of each transaction, the transactions are put into a block by the Proposer Node.
- The block enters the verification/consensus algorithm as described in Validation/Consensus.
- Once the block is verified, its transactions are processed and the new state is computed with the result of the block's transactions.
- The new state data is written to the block and the block is inserted into the chain.
Smart Contracts are programs that govern the behavior of accounts on the blockchain. Smart Contracts are written in a high level programming language called Solidity which supports:
- Static Types
- Complex User Defined Types
Smart contracts allow for complex logic defining how data can be used or modified. They are especially useful in applications implementing Voting, Arbitration, Blind Auctions, Supply Chain Management, or Asset Tracking. Since all behavior is well-defined and agreed on by every member participating in the application, there is no room for unclear or "grey areas" of the rules. Smart Contracts operate on the principle of "the code is the truth". The program being run is a contract between the caller, and the user who created the program. The agreement in the contract is how data should be created and modified.
A contract is a form of an account (contract account), therefore every contract has a unique address. The address of a contract is determined at the time the contract is created by hashing the contract creator's
Because smart contracts involve a whole world of logic and programming, the full breadth of their capabilities and intricacies will not be discussed here. Visit the STRATO VM and Developing Smart Contracts to learn more about Solidity in STRATO, and writing real contracts for applications.
- Ethereum Docs discussing Blockchains
- Smart Property
- MIT's Opencourseware on Bitcoin
- Satoshi Nakamoto's Whitepaper introducing Bitcoin
- Understanding the Bitcoin Whitepaper
- Upgradeable Smart Contracts
- Smart Contracts