Sawtooth architecture

The Sawtooth architecture has five core components:

These five core components resemble the five forces that power Bitcoin, which we examined in previous chapters:

Sawtooth has a permissioned network in order to control who can connect, send transactions, and participate in the consensus.

Also, some default smart contract templates are provided. They're divided by function and grouped into transaction families. This is an innovative idea. There are smart contract templates for managing network settings, and off-the-shelf marketplace and supply chain solutions. There is also a tool for integrating Ethereum smart contracts with Sawtooth.

Users can develop further their own smart contracts and transaction families.

This approach is a little bit different from what we find in general-purpose smart contract platforms. In Ethereum, for example, the same generic instruction set, also known as opcodes, is used for all types of applications. So, smart contracts for financial services, media, supply chain, healthcare, and so on, would use the same toolbox of programming commands.

In Hyperledger Sawtooth, each transaction family has its own smart contract logic, composed of operations specific to that domain. This makes Sawtooth programming both restrictive and secure at the same time, as seen in the following diagram:

With a smaller code base, the flexibility of what you can do is restricted, but the probability of costly errors is smaller. This design choice follows a similar logic to the reason why the programming capabilities in Bitcoin were restricted from the outset.

Furthermore, Sawtooth enables developers to write smart contracts in a variety of languages, such as Python, JavaScript, C++, Rust, and Go. It's also flexible regarding virtual machines and both the Ethereum and JVMs can be used.

Sawtooth doesn't take a fundamental position on which consensus mechanism is best. Rather, it offers an interface that allows for a variety of consensus protocols to be used.

We can broadly distinguish two main approaches to consensus protocols:

The first, also known as Nakamoto consensus, elects a leader through some form of lottery. The leader then proposes a new block to be added to the blockchain. In Bitcoin, for example, the first miner to solve the PoW cryptographic puzzle wins the leader-election lottery.

The second approach, also known as Byzantine Fault-Tolerance uses votes among consensus participants to elect a leader.

The novel consensus algorithm Sawtooth proposes and adds to its stack is PoET. It is a Nakamoto-style consensus algorithm, designed for trusted enterprise environment. It allows a leader node to be elected randomly based on the time that the node has waited before proposing a block.

PoET provides a similar distribution of results to other lottery algorithms, such as PoW in Bitcoin. The probability of election is proportional to the resources contributed (in this case, resources are general-purpose processors, or CPUs, with a trusted execution environment). Code and data loaded inside the trusted execution environment are protected with respect to confidentiality and integrity.

In summary, the key innovations introduced by Sawtooth are the domain-specific smart contract layer and the PoET consensus algorithm. They are essentially modifications of the Ethereum Virtual Machine (EVM), and the Bitcoin PoW consensus protocol.

The project is neatly summarized by The Sawtooth team, as follows:

Sawtooth is a blockchain platform designed for enterprise usage. Sawtooth builds upon the learnings of platforms before it such as Bitcoin and Ethereum and is designed with a focus on modularity and extensibility. Sawtooth is unique from existing blockchain platforms in that it allows developers to program their smart contracts in a variety of traditional programming languages. Future Sawtooth developments will focus on increasing the throughput and privacy of transactions.

Now, let's move on to the other notable Hyperledger projects.