[PROPOSAL] zkSync Pubdata-Accurate Gas & Fee Profiler (Upstream-Ready)

Summary

A Hardhat + Foundry add-on that measures execution gas and pubdata bytes on zkSync Era (including bootloader overhead) and outputs a conservative gas_per_pubdata_limit recommendation per call. Built to integrate with existing zkSync developer workflows, shipped as standalone plugins and upstream PRs (best-effort).

Problem

On zkSync Era, user fees depend on L2 execution gas + pubdata (bytes posted for state diffs, logs/messages, bytecode). Pubdata volume is only known post-execution, and common gas reporters don’t provide a zkSync-accurate breakdown or make bootloader overhead visible.

Consequences:

  • Mis-sized gas_per_pubdata_limit can cause reverts or unnecessarily high fees.
  • Teams lack a clear, per-function view of where costs originate (storage vs. logs/messages vs. bytecode).
  • CI lacks a simple guardrail to catch pubdata-heavy changes before merge.

Solution

A profiling layer that runs in tests/scripts (and ad-hoc) to:

  1. Measure: execution gas and pubdata bytes by category (storage writes, L2→L1 logs, L2→L1 messages, bytecode publish), with bootloader overhead shown explicitly.
  2. Price: the footprint using current batch parameters from zkSync JSON-RPC.
  3. Recommend: a conservative gas_per_pubdata_limit and warn/fail when a call likely exceeds safe bounds.
  4. Output: a developer-friendly table and machine-readable JSON suitable for CI.

Non-Overlap & Stack Fit

  • No devnet/orchestrator duplication. We reuse anvil-zksync and official Hardhat/Foundry zkSync integrations for execution and traces.
  • To our knowledge, there is no publicly documented pubdata-aware profiler in the official plugin sets; our scope is limited to fee visibility and recommendations.
  • Upstream PRs will be opened, but the standalone plugins deliver value independently of merge timing.

Technical Implementation Plan

Architecture

  • Core library (TypeScript; thin bindings if needed):
    • Trace ingestion (debug RPC where available; otherwise anvil-zksync verbose tracing).
    • Pubdata classification & byte counters aligned to protocol categories.
    • Fee calculator reading current batch parameters via documented zkSync JSON-RPC.
    • gas_per_pubdata_limit advisor (conservative by default; never auto-injects without an explicit flag).

Integrations

  • Foundry reporter: forge test --zks-fee-profiler → table + JSON (exec gas, pubdata by category, bootloader overhead, recommended gas_per_pubdata_limit, estimated fee).
  • Hardhat task/reporter: npx hardhat analyze:fees with Mocha annotations.
  • Thin CLI: zks-fee analyze <tx|script> against anvil or a forked Era RPC.

**Method **

  • Execute/trace locally, derive state-diff signals, and attribute pubdata bytes to categories.
  • Read current batch inputs via JSON-RPC and compute an estimated fee; show bootloader overhead as a distinct line item.
  • Recommend a conservative gas_per_pubdata_limit (SDKs may expose this as gasPerPubdata/gasPerPubdataLimit).

Deliverables

  1. Core OSS library: pubdata classification, fee calculator, conservative limit advisor.
  2. Foundry integration: reporter flag + JSON output; tests and examples.
  3. Hardhat integration: task/reporter package; examples.
  4. Standalone CLI for ad-hoc analysis.
  5. Three example repos demonstrating storage-heavy patterns; L2→L1 logs/messages; bytecode size/factoryDeps trade-offs.
  6. Docs: “Fees on zkSync for engineers”—how to read reports, set limits, wire CI.

Milestones

Milestone 1: Profiling Kernel (Weeks 1–2) — $15,000

  • Byte counters by category; bootloader line item; pricing from JSON-RPC; CLI PoC.
  • Acceptance: On 10 canonical calls, stable category counts; table + JSON emitted.

Milestone 2: Foundry Reporter (Weeks 3–4) — $12,000

  • Reporter flag + JSON; docs; 10-case test set.
  • Acceptance: For the set, median fee delta ≤5%, p95 ≤10% versus fees computed from current batch parameters.

Milestone 3: Hardhat Task/Reporter (Week 5) — $7,000

  • Task + annotations; examples.
  • Acceptance: Same deltas achieved on anvil and a forked provider.

Milestone 4: Advisor & CI Guardrails (Weeks 6–7) — $8,000

  • Conservative gas_per_pubdata_limit advisor; CI sample that flags unsafe diffs.
  • Acceptance: On a 20-case suite, recommendations prevent pubdata-limit reverts; CI passes with reproducible outputs.

Milestone 5: Conformance & Docs (Weeks 8–9) — $8,000

  • 20+ case suite; delta dashboard script; developer guide.
  • Acceptance: Suite meets median/p95 targets; docs published.

Budget (Total $50,000)

  • Core engineering (kernel + pricing + advisor): $30,000
  • Integrations & tests (Foundry/Hardhat, CI, 20+ vectors): $7,000
  • Docs & examples (3 repos + guide): $6,000
  • Maintenance buffer (6 months for RPC/fee-model updates): $7,000

Acceptance Criteria (objective)

  • Accuracy: On ≥20 canonical interactions, median fee delta ≤5%, p95 ≤10% vs. fees derived from current batch parameters; category bytes consistent with traces.
  • Safety: Default (conservative) gas_per_pubdata_limit recommendations avoid pubdata-limit reverts in the suite; warnings surface likely over-cap calls.
  • DX: One-command setup; works with current Era testnet/mainnet and anvil-zksync; JSON artifacts are CI-ready.
  • Upstreamability: PRs opened; plugins usable independently of merges.

Risks & Mitigations

  • RPC/spec churn → Adapter layer; version-pinned CI; funded maintenance buffer.
  • Trace opacity → Dual backends (debug RPC where available; anvil verbose locally) + explicit bootloader line item with reconciliation notes.
  • Overlap optics → Strictly fee-profiling scope; no devnet/orchestrator; integrates into existing Foundry/Hardhat flows.

Maintenance & Sustainability

  • 3-month upkeep to track RPC/fee changes and keep CI green.
  • Compact codebase, contributor guide, and conformance tests to ease long-term maintenance.
  • License: MIT. Packages published to NPM; examples in public repos.

Impact & Targets

  • Accuracy target: median fee delta ≤5%, p95 ≤10% on the suite.
  • DX target: single-call local report ≤2s on typical dev machines.
  • Adoption target: early downloads across plugin packages in the first 60 days (tracked via NPM stats).

Team & Past Work

About us
Dapps over Apps is a collective advancing Web3 through developer tooling and education. We build practical, open-source tools that improve developer experience (DX) and onboard new builders.

Selected Past Work

Repo: https://github.com/Supercoolkayy/Abitrum-stylus-extension/tree/

  • Avatar-Everywhere CLI (Portable Sandbox Identity Toolkit) — converts Sandbox avatars → VRM for Unity/VRChat and more, with on-chain ownership verification before conversion.
    Package: avatar-everywhere-cli · PyPI

Team

Abdulkareem Oyeneye — Project Lead / Developer Tooling Engineer
Leads planning and delivery for developer-tooling projects with a focus on DX and roadmap execution. For this proposal: overall architecture, stakeholder comms, and release management.
Links: LinkedIn

Gospel Ifeadi — Smart Contract Engineer
Works across Rust, C++, JavaScript, and Python; experience with contract development, automation, and tooling integrations. For this proposal: Solidity/contracts integration, test harnesses, and Hardhat/Foundry adapters.
Links: X (Twitter)

Emmanuel Charles — Blockchain Developer & QA Engineer
Background in Rust, TypeScript, and C++; blends contract engineering with rigorous QA. For this proposal: conformance test suite, CI pipelines, and artifact validation.
Links: LinkedIn

Musa Abdulkareem — ZK Engineer
Focus on protocol-level integrations and performance-minded engineering. For this proposal: bootloader/fee-model reconciliation, JSON-RPC adapters, and performance profiling.
Links: LinkedIn

Contact:
Team@dappsovers.com
X/Twitter