Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Pre-generate runtime metadata, remove from runtime binary? #10057

@ascjones

Description

@ascjones

Following on from #8615, the size of the metadata has increased (because of all the type information). Here are some benchmarks I did during the PR:

#8370 (comment)
#8615 (comment)
#8615 (comment)

There was some discussion #8370 (comment) (/cc @tomusdrw, @apopiak, @bkchr, @dvdplm) about whether it would be worth pre-generating the metadata and storing it somewhere other than in the runtime binary. For the purposes of getting the PR done sooner rather than later, we decided we could handle the larger binary size in the short term.

One solution would be to generate the metadata during build time, which might involve:

  • only include metadata when building with std
  • compile with std and then invoke a generate_metadata function
  • encode and (optionally) compress the metadata
  • calculate the hash of the encoded metadata
  • store the hash of the metadata in the runtime wasm, and store the metadata itself somewhere else.

I'm not intimately familiar with the existing build process, but I believe this workflow is not possible for the existing dev chain runtime where the wasm bytes are embedded directly into a constant for the std build.

One alternative might be to include the metadata only in the std build and have the node only allow the state_getMetadata query when running a native runtime, and then do some caching there. Although I think I heard that native runtimes might be deprecated in the future.

So the open questions here are:

  1. Is it possible to pre-generate the metadata during the build process? (@bkchr)
  2. Where should we store the metadata once it has been pre-generated?

Linking to #10056, which can be solved by this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions