Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 59 additions & 66 deletions applications/c++polkadot-light-client-implementation.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,66 @@
# "Motif": Polkadot Light Client in C++
# Proposal: "Motif" - Polkadot Light Client in C++

- **Team Name:** Equilibrium
- **Payment Address:** Ethereum: 0x4126272BA14F7a124b1B98633678e0e5F87Ec478 (USDC)
- **[Level](https://github.com/w3f/Grants-Program/tree/master#level_slider-levels):** 3
- **Proponent:** [123Xkz12bGr8i21V7vuMwBiMMWULGT7fhDJSxpwDXjg8aHD5](https://polkadot.subscan.io/account/123Xkz12bGr8i21V7vuMwBiMMWULGT7fhDJSxpwDXjg8aHD5)
- **Date:** 10.10.2022
- **Requested DOT:** $359,040

## Project Overview :page_facing_up:

This application is for a follow-up grant to [Polkadot Light Client in C++](https://github.com/w3f/Grants-Program/blob/master/applications/c%2B%2Bpolkadot-light-client.md).

### Overview
## Short description :page_facing_up:

> A light client or light node is a piece of software that connects to full nodes to interact with the blockchain ... [providing] a much better end-user experience while letting end-users access the blockchain in a decentralized and secure manner.[^1]

[^1]: Source: [parity.io/blog](https://www.parity.io/blog/what-is-a-light-client/)

This project aims to create a new light client implementation for Substrate, written in C++. The client will be an alternative to [substrate-connect](https://wiki.polkadot.network/docs/build-substrate) and other clients like it.

Reasons for having another light client:
## Context of the proposal

- Improve the light client specifications. As for now, there is only one [smoldot](https://github.com/paritytech/smoldot)-based light client implementation, which can lead to certain things and workflows being poorly documented, e.g., the light client API
This application is for a follow-up grant to Grants Program grant [Polkadot Light Client in C++](https://github.com/w3f/Grants-Program/blob/master/applications/c%2B%2Bpolkadot-light-client.md).

Reasons for writing it in C++:
- Involve the C++ community in Polkadot development. As for now, there is only a full node C++ implementation ([Kagome](https://github.com/soramitsu/kagome))
- Add more integration options for mobile and desktop platforms. C++ light client library may be reused for creating mobile and desktop wallets. C++ code of the library will also be compiled to a WASM module, allowing the launch of a light client in a browser
The previous grant for the Polkadot Light Client in C++ focused on extending the Polkadot specification with Light Client requirements and delivering a detailed specification for the implementation of the client outlined in Solution. The actual implementation will start conditional on the acceptance of this proposal.

### Project Details
Once the light client is delivered, we hope to continue working on further performance improvements based on ideas and community feedback. In addition, we’d like to explore the possibility of expanding the light client into a full node.

#### About Equilibrium

Equilibrium is a software consultancy and venture studio with a mission to further privacy and decentralization. Our clients include StarkWare, ZCash, Aleo, Protocol Labs, The Ethereum Foundation, Polygon, and quite a few more. Our expertise is deeply technical, and we also employ economists and expert cryptographers to deliver results beyond the bounds of software development.

Our recent work includes:
- [Pathfinder](https://github.com/eqlabs/pathfinder) full node for Starknet
- [Ziggurat](https://github.com/eqlabs/ziggurat) test suite used by several networks

Equilibrium has received three previous grants from the Web3 Foundation: for offchain::ipfs, for PolkaFS research, and for the research of a Polkadot light client in C++ that this proposal is about.

#### Contact & company information
- Contact Name: Olli Tiainen
- Contact Email: olli@equilibrium.co
- Website: https://equilibrium.co/
- Registered Address: Linnankatu 3, 20100 Turku, Finland
- Registered Legal Entity: Equilibrium Group Oy

#### Team members

- **Vaclav Barta** ([Github](https://github.com/vbar), [LinkedIn](https://www.linkedin.com/in/v%C3%A1clav-b%C3%A1rta-b6842b2/) is a Senior Software Developer at Equilibrium. Having implemented C++ projects for companies from Akamai to Deutsche Bank, currently creating smart contract pipelines from C to WebAssembly for XRPL Foundation.
- **Dmytro Gordon** ([Github](https://github.com/GraDKh), [LinkedIn](https://www.linkedin.com/in/dmytro-gordon-58185b5a/) is a Senior Developer at Eiger (a subsidiary of Equilibrium). He has 10+ years of experience in C++ in various domains, including cryptocurrency trading (FineryTech) and portfolio management (Globallogic).
- **Kyle Granger** ([Github](https://github.com/kylegranger) is a Senior Software Developer at Eiger (a subsidiary of Equilibrium). He has 20+ years of experience with C++ in domains including VoIP, WebRTC, block cipher design, broadcast TV, 3D graphics, and industrial cameras.

## Problem statement

Increasing client diversity is an important part of developing any mature protocol as it
- expands the developer pool capable of building secure, highly performant applications,
- improves specifications, and
- diversifies risk across multiple implementations.

For now, the Polkadot ecosystem has only one light client based on [smoldot](https://github.com/paritytech/smoldot) written in Rust.

We propose expanding the set of clients available for developers by building a new light client in C++ to
- provide the C++ community an alternative to the full node ([Kagome](https://github.com/soramitsu/kagome)) in C++
- expand the developer community interested in developing secure applications on Polkadot
- enhance developer experience by making the client smaller and easier to understand
- improve light client specifications e.g. the light client API
- add more integration options for mobile and desktop platforms: C++ light client library may be reused for creating mobile and desktop wallets, and the code will also be compiled to a WASM module, allowing the launch of a light client in a browser.


## Solution

[![mermaid.png](https://i.postimg.cc/PrgJtfkN/mermaid.png)](https://postimg.cc/56mbgVyM)

Expand All @@ -42,7 +78,7 @@ To support the light client functionality, we will implement support of the foll

We will use hash_map with serialization/deserialization to hold the blockchain state. In addition, we will use OpenSSL for cryptography functions (e.g., Blake2) and port the required algorithms not included in OpenSSL (e.g., Schnorr signatures).

#### Requirements
### Requirements

Note: The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119).

Expand All @@ -55,9 +91,6 @@ _User Experience_
- The client library MUST be architected to minimize the coupling of functionality and the user interface
- The client library MUST support Linux and WebAssembly targets. It MUST be usable in browsers with a JS wrapper(hereafter _WASM module_).
- The client library SHOULD be implemented as cross-platform but full support of other platforms(e.g. Windows, Mac OS, Android) is out of the scope.



- The client MUST be sufficiently documented
- The client MUST contain standalone documentation for users
- The client library code SHOULD contain inline documentation for current and future developers
Expand All @@ -76,47 +109,15 @@ _Functionality_

[^2]: This could be discussed in future grant proposals.

## Team :busts_in_silhouette:

#### About Equilibrium

Equilibrium is a software consultancy and venture studio with a mission to further privacy and decentralization. Our clients include StarkWare, ZCash, Aleo, Protocol Labs, The Ethereum Foundation, Polygon, and quite a few more. Our expertise is deeply technical, and we also employ economists and expert cryptographers to deliver results beyond the bounds of software development.

Our recent work includes:
- [Pathfinder](https://github.com/eqlabs/pathfinder) full node for Starknet
- [Ziggurat](https://github.com/eqlabs/ziggurat) test suite used by several networks

Equilibrium has received three previous grants from the Web3 Foundation: for offchain::ipfs, for PolkaFS research, and for the research of a Polkadot light client in C++ that this proposal is about.

#### Contact information
- Contact Name: Olli Tiainen
- Contact Email: olli@equilibrium.co
- Website: https://equilibrium.co/

#### Legal structure
- Registered Address: Linnankatu 3, 20100 Turku, Finland
- Registered Legal Entity: Equilibrium Group Oy

#### Team members

- **Vaclav Barta** ([Github](https://github.com/vbar), [LinkedIn](https://www.linkedin.com/in/v%C3%A1clav-b%C3%A1rta-b6842b2/) is a Senior Software Developer at Equilibrium. Having implemented C++ projects for companies from Akamai to Deutsche Bank, currently creating smart contract pipelines from C to WebAssembly for XRPL Foundation.
- **Dmytro Gordon** ([Github](https://github.com/GraDKh), [LinkedIn](https://www.linkedin.com/in/dmytro-gordon-58185b5a/) is a Senior Developer at Eiger (a subsidiary of Equilibrium). He has 10+ years of experience in C++ in various domains, including cryptocurrency trading (FineryTech) and portfolio management (Globallogic).
- **Kyle Granger** ([Github](https://github.com/kylegranger) is a Senior Software Developer at Eiger (a subsidiary of Equilibrium). He has 20+ years of experience with C++ in domains including VoIP, WebRTC, block cipher design, broadcast TV, 3D graphics, and industrial cameras.
### Milestones & deliverables :nut_and_bolt:

## Development Status :open_book:

The previous grant for the Polkadot Light Client in C++ focused on extending the Polkadot specification with Light Client requirements and delivering a detailed specification for the implementation of the client outlined in Project Details.
The actual implementation will start conditional on the acceptance of this proposal.

## Development Roadmap :nut_and_bolt:

### Overview
#### Overview

- **Total Estimated Duration:** 4 months
- **Full-Time Equivalent (FTE):** 3 FTE
- **Total Costs:** $359,040

### Milestone 1 — Native light client console application with minimal JSON RPC functionality
#### Milestone 1 — Native light client console application with minimal JSON RPC functionality

- **Estimated duration:** 1 month
- **FTE:** 3
Expand All @@ -134,7 +135,7 @@ The actual implementation will start conditional on the acceptance of this propo
| 4 | Chain connection and event processing support | Add support of chainHead\_unstable\_follow, chainHead\_unstable\_unfollow and chainHead\_unstable\_unpin JSON RPC methods |


### Milestone 2 — C++ library with light client functionality
#### Milestone 2 — C++ library with light client functionality

- **Estimated duration:** 1 month
- **FTE:** 3
Expand All @@ -148,7 +149,7 @@ The actual implementation will start conditional on the acceptance of this propo
| 0d. | Docker | We will provide a Dockerfile(s) that can be used to test all the functionality delivered with this milestone. |
| 1 | C++ library artifact | Prepare separate C++ library artifact (separate C++ build and installation targets along with documentation, tests and examples) |

### Milestone 3 — JS light client library
#### Milestone 3 — JS light client library

- **Estimated duration:** 1 month
- **FTE:** 3
Expand All @@ -164,7 +165,7 @@ The actual implementation will start conditional on the acceptance of this propo
| 2 | WASM compilation target | Add WASM compilation target for C++ client library |
| 3 | JS wrapper | Implement JS wrapper around WASM module |

### Milestone 4 — Implement more JSON RPC methods
#### Milestone 4 — Implement more JSON RPC methods

- **Estimated duration:** 1 month
- **FTE:** 3
Expand All @@ -179,15 +180,7 @@ The actual implementation will start conditional on the acceptance of this propo
| 0e. | Article | We will publish an article on Medium that explains why this version of a light client was created, how it was built, and what users can do with it. |
| 1 | Additional JSON RPC methods | Add support of _rpc\_methods_, _chainHead\_unstable\_storage_, _chainHead\_unstable\_call_ and _chainHead\_unstable\_stopCall_ |

## Future Plans

Once the light client is delivered, we hope to continue working on further performance improvements based on ideas and community feedback. In addition, we’d like to explore the possibility of expanding the light client into a full node.

We will also promote the light client on our social media and other marketing channels.

## Additional Information :heavy_plus_sign:

### Why Polkadot Network?
## Why Polkadot Network?

Equilibrium believes the Polkadot (and by proxy, Kusama and Substrate) is exceptional for the following reasons:

Expand Down