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.
We tried harnessing
subxt
for the 'call_runtime' feature. Although we can remove the need of manually crafting call object, there are still some issues due to the subxt's design.subxt
macro assumes thatsubxt
crate is available. This is fine for all standard usecases, where one uses full subxt power. However, in our case, we need only runtime types module, without any othersubxt
features. Especially, because fullsubxt
is far from being no-std compatible and therefore it cannot be used in smart contracts context. For this, we can depend solely onsubxt_macro
crate, which is no-std compatible and provides only the required macro. Unfortunately, we still have to provide at least a dummysubxt
module for primitive types and reexports.Macro configuration is not trivial. Also, it still lacks possibility of picking only a subset of pallets.
Passing runtime metadata to the macro has to be done with a running node (
runtime_metadata_url
). Usingruntime_metadata_path
fails during contract building phase withcargo contract
(Failed IO for /tmp/cargo-contract_mB5KYC/metadata.scale, make sure that you are providing the correct file path for metadata: No such file or directory (os error 2)
).subxt
usesstd
library forboxed
,vec
,string
etc. This fails for no-std context, where SC is built. Unfortunately, we find it very hard to remove all such dependencies (e.g. by pointing to thealloc
crate). For now, we prepared a temporary version ofsubxt
that works well in no-std context, but fails in a standard one.RuntimeCall
enum is not self-contained. It depends on a group of pallet-specific type families. This is not a problem for a standard usecase, where one uses fullsubxt
power. However, in our case, this blocks puttingRuntimeCall
into a single place likeEnvironment
trait, so that any contract can conveniently build a call object. Instead, every contract has to have an access to the whole module with runtime types.This is rather a call for discussion / current best effort for #1675.
Ad 4.
Problematic imports:
::std::borrow
: easily convertible to::core::borrow
, no further issues here::std::collections
: easily convertible to::core::alloc::collections
, no further issues here::std::boxed
,::std::vec
: could be taken fromsp_core::sp_std::
(available only under specificsubxt
feature) or somewhere wherealloc
is always available::std::string
:alloc
needed in both std and no-std contexts; notice, that this cannot be feature-gated, because the crate, where the macro is used might not havestd
feature but not be no-stdcc: @athei @cmichi @jsdw