Skip to content

Instantly share code, notes, and snippets.

@jsign
Last active October 5, 2023 15:19
Show Gist options
  • Save jsign/44ef96c3762b6fb229aed7f9c5b03f71 to your computer and use it in GitHub Desktop.
Save jsign/44ef96c3762b6fb229aed7f9c5b03f71 to your computer and use it in GitHub Desktop.
2023-10-05 VKT bench

CPU: AMD Ryzen 7 3800XT 8-Core Processor

Client: geth

Random key-values proving in a VKT

##### VKT proof benchmark #####
Setup: **in-memory** tree with 1000000 random key-values...

For 1 random-key values of the tree:
	Generating proof took 39ms:
		Collected 8 polynomials evaluations to prove
		Collecting those polys evals (comm, evals, etc) took 0ms
		The rest (Multiproof + nits) took 39ms
	Serializing proof took 0ms
	Deserializing proof took 0ms

For 1000 random-key values of the tree:
	Generating proof took 210ms:
		Collected 7307 polynomials evaluations to prove
		Collecting those polys evals (comm, evals, etc) took 107ms
		The rest (Multiproof + nits) took 103ms
	Serializing proof took 7ms
	Deserializing proof took 45ms

For 2000 random-key values of the tree:
	Generating proof took 357ms:
		Collected 14352 polynomials evaluations to prove
		Collecting those polys evals (comm, evals, etc) took 189ms
		The rest (Multiproof + nits) took 167ms
	Serializing proof took 11ms
	Deserializing proof took 80ms

For 4000 random-key values of the tree:
	Generating proof took 650ms:
		Collected 28377 polynomials evaluations to prove
		Collecting those polys evals (comm, evals, etc) took 343ms
		The rest (Multiproof + nits) took 307ms
	Serializing proof took 20ms
	Deserializing proof took 156ms

For 8000 random-key values of the tree:
	Generating proof took 1292ms:
		Collected 56284 polynomials evaluations to prove
		Collecting those polys evals (comm, evals, etc) took 645ms
		The rest (Multiproof + nits) took 646ms
	Serializing proof took 36ms
	Deserializing proof took 309ms

For 16000 random-key values of the tree:
	Generating proof took 2706ms:
		Collected 111399 polynomials evaluations to prove
		Collecting those polys evals (comm, evals, etc) took 1180ms
		The rest (Multiproof + nits) took 1526ms
	Serializing proof took 68ms
	Deserializing proof took 598ms

Interpretation notes:

  • A VKT with 1 million nodes is generated (important assumption about depth!)
  • For each case, we generate a proof for X random key-values, so this is a bit pessimistic since, in an EVM block execution, there should be some “locality” behavior in the access which reduces the number of openings.
  • In each case, it’s detailed Collected XXXX polynomials evaluations to prove showing how many openings this proof must prove in each case.
  • As mentioned in the output, the VKT is in-memory. A client will have to optimize to try making loading nodes from disk to have the least amount of overhead as possible, but probably we need to account for some extra overhead from that.

Extra notes:

  • If proofs should also include post-state, then that should be accounted as extra overhead.

Raw benchmark of cryptography lib

In this benchmark, we forget about the VKT and just benchmark creating a multiproof for X number of polynomial openings.

##### Raw polynomials multiproof benchmark #####
For 1 polynomials:
	Proving:
		Proof serialization duration: 0.11ms
		Proof creation duration: 84ms
		Duration per step:
			Generate challenge r and powers : 0.02ms
			Calculate t, g(x) and D         : 30.59ms
			Calculate h(x) and E            : 20.41ms
			Calculate (h-g)(x) and E-D      : 0.00ms
			IPA for (h-g)(x) and E-D on t   : 33.73ms
	Verification:
		Proof deserialization duration: 0.11ms
		Total duration: 5ms
		Duration per step:
			Generate challenge r and powers                       : 0.01ms
			Calculating helper_scalars r^i/(t-z_i)                : 0.01ms
			g_2(t) = SUM y_i*(r^i/(t-z_i))=SUM y_i*helper_scalars : 0.06ms
			Compute E                                             : 0.32ms
			Compute E-D and verify IPA                            : 4.71ms

For 1000 polynomials:
	Proving:
		Proof serialization duration: 0.11ms
		Proof creation duration: 50ms
		Duration per step:
			Generate challenge r and powers : 2.33ms
			Calculate t, g(x) and D         : 13.89ms
			Calculate h(x) and E            : 4.11ms
			Calculate (h-g)(x) and E-D      : 0.00ms
			IPA for (h-g)(x) and E-D on t   : 30.27ms
	Verification:
		Proof deserialization duration: 0.11ms
		Total duration: 10ms
		Duration per step:
			Generate challenge r and powers                       : 3.47ms
			Calculating helper_scalars r^i/(t-z_i)                : 0.06ms
			g_2(t) = SUM y_i*(r^i/(t-z_i))=SUM y_i*helper_scalars : 0.05ms
			Compute E                                             : 2.81ms
			Compute E-D and verify IPA                            : 3.81ms

For 2000 polynomials:
	Proving:
		Proof serialization duration: 0.13ms
		Proof creation duration: 60ms
		Duration per step:
			Generate challenge r and powers : 5.52ms
			Calculate t, g(x) and D         : 19.88ms
			Calculate h(x) and E            : 4.03ms
			Calculate (h-g)(x) and E-D      : 0.00ms
			IPA for (h-g)(x) and E-D on t   : 31.38ms
	Verification:
		Proof deserialization duration: 0.13ms
		Total duration: 14ms
		Duration per step:
			Generate challenge r and powers                       : 5.89ms
			Calculating helper_scalars r^i/(t-z_i)                : 0.08ms
			g_2(t) = SUM y_i*(r^i/(t-z_i))=SUM y_i*helper_scalars : 0.05ms
			Compute E                                             : 4.74ms
			Compute E-D and verify IPA                            : 3.87ms

For 4000 polynomials:
	Proving:
		Proof serialization duration: 0.11ms
		Proof creation duration: 78ms
		Duration per step:
			Generate challenge r and powers : 11.09ms
			Calculate t, g(x) and D         : 30.85ms
			Calculate h(x) and E            : 4.03ms
			Calculate (h-g)(x) and E-D      : 0.00ms
			IPA for (h-g)(x) and E-D on t   : 32.32ms
	Verification:
		Proof deserialization duration: 0.11ms
		Total duration: 21ms
		Duration per step:
			Generate challenge r and powers                       : 9.28ms
			Calculating helper_scalars r^i/(t-z_i)                : 0.17ms
			g_2(t) = SUM y_i*(r^i/(t-z_i))=SUM y_i*helper_scalars : 0.03ms
			Compute E                                             : 8.11ms
			Compute E-D and verify IPA                            : 3.72ms

For 8000 polynomials:
	Proving:
		Proof serialization duration: 0.11ms
		Proof creation duration: 113ms
		Duration per step:
			Generate challenge r and powers : 25.60ms
			Calculate t, g(x) and D         : 53.76ms
			Calculate h(x) and E            : 4.03ms
			Calculate (h-g)(x) and E-D      : 0.00ms
			IPA for (h-g)(x) and E-D on t   : 30.55ms
	Verification:
		Proof deserialization duration: 0.11ms
		Total duration: 32ms
		Duration per step:
			Generate challenge r and powers                       : 16.05ms
			Calculating helper_scalars r^i/(t-z_i)                : 0.31ms
			g_2(t) = SUM y_i*(r^i/(t-z_i))=SUM y_i*helper_scalars : 0.03ms
			Compute E                                             : 13.42ms
			Compute E-D and verify IPA                            : 2.88ms

For 16000 polynomials:
	Proving:
		Proof serialization duration: 0.11ms
		Proof creation duration: 198ms
		Duration per step:
			Generate challenge r and powers : 64.94ms
			Calculate t, g(x) and D         : 99.44ms
			Calculate h(x) and E            : 4.06ms
			Calculate (h-g)(x) and E-D      : 0.00ms
			IPA for (h-g)(x) and E-D on t   : 30.49ms
	Verification:
		Proof deserialization duration: 0.11ms
		Total duration: 56ms
		Duration per step:
			Generate challenge r and powers                       : 32.02ms
			Calculating helper_scalars r^i/(t-z_i)                : 0.72ms
			g_2(t) = SUM y_i*(r^i/(t-z_i))=SUM y_i*helper_scalars : 0.03ms
			Compute E                                             : 21.26ms
			Compute E-D and verify IPA                            : 2.92ms

For 128000 polynomials:
	Proving:
		Proof serialization duration: 0.12ms
		Proof creation duration: 3000ms
		Duration per step:
			Generate challenge r and powers : 2221.08ms
			Calculate t, g(x) and D         : 743.75ms
			Calculate h(x) and E            : 4.04ms
			Calculate (h-g)(x) and E-D      : 0.00ms
			IPA for (h-g)(x) and E-D on t   : 31.76ms
	Verification:
		Proof deserialization duration: 0.12ms
		Total duration: 402ms
		Duration per step:
			Generate challenge r and powers                       : 260.35ms
			Calculating helper_scalars r^i/(t-z_i)                : 17.53ms
			g_2(t) = SUM y_i*(r^i/(t-z_i))=SUM y_i*helper_scalars : 0.04ms
			Compute E                                             : 121.05ms
			Compute E-D and verify IPA                            : 3.59ms

Interpretation notes:

  • The current implementation tries to parallelize a decent amount of work, so core number is quite important.

Other notes:

  • It’s planned to run these benchmarks in less powerful CPUs, like in a Rock5B.
  • When the new Kaustinen network is working, we can try logging “real-ish” e2e benchmark provings to avoid a bit these synthetic setup. That can account for extra overhead at the geth layer (e.g: node loading from disk if needed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment