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

try-runtime-cli: path to being an independent CLI #12975

Closed
5 tasks done
Tracked by #178
kianenigma opened this issue Dec 19, 2022 · 6 comments · Fixed by polkadot-developers/substrate-docs#2043
Closed
5 tasks done
Tracked by #178
Assignees
Labels
J0-enhancement An additional feature request. T1-runtime This PR/Issue is related to the topic “runtime”. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Comments

@kianenigma
Copy link
Contributor

kianenigma commented Dec 19, 2022

... and capable of interacting with any substrate-based chain, at any without needing to care about the block format.

As of #12537, the try-runtime-cli does not care about the local runtime anymore. It always uses the path to the wasm file.

If you look at the code now, there are only two reasons why try-runtime-cli is part of substrate/polkadot/cumulus now:

  1. Get the list of host functions from the native executor
  2. Get the block format

cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>>(),

The former can be hardcoded and as far as I know we don't really change it. It should simple be SubstrateHostFunctions default set.

And the latter, should be provided by sub-xt. sub-xt is now capable of fetching the metadata of a remote node and generating types from it, including the block format, at compile-time, which is awesome and exactly what we need.

If done, there'd be one try-runtime-cli, capable of working with all substrate-based chains, with much faster compile-time, and capable of living outside of substrate repo even.

Tasks

@kianenigma kianenigma added J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Dec 19, 2022
@pmikolajczyk41
Copy link
Contributor

Generally, extracting try-runtime outside node binary sounds great for me. However, there is at least one thing that I want to bring some attention to.

Since we have the assumption that try-runtime is a universal tool (in terms of chain it communicates with), in some future situations we might have to allow users to inject custom logic. As an example, you can refer to my PR with fast-forward subcommand. There, I require from the user to provide a 'factory' of inherents and pre-runtime digests. Similar thing will occur if we decide to add block translation gadget (for block format mismatch) - the user will have to define logic for how old extrinsics should be translated to the new ones.

For such cases, I would propose dividing try-runtime into lib and bin crates, where the latter one would be ready-to-use CLI tool, that exposes all the functionalities that don't require external logic. The former would keep all the non-CLI code, including additional generic functionalities (for injecting custom semantics) - like fast-forward.

@kianenigma
Copy link
Contributor Author

For such cases, I would propose dividing try-runtime into lib and bin crates, where the latter one would be ready-to-use CLI tool, that exposes all the functionalities that don't require external logic.

Perhaps the lib-part can go into frame/try-runtime which already exists?

@pmikolajczyk41
Copy link
Contributor

where would we keep the binary (the tool)? other repository?

@kianenigma
Copy link
Contributor Author

I would start with this repo but no dependency on sc-*, and then it would be free to go anywhere

@pmikolajczyk41
Copy link
Contributor

Sounds good then

@kianenigma
Copy link
Contributor Author

https://github.com/paritytech/try-runtime-cli is there for me and @pmikolajczyk41 to try this out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. T1-runtime This PR/Issue is related to the topic “runtime”. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants