The Matching Engine follows the following algorithm to match Proof Requesters with Proof Generators:
- The Matching Engine picks an unassigned Proof Request from the queue.
- It checks whether the Assignment Deadline since the Proof Request was submitted onchain hasn't passed.
- It filters Generators who have registered in the Market corresponding to the Proof Request such that:
- Max Proof Generation Time (submitted by Requesters) <= MaxProofTime (quoted by Generators)
- Budget (submitted by Requesters) >= PricePerProof (quoted by Generators)
- Available native stake (that's not already locked up in a job) >= Native stake per job for the Market
- Available Symbiotic stake (that's not already locked up in a job) >= Symbiotic stake per job for the Market
- Available compute (that's not already being used) >= Minimum compute required per job for the Market
- Amongst Generators that meet the above criteria, a Generator is randomly picked with a probability such that:
- it is inversely proportional to PricePerProof
- it is inversely proportional to MaxProofTime
- it is inversely proportional to the number of times the Generator missed submitting a valid proof in the past 48 hours
Below is deeper logic behind the weighted_time_cost_random_selection
.
Let i∈{1,2,…,n} denote the index for each candidate.ci=Proof generation cost for candidate i,ti=Proposed time for candidate i,mi=Number of missed jobs for candidate i in last 48 hours ,mi≥0(assume mi=0 if no record exists).
1. Normalization
First, we define the maximum values for cost and time across all candidates. To avoid division by zero, if these maximums are zero, they are replaced by 1:
Mc=1≤j≤nmaxcj,with Mc=1 if jmaxcj=0,
Mt=1≤j≤nmaxtj,with Mt=1 if jmaxtj=0.
Each candidate's cost and time are normalized as:
c^i=Mcci,t^i=Mtti.
2. Weight Computation
The weight ( w_i ) for candidate ( i ) is computed by inverting the normalized cost and time (so that lower values yield higher weight) and then applying an exponential penalty based on the number of missed jobs:
wi=c^it^i1×2−mi.
Equivalently, substituting the normalized values, the weight can be written as:
wi=citiMcMt×2−mi.
3. Selection Probability
Candidate ( i ) is chosen with a probability proportional to its weight. That is, the probability ( P(i) ) that candidate ( i ) is selected is given by:
P(i)=j=1∑nwjwi=j=1∑ncjtjMcMt2−mjcitiMcMt2−mi.
Summary
The entire process can be summarized mathematically as follows:
-
Normalization:
c^i=maxjcjci,t^i=maxjtjti.
-
Weight Calculation:
wi=c^it^i1⋅2−mi=citiMcMt⋅2−mi.
-
Selection Probability:
P(i)=∑j=1nwjwi.