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

common: wasmToSchema: Base custom section resolution on module version #233

Merged
merged 10 commits into from
Apr 26, 2024

Conversation

bisgardo
Copy link
Contributor

@bisgardo bisgardo commented Aug 9, 2023

Purpose

Ensure that getEmbeddedSchema (on ConcordiumGRPCClient) is able to resolve legacy schemas (i.e. schemas without embedded versions).

Also make parsing of contract schema more precise based by using the module version information that is now exposed by the gRPC client. This in turn also documents the relationship between module and schema versions.

Changes

The module version is now used to determine what custom sections to look for. Added comments explain the expected results.

The extraction code is migrated from the dapp-library @concordium/react-components. Specifically, the contents of function getEmbeddedModuleSchema was replaced with the contents of findSchema and its helper function findCustomSections was added and adjusted to use the SDK types.

Finally, getEmbeddedModuleSchema was made non-async and wasmToSchema removed because it was nothing but a more limited version of getEmbeddedModuleSchema.

Addresses Concordium/concordium-dapp-libraries#66.

@bisgardo
Copy link
Contributor Author

@orhoj @shjortConcordium @rasmus-kirk @abizjak Do we want this? If so I'll clean it up and add some tests.

I think it would be useful and simplify https://github.com/Concordium/concordium-dapp-libraries/pull/46/files.

@soerenbf
Copy link
Collaborator

@bisgardo Stumbled upon this PR with no reviewers and no replies. Is this still relevant? I guess if it's a general purpose thing that you've needed to implement in dapp-libraries, it might as well exist here instead?

I'm sorry this has been dangling for so long. If you deem it relevant still, I'll be happy to take a look if you get it up to speed with the main branch.

Otherwise please close it 😄

@bisgardo
Copy link
Contributor Author

@bisgardo Stumbled upon this PR with no reviewers and no replies. Is this still relevant? I guess if it's a general purpose thing that you've needed to implement in dapp-libraries, it might as well exist here instead?

I'm sorry this has been dangling for so long. If you deem it relevant still, I'll be happy to take a look if you get it up to speed with the main branch.

Otherwise please close it 😄

@soerenbf Thanks for poking at this. I still think it's relevant :) The reason I didn't add reviewers was that I didn't consider it ready for review and I didn't want to finish it up before it was deemed worthy of doing.

I merged main into the PR branch. A couple of things have changed in the meantime and the feature seems more widely used and there seems to be some duplication that I'll try and address as part of it.

Return undefined instead of failing (force-unwrapping) when no schema was found.
@bisgardo bisgardo requested review from rasmus-kirk and soerenbf and removed request for rasmus-kirk April 17, 2024 11:23
@bisgardo bisgardo marked this pull request as ready for review April 17, 2024 11:23
@bisgardo bisgardo changed the title common: wasmToSchema: Add support for legacy schema locations based on module version common: wasmToSchema: Base custom section resolution on module version Apr 17, 2024
Let `ConcordiumGRPCClient.getEmbeddedSchema` return `RawModuleSchema` instead of only the buffer.
Copy link
Collaborator

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

As these are breaking changes, I don't think these should be just merged to main. As I see it, we have 2 options: either change these to not be breaking (if possible), or follow the process outlined below.

The way we usually handle breaking changes is:

  • Make a new release branch, i.e. release/web-sdk/8
  • Target this branch for PR's implementing breaking changes
  • Merge this when we're ready.

If you need to use these changes, I would suggest publishing them to npm under either the alpha or beta tag (we usually use alpha for internal preliminary release versions. If you intend to publish the dapp-libraries based on this, I would use beta).

packages/sdk/src/types/VersionedModuleSource.ts Outdated Show resolved Hide resolved
packages/sdk/src/pub/types.ts Show resolved Hide resolved
packages/sdk/src/grpc/GRPCClient.ts Outdated Show resolved Hide resolved
packages/sdk/CHANGELOG.md Outdated Show resolved Hide resolved
packages/sdk/src/types/VersionedModuleSource.ts Outdated Show resolved Hide resolved
@bisgardo
Copy link
Contributor Author

As these are breaking changes, I don't think these should be just merged to main. As I see it, we have 2 options: either change these to not be breaking (if possible), or follow the process outlined below.

The way we usually handle breaking changes is:

* Make a new release branch, i.e. `release/web-sdk/8`

* Target this branch for PR's implementing breaking changes

* Merge this when we're ready.

If you need to use these changes, I would suggest publishing them to npm under either the alpha or beta tag (we usually use alpha for internal preliminary release versions. If you intend to publish the dapp-libraries based on this, I would use beta).

I'm in favor of keeping it a breaking change because having ConcordiumGRPCClient.getEmbeddedSchema only support new kinds of schemas (and actually throw an error if it's an old one) doesn't make a whole lot of sense. I would actually go a step further and remove it entirely because it's trivially expressed in terms of getModuleSource and getEmbeddedModuleSchema.

I'll let you decide what should happen. Just let me know and I'll make the relevant changes.

Btw. I'm in no rush to use this in dapp-libs. But I'm happy to prepare a PR to be merged when the time is right.

@soerenbf
Copy link
Collaborator

soerenbf commented Apr 24, 2024

I'm in favor of keeping it a breaking change because having ConcordiumGRPCClient.getEmbeddedSchema only support new kinds of schemas (and actually throw an error if it's an old one) doesn't make a whole lot of sense. I would actually go a step further and remove it entirely because it's trivially expressed in terms of getModuleSource and getEmbeddedModuleSchema.

I'll let you decide what should happen. Just let me know and I'll make the relevant changes.

I think I would prefer to just keep the method on the GRPC client, as I think it will be easier for user to migrate.

Please create a release branch for the next major version of the SDK and set it as the target branch for this. Then we'll release the changes with the next protocol update.

Copy link
Collaborator

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

Assuming this is not merged to main but to a release branch for the next major version 😉

…d instead of null

This is consistent with the rest of the library. Also removed some now-redundant `await`s from tests.
@bisgardo bisgardo changed the base branch from main to release/web-sdk/8 April 25, 2024 18:38
@bisgardo bisgardo requested a review from soerenbf April 25, 2024 18:44
@bisgardo
Copy link
Contributor Author

Assuming this is not merged to main but to a release branch for the next major version 😉

Created the release branch and set it as merge target. I also did the change with undefined instead of null. Can you please give that a quick look before I merge?

Copy link
Collaborator

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

Thanks! looks good 👍

@bisgardo bisgardo merged commit a2f852b into release/web-sdk/8 Apr 26, 2024
11 checks passed
@bisgardo bisgardo deleted the mo/schema-from-module branch April 26, 2024 09:54
@soerenbf soerenbf mentioned this pull request Aug 28, 2024
7 tasks
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.

2 participants