pub trait ReadRuntimeVersion: Send + Sync {
    fn read_runtime_version(
        &self,
        wasm_code: &[u8],
        ext: &mut dyn Externalities
    ) -> Result<Vec<u8>, String>; }
Expand description

A trait that allows reading version information from the binary.

Required methods

Reads the runtime version information from the given wasm code.

The version information may be embedded into the wasm binary itself. If it is not present, then this function may fallback to the legacy way of reading the version.

The legacy mechanism involves instantiating the passed wasm runtime and calling Core_version on it. This is a very expensive operation.

ext is only needed in case the calling into runtime happens. Otherwise it is ignored.

Compressed wasm blobs are supported and will be decompressed if needed. If uncompression fails, the error is returned.

Errors

If the version information present in binary, but is corrupted - returns an error.

Otherwise, if there is no version information present, and calling into the runtime takes place, then an error would be returned if Core_version is not provided.

Implementors