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

chain-spec-builder: Do not swallow unknown fields #4873

Closed
skunert opened this issue Jun 25, 2024 · 2 comments · Fixed by #4889
Closed

chain-spec-builder: Do not swallow unknown fields #4873

skunert opened this issue Jun 25, 2024 · 2 comments · Fixed by #4889

Comments

@skunert
Copy link
Contributor

skunert commented Jun 25, 2024

Follow up of #4685.

We should not swallow any fields when modifying existing chain-specs. Currently para_id and relaychain fields would not be present in the output chain spec.

@CrackTheCode016
Copy link
Contributor

I believe the cause is due to the existing chain spec being parsed via ChainSpec::from_json, which assumes no extensions / custom fields, aka just the default config.

To ensure any fields can be preserved, we can simply parse the file via fs::read, then serde_json::read_slice, merge in place, versus converting to ChainSpec. Other option is to hardcode them as part of the default config but not sure we want that.

@bkchr
Copy link
Member

bkchr commented Jun 27, 2024

Or we could just keep the original json file around, continue using from_json and when the operation is finished we merge back the new chainspec to the original file.

github-merge-queue bot pushed a commit that referenced this issue Sep 4, 2024
When using with `polkadot-parachain`, you usually need to specify the
`relay_chain` and `para_id` fields in the chain spec.

With this PR it can be achieved by specifying newly added `--para-id`
and `--relay-chain` command line args, e.g:
```
chain-spec-builder create -r _runtime.wasm  --para-id 100 --relay-chain xxx default
```

This was implemented by simple _json_ blobs merging.

Additionally unit tests covering basic functionality were added.

Also adds a fix for not overwriting the chain spec with the default
config each time, swallowing not standard fields is also fixed.

Fixes: #4873

---------

Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: done
Development

Successfully merging a pull request may close this issue.

3 participants