Introduction to the TEE computing task of Phala Network
Phala可信网络
2021-02-09 01:17
本文约2205字,阅读全文需要约9分钟
Welcome everyone to participate in the discussion

familiarPhala Economic White PaperFriends of mine may know that Phala’s mining rewards are divided into online rewards and computing task rewards. The second phase of the 1605 competition focuses on introducing calculation task rewards on the basis of online rewards. This article is an introduction to the computing tasks of the Vendetta testnet.

1. Background summary
  • The computing tasks in this testnet are generated virtually by the system, and each Round (600 blocks) generates 5 computing tasks fixedly. The amount of mining rewards is consistent with the white paper, where 50% of the rewards for each block dug out will be obtained by TEEs that perform privacy computing tasks, 30% of the rewards will be obtained by all online TEEs, and 20% will flow into the treasury through the chain Democratic governance by the Upper Council;
  • In the Vendetta test network, the minimum mortgage amount for CPU is 0 tPHA; TEE miners can use tPHA to make additional mortgages for their own CPUs, and anyone can also use their own tPHA to mortgage other TEE miners, but automatic distribution to nomination is not supported at the time of settlement person;
  • Within 1 Round, 1 TEE can be assigned to 1 computing task at most;
  • The algorithm and parameters of computing task distribution in the test network are experimental, and will be upgraded after the main network is launched; the settlement method of rewards may also change;
  • The flow of the TEE calculation task is roughly as follows:

code reading

2. Privacy computing task dispatching algorithm

2.1 Core Logic

  • Like any order dispatching algorithm, we need to assign the most appropriate TEE to complete the calculation according to the characteristics of the privacy computing task;
  • Therefore, the Phala Network system will score the characteristics of each TEE device according to the core requirements of computing characteristics, and obtain the Score of each TEE;
  • According to the Score of all online TEEs, the assignment results are calculated through the weighted random sampling formula;
  • After the assigned TEE completes the privacy calculation, the system will automatically settle and issue rewards. To ensure system security, rewards will be frozen for a period of time. (The reward issued by the Vendetta test network is FireII, which is only used for the statistics of the settlement prize pool and cannot be transferred).
2.2 TEE calculates the core indicators of order dispatch
  • The probability of TEE-CPU assigned to computing tasks mainly depends on two characteristics of the CPU: computing power and security.
  • The computing power is evaluated by the CPU score, and iterations will be realized through on-chain voting-no fork upgrade in the future;
  • Security is relative to a single CPU stake.
  • Computing power and security do not linearly increase the probability of TEE miners obtaining computing tasks. The probability formula will be elaborated in the next section.
2.3 TEE miners get a score for dispatch probability

According to the core indicators of TEE computing dispatch orders, we can calculate the fitness score of each TEE assigned computing tasks. The formula for calculating the score is as follows:

2.4 Weighted random sampling without replacement (weighted random sampling without replacement)

We use weighted random sampling without replacement (meaning that each TEE can only be drawn once), and randomly select N TEEs from all M online TEEs to perform computing tasks.

Weighting means that the probability score W of each TEE will be used as the basic value in sampling, that is, the higher the W, the higher the probability of being selected.

Example of weighted random sampling without replacement:

Assuming there are three machines A, B, and C, the A task is divided into 3, the B task is divided into 2, and the C task is divided into 1. Now one of the three machines is selected, and the probability of A being selected is

If two machines are drawn, the probability of A being drawn is

According to the actual situation of the first phase of the 1605 competition, five TEEs may be selected from thousands to tens of thousands of TEEs in a real environment, but the logic is consistent with the above example.

In order to allow TEE miners to predict their own probability of winning and simulate the relationship between the amount of mortgaged tPHA and the probability of winning, we will provide Dashboard's privacy calculation probability calculator, and miners can fill in their own machine performance and expected mortgage amount to simulate the probability of dispatching .

3. Data simulation of order dispatching algorithm 3.1 Correlation between additional mortgage amount and selection probability

Assuming that the TEE scores are consistent, the impact of different mortgage amounts on the selection probability.

The algorithm is clear, but based on the algorithm alone, the probability of a single mining machine being selected cannot be calculated, because the probability of being selected is related to the number of currently online mining machines and their task points. We simulated the increase in the probability of winning by the additional amount of collateral:

Assume that Rorschach has a 300-point TEE (red line in the figure), and assume that other TEEs are 5,000 machines with 420 points, and all of them are mortgaged with an additional 1,000 tPHA. If 5 of the 5001 (including Rorschach's) mining machines are selected to perform computing tasks, then as Rorschach increases additional mortgages, the probability of being assigned will increase as follows:

It can be seen from the figure:

  • The probability of 5 being drawn from more than a thousand machines is very low, about 0.05%;
  • As the mortgage amount increases, the probability increases rapidly at first, and then slowly;
  • But even if the mortgage amount increases to 20,000, the winning rate only increases to 0.17%.
3.2 Correlation between machine performance and selection probability

In the picture above, the light blue, red, yellow, and green machines have scores of 400, 300, 200, and 100 points respectively. It can be seen that the machine performance maintains a constant absolute advantage in the probability of winning.

3.3 How should multiple mining machines allocate additional mortgages?

Assuming that Rorschach has two identical mining machines, when the total amount of mortgage is the same, how to distribute the mortgage has little effect on the overall income. The simulated situation in the figure below is that Rorschach has two 420-point TEEs, and both have pledged 5000tPHA. The other TEEs are 5,000 units, 1,000tPHA collateral, all of which are 420 points.

Now Rorschach has 20,000tPHA, as shown in the picture below:

  • The far left side of the abscissa indicates that all 20,000tPHA was given to one of the TEEs, with a probability of 0.28%;
  • The far right is to give all 20000tPHA to another, which is also 0.28%;
  • The middle is evenly divided, with a probability of 0.32%.

It can be seen that the average distribution will be a little more than that of only one of them.forumforumDiscuss more with us.

About Phala

Phala Network is a privacy computing parachain on Polkadot. Based on a pow-like economic incentive model, Phala will build a distributed privacy computing cloud composed of hundreds of thousands of miners around the world, and then act as a Polkadot parachain to radiate all blockchains. Ecological Defi, data services and other applications. Phala-based applications pLibra and Web3 Analytics have received two grants from the web3 foundation. Inaugural members of the Substrate Builders Program. Member of the Linux Foundation. Member of the Privacy Computing Consortium (CCC).

Phala可信网络
作者文库