EIP-7923: Linear, Page-Based Memory Costing

discussions-to for: Add EIP: Linear, Page-Based Memory Costing by charles-cooper · Pull Request #9556 · ethereum/EIPs · GitHub

adding the EIP link, now that it has been merged: EIP-7923: Linear, Page-Based Memory Costing

2 Likes

Isn’t this advocating for removing the 63/64 rule?

1 Like

Bit off topic, but yes, I think that should be removed as well.

1 Like

Since memory access gets substantially more expensive after around 32MB, I considered several variants:

  1. Thrash costing only, global memory limit is implied by gas limit (currently in the EIP)
  2. No thrash costing, limit per message call. This has the disadvantage that the global limit has to be inferred from the call stack limits
  3. No thrash costing, global memory limit. This has the disadvantage that the global memory limit may need to be kept small permanently, since CPU cache grows very slowly over time.
  4. Thrash costing AND global memory limit. This has the disadvantage that developers may come up with valid use cases for using much more memory and be blocked by EVM limitations, but on the other hand, it can help nodes reason about DoS vectors invariant of gas limit (see EIP-7686: Linear EVM memory limits - #5 by qizhou).

I think all of these fall in the realm of ‘acceptable’ solutions. I personally prefer 1, 4 or 3, in that order.

63/64 rule is still necessary if for page-based memory since this does not limit the memory of child calls. Is there an alternative mechanism that should be done. Limiting maximum memory size on a transactions level based on gas limit?

I think one of the motivations for this EIP actually is that the memory limit is invariant wrt the state of the call stack, so you don’t need to think about how allocation patterns across the call stack can affect memory usage. In this EIP, there is an implied limit of memory usage based on the gas limit, which in the current iteration of the draft, would be gas_limit * 4096 / 109, where 4096 is the number of bytes per page, and 109 is the cost to allocate a page.

I’ve added this transaction global limit in the latest commit: Add EIP: Linear, Page-Based Memory Costing by charles-cooper · Pull Request #9556 · ethereum/EIPs · GitHub

Do you benchmarks also include clearing costs; as memory will have to be zeroed to not leak data between transactions

Yes – that’s included in the 100 gas cost to allocate+zero a page.