Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node/cli: export genesis metadata #148

Merged
merged 1 commit into from
Dec 22, 2023
Merged

Conversation

pepyakin
Copy link
Contributor

@pepyakin pepyakin commented Dec 21, 2023

This commit adds a new subcommand to the CLI that exports metadata from
the compiled-in runtime, similar to the existing subcommands like
export-genesis-state and export-genesis-wasm.

A typical usage would be

sugondat-node export-genesis-metadata --raw binary_metadata.scale
subxt codegen --file binary_metadata.scale | \
	rustfmt --edition=2021 --emit=stdout > src/metadata.rs

Ideally, it would be solved by paritytech/polkadot-sdk#2745 and thus we could
just take the wasm blob (either exported by export-genesis-wasm) and just get
it from there via simple of the shelf tools. Until then, we will have this command.

Closes #142

Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

pub struct ExportGenesisMetadataCmd {
#[allow(missing_docs)]
#[command(flatten)]
pub shared_params: sc_cli::SharedParams,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like this one, because it makes the CLI output to look like below. Spot the needed commands.

Options:
      --chain <CHAIN_SPEC>
          Specify the chain specification.

          It can be one of the predefined ones (dev, local, or staging) or it can be a path to a file with the chainspec
          (such as one exported by the `build-spec` subcommand).

      --dev
          Specify the development chain.

          This flag sets `--chain=dev`, `--force-authoring`, `--rpc-cors=all`, `--alice`, and `--tmp` flags, unless
          explicitly overridden. It also disables local peer discovery (see --no-mdns and --discover-local)

  -d, --base-path <PATH>
          Specify custom base path

  -l, --log <LOG_PATTERN>...
          Sets a custom logging filter (syntax: `<target>=<level>`).

          Log levels (least to most verbose) are `error`, `warn`, `info`, `debug`, and `trace`.

          By default, all targets log `info`. The global log level can be set with `-l<level>`.

          Multiple `<target>=<level>` entries can be specified and separated by a comma.

          *Example*: `--log error,sync=debug,grandpa=warn`. Sets Global log level to `error`, sets `sync` target to debug
          and grandpa target to `warn`.

      --detailed-log-output
          Enable detailed log output.

          Includes displaying the log target, log level and thread name.

          This is automatically enabled when something is logged with any higher level than `info`.

      --disable-log-color
          Disable log color output

      --enable-log-reloading
          Enable feature to dynamically update and reload the log filter.

          Be aware that enabling this feature can lead to a performance decrease up to factor six or more. Depending on
          the global logging level the performance decrease changes.

          The `system_addLogFilter` and `system_resetLogFilter` RPCs will have no effect with this option not being set.

      --tracing-targets <TARGETS>
          Sets a custom profiling filter.

          Syntax is the same as for logging (`--log`).

      --tracing-receiver <RECEIVER>
          Receiver to process tracing messages

          [default: log]

          Possible values:
          - log: Output the tracing records using the log

  -r, --raw
          Write output in binary. Default is to write in hex

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

I am reluctant to do something about it though.

This commit adds a new subcommand to the CLI that exports metadata from
the compiled-in runtime, similar to the existing subcommands like
`export-genesis-state` and `export-genesis-wasm`.

A typical usage would be

```bash
sugondat-node export-genesis-metadata --raw binary_metadata.scale
subxt codegen --file binary_metadata.scale | \
	rustfmt --edition=2021 --emit=stdout > src/metadata.rs
```

Ideally, it would be solved by [paritytech/polkadot-sdk#2745] and thus we could
just take the wasm blob (either exported by `export-genesis-wasm`) and just get
it from there via simple of the shelf tools. Until then, we will have this command.

[paritytech/polkadot-sdk#2745]: paritytech/polkadot-sdk#2745
@pepyakin pepyakin force-pushed the pep-export-genesis-metadata branch from cd327db to 3f05f8a Compare December 21, 2023 16:41
@pepyakin pepyakin linked an issue Dec 21, 2023 that may be closed by this pull request
@rphmeier rphmeier merged commit f1af438 into main Dec 22, 2023
5 checks passed
@rphmeier rphmeier deleted the pep-export-genesis-metadata branch December 22, 2023 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

investigate if we can easily extract the metadata from the node
2 participants