Drink backend: support runtime call #1891
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since inkdevhub/drink#36 is done, we can finally support arbitrary runtime calls in e2e tests. However, the solution is kinda tricky.
Problem
In drink! we have strongly typed runtime calls. This is because we keep the runtime directly, in-memory, and thus we have access to the
RuntimeCall
enum family. And thus there's no need of dynamic dispatch.In standard e2e backend (i.e. node+subxt) we must have only dynamic dispatch. This is because we support running a node with an arbitrary runtime, and therefore we cannot statically generate runtime types, including
RuntimeCall
enum family.But in order to support using both backends with the same test code, we have to provide a common interface...
Solution
We can't make
ChainBackend::runtime_call
statically typed, since forsubxt_client::Client
there is no way of providing correct types. Hence, we have to leave the API as it is (i.e. dynamic dispatch with pallet and call as strings and call data assubxt::Value
wrappers).For the drink! implementation we do following mumbo-jumbo:
RuntimeCall
object🤷♂️
Note
Since
drink::MinimalRuntime
andsubstrate-contracts-node
's runtime use different addressing, the testcases that relate to runtime calling are compatible with only one backend. However, notice that this is the incompatibility of used runtimes, not backends, and thus it's okay.