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

replace Goscale implementation with Gossamer #210

Open
StoyanDrumev opened this issue Oct 3, 2023 · 4 comments
Open

replace Goscale implementation with Gossamer #210

StoyanDrumev opened this issue Oct 3, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@StoyanDrumev
Copy link
Collaborator

StoyanDrumev commented Oct 3, 2023

The current implementation does not support Go reflection, and type definitions are wrapped around Go primitive types, which makes development unpleasant. We propose spending some time trying to integrate Gossamer’s SCALE package since TinyGo has released a new version that includes better reflection support. Narrowing down the missing parts would be beneficial. A single implementation in Go will be more reliable and developer-friendly when it is maintained by both projects, and it will showcase the usage needs of both host and runtime environment.

@StoyanDrumev StoyanDrumev converted this from a draft issue Oct 3, 2023
@failfmi failfmi changed the title Replace Goscale implementation with Gossamer replace Goscale implementation with Gossamer Oct 13, 2023
@radkomih radkomih added the enhancement New feature or request label Nov 8, 2023
@failfmi failfmi moved this from 📋 Backlog to 🆕 New in Gosemble - Polkadot Runtimes Dec 4, 2023
@failfmi failfmi moved this from 🆕 New to 🔖 On hold in Gosemble - Polkadot Runtimes Dec 4, 2023
@radkomih
Copy link
Collaborator

radkomih commented Dec 5, 2023

It's not possible to switch to the Gossamer scale codec, as the reflect implementation in Tinygo still lacks certain methods that are required by the codec: CanConvert, MethodByName, Call, Out.

@radkomih
Copy link
Collaborator

radkomih commented Dec 12, 2023

Instead of completely switching to Gossamer's SCALE types, we might consider an alternative approach.
The implementation of their VaryingData type is problematic due to the missing reflect functionality, and it seems unnecessarily complicated. However, the rest of the SCALE types appear to be ok, so we might consider adopting Gossamer's SCALE while using our implementation for the VaryingData type (type VaryingData []Encodable).

Summary of the tests we conducted (using a fork of Gossamer's SCALE implementation with the necessary modifications to support our VaryingData type - https://github.com/LimeChain/gossamer/tree/scale-codec-fixes):

  • The encoding works with all basic and composite types (including our wrapper types).
  • The implementation of the decoding interface values, which is not supported by Gossamer's SCALE, but is required for our VaryingData type, has an issue, specifically in Tinygo: reflect: setting an interface value tinygo-org/tinygo#4040.

Switching to Gossamer's SCALE seems feasible, however, we will still need to maintain a fork of it with the necessary changes for supporting our VaryingData type. Additionally, this approach could allow for simplification of many parts of the code.

Related issue: #308

@EclesioMeloJunior
Copy link

EclesioMeloJunior commented Jan 3, 2024

Hello @radkomih! I was working on this project https://github.com/crypto2lab/scale-codec, it is a scale-codec implementation free of reflection and can be compiled to wasm. It already supports enums (VDT's), results, options, tuples and I am still working on structs.

Basically you can have examples of usage here:

@radkomih
Copy link
Collaborator

radkomih commented Jan 3, 2024

@EclesioMeloJunior thanks a lot for sharing this, I'll definitely check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🔖 On hold
Development

No branches or pull requests

3 participants