Skip to content

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Sep 22, 2025

this pr is experimental for future works, do not review.

Motivation

The current fee schedule applies static, worst-case prices to opcodes and syscalls. Real workloads
show wide variance in CPU, memory, and storage usage, so contracts can significantly underpay (e.g.,
concatenating big buffers or emitting large notifications) while attackers can exploit cheap opcodes
to force expensive work. We also lack a policy knob to tune in-memory allocations independently of
storage writes.

Summary

  • Introduce a ResourceCost model and hook it into the VM so opcodes, syscalls, and native methods
    charge for actual CPU, transient memory, and persistent storage.
  • Meter inline push-byte opcodes, data-copy primitives, iterators, runtime logging, storage APIs, and
    native contract entry points proportionally to the data they touch.
  • Expose a MemoryFeeFactor managed by the Policy contract and surface it through RPC, enabling
    governance to tune transient memory pricing.
  • Update docs/tests to reflect the dynamic schedule and add regression coverage for the new pricing
    rules.

@Jim8y Jim8y marked this pull request as draft September 22, 2025 10:08
@Jim8y Jim8y changed the title Add runtime-aware gas accounting [Non-Review] Add runtime-aware gas accounting Sep 22, 2025
@Jim8y Jim8y changed the title [Non-Review] Add runtime-aware gas accounting [Non-Review] Add runtime-aware gas cost accounting Sep 22, 2025
@Jim8y Jim8y added the Feature Type: Large changes or new features label Sep 22, 2025
@cschuchardt88 cschuchardt88 added the DO NOT REVIEW Not yet ready for review, this is just a placeholder pr, will be polished later to make it complete. label Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT REVIEW Not yet ready for review, this is just a placeholder pr, will be polished later to make it complete. Feature Type: Large changes or new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants