ZK + PARTH Bonus: Calculating how many users are needed to achieve 100,000 TPS
In this post, we will derive a formula which calculates the number of users that need to participate in a QED block to attain 100,000 TPS.
In our previous blog post, we showed that the TPS of QED running on a 2-to-1 configuration can be calculated as:
TPS(u)=Block Time# of Transactions=log4(u)∗(kr+knet)ktx∗u
In reality, QED uses a 4-to-1 proof configuration, where each decentralized proving job recursively verifiers 4 proofs and 4 delta merkle proofs for performance reasons, so the actual equation we can use to model our TPS is:
TPS(u)=Block Time# of Transactions=log4(u)∗(kr+knet)ktx∗u
Where:
u is the number of users participating in a block
ktx is the average number of transactions each participating user performs during the block
kr is the time it takes to recursively verify 2 proofs and associated delta merkle proofs (proving time for each job performed by the decentralized proving network)
knet is the time it takes to send a proof to a decentralized proof miner (~30kb)
The only downside of using a 4-to-1 configuration is that our proving time is slightly longer, notably ~500ms on consumer hardware instead of 380ms in the 2-to-1 configuration.
Calculating the numbers user required to hit 100,000 TPS
Using our formula, if we wanted to see how many users would need to participate in a block to attain a TPS of 100,000, we would need to solve the equation below for u:
100000=log4(u)∗(kr+knet)ktx∗u
To find the inverse, let's first clean up our equation a bit, we will say x represents our desired TPS:
t=log4(u)∗(kr+knet)ktx∗u
Let's clean things up a bit, substituting log4(u)=ln(4)ln(u) using the change of base rule for logarithms:
Multiplying by ktxln(4)kr+knet on both sides we get:
ktxln(4)kr+knett=lnuu
We want to solve for u, so remember our goal is to find some function f(t) such that u=f(t) where t is our desired TPS, so our target equation should start with u=some function of t. To get u isolated we need to find a function g(x) such that g(ln(u)u)=u, that way we can say that:
g(ktxln(4)kr+knett)=g(lnuu)
And since g(x) is defined such that g(ln(u)u)=u:
u=g(ktxln(4)kr+knett)
Or in other words:
Users(TPS)=g(ktxln(4)kr+knet⋅TPS)
Now we just have to find a function g(x) such that g(ln(u)u)=u.
To help us find such a function let's let y(x)=lnxx, therefore it follows that y−1(x)=g(x), so now we have simplified our original problem to finding the inverse of y(x).
y=lnxx
Let's first define z to equal z=y1=xlnx:
z=xlnx
We can then multiply both sides by x to get:
zx=lnx
Raising e to the power of both sides we get:
ezx=elnx
Simplifying, we get:
ezx=x
Let's now multiply both sides by −z⋅e−zx:
ezx⋅(−z⋅e−zx)=x⋅(−z⋅e−zx)
Simplifying, we get:
−z=−zx⋅e−zx
Now let's set p=−zx, and replace −zx with p in our equation:
−z=p⋅ep
It turns out that there is a function called the Lambert W function (referred to as W(x)) which has the property that:
W(x⋅ex)=x
Let's apply Lambert's W function to both sides of our equation:
W(−z)=W(p⋅ep)
Using the properties we know about Lambert's W function we can further simplify to:
W(−z)=p
Since p=−xz, we can rewrite this as:
W(−z)=−xz
Since z=y1, we can further rewrite our equation as:
W(y−1)=−yx
If we multiply both sides by −y, we now have an expression for x 🎉:
x=−y⋅W(y−1)
Hence, we now have a function which meets the desired requirements of g(x):
g(x)=−x⋅W(x−1)
And since we already showed that:
Users(TPS)=g(ktxln(4)kr+knet⋅TPS)
We now can now write a formula for the number of users that need to submit proofs in a block to attain a certain TPS on QED:
To keep our math simple moving forward, let's set the constant c to equal ktxln(4)kr+knet:
c=ktxln(4)kr+knet
Therefore, Users(TPS) can be rewritten as:
Users(TPS)=−TPS⋅c⋅W(TPS⋅c−1)
Let's use some experimental values from QED's internal testnet to calculate the number of users we need to attain 100,000 TPS on QED.
The proving time required to recursively verify 4 proofs and 4 corresponding delta merkle proofs that link to the nearest common ancestor merkle cap is ~500ms, so kr=0.5
The proof size is ~30kb, so lets say it takes 100ms to send over the network to any where around the world (it fits in a single TCP packet, so think of this as "ping" time)
Let's say each user submits an average of 3 transactions per block, so ktx=3
To keep our math simple, let's first solve for c=ktxln(4)kr+knet