Search projects, hackathons, sponsors and tech

    ← All projects

    Dotscale

    SCALE Codec Comparator - It compares multiple implementations of SCALE Codec with the reference Rust Implementation.

    Demo

    About

    The problem it solves We worked on a proposal of [SCALE Codec Comparator](https://github.com/w3f/General-Grants-Program/blob/master/rfps/scale-codec-comparator.md) 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](https://github.com/centrifuge/go-substrate-rpc-client/blob/master/scale/codec.go) in Golang and [integrate it with the CI](https://github.com/arijitAD/dotscale/pull/3/checks?check_run_id=2703587535) 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](https://github.com/paritytech/parity-scale-codec). * The test is run on [Github Actions](https://github.com/arijitAD/dotscale/runs/2703587535?check_suite_focus=true) on every [pull request](https://github.com/arijitAD/dotscale/pull/3) raised in the library. * Updates the [Badge status](https://github.com/arijitAD/dotscale#dotscale---scale-codec-comparator) on the repo and generates the [HTML report](https://arijitad.github.io/dotscale/). ## 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.

    How it's made

    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 ![](https://i.imgur.com/eTNK8Oz.jpg) ### Badge Integration [![Badge Integration](https://i.imgur.com/IxXZ6nW.png)](https://github.com/arijitAD/dotscale) ### Report Generation [![Report Generation](https://i.imgur.com/UvgLyxh.png)](https://arijitad.github.io/dotscale/) ## 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 ![](https://i.imgur.com/1ng5zT4.jpg)