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

Fix tools/codegen util #2669

Closed
bkontur opened this issue Nov 2, 2023 · 8 comments
Closed

Fix tools/codegen util #2669

bkontur opened this issue Nov 2, 2023 · 8 comments
Assignees

Comments

@bkontur
Copy link
Contributor

bkontur commented Nov 2, 2023

When I tried to regenerate codegen-runtimes: https://github.com/paritytech/parity-bridges-common/blob/polkadot-staging/scripts/regenerate_runtimes.sh#L14-L16
from polkadot-sdk master wasm files, there was some inconsistency with subxt with Header one vs two arguments,
I didnt investigate it further, probably subxt is not adjusted to some polkadot-sdk stuff.

error[E0107]: struct takes 2 generic arguments but 1 generic argument was supplied
    --> relays/client-bridge-hub-westend/src/codegen_runtime.rs:1133:31
     |
1133 | ...                   ::sp_runtime::generic::Header<::core::primitive::u32>,
     |                                              ^^^^^^ ---------------------- supplied 1 generic argument
     |                                              |
     |                                              expected 2 generic arguments
     |
note: struct defined here, with 2 generic parameters: `Number`, `Hash`
    --> /home/bparity/.cargo/git/checkouts/polkadot-sdk-cff69157b985ed76/1cf7d3a/substrate/primitives/runtime/src/generic/header.rs:41:12
     |
41   | pub struct Header<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> {
     |            ^^^^^^ ------                                     ----
help: add missing generic argument
     |
1133 |                             ::sp_runtime::generic::Header<::core::primitive::u32, Hash>,
@bkontur
Copy link
Contributor Author

bkontur commented Nov 2, 2023

@serban300 for Rococo/Westend I manualy edited codegen-runtime.rs to add Westend enums there,
could you please take a look when have time?

@serban300
Copy link
Collaborator

Yes, sure, I'll take a look. Probably today.

@serban300
Copy link
Collaborator

serban300 commented Nov 3, 2023

It doesn't seem to be a subxt-codegen issue. The problem is that the metadata extracted from the wasm looks something like:

            type: {
              path: [
                sp_runtime
                generic
                header
                Header
              ]
              params: [
                {
                  name: Number
                  type: 4
                }
                {
                  name: Hash
                  type: None
                }
              ]

And before it was like this:

            type: {
              path: [
                sp_runtime
                generic
                header
                Header
              ]
              params: [
                {
                  name: Number
                  type: 4
                }
                {
                  name: Hash
                  type: 265
                }
              ]

The problem is that:

                {
                  name: Hash
                  type: None
                }

It's probably a runtime metadata issue or a wasm-loader issue. Researching

@serban300
Copy link
Collaborator

Ran the new version of BHR locally using zombienet, and I'm getting the same metadata that leads to the issue:

                {
                  name: Hash
                  type: null
                }

So it's not a problem with wasm-loader .

Looks like some metadata change. Not sure if it's a problem, or if subxt should adapt to this somehow.

@serban300
Copy link
Collaborator

Found what's causing the metadata change:

A #[scale_info(skip_type_params(Hash))] has been added to the structure.

@serban300
Copy link
Collaborator

Opened an issue in the subxt repo related to this: paritytech/subxt#1247

@serban300
Copy link
Collaborator

It was fixed by this:

https://github.com/paritytech/parity-bridges-common/blob/8593aef5896e96cacb4a28b42e39a0c05cd7a3b5/scripts/regenerate_runtimes.sh#L27-L29

Since we can't do a better fix in subxt, I will close this issue.

@bkontur
Copy link
Contributor Author

bkontur commented Oct 1, 2024

It was fixed by this:

https://github.com/paritytech/parity-bridges-common/blob/8593aef5896e96cacb4a28b42e39a0c05cd7a3b5/scripts/regenerate_runtimes.sh#L27-L29

Since we can't do a better fix in subxt, I will close this issue.

@serban300 what about doing this "find/seed replace" in rust code directly in tools/runtime-codegen? It could save us time when regenerating :)

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

No branches or pull requests

2 participants