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

core::crypto: features cleanup in tests #1983

Closed
wants to merge 6 commits into from

Conversation

michalkucharczyk
Copy link
Contributor

@michalkucharczyk michalkucharczyk commented Oct 23, 2023

There are three features that affect how crypto module is compiled: std, full_crypto and serde.

Following invocations are now failing:

cargo test --no-default-features --features="full_crypto"
cargo test --no-default-features --features="full_crypto,serde"
cargo test --no-default-features --features="serde"
cargo test --no-default-features

This PR adds the features to the test, so these commands are working properly.

Some groundwork for: #1984

@michalkucharczyk michalkucharczyk changed the title core::crypto: features cleanup in tests core::crypto: features cleanup in tests Oct 23, 2023
@michalkucharczyk michalkucharczyk requested review from davxy and a team October 23, 2023 10:24
@michalkucharczyk michalkucharczyk added the T0-node This PR/Issue is related to the topic “node”. label Oct 23, 2023
@@ -132,6 +132,7 @@ serde = [
"secrecy/alloc",
"sp-core-hashing",
"sp-storage/serde",
"sp-runtime-interface/disable_target_static_assertions",
Copy link
Contributor Author

@michalkucharczyk michalkucharczyk Oct 23, 2023

Choose a reason for hiding this comment

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

This probably should not be here. However without this compilation fails:

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
  --> substrate/primitives/runtime-interface/src/impls.rs:45:1
   |
45 | assert_eq_size!(usize, u32);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: source type: `usize` (64 bits)
   = note: target type: `u32` (32 bits)
   = note: this error originates in the macro `assert_eq_size` (in Nightly builds, run with -Z macro-backtrace for more info)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is wrong and needs to be removed!

Copy link
Member

Choose a reason for hiding this comment

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

Substrate currently assumed that no_std == arch::wasm32. Shitty, I know, but that is currently the assumption.

Copy link
Contributor

@koute koute Oct 23, 2023

Choose a reason for hiding this comment

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

Yes, ideally that assert should be changed to check for wasm32 and not for no_std, and then you won't need to disable it.

...as Basti said, the current assumption everywhere is that no_std equals WASM, which, uh, I guess I'll have to fix soon-ish since I'll be wanting to get the RISC-V based runtimes working. :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall we remove this one too?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah good idea.

@michalkucharczyk michalkucharczyk requested a review from a team as a code owner October 23, 2023 11:01
@paritytech-ci paritytech-ci requested a review from a team October 23, 2023 11:03
@burdges
Copy link

burdges commented Oct 23, 2023

Is serde still relevant?

@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Oct 23, 2023

Is serde still relevant?

At the moment: yes.

We had some discussion on removing this feature and inclusion of serde dependency unconditionally, but we didn't reach a conclusion.

.gitlab/pipeline/test.yml Outdated Show resolved Hide resolved
@@ -569,6 +577,7 @@ mod test {
}

#[test]
#[cfg(feature = "std")]
Copy link
Member

Choose a reason for hiding this comment

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

As we only run tests in std why do we need all this feature gating?

Copy link
Contributor Author

@michalkucharczyk michalkucharczyk Oct 23, 2023

Choose a reason for hiding this comment

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

Yes. I want e.g. time cargo test --release -p sp-core --no-default-features --features="serde" to be executed correctly.

Copy link
Member

Choose a reason for hiding this comment

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

But you don't run this anymore? And serde is mainly about testing that it compiles?

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 want to run it locally. I want to have ability to test the sp-core with the different feature sets it offers. serde was just an example, full-crypto or full-crypto,serde are the other options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have trait methods definition under std, so w/o this paricular gate you will get:

cargo +nightly check --tests --no-default-features --features="full_crypto"

error[E0599]: no function or associated item named `from_full` found for struct `ecdsa::Public` in the current scope
   --> substrate/primitives/core/src/ecdsa.rs:588:12
    |
80  | pub struct Public(pub [u8; PUBLIC_KEY_SERIALIZED_SIZE]);
    | ----------------- function or associated item `from_full` not found for this struct
...
588 |             Public::from_full(
    |                     ^^^^^^^^^ function or associated item not found in `Public`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `sp-core` (lib test) due to previous error

Copy link
Member

Choose a reason for hiding this comment

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

I want to run it locally. I want to have ability to test the sp-core with the different feature sets it offers. serde was just an example, full-crypto or full-crypto,serde are the other options.

These features are not changing anything in the implementation, they only unlock different kind of functions etc. When you run everything using std you test the logic. We also don't have logic in there that is different based on features. So, not sure what you want to test there.

Copy link
Member

Choose a reason for hiding this comment

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

We have trait methods definition under std, so w/o this paricular gate you will get:

cargo +nightly check --tests --no-default-features --features="full_crypto"

Because you are using --tests. Just drop this, these tests only need to work on std.

Copy link
Contributor Author

@michalkucharczyk michalkucharczyk Oct 24, 2023

Choose a reason for hiding this comment

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

IMO the tests should be runnable for any set of features provided by this module. The point of this PR was to check if tests are fine for particular features (or combinations of them).

If we always want to test with default features, then this PR does not make sense.

Copy link
Member

Choose a reason for hiding this comment

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

I mean checking that it compiles make sense. (without the tests). To ensure that these features compile on their own.

serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Mar 26, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Mar 27, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
bkchr pushed a commit that referenced this pull request Apr 10, 2024
* removed FromBridgedChainMessageDispatch in favor of XcmBlobMessageDispatch

* use HaulBlobExporter/HaulBlobExporterAdapter instead of XcmBridge/XcmBridgeAdapter

* tests for sending/dispatching messages

* use new schema in testnet bridges + some cleanup

* clippy

* spelling + added TODO

* cleanup some checks

* benchmarks compilation

* all is XCM

* updated README.md

* ref issue from TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T0-node This PR/Issue is related to the topic “node”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants