Improve memory metering for WASM VMs #1970
mootz12
started this conversation in
Core Advancement Proposals
Replies: 1 comment
-
|
Just to add more context, the best return on investment of such change will actually be towards the oracle providers, then the core lending/defi protocols. If oracles will re build and re deploy the existing contracts with the new linear memory reduced, many protocols (mine included) will be more efficent in reading a bunch of prices for complex positions and in the future ETF style contracts calculating NAV, ETF price. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
As Stellar's DeFi ecosystem grows, protocols built on top of other protocols are performing lots of cross-contract calls. The way memory is metered for WASM VMs puts an artificial ceiling on how many cross-contract calls fit within the per-transaction 40 MB
mem_byteslimit.By default, contracts compiled with
stellar-clideclare a WASM linear memory with a ~1 MiB initial size. Each VM instantiation accrues that amount (+ more) to themem_bytesmeter and does not credit any back when the VM is torn down. For contracts with lots of sequential cross-contract calls, this causes them to hitmem_byteslimits without using much memory.This has impacted builders a few times recently:
Proposal
We add the ability to credit memory allocated for a WASM VM after it's frame is popped back to
mem_bytes.Alternatives
stellar-clican likely safely reduce the WASM stack size down from 1 MiB for contract builds. However, this doesn't help contracts that are already live, like Blend. This should be explored regardless of the outcome of this discussion.Beta Was this translation helpful? Give feedback.
All reactions