Big Phat Guide For Phala Network — Part One

ChrisBck
11 min readSep 30, 2023

A Guide For the Rest of Us!

This is part one of a series of articles that aims to demystify the internals of Phala Network. Most Phala literature is written for developers and engineers, or at least an audience with a decent level of technical savvy. This guide is for everyone else.

Phala is…

A large network of computers that can be accessed and used by anyone who wishes to rent them by staking PHA tokens. This is their stake-to-compute model, with the more tokens staked, the more processing power (sometimes called compute) is provided. When the user no longer requires the compute, they simply unstake and get all their tokens back! So, it’s not actually renting as the tokens you supply are returned in full.

Phala is a Cloud Computing service?

Essentially yes, but it is also important to note that cloud computing is different from cloud storage. Cloud storage is what you already know as Google Drive, Onedrive and Drobox. Phala doesn’t supply storage but can easily use any one of these services or any Web3 alternatives such as Crust Network, IPFS or Arweave.

Phala focuses purely on the processing of data. Similar services are offered by Big Tech companies Microsoft, Amazon and Google. However, Phala Network specialises in a particular niche in this field. The Big Tech companies offer a wider range of services that caters to Web2.0 solutions for big companies. They offer all sorts of suites and tools to manage and administrate the services, whereas Phala Network focusses on providing a secure and decentralised product.

Another notable factor is that Phala doesn’t provide a cloud computation service like a remote server rental which has to be administered and maintained. It provides the ability to run programs on these remote computers, all the hardware, security and administration is taken care of for you. It is a specific kind of cloud computing that offers more flexibility. Big tech products that align most closely are:

  • Microsoft Azure Functions
  • Amazon AWS Lambda
  • Google Cloud Functions

The advantages and workings of this type of technology will be described in more detail later.

Who is this service for?

Anyone really but is most likely going to interest Web3 builders at present. Cloud computing provided by Big Tech are similar in principle to Phala Network but there are key differences:

Cost
A big factor is cost. Not only are Web2 solutions expensive but it is also difficult to estimate how much it will cost you. Phala Network, on the other hand, offers a different approach. By staking your tokens, you’ll gain access to processing power. This straightforward method eliminates the complexity of cost estimation. Sure, you need to lock up more tokens to get more processing power, but it is returned when you are done with the processing.

Decentralisation
This is huge in Web3. When your operations run on Phala infrastructure, worries about a central authority flipping the off-switch vanish. You retain control. This isn’t merely a theoretical concept — history provides instances where central authorities shut down services, sometimes for policy breaches, sometimes for more contentious reasons. This power over a service’s fate, resting in the hands of a single entity, raises concerns. Even staying within terms and conditions isn’t a guarantee, as policy changes and external pressures (such as from Governments) can disrupt operations.

We can get an idea of just how much of the cloud computing infrastructure is controlled by a handful of companies by checking this infographic.

Source — https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/

Four companies today own 67% of the world’s $130 billion cloud market (Amazon, Microsoft, Google, and Alibaba) — https://botpopuli.net/digging-deeper-assessing-big-techs-capture-of-the-internets-infrastructure/

It’s crazy to think that a small number of companies, and basically a handful of people, are calling the shots in the cloud computing market. But when you connect the dots and think about who depends on this technology — even services like the media could be potentially swayed by these few players. Imagine if a tiny group could control the news you read — sounds sketchy, right? That’s why spreading out control matters so much in Web3.

So, in essence: decentralisation is all about keeping things fair and handing more power back to us regular folks. Just remember, all this is why Web3 is big on decentralisation.

Apart from Decentralisation, what makes Phala unique? What is its niche?

There are a few features which make Phala Network technology unique and special. There are a few words you will hear time and again when you hear about Phala. To the extent you may brush these off as just some other buzzwords. These are more than buzzwords though; I’ll take some time to explain them and explore why they are meaningful.

Off-Chain

Before explaining off-chain, we’ll layout what it means to be on-chain.

On-chain transactions and activities occur directly within the blockchain network. When a transaction is on-chain, it is recorded on the blockchain ledger, which is a tamper-proof database shared across the network’s nodes (computers). This means that the transaction data is publicly visible and verifiable by anyone on the blockchain.

Key characteristics of on-chain transactions include:

  • Transparency: Transaction details are publicly accessible.
  • Security: Transactions are secured by the blockchain.
  • Immutability: Once recorded, on-chain data is extremely difficult to alter.

Examples of on-chain activities include sending and receiving cryptocurrency, executing smart contracts, and recording data on the blockchain.

Off-chain means bypassing the blockchain and directly accessing the computers on the network (or on some other network or web2 solution). This is much faster as data can be processed without having to go through the blockchain update and verification mechanism (you’ve probably heard this being referred to as consensus). The results would usually then be recorded on the blockchain. This means bigger, processor intensive programs can be executed as there is no longer the same burden on the blockchain network, thus greatly reducing gas fees. I mentioned 3 key features of on-chain transactions:

  • Transparency
  • Security
  • Immutability

Does this mean we lose these features when we go off-chain? Usually yes, in fact this type of hybrid off-chain / on-chain processing is what is used in many supposed web3.0 dApps. Many web3 games run their game logic on web2 servers and simply write the results on a blockchain. This is not true web3 as they lose their decentralisation by being dependant on a centralised server. This is what sets Phala Network apart. Phala’s niche is its specialised technology that preserves the on-chain features mentioned, but with all the benefits of being off-chain and fully decentralised.

Security

Phala maintains robust security due to its software implementation and its strict hardware requirements for all the computers that make up its network. All the computers that are available for cloud computation must have special Trusted Execution Environments (TEE) capabilities. These are secure areas of a CPU which are dedicated to executing code in an ultra-secure manner. You are already using this type of hardware, possibly without knowing it. In your smartphone, this kind of technology is what runs your fingerprint or facial recognition routines. This type of processing has to be kept separate from normal processing and must be tamper proof, even with physical access to the device. These are known as secure enclaves, and this is where your code will run when you deploy it on Phala Networks’ cloud. Security is further bolstered by Phala’s blockchain. Access to these secure enclaves is governed by the Phala blockchain.

This means once the code is deployed, it cannot be altered or even seen by bad actors. Therefore, sensitive details such as customer private information is protected and secure by default. Think how often you see in the news, reports of companies that have had a data breach that led to email and private data being compromised. Here is a compiled list https://en.wikipedia.org/wiki/List_of_data_breaches. You may notice that many of these are huge corporations that will undoubtedly have their own IT security departments and available funds to provide high level security. The fact is, it is very difficult to guard against this type of thing in Web2, whereas Phala provides this solution out-of-the-box! As a side note, Phala does not provide the storage for such data but would process the data, encrypt it, then send it to the storage platform.

Trustless and Verifiable

This term is often associated with blockchain services but seldom explained. A trustless system is essentially a service where the need for trust has been removed. This can be achieved in several ways and depends on the application.

A simple example of a trustless transaction would be the sale of an NFT using a smart contract. The seller has put their NFT up for sale at a set price, he has signed a transaction, using the private keys stored in their crypto wallet which authorises the smart contract to transfer the ownership of the NFT on the condition that the set price has been paid. When the buyer agrees to the price and signs a transaction, again using their private crypto key, which authorizes the smart contract to transfer the agreed sum of crypto funds to the seller. When the signed transaction is confirmed, the smart contract will simultaneously transfer the funds to the seller and the NFT to the buyer. At no point was anyone trusted during this transaction, because the whole process was governed by code. As soon as the conditions were met, the goods were transferred automatically. Of course, it could be argued that the smart contract has to be trusted as it could be part of a malicious scam. This for the most part is true, however before signing the transaction, the details can be checked and verified. This does require technical savvy but the fact that it is possible means that no trust is required. Crypto wallets are becoming more friendly in this respect and are detailing exactly what you are signing. This makes it easier verify you are not being scammed.

“Talisman opens up and shows us the SignRequest with the message as plain text in the lighter gray frame. Note that Talisman is the perfect tool for when you have doubts about a dApps integrity. There is no guarantee that the dApps user interface shows you the same transaction request that it is actually requesting signing for. The Talisman interface, however, always shows the exact message or transaction that you are going to submit.”https://docs.talisman.xyz/talisman/navigating-the-paraverse/sending-and-receiving-funds/reading-transaction-details

This is fine for a simple NFT sale but how can cloud computing be trustless? Good question, even if I did ask it myself. A concrete, relatable example will help best to describe how this is possible. Imagine a scenario where a country has evolved a complex voting system for it government selection. The system is not a simple first past the post sort of deal. It has a complex scoring system, with different officials in each district being score weighted depending on their position held. The scores for each party are totalled up depending on what officials win their district. When the voters cast their vote, it is recorded on the blockchain anonymously, and they get a receipt with their transaction ID.

All the voting data is fed to a computer program running on off-chain computers. As the data is recorded on the blockchain it is safe and can’t be tampered with. Access to the cloud computation is also secured via the blockchain and the processing is done in the secure enclaves so is therefore also tamper-proof. After the voting period ends, the final result is calculated, but in a shock plot twist, a disgruntled failed candidate claims foul play and that the result is rigged. They claim that the process is flawed and the technology has been hacked. If only there was some way of verifying the votes and validating the data.

Well, because all the votes are recorded on the blockchain and can’t be changed. The votes can be verified without trust. Individuals can even check their vote by looking up the transaction ID on the blockchain. We can also run the same data through another computer (or many computers) running on the cloud and verify that we get the same results. We have verified and validated the results by replicating the process. We can even calculate a signature of the program being run, called a hash, and compare it with the signature with the original program that was created. This verifies that it is the exact same program, even if one single binary digit is changed, then it will have a completely different signature. Kind of like a fingerprint for software.

Because the system is provable in this way, no trust has to be placed as everything is verifiable. As long as we get the same results everytime from feeding in the same information, we can determine that the process is valid. Even if we don’t see the inner workings of the secure enclaves, we can be sure the results are verifiable and trustless.

You may see the following mantra being bandied about throughout the blockchain communities:
“Don’t trust, verify” or “less trust, more truth”.

They are simply fundamental principles that encourage you to seek evidence, validate claims and ensure the accuracy and truthfulness rather than relying on trust, which can be fragile and subject to manipulation. In comparison, centralised services from big tech are built heavily on trust and this can prove costly on the users or trustees.

Scalability

The ability for something to be able to grow is known as its scalability. Think back to any of the peak times in crypto. When there is so much buzz around crypto, everyone is making transactions and executing smart contracts. This results in networks slowing down and gas fees becoming expensive. If you remember back to when the Crypto Kitties game launched on Ethereum, it broke the network due to the amount of computation it generated. These incidents highlighted that blockchains have issues in scaling up to meet demand.

This is where scalable systems like Phala and Aws Lambda shine. The programs are uploaded and deployed on any available computer that can process them. They are not restricted to a single computer. So, to meet demand, copies of these programs can be made and then run on available processors. The programs are like a blueprint and when demand is increased, another instance of the program can be generated and deployed to take on the extra work. In Web2.0, you will be charged as more instances are deployed but with Phala, it is simply a matter of staking more tokens.

This is in a nutshell how Phala tackles the issue of scalability, it provides an elegant solution to the problem. There is a lot more to it than I have outlined but things start getting technical and outside the scope of this article. For more information on this I would recommend the following reading:

Summary

In essence, we have covered the ethos of Phala Network and what it achieves. We have not covered the how it achieves this yet. In the following articles we will look at the workings of the Phala blockchain and its tokens, as well as Phat Contracts. Phat Contracts are the programs that run on the Phala Network computers, they are very powerful tools that open up a world of possibilities.

--

--

ChrisBck

Phala Phanatic - Web3.0 Enthusiast - Lover of Technology