-
Notifications
You must be signed in to change notification settings - Fork 126
Description
Memory-mapped linear storage in Ethereum was proposed IIRC by @AlexeyAkhunov. Here we give a potential implementation of that in ewasm.
The proposal is that instead of fixed-length/fixed-key storage values, storage is linear, extendable and accessed like memory. We can take a design cue from POSIX: mmap.
API: storageMap(memoryOffset: i32, storageOffset: i32, storageLength: i32)
In the naive implementation this would:
- keep track of each
storageMap - disallow overlapping and duplicate areas
- load and copy storage into the memory area at the first invocation
- at termination of the execution the tracked areas from memory are written back to storage
In an optimised implementation with control over the VM could, while still requiring storageMap, load bytes / words / etc. on-demand at the first time the area is accessed and keep track of changed areas.
In the future when Wasm support multiple memory segments, instead of mapping into the "main" working memory, storage could be mapping 1-to-1 in a dedicated segment, without the need of a host function.