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

Update tc-subxt to bounded types #1205

Conversation

4meta5
Copy link
Contributor

@4meta5 4meta5 commented Oct 15, 2024

Motivation here #1185 (comment)
This PR is made on top of that PR and it is NOT done yet

  • shards (commit)
  • tasks (submit_result)
  • network (register_network)
  • dmail (send_email) (did use wrapper struct for this one because chain_name and network_name were two fields)
  • update chronicle, runtimes
  • re-run benchmarks => generate new weights
  • (WIP) update tc-subxt

@4meta5 4meta5 mentioned this pull request Oct 15, 2024
10 tasks
@4meta5 4meta5 changed the title Redo bounded extrinsic types with easier types for subxt Redo bounded extrinsic inputs with easier types for subxt Oct 16, 2024
@4meta5 4meta5 self-assigned this Oct 16, 2024
@4meta5 4meta5 added this to the Milestone Q4 2024 milestone Oct 16, 2024
@4meta5 4meta5 added the !ci-benchmark Benchmark and commit new weights label Oct 16, 2024
@4meta5 4meta5 requested a review from dvc94ch October 16, 2024 19:21
@4meta5
Copy link
Contributor Author

4meta5 commented Oct 16, 2024

@dvc94ch @Haider-Ali-DS I am trying to update tc-subxt and continue to face errors related to the BoundedVec type.

Would've tried creating wrapper structs for all BoundedVecs as was done for the new ChainNetwork type, but that did not work:

error[E0308]: `match` arms have incompatible types
  --> tc-subxt/src/api/networks.rs:41:4
   |
41 |               self.client.runtime_api().at_latest().await?.call(runtime_call).await?
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |               |
   |               expected `ChainNetwork`, found a different `ChainNetwork`
   |               this is found to be of type `std::option::Option<tc_subxt_metadata::timechain::runtime_types::time_primitives::network::ChainNetwork>`
   |
  ::: tc-subxt/src/metadata.rs:7:3
   |
7  | /         match $variant {
8  | |             $crate::metadata::MetadataVariant::Mainnet => {
9  | |                 use tc_subxt_metadata::timechain as metadata;
...  |
35 | |             },
36 | |         }
   | |_________- `match` arms have incompatible types
   |
   = note: expected enum `std::option::Option<tc_subxt_metadata::timechain::runtime_types::time_primitives::network::ChainNetwork>`
              found enum `std::option::Option<tc_subxt_metadata::testnet::runtime_types::time_primitives::network::ChainNetwork>`

Rest of errors which are easily resolved if the above error can be fixed:

error[E0308]: `?` operator has incompatible types
  --> tc-subxt/src/api/shards.rs:87:7
   |
84 |     ) -> Result<Option<BoundedVec<TssPublicKey, ConstU32<MAX_SHARD_SIZE>>>> {
   |          ------------------------------------------------------------------ expected `std::option::Option<polkadot_sdk::frame_election_provider_support::BoundedVec<[u8; 33], ConstU32<100>>>` because of return type
...
87 |             Ok(self.client.runtime_api().at_latest().await?.call(runtime_call).await?)
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<BoundedVec<[u8; 33], ...>>`, found `Option<BoundedVec<[u8; 33]>>`
   |
   = note: `?` operator cannot convert from `std::option::Option<tc_subxt_metadata::timechain::runtime_types::bounded_collections::bounded_vec::BoundedVec<[u8; 33]>>` to `std::option::Option<polkadot_sdk::frame_election_provider_support::BoundedVec<[u8; 33], ConstU32<100>>>`
   = note: `BoundedVec<[u8; 33]>` and `BoundedVec<[u8; 33], ConstU32<100>>` have similar names, but are actually distinct types
note: `BoundedVec<[u8; 33]>` is defined in crate `tc_subxt_metadata`
  --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:1:1
   |
1  | / #[subxt::subxt(
2  | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/mainnet-runtime/mainnet_runtime.metadata.scale",
3  | |         derive_for_all_types = "PartialEq, Clone",
4  | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...  |
16 | |
17 | |     )]
   | |______^
note: `BoundedVec<[u8; 33], ConstU32<100>>` is defined in crate `bounded_collections`
  --> /Users/4meta5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bounded-collections-0.2.0/src/bounded_vec.rs:47:1
   |
47 | pub struct BoundedVec<T, S>(pub(super) Vec<T>, #[cfg_attr(feature = "serde", serde(skip_serializing))] PhantomData<S>);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: `?` operator has incompatible types
  --> tc-subxt/src/api/shards.rs:87:7
   |
84 |     ) -> Result<Option<BoundedVec<TssPublicKey, ConstU32<MAX_SHARD_SIZE>>>> {
   |          ------------------------------------------------------------------ expected `std::option::Option<polkadot_sdk::frame_election_provider_support::BoundedVec<[u8; 33], ConstU32<100>>>` because of return type
...
87 |             Ok(self.client.runtime_api().at_latest().await?.call(runtime_call).await?)
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<BoundedVec<[u8; 33], ...>>`, found `Option<BoundedVec<[u8; 33]>>`
   |
   = note: `?` operator cannot convert from `std::option::Option<tc_subxt_metadata::testnet::runtime_types::bounded_collections::bounded_vec::BoundedVec<[u8; 33]>>` to `std::option::Option<polkadot_sdk::frame_election_provider_support::BoundedVec<[u8; 33], ConstU32<100>>>`
   = note: `BoundedVec<[u8; 33]>` and `BoundedVec<[u8; 33], ConstU32<100>>` have similar names, but are actually distinct types
note: `BoundedVec<[u8; 33]>` is defined in crate `tc_subxt_metadata`
  --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:20:1
   |
20 | / #[subxt::subxt(
21 | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/testnet-runtime/testnet_runtime.metadata.scale",
22 | |         derive_for_all_types = "PartialEq, Clone",
23 | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...  |
35 | |
36 | |     )]
   | |______^
note: `BoundedVec<[u8; 33], ConstU32<100>>` is defined in crate `bounded_collections`
  --> /Users/4meta5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bounded-collections-0.2.0/src/bounded_vec.rs:47:1
   |
47 | pub struct BoundedVec<T, S>(pub(super) Vec<T>, #[cfg_attr(feature = "serde", serde(skip_serializing))] PhantomData<S>);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> tc-subxt/src/api/tasks.rs:64:7
    |
64  |             Ok(output)
    |             -- ^^^^^^ expected `Option<Result<(), ...>>`, found `Option<Result<(), BoundedVec<u8>>>`
    |             |
    |             arguments to this enum variant are incorrect
    |
    = note: `BoundedVec<u8>` and `BoundedVec<u8, ConstU32<500>>` have similar names, but are actually distinct types
note: `BoundedVec<u8>` is defined in crate `tc_subxt_metadata`
   --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:1:1
    |
1   | / #[subxt::subxt(
2   | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/mainnet-runtime/mainnet_runtime.metadata.scale",
3   | |         derive_for_all_types = "PartialEq, Clone",
4   | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...   |
16  | |
17  | |     )]
    | |______^
note: `BoundedVec<u8, ConstU32<500>>` is defined in crate `bounded_collections`
   --> /Users/4meta5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bounded-collections-0.2.0/src/bounded_vec.rs:47:1
    |
47  | pub struct BoundedVec<T, S>(pub(super) Vec<T>, #[cfg_attr(feature = "serde", serde(skip_serializing))] PhantomData<S>);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: the type constructed contains `std::option::Option<Result<(), tc_subxt_metadata::timechain::runtime_types::bounded_collections::bounded_vec::BoundedVec<u8>>>` due to the type of the argument passed
   --> tc-subxt/src/api/tasks.rs:64:4
    |
64  |             Ok(output)
    |             ^^^------^
    |                |
    |                this argument influences the type of `Ok`
note: tuple variant defined here
   --> /Users/4meta5/.rustup/toolchains/1.79.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:506:5
    |
506 |     Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^
    = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> tc-subxt/src/api/tasks.rs:64:7
    |
64  |             Ok(output)
    |             -- ^^^^^^ expected `Option<Result<(), ...>>`, found `Option<Result<(), BoundedVec<u8>>>`
    |             |
    |             arguments to this enum variant are incorrect
    |
    = note: `BoundedVec<u8>` and `BoundedVec<u8, ConstU32<500>>` have similar names, but are actually distinct types
note: `BoundedVec<u8>` is defined in crate `tc_subxt_metadata`
   --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:20:1
    |
20  | / #[subxt::subxt(
21  | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/testnet-runtime/testnet_runtime.metadata.scale",
22  | |         derive_for_all_types = "PartialEq, Clone",
23  | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...   |
35  | |
36  | |     )]
    | |______^
note: `BoundedVec<u8, ConstU32<500>>` is defined in crate `bounded_collections`
   --> /Users/4meta5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bounded-collections-0.2.0/src/bounded_vec.rs:47:1
    |
47  | pub struct BoundedVec<T, S>(pub(super) Vec<T>, #[cfg_attr(feature = "serde", serde(skip_serializing))] PhantomData<S>);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: the type constructed contains `std::option::Option<Result<(), tc_subxt_metadata::testnet::runtime_types::bounded_collections::bounded_vec::BoundedVec<u8>>>` due to the type of the argument passed
   --> tc-subxt/src/api/tasks.rs:64:4
    |
64  |             Ok(output)
    |             ^^^------^
    |                |
    |                this argument influences the type of `Ok`
note: tuple variant defined here
   --> /Users/4meta5/.rustup/toolchains/1.79.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:506:5
    |
506 |     Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^
    = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> tc-subxt/src/worker.rs:193:48
    |
193 |                         metadata::tx().shards().commit(shard_id, commitment, proof_of_knowledge);
    |                                                 ------           ^^^^^^^^^^ expected `BoundedVec<[u8; 33]>`, found `BoundedVec<[u8; 33], ConstU32<100>>`
    |                                                 |
    |                                                 arguments to this method are incorrect
    |
    = note: `BoundedVec<[u8; 33], ConstU32<100>>` and `BoundedVec<[u8; 33]>` have similar names, but are actually distinct types
note: `BoundedVec<[u8; 33], ConstU32<100>>` is defined in crate `bounded_collections`
   --> /Users/4meta5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bounded-collections-0.2.0/src/bounded_vec.rs:47:1
    |
47  | pub struct BoundedVec<T, S>(pub(super) Vec<T>, #[cfg_attr(feature = "serde", serde(skip_serializing))] PhantomData<S>);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `BoundedVec<[u8; 33]>` is defined in crate `tc_subxt_metadata`
   --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:1:1
    |
1   | / #[subxt::subxt(
2   | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/mainnet-runtime/mainnet_runtime.metadata.scale",
3   | |         derive_for_all_types = "PartialEq, Clone",
4   | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...   |
16  | |
17  | |     )]
    | |______^
note: method defined here
   --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:1:1
    |
1   | / #[subxt::subxt(
2   | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/mainnet-runtime/mainnet_runtime.metadata.scale",
3   | |         derive_for_all_types = "PartialEq, Clone",
4   | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...   |
16  | |
17  | |     )]
    | |______^
    = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> tc-subxt/src/worker.rs:193:48
    |
193 |                         metadata::tx().shards().commit(shard_id, commitment, proof_of_knowledge);
    |                                                 ------           ^^^^^^^^^^ expected `BoundedVec<[u8; 33]>`, found `BoundedVec<[u8; 33], ConstU32<100>>`
    |                                                 |
    |                                                 arguments to this method are incorrect
    |
    = note: `BoundedVec<[u8; 33], ConstU32<100>>` and `BoundedVec<[u8; 33]>` have similar names, but are actually distinct types
note: `BoundedVec<[u8; 33], ConstU32<100>>` is defined in crate `bounded_collections`
   --> /Users/4meta5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bounded-collections-0.2.0/src/bounded_vec.rs:47:1
    |
47  | pub struct BoundedVec<T, S>(pub(super) Vec<T>, #[cfg_attr(feature = "serde", serde(skip_serializing))] PhantomData<S>);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `BoundedVec<[u8; 33]>` is defined in crate `tc_subxt_metadata`
   --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:20:1
    |
20  | / #[subxt::subxt(
21  | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/testnet-runtime/testnet_runtime.metadata.scale",
22  | |         derive_for_all_types = "PartialEq, Clone",
23  | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...   |
35  | |
36  | |     )]
    | |______^
note: method defined here
   --> /Users/4meta5/analog/timechain/target/debug/build/tc-subxt-metadata-67204c1ecbd44c01/out/metadata.rs:20:1
    |
20  | / #[subxt::subxt(
21  | |         runtime_metadata_path = "/Users/4meta5/analog/timechain/target/debug/wbuild/testnet-runtime/testnet_runtime.metadata.scale",
22  | |         derive_for_all_types = "PartialEq, Clone",
23  | |         substitute_type(path = "time_primitives::gmp::GmpMessage", with = "::subxt::utils::Static<time_primitives::gmp::GmpMessage>"),
...   |
35  | |
36  | |     )]
    | |______^
    = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info)

@4meta5 4meta5 changed the title Redo bounded extrinsic inputs with easier types for subxt Update tc-subxt to bounded types Oct 16, 2024
@4meta5 4meta5 requested a review from haider-rs October 16, 2024 21:55
@4meta5 4meta5 added help wanted ready-for-review PR author(s) done with coding and reviewer[s] can start priority: critical and removed !ci-benchmark Benchmark and commit new weights labels Oct 16, 2024
@4meta5
Copy link
Contributor Author

4meta5 commented Oct 17, 2024

Closing this and going with the full wrapper struct approach

@4meta5 4meta5 closed this Oct 17, 2024
@4meta5 4meta5 deleted the amar-subxt-metdata-requirements-for-bounded-types branch October 17, 2024 16:45
@4meta5 4meta5 mentioned this pull request Oct 17, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: critical ready-for-review PR author(s) done with coding and reviewer[s] can start
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants