Currently, the FVM references wasm modules directly on-chain as raw-blobs. However, this doesn't leave any room for additional metadata.
Ideally, we'd add a new multicodec for "wasm" code so we can understand the wasm modules as structured data. However, we probably don't want to have to load the entire wasm module just to read the metadata, no matter what we do here.
Proposal
Store on-chain wasm modules behind a "metadata" object.
ActorState.Code (the "code" CID) would then refer to this Code object, instead of directly
referring to wasm module.
Drawbacks
This adds an additional (small) object per WASM module. But the size should be minimal (less than 50 bytes).
This makes resolving the underlying WASM module slightly more expensive (need to resolve the ActorState object, then the Code object, then the actual "code". However, FVM clients are expected to pre-compile and cache actor code anyways, so this shouldn't matter in practice as long as we key this cache by Cid(Code) and not Code.code.
Alternatives
Only store the metadata in the init actor. This will remove the indirection, but won't save any chain state.
Don't add any metadata. At the moment, the only metadata is the code's "type", which could be recorded in the CID itself. However, I expect we'll want more metadata in the future.
Currently, the FVM references wasm modules directly on-chain as raw-blobs. However, this doesn't leave any room for additional metadata.
Ideally, we'd add a new multicodec for "wasm" code so we can understand the wasm modules as structured data. However, we probably don't want to have to load the entire wasm module just to read the metadata, no matter what we do here.
Proposal
Store on-chain wasm modules behind a "metadata" object.
ActorState.Code
(the "code" CID) would then refer to thisCode
object, instead of directly referring to wasm module.Drawbacks
ActorState
object, then theCode
object, then the actual "code". However, FVM clients are expected to pre-compile and cache actor code anyways, so this shouldn't matter in practice as long as we key this cache byCid(Code)
and notCode.code
.Alternatives