原文

Ethereum Foundationからの助成金を受け、最近ConstantineにPeerDASのサポートを追加しました。

最先端の研究と慎重なエンジニアリングを組み合わせることで、c-kzg-4844と比較して30%の高速化を実現し、プリコンピュテーションテーブルのメモリ使用量を4分の1に削減しました(そして、より多くのメモリはより多くの高速化につながります)。これは、リソースに制約のあるデバイスにとって大きな助けとなるはずです。

ベンチマークプリコンピュートc-kzg-4844 (シリアル)constantine (シリアル)Δ%
blob_to_kzg_commitment29.857 ms19.556 ms-34.5%
compute_kzg_proof31.482 ms20.235 ms-35.7%
compute_blob_kzg_proof31.691 ms19.858 ms-37.3%
verify_kzg_proof0.802 ms0.568 ms-29.1%
verify_blob_kzg_proof1.196 ms0.955 ms-20.2%
verify_blob_kzg_proof_batch 11.203 ms1.044 ms-13.2%
verify_blob_kzg_proof_batch 22.017 ms1.608 ms-20.3%
verify_blob_kzg_proof_batch 43.600 ms2.760 ms-23.3%
verify_blob_kzg_proof_batch 86.637 ms4.967 ms-25.2%
verify_blob_kzg_proof_batch 1613.056 ms9.205 ms-29.5%
verify_blob_kzg_proof_batch 3225.704 ms17.765 ms-30.9%
verify_blob_kzg_proof_batch 6451.174 ms34.736 ms-32.1%
precompute_load (L0)1163.746 ms
EIP-7594 (PeerDAS)
compute_cells1.932 ms1.020 ms-47.2%
compute_cells_and_kzg_proofsno precomp183.384 ms141.489 ms-22.8%
compute_cells_and_kzg_proofsckzg precomp=1, 768 KiB608.452 ms
compute_cells_and_kzg_proofsckzg precomp=2, 1536 KiB315.771 ms
compute_cells_and_kzg_proofsckzg precomp=3, 3 MiB226.319 ms
compute_cells_and_kzg_proofsckzg precomp=4, 6 MiB182.381 ms
compute_cells_and_kzg_proofsckzg precomp=5, 12 MiB156.495 ms
compute_cells_and_kzg_proofsckzg precomp=6, 24 MiB138.634 ms
compute_cells_and_kzg_proofsckzg precomp=7, 48 MiB129.472 ms
compute_cells_and_kzg_proofsckzg precomp=8, 96 MiB120.608 ms
compute_cells_and_kzg_proofsctt t=64, b=6, 32.2 MiB115.359 ms
compute_cells_and_kzg_proofsctt t=64, b=8, 96.0 MiB105.269 ms
compute_cells_and_kzg_proofsctt t=64, b=10, 312.0 MiB95.802 ms
compute_cells_and_kzg_proofsctt t=64, b=12, 1056.0 MiB87.591 ms
compute_cells_and_kzg_proofsctt t=128, b=6, 16.5 MiB114.424 ms
compute_cells_and_kzg_proofsctt t=128, b=8, 48.0 MiB101.874 ms
compute_cells_and_kzg_proofsctt t=128, b=10, 156.0 MiB95.423 ms
compute_cells_and_kzg_proofsctt t=128, b=12, 528.0 MiB88.957 ms
compute_cells_and_kzg_proofsctt t=256, b=6, 8.2 MiB117.055 ms
compute_cells_and_kzg_proofsctt t=256, b=8, 24.0 MiB98.698 ms
compute_cells_and_kzg_proofsctt t=256, b=10, 84.0 MiB97.307 ms
compute_cells_and_kzg_proofsctt t=256, b=12, 288.0 MiB93.098 ms
recover_cells_and_kzg_proofs¹see ¹137.245 ms97.272 ms-29.1%
verify_cell_kzg_proof_batch²439.979 ms381.058 ms-13.4%

注記:

  • ¹ リカバリ: c-kzg-4844はprecompute=8 (96 MiB) を使用。constantineはt=256, b=8 (24 MiB) を使用。
  • ² c-kzg-4844は8192セル (64ブロブ) を検証。constantineはこの設定に一致。
  • Δ%はc-kzg-4844に対するconstantineの相対値を示す (負の値は高速化)。
  • c-kzg-4844のプリコンピュートレベルとconstantineの(t, b)設定は直接比較できない。
  • Precompute=8 (c-kzg-4844) は96 MiBのメモリと引き換えにFK20操作で約34%の高速化を実現。

主なハイライト:

マルチスレッドについて

EIP-4844とは異なり、PeerDASはまだ並列化していませんが、Constantineの並列バックエンドは高度にチューニングされており(go-kzg-4844との比較はこちらを参照 Releasing Constantine v0.2.0 (Jan 2025), a modular cryptography stack for Ethereum 22%高速化)、低オーバーヘッドでネストされた並列処理が可能です。実際、私のMSMは3レベルの並列処理を持ち、PeerDASのボトルネックは128個のプリコンピュートされたMSMに対する非常に並列性の高いforループです: constantine/constantine/math/matrix/toeplitz.nim at e6bee85e8c7a89af279460e4ca03283d817d1ce9 · mratsim/constantine · GitHub

proc finish*[EC, ECaff, F; N: static int](
  ctx: var ToeplitzAccumulator[EC, ECaff, F],
  output: var openArray[EC],
  polyphaseSpectrumBank: openArray[PrecomputedMSM[EC, N]]
): ToeplitzStatus {.raises: [], meter.} =
  ## Finalize using precomputed MSM tables (one per output position).
  ## For each output position `i`, extracts the `L` scalars from `coeffs`
  ## and computes `output[i]` using `polyphaseSpectrumBank[i].msm_vartime`.
  ## After all MSMs, an in-place EC IFFT is applied to `output`.
  let n = ctx.size
  if n == 0 or output.len != n or ctx.offset != ctx.L or polyphaseSpectrumBank.len != n or N != ctx.L:
    return Toeplitz_MismatchedSizes
  let scalars = cast[ptr UncheckedArray[F.getBigInt()]](ctx.scratchScalars)
  for i in 0 ..< n:
    for offset in 0 ..< ctx.L:
      scalars[offset].fromField(ctx.coeffs[i * ctx.L + offset])
    polyphaseSpectrumBank[i].msm_vartime(output[i], scalars.toOpenArray(ctx.L))
  checkReturn ec_ifft_nn(ctx.ecFftDesc, output, output)
  return Toeplitz_Success

したがって、8コアZen 4を搭載したミニPC(Ryzen 7840HSはラップトップやミニPCで非常に人気があります)を想定すると、64ブロブの証明で15ミリ秒を下回ることは十分に可能だと確信しています。


関連PR:

1投稿 - 1参加者

トピック全文を読む