Dotscale
SCALE Codec Comparator - It compares multiple implementations of SCALE Codec with the reference Rust Implementation.
Created on 30th May 2021
•
Dotscale
SCALE Codec Comparator - It compares multiple implementations of SCALE Codec with the reference Rust Implementation.
The problem Dotscale solves
We worked on a proposal of SCALE Codec Comparator from the general grant program which we felt would benefit the developer ecosystem.
There are a couple of published implementations of the SCALE Codec. Since each is implemented by a different team & the reference implementation still introduces small fixes, it would be beneficial to compile a table of feature completeness. This would provide (some) assurance that the implementation in a given language is safe & sound to use.
For this hackathon, we planned to deliver a PoC which tests one of the SCALE Codec Library implementation in Golang and integrate it with the CI so that we can see live report and Badge in the project repo.
What it does
- Runs a list of SCALE codec unit tests against the codec library.
- Compares the result with the reference rust implementation.
- The test is run on Github Actions on every pull request raised in the library.
- Updates the Badge status on the repo and generates the HTML report.
How we built it
- Explored the SCALE codec by looking into the Rust Library to learn about the encoding and decoding format.
- Learned about Rust FFI and created an FFI wrapper over the GO scale codec library.
- Wrote test for various types (
string,i8,u16,u32,vecu8,optionbool,optional) for encoding and decoding. - Compared the result with the rust library.
- Integrated the test to CI (Github actions) and generated the badge and report.
Challenges we ran into
It was a challenging project altogether but major challenges were:
- We were new to Rust and Substrate it was quite a learning curve to understand scale codec by reading the reference Rust implementation.
- Exploring the Rust FFI(Foreign Function Interface) which we used to call multiple programming languages from Rust.
- Lot of SigSegV, since we were dealing with the memory unsafely.
- Integrating the report and badges in Github Actions.
Workflow

Badge Integration
Report Generation
Future work
We plan to implement the FFI wrapper for other SCALE codec libraries and integrate them to the CI to get a comprehensive report on the feature completeness.
https://github.com/arijitAD/dotscale#roadmap


