streamingfast / substreams

Powerful Blockchain streaming data engine, based on StreamingFast Firehose technology.
Apache License 2.0
160 stars 45 forks source link

This enables running module with wasmbindgen shims by specifying runtime extension `wasm-bindgen-shims` #476

Closed maoueh closed 4 months ago

maoueh commented 4 months ago

The Substreams binary type can now be optionally composed of runtime extensions by appending a +<extension>,[<extesions...>] at the end of the binary type. Extensions are key[=value] that are runtime specifics. If you were parsing generic Substreams manifest, you will now need to handle that possibility in the binary type. If you were reading the field without any processing, you don't have to change nothing.

The first runtime extensions that we add is wasm-bindgen-shims which will enable Substreams importing those shims to run correctly as long as they are never called which is usually the case. We achieve this my binding wasm bindgen module and their imports to a dummy implementation that fails as soon as it's called.

This enables Substreams to import for example alloy in the Ethereum world to perform some Ethereum related operations. It also enables developer to pull in solana_program in Solana world so they are able to decode IDL directly.

To enable the feature, change:

binaries:
  default:
    type: wasm/rust-v1
    file: <some_file>

to become

binaries:
  default:
    type: wasm/rust-v1+wasm-bindgen-shims
    file: <some_file>

This instructs the Substreams processing engine on the server to shims the WASM bindgen imports with dummy implementation.