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

DispatchError::Module is now a tuple variant in latest Substrate #439

Merged
merged 8 commits into from
Feb 15, 2022

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented Feb 7, 2022

Update the codegen to accomodate this change.

When nightly CI fails owing to a new substrate binary, this is hopefully the fix.

@dvdplm
Copy link
Contributor

dvdplm commented Feb 8, 2022

CI's angry because of outdated metadata?

@jsdw
Copy link
Collaborator Author

jsdw commented Feb 8, 2022

I'll see whether it succeeds now; I'm assuming it'll start passing when a new binary is built with the breaking changes in.

(although we haven't had nightly CI complain yet so maybe not just yet!)

@ascjones
Copy link
Contributor

I need this 🙏

@@ -81,8 +81,8 @@ pub fn generate_error_details(metadata: &RuntimeMetadataV14) -> ErrorDetails {
},
dispatch_error_impl_fn: quote! {
pub fn details(&self) -> Option<ErrorDetails> {
if let Self::Module { index, error } = self {
match (index, error) {
if let Self::Module (module_error) = self {
Copy link
Contributor

Choose a reason for hiding this comment

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

One downside of this is that this codegen is now not backwards compatible with older versions of substrate. Not sure what a nice solution to this is. Of course we can always detect whether it is the tuple variant of the old struct variant, but then that is not a nice solution :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mmm yeah; the only solution that comes to mind is doing a proper check for it in the metadata and conditionally outputting one or the other. Perhaps that's worth doing though so that this passes CI now (and continues to pass when the change finally lands)?

Side note: I'm wondering why the change hasn't made it to the binary that CI uses yet. Any ideas? I may have to look into that!

Copy link
Contributor

Choose a reason for hiding this comment

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

the only solution that comes to mind is doing a proper check for it in the metadata and conditionally outputting one or the other.

I agree, unfortunately that seems to be the only way to do this.

I'm wondering why the change hasn't made it to the binary that CI uses yet. Any ideas?

I thought it automatically uses a recent build from master? If that was working right it should be there. Unless something is being cached somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Asked in the CI/CD room. We rely on a binary made available at https://releases.parity.io/substrate/x86_64-debian:stretch/latest/substrate/substrate from a nightly job on substrate gitlab, but the binary is from a commit ~21 days old..

Copy link
Collaborator Author

@jsdw jsdw Feb 14, 2022

Choose a reason for hiding this comment

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

The nightly job could certainly build and run the latest binary from master, but doing so would slow down the regular CI a bunch I suspect, so it would keep failing (not sure how much caching would end up helping though), so I avoided it.

@dvdplm
Copy link
Contributor

dvdplm commented Feb 15, 2022

@jsdw Do you want to do the conditional check on the metadata to stay backwards compatible in this PR? Otherwise I'd be inclined to merge this.

@jsdw
Copy link
Collaborator Author

jsdw commented Feb 15, 2022

@jsdw Do you want to do the conditional check on the metadata to stay backwards compatible in this PR? Otherwise I'd be inclined to merge this.

Lemme have a stab at backward compat :)

codegen/src/api/errors.rs Outdated Show resolved Hide resolved
codegen/src/api/errors.rs Outdated Show resolved Hide resolved
codegen/src/api/errors.rs Outdated Show resolved Hide resolved
codegen/src/api/errors.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

LGTM

@jsdw jsdw merged commit cb9177a into master Feb 15, 2022
@jsdw jsdw deleted the jsdw-module-error branch February 15, 2022 16:15
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.

None yet

4 participants