26/04/2021
Pi’s Adaptations to Stellar Consensus Protocol (SCP)
Pi’s consensus algorithm builds atop SCP. SCP has been formally proven [Mazieres 2015] and is currently implemented within the Stellar Network. Unlike Stellar Network consisting mostly of companies and institutions (e.g., IBM) as nodes, Pi intends to allow devices of individuals to contribute on the protocol level and get rewarded, including mobile phones, laptops and computers. Below is an introduction on how Pi applies SCP to enabling mining by individuals.
There are four roles Pi users can play, as Pi miners. Namely:
Pioneer. A user of the Pi mobile app who is simply confirming that they are not a “robot” on a daily basis. This user validates their presence every time they sign in to the app. They can also open the app to request transactions (e.g. make a payment in Pi to another Pioneer)
Contributor. A user of the Pi mobile app who is contributing by providing a list of pioneers he or she knows and trusts. In aggregate, Pi contributors will build a global trust graph.
Ambassador. A user of the Pi mobile app who is introducing other users into Pi network.
Node. A user who is a pioneer, a contributor using the Pi mobile app, and is also running the Pi node software on their desktop or laptop computer. The Pi node software is the software that runs the core SCP algorithm, taking into account the trust graph information provided by the Contributors.
A user can play more than one of the above roles. All roles are necessary, thus all roles are rewarded with newly minted Pi on a daily basis as long as they participated and contributed during that given day. In the loose definition of a “miner” being a user who receives newly minted currency as a reward for contributions, all four roles are considered to be Pi miners. We define“mining” more broadly than its traditional meaning equated to executing proof of work consensus algorithm as in Bitcoin or Ethereum.
First of all, we need to emphasize that the Pi Node software has not been released yet. So this section is offered more as an architectural design and as a request to solicit comments from the technical community. This software will be fully open source and it will also heavily depend on stellar-core which is also open source software, available here. This means that anyone in the community will be able to read, comment and propose improvements on it. Below are the Pi proposed changes to SCP to enable mining by individual devices.
Nodes
For readability, we define as a correctly connected node to be what the SCP paper refers to as an intact node. Also, for readability, we define as the main Pi network to be the set of all intact nodes in the Pi network. The main task of each Node is to be configured to be correctly connected to the main Pi network. Intuitively, a node being incorrectly connected to the main network is similar to a Bitcoin node not being connected to the main bitcoin network.
In SCP’s terms, for a node to get correctly connected means that this node must chose a “quorum slice” such that all resulting quorums that include this node intersect with the existing network’s quorums. More precisely, a node vn+1 is correctly connected to a main network N of n already correctly connected nodes (v1, v2, …, vn) if the resulting system N’ of n+1 nodes (v1, v2, …, vn+1) enjoys quorum intersection. In other words, N’ enjoys quorum intersection iff any two of its quorums share a node. -- i.e., for all quorums U1 and U2, U1∩U2 ≠ ∅.
The main contribution of Pi over the existing Stellar consensus deployment is that it introduces the concept of a trust graph provided by the Pi Contributors as information that can be used by the Pi nodes when they are setting up their configurations to connect to the main Pi network.
When picking their quorum slices, these Nodes must take into consideration the trust graph provided by the Contributors, including their own security circle. To assist in this decision, we intend to provide auxiliary graph analysis software to assist users running Nodes to make as informed decisions as possible. This software’s daily output will include:
a ranked list of nodes ordered by their distance from the current node in the trust graph; a ranked list of nodes based a pagerank analysis of nodes in the trust graph
a list of nodes reported by the community as faulty in any way a list of new nodes seeking to join the network
a list of most recent articles from the web on the keyword “misbehaving Pi nodes” and other related keywords; a visual representation of Nodes comprising the Pi network similar to what is shown in StellarBeat Quorum monitor [source code]
a quorum explorer similar to QuorumExplorer.com [source code]
a simulation tool like the one in StellarBeat Quorum monitor that shows the expected resulting impacts to this nodes’ connectivity to the Pi network when the current node’s configuration changes.
An interesting research problem for future work is to develop algorithms that can take into consideration the trust graph and suggest each node an optimal configuration, or even set that configuration automatically. On the first deployment of the Pi Network, while users running Nodes can update their Node configuration at any time, they will be prompted to confirm their configurations daily and asked to update them if they see fit.
Mobile app users
When a Pioneer needs to confirm that a given transaction has been executed (e.g. that they have received Pi) they open the mobile app. At that point, the mobile app connects to one or more Nodes to inquire if the transaction has been recorded on the ledger and also to get the most recent block number and hash value of that block. If that Pioneer is also running a Node the mobile app connects to that Pioneer’s own node. If the Pioneer is not running a node, then the app connects to multiple nodes and to cross check this information. Pioneers will have the ability select which nodes they want their apps to connect to. But to make it simple for most users, the app should have a reasonable default set of nodes, e.g. a number of nodes closest to the user based on the trust graph, along with a random selection of nodes high in pagerank. We ask for your feedback on how the default set of nodes for mobile Pioneers should be selected.
Mining rewards
A beautiful property of the SCP algorithm is that it is more generic than a blockchain. It coordinates consensus across a distributed system of Nodes. This means that the same core algorithm is not only used every few seconds to record new transactions in new blocks, but also it can be used to periodically run more complex computations. For example, once a week, the stellar network is using it to compute inflation on the stellar network and allocate the newly minted tokens proportionally to all stellar coin holders (Stellar’s coin is called lumens). In a similar manner, the Pi network employs SCP once a day to compute the network-wide new Pi distribution across all Pi miners (pioneers, contributors, ambassadors, nodes) who actively participated in any given day. In other words, Pi mining rewards are computed only once daily and not on every block of the blockchain.
For comparison Bitcoin allocates mining rewards on every block and it give all of the reward to the miner who was lucky enough to be able to solve a computationally intensive randomized task. This reward in Bitcoin currently 12.5 Bitcoin (~$40K) is given to only one miner every 10 minutes. This makes it extremely unlikely for any given miner to ever get rewards. As a solution to that, bitcoin miners are getting organized in centralized mining pools, which all contribute processing power, increasing the likelihood of getting rewards, and eventually sharing proportionally those rewards. Mining pools are not only points of centralization, but also their operators get cuts reducing the amount going to individual miners. In Pi, there is no need for mining pools, since once a day everyone who contributed get a meritocratic distribution of new Pi.
Transaction fees
Similar to Bitcoin transactions, fees are optional in the Pi network. Each block has a certain limit of how many transactions can be included in it. When there is no backlog of transactions, transactions tend to be free. But if there are more transactions, nodes order them by fee, with highest-fee-transactions at the top and pick only the top transactions to be included in the produced blocks. This makes it an open market. Implementation: Fees are proportionally split among Nodes once a day. On every block, the fee of each transaction is transferred into a temporary wallet from where in the end of the day it is distributed to the active miners of the day. This wallet has an unknown private key. Transactions in and out of that wallet are forced by the protocol itself under the consensus of all nodes in the same way the consensus also mints new Pi every day.
Limitations and future work
SCP has been extensively tested for several years as part of the Stellar Network, which at the time of this writing is the ninth largest cryptocurrency in the world. This gives us a quite large degree of confidence in it. One ambition of the Pi project is to scale the number of nodes in the Pi network to be larger than the number of nodes in the Stellar network to allow more everyday users to participate in the core consensus algorithm. Increasing the number of nodes, will inevitably increase the number of network messages that must be exchanged between them. Even though these messages are much smaller than an image or a youtube video, and the Internet today can reliably transfer videos quickly, the number of messages necessary increases with the number of participating nodes, which can become bottleneck to the speed of reaching consensus. This will ultimately slow down the rate, at which new blocks and new transactions are recorded in the network. Thankfully, Stellar is currently much faster than Bitcoin. At the moment, Stellar is calibrated to produce a new block every 3 to 5 seconds, being able to support thousands of transactions per second. By comparison, Bitcoin produces a new block every 10 minutes. Moreover, due to Bitcoin’s lack in the safety guarantee, Bitcoin’s blockchain in rare occasions can be overwritten within the first hour. This means that a user of Bitcoin must wait about 1 hour before they can be sure that a transaction is considered final. SCP guarantees safety, which means after 3-5 seconds one is certain about a transaction. So even with the potential scalability bottleneck, Pi expects to achieve transaction finality faster than Bitcoin and possibly slower than Stellar, and process more transactions per second than Bitcoin and possibly fewer than Stellar.
While scalability of SCP is still an open research problem. There are multiple promising ways one could speed things up. One possible scalability solution is bloXroute. BloXroute proposes a blockchain distribution network (BDN) that utilizes a global network of servers optimized for network performance. While each BDN is centrally controlled by one organization, they offer a provably neutral message passing acceleration. I.e. BDNs can only serve all nodes fairly without discrimination as messages are encrypted. This means the BDN does not know where messages come from, where they go, or what is inside. This way Pi nodes can have two message passing routes: A fast one through BDN, which is expected to be reliable most of the time, and its original peer-to-peer message passing interface that is fully decentralized and reliable but is slower. The intuition of this idea is vaguely similar to caching: The cache is place where a computer can access data very quickly, speeding the average computation, but it is not guaranteed to always have every needed piece of information. When the cache misses, the computer is slowed down but nothing catastrophic happens. Another solution can be using secure acknowledgment of multicast messages in open Peer-to-Peer networks [Nicolosi and Mazieres 2004] to speed up message propagation among peers.