Published on

# ZK + PARTH Bonus: How Many Concurrent Users does QED need to hit 100,000 TPS

Authors
• Name
Carter Jack Feldman
@cmpeq

# 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)=\frac{\text{\# of Transactions}}{\text{Block Time}}=\frac{k_{\text{tx}}*u}{\log_4(u)*(k_r+k_{net})}$ 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)=\frac{\text{\# of Transactions}}{\text{Block Time}}=\frac{k_{\text{tx}}*u}{\log_4(u)*(k_r+k_{net})}$

Where:

• $u$ is the number of users participating in a block

• $k_{tx}$ is the average number of transactions each participating user performs during the block

• $k_r$ 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)

• $k_{net}$ 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=\frac{k_{\text{tx}}*u}{\log_4(u)*(k_r+k_{net})}$

To find the inverse, let's first clean up our equation a bit, we will say $x$ represents our desired TPS:

$t=\frac{k_{\text{tx}}*u}{\log_4(u)*(k_r+k_{net})}$

Let's clean things up a bit, substituting $\log_4(u)=\frac{\ln(u)}{\ln(4)}$ using the change of base rule for logarithms:

$t=\frac{k_{\text{tx}}*u}{\log_4(u)*(k_r+k_{net})}=\frac{k_{\text{tx}}*u}{\frac{\ln(u)}{\ln(4)}*(k_r+k_{net})}=\frac{k_{tx}}{\frac{k_r+k_{net}}{\ln(4)}}*\frac{u}{\ln(u)}=\frac{k_{tx}\ln(4)}{k_r+k_{net}}*\frac{u}{\ln{u}}$

Multiplying by $\frac{k_r+k_{net}}{k_{tx}\ln(4)}$ on both sides we get:

$\frac{k_r+k_{net}}{k_{tx}\ln(4)}t=\frac{u}{\ln{u}}$

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=\text{some function of t}$. To get $u$ isolated we need to find a function $g(x)$ such that $g(\frac{u}{\ln(u)})=u$, that way we can say that:

$g\left(\frac{k_r+k_{net}}{k_{tx}\ln(4)}t\right)=g\left(\frac{u}{\ln{u}}\right)$

And since $g(x)$ is defined such that $g(\frac{u}{\ln(u)})=u$:

$u=g\left(\frac{k_r+k_{net}}{k_{tx}\ln(4)}t\right)$

Or in other words:

$\text{Users}(TPS)=g\left(\frac{k_r+k_{net}}{k_{tx}\ln(4)}\cdot TPS\right)$

Now we just have to find a function $g(x)$ such that $g(\frac{u}{\ln(u)})=u$.

To help us find such a function let's let $y(x)=\frac{x}{\ln{x}}$, 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=\frac{x}{\ln{x}}$

Let's first define $z$ to equal $z=\frac{1}{y}=\frac{\ln{x}}{x}$:

$z=\frac{\ln{x}}{x}$

We can then multiply both sides by $x$ to get:

$zx=\ln{x}$

Raising $e$ to the power of both sides we get:

$e^{zx}=e^{\ln x}$

Simplifying, we get:

$e^{zx}=x$

Let's now multiply both sides by $-z\cdot e^{-zx}$:

$e^{zx}\cdot(-z\cdot e^{-zx})=x\cdot (-z\cdot e^{-zx})$

Simplifying, we get:

$-z=-zx\cdot e^{-zx}$

Now let's set $p=-zx$, and replace $-zx$ with $p$ in our equation:

$-z=p\cdot e^p$

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\cdot e^x)=x$

Let's apply Lambert's W function to both sides of our equation:

$W(-z)=W(p\cdot e^p)$

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=\frac{1}{y}$, we can further rewrite our equation as:

$W\left(\frac{-1}{y}\right)=-\frac{x}{y}$

If we multiply both sides by $-y$, we now have an expression for $x$ 🎉:

$x=-y\cdot W\left(\frac{-1}{y}\right)$

Hence, we now have a function which meets the desired requirements of $g(x)$:

$g(x)=-x\cdot W\left(\frac{-1}{x}\right)$

And since we already showed that:

$\text{Users}(\text{TPS})=g\left(\frac{k_r+k_{net}}{k_{tx}\ln(4)}\cdot \text{TPS}\right)$

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:

$\text{Users}(\text{TPS})=-\text{TPS}\cdot\left(\frac{k_r+k_{net}}{k_{tx}\ln(4)}\right)\cdot W\left(\frac{-1}{\text{TPS}\cdot\left(\frac{k_r+k_{net}}{k_{tx}\ln(4)}\right)}\right)$

To keep our math simple moving forward, let's set the constant $c$ to equal $\frac{k_r+k_{net}}{k_{tx}\ln(4)}$:

$c=\frac{k_r+k_{net}}{k_{tx}\ln(4)}$

Therefore, $\text{Users}(\text{TPS})$ can be rewritten as:

$\text{Users}(\text{TPS})=-\text{TPS}\cdot c \cdot W\left(\frac{-1}{\text{TPS}\cdot c}\right)$

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 $k_r=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 $k_{tx}=3$

To keep our math simple, let's first solve for $c=\frac{k_r+k_{net}}{k_{tx}\ln(4)}$

$c=\frac{k_r+k_{net}}{k_{tx}\ln(4)}=\frac{0.5+0.1}{3\ln(4)}=\frac{0.6}{3\ln(4)}\approx0.1442695$

So $\text{Users}(100000)$ can be written as:

$\text{Users}(100000)=-100000\cdot\frac{0.6}{3\ln(4)}\cdot W\left(\frac{-1}{100000\cdot\frac{0.6}{3\ln(4)}}\right)$

Approximating for $\frac{0.6}{3\ln(4)}$, we get:

$\text{Users}(100000)=-14426.95\cdot W(-0.000069314718)$

To evaluate the Lambert W function, we can use Wolfram Alpha: (we round up because there is no such thing as 0.166 of a user)

Hence, we arrive at the result that a block must have 174,096 users participating in a block to hit 100,000 TPS!

$\text{Users}(100000)=174096$

Let's check with our original equation just to make sure:

$TPS(u)=\frac{\text{\# of Transactions}}{\text{Block Time}}=\frac{k_{\text{tx}}*u}{\log_4(u)*(k_r+k_{net})}$

Plugging in $u=174096$, we get the correct answer 🎉

$TPS(174096)=\frac{3*174096}{\log_4(174096)*(0.5+0.1)}\approx 100000.4392383768 \text{ TPS}$