Java Host Research Proposal
- Project Name: Research feasibility of Polkadot Host in Java
- Team Name: LimeChain
- Payment Address: eth:0x1F7683228Ee9Bc65335374eA5c92B81C74131404 (USDC/USDT/DAI)
- Level: 3
Project Overview 📄
Over the past several years the Polkadot and Substrate community has put a lot of effort into growing the diversity of both Host and Runtime implementations. Firstly, in addition to the Substrate runtime environment, currently, an alternative framework for building Substrate-compatible runtimes in Go is being developed (by another team at LimeChain) . On top of that, multiple different language host implementations have been built, and are currently maintained and improved:
- Go: gossamer by ChainSafe
- C++: kagome by Soramitsu
- Rust: polkadot by Parity
- Rust Light Client: smoldot by Parity
While the ecosystem is growing with multiple alternatives for host implementation, adding a host implementation in Java will further enhance the diversity, and will enable a whole new subset of participants to enter the Polkadot ecosystem.
If we try to judge the possible diversity increase, we can look no further than the Ethereum ecosystem as an example of client diversity. Currently, around 18% of the consensus nodes run the Java-based consensus client (Teku) and around 6% of the users run the java execution client (Hyperledger Besu).
Furthermore, such a host written in java has the chance of attracting the attention of the Java development communities and Java-centric organisations. These ecosystems and organisations usually consist of well-established organisations and communities. Some of the key advantages of Java-based applications include:
- Platform independence: Java code can be run on any device or operating system that supports a Java Virtual Machine ( JVM), making it a highly portable language. This is particularly valuable for enterprises, which often have complex, distributed IT environments with a mix of different operating systems and hardware platforms.
- Scalability and performance: Java is a high-performance language that is designed to be scalable and efficient. It has a number of features, such as just-in-time compilation and garbage collection, that make it well-suited for large-scale, resource-intensive applications. The team at Limechain is a contributor to Hedera Hashgraph - a high performant BFT-based ledger network primarily built in Java.
- Strong community and support: As a widely-used language with a large and active community of developers, Java has a wealth of resources and support available for developers. This includes support on the most popular libraries, as well as a wealth of online resources and communities where developers can go for help and advice.
- Enterprise-grade libraries and tools: Java has a rich ecosystem of libraries and tools that are specifically designed for enterprise-grade applications. This includes things like enterprise application frameworks, data access libraries, and security tools, all of which make it easier for developers to build high-quality, enterprise-grade applications. One such, relevant example is the Java version of the wasm execution environment - wasmer
In summary, having a host implementation in Java will further expand the ecosystem and enhance diversity. If the state of the blockchain networks, and the history of software engineering for that matter, has taught us anything, it is that the bigger and more diverse the ecosystem is - in terms of both people and software, the more resilient it is. With this research, we want to contribute to increasing both of these.
Research & PoC development
The end goal of this initiative is to create a host implementation in Java. Going directly for a host implementation could prove a challenging task, thus spending the time to abstract and formalise the different building blocks and their implementation feasibility in Java is the rational first step.
The end goal of the research as part of this grant is to prove the feasibility and formalise the architecture of Java Host written in Java.
We would focus on clearing out the unknowns, mitigating the risks and doing feasibility research for several components that hold the biggest risks:
- Runtime Execution Environment - Verify that Java can be a viable and performant execution environment for WASM,
and especially the WebAssembly MVP with the domain-specific API that Polkadot uses. In order to clear out this
unknown, the team will create a PoC to prove or disprove the feasibility of a Java-based execution environment. The
library to be tested is
wasmer-java. The following functionalities of
wasmer-javawill be tested:
wasm(WebAssemblyMVP) bytecode for execution
- Import Host APIs within the Runtime
- Verify that all
cryptoand hashing primitives can be implemented in Java
- Verify that all
__heap_baseexported from the
- Allocate/Deallocate memory buffer for transferring data between Host and Runtime
- Set data in the shared memory buffer for sending data to Runtime
- Call exported from the WASM Bytecode function with data arguments
- Read and parse the returned data of the WASM Runtime from the shared memory buffer
- PolkaJ - https://github.com/emeraldpay/polkaj has a lot of the required building blocks for a Java Host. The team
will verify or disprove the feasibility of the
SCALEcodec implementation as-well as the WASM Wrapper implementation of https://github.com/w3f/schnorrkel. As an alternative implementation of
schnorrkelwe will explore https://github.com/debuggor/schnorrkel-java as-well.
- libp2p -
yamuxand kademlia are not yet supported in the JVM implementation. We will assess the scope of the missing libraries and will contact the team to discuss potential implementation on their side or contributing on our.
Furthermore, the project will include multiple research outcomes, detailing and specifying the way that the different components of light and full nodes can be built.
- Daniel Ivanov
- Georgi Spasov
- Viktor Todorov
- Contact Name: Christian Veselinov, Zhivko Todorov, George Spasov
- Contact Email: firstname.lastname@example.org , email@example.com, firstname.lastname@example.org
- Website: https://limechain.tech
- Registered Address: Bulgaria, Dragan Tsankov 23A, 1113, Sofia, Bulgaria
- Registered Legal Entity: LimeLabs Ltd.
At LimeChain, we feel confident in and have a lot of development hours invested in the Polkadot ecosystem. Some of the ecosystem work we’ve done involves the creation of Runtime from scratch and evolving it into fully capable frameworks for building Substrate Runtimes.
We have extensive experience in building Java clients, given that we are contributors to Hedera Hashgraph, where we are part of the development of the network client in Java. We also feel experienced in building developer tooling, specifically within Rust/WebAssembly (matchstick). All of this emphasizes that the knowledge/expertise of the company spans across the required technological stacks - Substrate, WebAssembly and Java.
Team Code Repos
Please also provide the GitHub accounts of all team members. If they contain no activity, references to projects hosted elsewhere or live are also fine.
Team LinkedIn Profiles (if available)
Development Status 📖
As part of our current research, we’ve compared the Polkadot host specification and requirements with the currently available tools and libraries in Java needed to implement it. While the preliminary research shows positive results, several important aspects of the creation of a host need to be further proven, tested or researched:
- The feasibility of using Java as an execution environment for WebAssembly MVP
- Another popular Polkadot Host implementation - Gossamer - uses wasmer as an execution environment for the runtime WebAssembly. Wasmer-java is an available option but needs to be tested out against WebAssembly MVP and the domain-specific APIs.
- The overall feasibility of the creation of the different modules and the rough architecture (storage, consensus, networking, RPCs, etc) in order to create light and full client nodes.
Development Roadmap 🔩
Described below are the steps we think are necessary to get a deep understanding of how the Java host can be built:
- Review and build a PoC for
wasmer-javaagainst WebAssembly MVP
- In order to prove the feasibility of Java being an execution environment we will create a small POC showcasing the ability of Java to communicate with a WebAssembly MVP binary
- Validate / Invalidate the applicability of PolkaJ
- Reusing the
- Reusing the
schnorrkelof PolkaJ or schnorrkel-java
- Reusing the
- Research the feasibility of libp2p-jvm
- Discuss timelines on implementing
kademliawith Protocol Labs or potential contribution
- Discuss timelines on implementing
- Research the feasibility of the different modules needed in order to create a light client
- Research the feasibility of the different modules needed in order to create a full host
- Propose an architecture and sensible roadmap for implementing a Java Host, based on the previous steps
- Total Estimated Duration: 6 working weeks
- Full-Time Equivalent (FTE): 2
- Total Costs: $36,000
Milestone 1 — Research the feasibility of Polkadot Host in Java
- Estimated duration: 6 working weeks
- FTE: 2
- Costs: $36,000
This milestone will:
|0b.||Documentation||We will provide Markdown documentation of the whole research, explaining the necessary steps needed to resolve the technical challenges of the creation of a Java-based light client and full host.|
|1a.||PoC||Research and outline the feasibility of using |
|1b.||Testing Guide||We will provide a testing guide of the PoC of a Java-based WASM execution environment|
|1c.||Docker||We will provide a Dockerfile(s) that can be used to test the PoC.|
|2.||Research||Research and verify the feasibility of reusing PolkaJ libraries for various components such as |
|2.||Research||Research and outline the design of the p2p module of the Java Polkadot Host. Asses the implementation of |
|3.||Research||Research and outline the design of the storage module (Host and Runtime) of the Java Polkadot Host.|
|4.||Research||Research and outline the design of the RPC API of the Java Polkadot Host.|
|5.||Research||Research and outline the design of the modules and APIs for the Java Polkadot Host to be part of the consensus-reaching processes.|
|6.||Documentation||Java Polkadot Host design document will be produced that combines the research findings of the previous deliverables and outlines a high-level specification for the creation of a Java-based Host.|
|7.||Documentation||Java Polkadot Host design document will be produced that combines the research findings of the previous deliverables and outlines a high-level specification for the creation of a Java-based Light-client.|
Having this research will give us a clear understanding of how Java light and full clients can be built. Completing it will become the foundational block for the creation of the Java-based Host which would be the next step for the team after delivering this research.
Additional Information ➕
LimeChain has been a long-time contributor to the Substrate ecosystem mainly focused on developer tooling. Due to our involvement in the space, we are working with various clients, developing smart contracts and working on parachains.