Virtual Rollups SDK Launches

Integrate Free Gas, Web2 UX in Under an Hour

Alexander AtamanovJosé.virtual |  Aug 23, 2023

August 23, 2023, marks the rollout of Virtual Labs SDK version 0.2 to selected beta partners! This update extends the feature set to include free gas, instant P2P finality, and a seamless UX to all games. It also refines the architectural components from the initial version, aiming to provide a more developer-centric interface. This article will be highly technical and is intended for developers and those interested in Virtual Rollups from a granular POV. If you are new to Virtual Labs or Virtual Rollups, the attached links provide a non-technical overview.

Source: Virtual Labs

The Highlights!

1. The Virtual Labs SDK is released to the first closed beta, which is now filled. To get in touch for new spots that have opened today, click here.

2. Virtual Labs is not only focused on user experience, but also developer experience with the launch of our Developer Portal and integration possible in under an hour with now all P2P network complexities abstracted away.

3. Virtual Labs Virtual Rollup users are the network nodes, validating their own data right in the browser.

  • This permissionless system increases decentralization via higher participation, lowers latency with direct connections, and secures a private and scalable network.

4. Our tech team is ready to assist you in your journey to bring on new users and increase engagement, made possible through a seamless UX!

The following few sections provide in-depth descriptions of our decision making process and architectural intricacies. To get to the meat and potatoes, skip to The Cool Part.

Virtual Labs JavaScript and Typescript SDK

Both Typescript and JavaScript stand as central languages in Web3 development, as they form the backbone of numerous decentralized applications, smart contract interactions, and front-end designs. JavaScript's longstanding presence in web development has led to a plethora of tools, libraries, and community support. Its applicability in server-side (Node.js) and client-side development creates a cohesive ecosystem that fits well with decentralized technologies. Virtual Labs SDK supports both - node.js and browser environments. Typescript, a superset of JavaScript, brings type safety to Web3 development. By providing static typing, it assists in catching errors at compile-time rather than runtime, leading to a more robust and maintainable codebase. Both languages are known for their compatibility with various blockchain protocols, libraries like web3.js, ethers.js, and frameworks, making them ideal choices for building diverse Web3 applications. The flexibility and extensive community contributions make these languages capable of adapting to the evolving nature of blockchain technology. That is why Virtual Labs has chosen to release our JS/TS SDK first. Typescript is the recommended way of interacting with Virtual Labs SDK, though.

Future Platforms: Unity, iOS, Android, and Go

Virtual Lab's roadmap includes expanding the SDK's compatibility to Unity, iOS, and Android. This planned expansion reflects the understanding of the growing need for cross-platform solutions, facilitating the integration of Virtual Rollup technology across various environments. It will open doors to new opportunities, including mobile-based decentralized applications based on the Virtual Rollup technology and immersive experiences through Unity, thereby broadening the scope and reach of Virtual Lab's capabilities.

Source: Virtual Labs, Sequence Diagram

API Access Types

Classical Promise-based API: This API type uses Promises, offering a structured way to handle asynchronous operations. It enables chaining, error management, and parallel task execution, aligning with current development patterns in JavaScript. Promise-based API requires a bit more technical knowledge and manual operation, than the subsequent option.

Reactive API: This approach leverages reactive programming principles based on RxJS to allow more automated interaction with the Virtual Labs Virtual Rollup. The reactive pattern encourages real-time responsiveness and a more intuitive development process, detailed further in Virtual Lab's Quick Start guide.

Virtual Labs SDK 0.2 Features

Virtual Labs SDK 0.2, designed for Typescript and Javascript, and emphasizes browser compatibility. The core architecture is built around the OntropySDK class, with two main provider members: OntropyNetworking and OntropyCrypto. The OntropySDK class itself is responsible for the interaction with the Virtual Rollup. You can check out the  Virtual Labs SDK API here.

Virtual Labs SDK Networking Capabilities

Virtual Labs supports two main communication methods:

  • Peer-to-Peer Networking using WebRTC Direct: A decentralized communication structure that aligns with the principles of Web3.
  • Broadcast Networking on socket.io: In version 0.2, this is the default option. Virtual Labs plans a gradual transition to peer-to-peer (P2P) as the supporting infrastructure expands. The P2P approach underscores the core tenets of decentralization, enhancing resilience, reducing latency, and negating dependence on centralized servers.

What is interesting about it? WebRTC Direct is a decentralized communication structure tailored for peer-to-peer (P2P) connections, highly suitable for the principles of Web3. WebRTC enables direct communication between browsers without the need for an intermediary server. This is achieved through a process called signaling, which involves the following technical steps:

  1. ICE Candidate Gathering: ICE (Interactive Connectivity Establishment) protocol is used to gather possible ways (candidates) to connect with peers. These candidates include potential IP addresses and ports of each peer.
  2. Offer/Answer Model: One peer (the offerer) creates an offer that contains information about media and supported codecs. The other peer (the answerer) then responds with an answer.
  3. NAT Traversal using STUN/TURN: In cases where peers are behind Network Address Translation (NAT) or firewalls, STUN (Session Traversal Utilities for NAT) servers are used to discover public IPs and ports. If a direct connection fails, TURN (Traversal Using Relays around NAT) servers act as relays to aid the connection.
  4. DTLS Handshake: A secure channel is created using the DTLS (Datagram Transport Layer Security) handshake, ensuring encrypted communication.

Decentralization Aspect of WebRTC Direct: The pivotal feature that distinguishes WebRTC Direct is its inherent decentralization. Unlike traditional client-server models where communication passes through a centralized server, WebRTC establishes a direct pathway between peers. This offers several key advantages:

  • Data Privacy and Integrity: Direct connections eliminate potential interception points, enhancing data privacy.
  • Reduced Latency: As data doesn't have to travel through a central server, communication is more immediate, optimizing real-time interaction.
  • Enhanced Resilience: Without dependency on central servers, the system is less prone to censorship resistance and outages.

In the context of Virtual Labs and Web3, WebRTC's decentralized nature is synergistic with the underlying ethos of transparency, trust, and elimination of centralized control. It empowers users with true ownership of their connections, reinforcing the principles of a decentralized network, while ensuring efficiency and security in communication.

Utilization of PubSub Mechanism: The Publish-Subscribe (PubSub) methodology, a well-known messaging pattern, is instrumental in the development of decentralized applications. Within the distributed networking architecture, nodes "publish" messages to a specified topic, and other nodes that have "subscribed" to that topic receive those messages. In the absence of reliance on central brokers, PubSub is aligned with the principles of a trustless and decentralized ecosystem. By employing this method, information dissemination becomes highly flexible and scalable, fostering real-time communication and collaboration without exposing the inner intricacies of the network. Virtual Labs extensively uses the PubSub pattern to form Virtual Labs Virtual Rollup sessions.

Integration of KatDHT and Kademlia for Distributed Hash Table (DHT): At the core of decentralization, implementing Kademlia-based Distributed Hash Tables (DHT) like KatDHT enhances the capability of Virtual Labs Virtual Rollups. This algorithm establishes an unstructured network topology, where nodes maintain data regarding other participants. By crafting a logical domain where each node holds a subset of the whole data, information can be retrieved through a series of inquiries. This design minimizes the reliance on specific nodes while maximizing fault tolerance and ensuring rapid response time. A fusion of Kademlia with Virtual Lab's architectural features yields a network that's both robust and adaptable to the fluidity of a decentralized landscape, sculpting an advanced framework for interconnected communication.

Source: Virtual Labs, Class Diagram

The Cool Part

The networking magic in Virtual Labs? It's all under the hood. Whether it's WebRTC or any other decentralized communication wizardry, developers don't have to sweat the small stuff. Virtual Lab's got it covered. The entire peer-to-peer networking layer is seamlessly abstracted away, leaving developers free to focus on what matters most: crafting top-notch decentralized apps. It's like having a supercharged engine that takes care of itself, letting developers ride the Web3 wave with style and ease.

Now, what's unique about Virtual Lab's approach? Well, it places the actual Virtual's Rollup users as the network nodes and does so right in the browser. This is not only innovative, but exciting! Eschewing the traditional dependence on back-end servers, Virtual Lab's in-browser execution hands over the keys to genuine decentralization. No intermediaries, no needless complexity—pure, unadulterated P2P interaction.

This novel concept goes beyond a mere technological flair and is genuinely useful:

  • Latency issues become virtually non-existent with direct P2P connections that cannot go down.
  • Decentralization is increased as only an internet connection and device capable of loading a browser are needed to become a node.
  • Even more, this is done automatically so every user who is playing and enjoying their game is also securing their own data, and the network
  • Because connections are direct, data remains private and secure
  • Virtual Labs is also scalable and adaptable as the dynamic capabilities of the Virtual Rollups SDK allow it to conform to any game with unlimited compute across an infinite horizontal spectrum (as opposed to L2s which stack on top of one another, deferring security downwards).

Virtual Labs SDK Cryptography Improvements

Version 0.1 served as the foundational layer for Virtual Lab's cryptography functions:

  • Multi-party randomness generation implemented on ElGamal in ModP groups;
  • ECDSA primitives;
  • Other cryptographic utilities.

The cryptography was initially developed in RUST and deployed as a wasm module, encompassing only a part of the needed cryptographic functionalities.

Version 0.2 goes beyond, significantly improving the cryptography module and introducing Networking and the API for direct interaction with the Virtual rollup. This step reflects Virtual Lab's commitment to streamlined development, improved scalability, and enhanced developer experience in the decentralized application landscape.

Some of the cryptographic updates include:

  • Modified Verifiably Fair Randomness on Elliptic Curve secp256k1: By adopting the secp256k1 curve, commonly used in Ethereum's ecosystem, Virtual Labs has optimized on-chain data verification. This curve's compatibility with prevalent blockchain standards enhances interoperability and resource efficiency within Ethereum.
  • MuSig2/FROST for Virtual Rollup State Verification: Utilizing MuSig2 and FROST within Virtual Lab’s framework provides a secure and efficient means to verify the virtual rollup state, aligning with Ethereum's multi-signature requirements and consensus mechanisms.
  • BLS12_381 Base Curves for Optimized BLS Verification (Experimental): The experimental incorporation of BLS12_381 base curves sets the groundwork for advanced BLS signature verification, a feature aligned with Ethereum 2.0's ambitions for scalability and efficiency.

These cryptographic updates reflect Virtual Lab's strategic alignment with Ethereum, enhancing functionality and performance within the Web3 environment.

SDK Documentation and Support

With the launch of version 0.2, Virtual Labs is not only releasing an updated SDK but also introducing a comprehensive technical documentation portal. This initiative represents a commitment to support and grow the developer community around  Virtual Lab's Virtual Rollup technology.

Technical Documentation Portal The newly-established portal serves as a central hub for all technical resources related to Virtual Labs SDK. Check it out: https://docs.virtual.tech/introduction/welcome

Here's what it currently includes and what it's aimed to become:

User Guides and SDK Documentation: The portal offers detailed user guides and extensive SDK documentation, catering to developers at different expertise levels.

Getting Started Guides: For those new to Virtual Labs, these guides provide step-by-step instructions on initial setup, configuration, and basic functionalities. SDK Reference: A comprehensive documentation covering all classes, methods, interfaces, and modules within the SDK. This section serves as a go-to manual for understanding the SDK's architecture and how to utilize its features. Sample Code and Tutorials: Practical examples and tutorials offer hands-on experience in building applications with the SDK, promoting learning through practice.

Future Evolution into a Technical Community: Virtual Lab's vision for this portal extends beyond being a mere repository of guides and references. It is planned to evolve into an active technical community, where developers can:

Manage Virtual Rollup Settings: Customization and control of rollup parameters will be accessible, providing developers the autonomy to tailor the Virtual Rollup to their specific requirements.

Manage Access Keys: A centralized interface for handling authentication and authorization, ensuring secure access and management within the Virtual Labs ecosystem.

Access Real-time Monitoring Data: Developers will be able to track critical system stats, key performance indicators, and related data on-the-fly. This feature enhances the ease of performance tuning, issue diagnosing, and strategic decision-making.

By building this platform,  Virtual Labs aims to create a collaborative and resource-rich environment. The integration of community input, support forums, and regular updates will foster innovation and growth within the ecosystem. The technical documentation portal reflects Virtual Lab's dedication to nurturing a developer-centric culture, recognizing that a well-supported community is instrumental in driving the adoption and success of  Virtual Lab's Virtual Rollup technology.

Compatibility List

Virtual Lab's cryptographic functionality is fundamentally built on WebAssembly (Wasm), and it is packed with modern tooling based on Vite to ensure comprehensive browser support. Here's an in-depth look into why Wasm plays a crucial role in  Virtual Labs compatibility and its benefits:

WebAssembly (Wasm) in Virtual Labs WebAssembly is a binary instruction format that operates as a virtual machine to execute code at native speed. The application of Wasm in Virtual Lab's cryptographic components offers several key advantages:

Performance: Wasm's binary format ensures that the code executes faster compared to the traditional approach. This leads to improved computational efficiency, particularly significant in cryptographic operations that demand high performance.

Language Flexibility: Wasm enables Virtual Labs to write cryptographic functions in languages like Rust, which are then compiled into Wasm. This promotes code optimization and allows leveraging language-specific features for enhanced security and reliability. It also allows us to build native libraries for any platform if needed.

Platform Independence: Being a standard supported by modern browsers, Wasm ensures that Virtual Lab's cryptographic features are consistent across various platforms. This platform-agnostic nature reduces fragmentation and facilitates smooth integration.

Security: Wasm operates within a sandboxed execution environment, minimizing potential security risks. Its strong typing and structured control flow provide additional layers of safety.

Integration with Vite: Packing with Vite, a build tool that aims to provide a faster and leaner development experience, enhances Virtual Lab's loading speed and compatibility across browsers.

Browser Support Virtual Lab's reliance on Wasm aligns it with all modern browsers that support WebAssembly. This corresponds to an estimated 95.07% share of global users, with an additional 1-1.5% that could potentially be converted to support with certain adjustments.

Source: CanIUse + Virtual Labs, Major Browser Compatibility List

It is worth noting that addressing compatibility with older browsers that lack Wasm support is not a current priority for Virtual Labs. The rationale behind this decision stems from:

Aligning with up-to-date standards and technologies that are progressively adopted in the development community. Concentrating efforts on enhancing features and functionality for the majority of users rather than diverting resources to cater to a diminishing segment. Virtual Lab's compatibility strategy, grounded in the utilization of WebAssembly, supports its commitment to delivering a robust, efficient, and secure solution. By focusing on modern browsers and leveraging Wasm's benefits, Virtual Labs ensures that its cryptographic functionality is accessible and optimized for the vast majority of users. This approach reflects a balance between technological innovation and practical considerations, aligning with Virtual Lab's vision and the evolving landscape of Web3 applications. You can check the browser compatibility on https://caniuse.com/?search=wasm

Conclusion

Thank you for reading about the  Virtual Labs SDK Launch. Our closed beta is currently full, but we are excited to open new spots starting today. To get in touch, please leave your function requirements and other needs and use cases in our short application form here.

We release new and exciting articles here and to your email every Wednesday. You may consider subscribing via the button down below. Additionally, following  Virtual Lab’s Twitter (X) serves as a good source of community and tech quicktakes.

Clicky