KasMedia Logo
Interview

Rusty Kaspa FAQs

May 19, 2024Jennifer Ghelardini8 min read

We spoke with Michael Sutton and CoderofStuff to clarify some of our questions about the recent Rusty Kaspa rewrite. We summarized their answers below:

What are the core solutions solved by migrating to Rust? 

Scalability towards local node resources. The Rust codebase is designed to optimize the host's computational resources, employing parallel processing extensively whenever feasible. It heavily relies on parallel processing wherever possible. This allows scaling the network to 10 BPS and beyond and handling it on commodity hardware by using all the available CPU threads in parallel.

Increase block rate beyond 10 BPS. Previously, the system architecture of the Golang node limited the block rate due to running the core consensus logic sequentially. While in Rust, the network uses all the available CPU threads in parallel, meaning that the core consensus logic can run concurrently.  

Introducing a pruning mechanism to mitigate rapid data growth. The Rust node offers advantages by addressing software bottlenecks to enhance speed and pruning efficiency and providing enhanced security inherent to Rust. The improvements to pruning come from complementing the existing reachability algorithms with a new algorithmic component that allows the dynamic deletion of structural DAG data, enabling on-the-fly header pruning.

Improve code modularity to increase community development. Creating more efficient code with greater modularity allows developers to easily commit to the Kaspa code and build decentralized applications (dapps) for the Kaspa community. 

Why choose the Rust language for the rewrite?

Rust is known for its efficiency as a programming language. Its performance is approximately 10% lower than that of C, which is considered the benchmark of low-level and optimized programming. However, Rust still offers high-level programming constructs that are unmatched in terms of code-writing productivity and security and safety measures.

Rust is one of the fastest and most memory-safe languages, and its modular code is interoperable with other languages. Its ability to optimize multiple parallel DB reads made it a natural choice for Kaspa.

How long did it take to complete the rewrite?

Kaspa developer Michael Sutton first introduced the code rewrite in Rust Language in July 2022 in the official Kaspa Discord, and it was approved as the first Kaspa Improvement Proposal (KIP—001). The community raised 100M KAS to fund the colossal undertaking, which is known in documentation as Rusty Kaspa. A team of about fifteen core developers completed it in roughly a year and a half.  

What are some advantages for running your node with the new software?

The main benefits to node maintainers include:

Near-constant storageRusty Kaspa nodes continuously prune both transaction data and headers. This approach maintains lower and more stable node disk usage levels over time that are nearly constant.

Fast sync times. Harnessing parallelism, Kaspa is able to boost the speed of processing headers and blocks, especially in IDB.

RPC software stackRusty Kaspa has provided design enhancements to the RPC interfaces, expected to be extended in the near future. 

How can an efficient client upscale throughput, particularly for Kaspa? 

To boost Kaspa's throughput, efficient client strategies include implementing consensus workflows with concurrency and parallelism. This means processing tasks concurrently in pipelines and validating data in parallel, optimizing hardware and software efficiency to minimize bottlenecks.

Rust's efficiency and support for parallel computation are crucial for Kaspa's high block rate and transaction concurrency. This enables Kaspa to maximize hardware utilization, as seen with testnet-11, achieving 10 blocks per second on affordable hardware and supporting up to 32 blocks per second on commodity hardware.

How does Rusty Kaspa achieve higher Speed (BPS and TPS) than with Kaspa in Go?

Kaspa was designed for parallel computation, which is the ability to process simultaneous blocks in parallel on diverse threads inside the same CPU. This breakthrough algorithm resulted in higher blocks per second while keeping the same block size, which increases transactions per second and ultimately results in faster throughput. 

Is Rusty Kaspa the first cryptocurrency network to validate parallel blocks simultaneously inside the same CPU on different cores?

Yes. To our knowledge, Kaspa is the first to do this. 

How exactly is pruning more efficient in Rust?

Kaspa in Go (Kaspad Golang) did not support concurrency, meaning that logic related to the core consensus ran sequentially. As pruning the block data is part of the consensus logic, this action must be completed before moving on to the next step. With Go, depending on the transaction load, there would be a few seconds to minutes when the block templates were not being updated. During this time, mining would be paused while the garbage collector would run to conclude pruning. This would result in a queue of parallel blocks that were all unaware of each other, known as an "anti-chain" of blocks. Some blocks created would result as red blocks and would not be rewarded due to the K=18 block limit. 

How is Rust for optimizing many parallel DB reads?

Rust is highly effective for optimizing many parallel database reads, especially using a robust database engine like RocksDB. Here are the key points based on Michael's insights:

Advanced Database Engine: Rust utilizes RocksDB, considered more advanced than LevelDB, the database engine used by Go. RocksDB's advanced features contribute significantly to optimizing parallel reads.

Concurrent Design: Rust's overall concurrent design is crucial for managing multiple stores and writing semantics with fine granularity. This means that data locking occurs only during actual writes, allowing for parallel database reads as a built-in feature.

Support for Read-Access from Secondary Processes: Unlike LevelDB, RocksDB supports read-access to the same database from a secondary process. This capability is particularly valuable as it enables external tools to access the database without shutting down the node. This feature is extremely useful for certain use-cases where uninterrupted access to the database is essential.

Does switching to Rust directly affect smart contract development?

The relevant code segments are much simpler to extend because they are structured in a robust and modular fashion. Moreover, the Rust WebAssembly (WASM) ecosystem has the potential to be incredibly valuable for smart-contract design purposes.

How does Rusty Kaspa incorporate WASM?

Rusty Kaspa leverages the power of WebAssembly (WASM) and Rust's compatibility with it to create a robust and secure development environment. Here's how Rusty Kaspa incorporates WASM:

Rusty Kaspa takes advantage of the synergy between Rust and WebAssembly (WASM) to create a robust development ecosystem. Here's an overview of how Rusty Kaspa incorporates WASM:

Rust's WASM Compatibility: An often-overlooked advantage of Rust is its seamless integration with WebAssembly and JavaScript. Rust code can be compiled into WebAssembly bytecode, serving as a bridge for various programming languages. This capability empowers Rusty Kaspa to deploy both client and server applications, regardless of the language they're written in, as long as they compile to WASM.

WebAssembly's Advantages: WebAssembly is rapidly becoming a standard in web development, supported by major tech companies, web browsers, and programming languages. It allows developers to write critical parts of their applications in high-performance languages like Rust, rather than relying solely on JavaScript. This flexibility enables Rusty Kaspa developers to create complete applications using languages that compile to WASM, running seamlessly across different platforms and browsers.

Rusty Kaspa's Wasm Frontend Framework: Rusty Kaspa introduces a significant enhancement with its Wasm frontend framework. This framework, coupled with the platform-agnostic Kaspa SDK, enables developers to build applications without worrying about platform-specific intricacies. "Platform agnostic" means that developers can focus solely on their application's functionality, abstracting away platform-specific considerations within the framework.

Simplified Development: Rusty Kaspa streamlines the development process by adopting a platform-agnostic approach. For instance, the framework abstracts complexities such as network communication handling across diverse platforms using the Workflow Rust framework. This abstraction ensures a smoother development experience for Rusty Kaspa developers.

Enhanced Security: Another notable benefit of Rusty Kaspa's frontend framework is enhanced security. The framework mitigates the risk of executing unauthorized code by utilizing only Rust libraries and avoiding external or JavaScript libraries. This security measure significantly enhances the overall security posture of applications built on Rusty Kaspa.

How do I transition my node to the new Rusty Kaspa software?

Michael Sutton released a Medium post detailing the best transition strategy and technical details to transition your node to the new software.

Can I watch the network create blocks in real time?

Users can see how quickly the network creates blocks here

Where can I learn more about Kaspa?

Please check out the main Kaspa websitetwitterDiscordYoutube for more information about twitter.  Check out Michael Sutton’s personal twitter and Medium pages for more development updates. Follow KASMedia to stay up to date on all things Kaspa - websitetwitter

What if I have questions? 

If you have any questions about KASMedia or Kaspa in general, please feel free to email the KASMedia team at [email protected] and we will get back to you as soon as we can. You can also email me directly at [email protected]

Enjoyed reading this article?

More articles like this

Comments

No comments yet!

Post a comment

KasMedia logo