Written by
0xIchigo
Published on
March 22, 2024
Copy link

How to Mitigate Spam QUICkly: All You Need to Know About Solana and QUIC

What’s this Article About?

Solana is the fastest and most scalable blockchain currently on the market. It is renowned for its transaction speeds, making it the perfect chain for various use cases. Irrespective of these feats, Solana’s network has been subject to fear, uncertainty, and doubt (colloquially abbreviated as FUD) regarding downtime. While this FUD has been a legitimate concern in the past, it is currently unwarranted. Why? The engineers at Solana Labs have been working on various network upgrades over the past year, most notably replacing Solana’s custom raw UDP-based protocol for ingesting transactions with QUIC.

In this article, we will examine the mechanics of network protocols, TCP and UDP, and explore how QUIC improves on both. We will then shift our focus to Solana and discuss its particular advantages. This article aims to give you a comprehensive understanding of why this network upgrade is a significant technical milestone for Solana.

Solana Network Upgrades

On December 13th, 2022, the Solana Foundation published a news article entitled “Solana Network Upgrades”. In this article, they outlined a number of upgrades being made to the network and their respective progress. The upgrades are as follows:

QUIC

  • Currently live on Mainnet-beta

Stake-weighted QoS

  • Currently live on Mainnet-beta

Fee markets

  • Currently live on Mainnet-beta, with RPC and wallet support coming soon
  • You can follow its progress here

Transaction size increase

  • Currently under development

Compact vote state

  • Currently live on Testnet

One of the big reasons as to why Solana has experienced downtime in the past has been due to spam. Some examples include:

  • The Grape IDO Spam on Sept 14 2021
  • DDoS Attacks that occurred from Jan 6-12 2022
  • NFT Mint Spam that occurred from Apr 30 - May 1 2022

Solana has had no reported case of downtime related to spam since the implementation of QUIC. This marks QUIC as a landmark achievement in improving Solana’s network traffic and data ingestion. Before we learning about QUIC, we must first explore the mechanics of network protocols. This better understanding of network fundamentals allows us to recognize the true impact QUIC has on Solana’s network.

What's a Network Protocol?

A network protocol is an established set of rules regarding how data is sent between devices on the same network. Network protocols allow connected devices to easily communicate with one another, regardless of their internals, structure, or design.

Imagine you’re seated across from your friend in a restaurant in Paris. You both decide to speak French, and, as a result, your conversation flows smoothly. Your mutual decision to speak French is an agreement upon a set of grammatical rules, vocabulary, and pronunciation that both parties understand.

Network protocols function in a similar manner for connected network devices, much like how French serves as a “protocol” for your Parisian restaurant conversation. The decision to use TCP, UDP, or QUIC is a decision to agree upon an established set of rules and conventions to exchange information. Adhering to a specific network protocol ensures that connected devices can understand one another without any confusion.

What’s TCP?

Transmission Control Protocol (TCP) is a standardized communications interface for sending streams of data between two endpoints on a network. Vint Cerf and Bob Kahn made the Transmission Control Program, a monolithic protocol that was divided it into a modular architecture consisting of TCP and the Internet Protocol (IP). The entire suite is referred to as TCP/IP. In our case, I am referring to the Transmission Control Protocol and not the entire suite when I use the abbreviation TCP.

Source: Differences between TCP and UDP by Palak Jain S for GeeksforGeeks

TCP is connection-oriented; it requires an established connection between the client and server before data is sent. TCP uses a three-step handshake to establish a connection: synchronize (SYN), synchronize-acknowledge (SYN-ACK), and acknowledge (ACK). You can think of SYN as extending your hand for a handshake and asking if the other person is ready to talk; SYN-ACK as the other person shaking your hand saying they’re ready to talk and asking if you’d like to continue; and ACK as you shaking their hand back saying you’d like to continue talking. Here, a session is established. Both parties know they are connected to one another, and they both agree that they are ready to share information.

TCP breaks data into packets, which are sent across the network. Small amounts of data are added to each packet. This additional data includes a sequence number that is used to detect lost or out of place packets, and a checksum that allows for errors within a packet to be detected.

When a conversation is interrupted, we ask the other person to repeat themselves so we’re sure we heard them correctly. TCP handles interruptions similarly with Automatic Repeat Request (ARQ). When a problem occurs, ARQ to tell the sender to re-send the damaged or lost packet. Then, TCP informs the user to slow down its rate of data transmission and limits the number of unacknowledged packets that can be in transit. Once the error is resolved, TCP has mechanisms in place to avoid congestion and gradually increases its speed.

TCP is not the right protocol for every use case as it sequences all of the traffic. Thus, if one portion of the data is lost or damaged, everything after that package needs to wait. But what if we didn’t have to wait?

What’s UDP?

User Datagram Protocol (UDP) is a standardized communications interface used for transmitting data over a network. Unlike TCP, UDP is connectionless and does not guarantee the delivery, ordering, or duplication of data packets. UDP does not have any handshaking dialogues, which makes data transmission susceptible to any unreliability in the underlying network. This makes UDP faster than other protocols because it does not spend time establishing a connection with the destination. This, however, also leads to people referring to the protocol as the “Unreliable Datagram Protocol”.

Source: Differences between TCP and UDP by Palak Jain S for GeeksforGeeks

UDP works by sending datagrams across the network. Datagrams are a more self-contained set of data with information used for routing from the source to the destination. Datagrams do not rely on other datagrams for routing because of this included information. These datagrams consist of a header and data. The header has four fields, all of which are 16-bits long: an optional source port, a destination port, a length, and an optional checksum. The sending process is as follows:

  • The sending application creates a UDP socket
  • The sending application puts the data it wishes to send in a UDP datagram, with a header containing the destination port and any other relevant information
  • The datagram is sent to the IP layer for routing and delivery
  • The IP layer takes the datagram and transfers it to the UDP layer, and is stripped of its header
  • The datagram is sent to the application listening on the specified port

Think of UDP as talking to someone across a busy room. You shout at this person, without worring if they’ve heard you or await their response. Here, you want to get your message across quickly without any sort of prolonged conversation. This is risky as they might not have heard everything you’ve said, but it could be very effective.

Why would you want to use a connectionless communications protocol like UDP when you have something more reliable such as TCP? UDP is extremely useful for time-sensitive applications, or cases where some loss of data is acceptable. Losing a few frames playing video games with your friends is infinitely better than continuous pausing and buffering. UDP is also used for VoIP calls, Domain Name System (DNS) queries, and monitoring and logging.

QUIC: Balancing Efficiency and Reliability

QUIC is a modern transport layer protocol designed by Jim Roskind at Google in 2013. It merges TCP’s reliability with UDP’s low-latency benefits, creating an optimized environment for rapid and secure asynchronous communication. QUIC sets itself apart by incorporating secure sessions and advanced flow control strategies, characteristic of TCP, into the more flexible and fast framework UDP provides.

Source: A Comprehensive Guide to HTTP/3 and QUIC by Anna Monus for DebugBear

In QUIC, the connection setup is streamlined by integrating the exchange of cryptographic keys and protocol details into its initial handshake, which is always securely encrypted with Transport Layer Security (TLS). The protocol enables multiplexed connections via UDP, allowing multiple independent data streams to reach their endpoints without affecting one another. QUIC independently controls the flow of each stream, ensuring that even if one stream encounters errors, it doesn’t hinder the others. This helps prevent head-of-line blocking (i.e., a line of packets is held up in a queue by a first packet), an issue TCP connections are often plagued with.

Should a packet be lost or damaged, QUIC is responsible for intelligently re-transmitting data, preserving the integrity and continuity of communication. Moreover, QUIC is robust against changes in the network environment. Each packet carries a connection identifier that uniquely identifies the connection to the server, regardless of the source. So, the connection can be reestablished by sending another packet because every packet contains this ID, meaning the original connection is still valid. This means that if you move to a different room, metaphorically speaking, your conversation isn’t dropped and continues seamlessly.

Imagine you’re in that busy room again, trying to talk to your friend. This time, you’re equipped with encrypted walkie-talkies, allowing for a secure and clear exchange. As your conversation covers various topics, your friend acknowledges each message with a thumbs up. A puzzled look cues you to repeat any misunderstood message, ensuring nothing is lost in translation. And if you or your friend moves to another room, the dialogue remains unbroken. That’s the essence of QUIC — robust, adaptable, and efficient communication.

How Solana Implements QUIC

Source: RL1: Surveying Solana by Sal Qadir for Galaxy Digital Research

QUIC offers a number of advantages to Solana, namely:

  • Reduced Connection Establishment Time: By optimizing the handshake process, QUIC minimizes latency
  • Multiplexing and Efficient Packet Management: QUIC’s ability to handle multiple data streams concurrently without head-of-line blocking improves transaction throughput and efficiency
  • Adaptability and Resilience: The protocol is designed to adapt to changing network conditions, which is a vital requirement for a distributed, decentralized system such as Solana
  • Customization for Network Optimization: QUIC’s flexibility allows for tailored implementations, such as Solana’s, to meet specific network performance and security goals

QUIC has been added to the port(s) that ingest user transactions. This allows for limits to be placed on an actor’s traffic so that the network can focus on processing genuine transactions. QUIC is live on Solana and was fully adopted to Mainnet-beta with release 1.13.4. Following its integration, the network has observed marked improvements in stability and throughput.

Despite these advancements, recent network congestion has sparked debate on QUIC’s compute efficiency compared to Solana’s previous UDP implementation. Critics point out that the raw UDP approach allowed validators to focus exclusively on transaction processing rather than managing handshake spam and encryption. Moreover, the exchange and verification of keys is not part of the initial handshake in Solana’s implementation. Solana uses QUIC’s option to send a “challenge packet” to verify IP addresses. The whole point of this challenge is to avoid the certificate verification on the first step of the handshake, instead of doing it on the second part of the handshake after IP validation. Whether Solana has had downtime related to spam or DDoS attacks remains debatable, given Solana’s recent network outage in February could be considered a denial of service.

With the network’s evolution, it is important to review and improve upon implementations made to the network continuously. QUIC aims to solve a lot of TCP and UDP’s issues, but, looking back, its effectiveness is debatable. An important consideration is to consider how something would work on hardware. TCP works much better on hardware than QUIC due to its simplicity. One could easily argue that with an AES instruction set, a TCP-based protocol would have more throughput than QUIC and would be more efficient regarding TPS.

Notably, the team at Jump Crypto is pushing the boundaries of QUIC. The team created their own robust and scalable implementation while developing Firedancer, a new validator client for Solana. Firedancer’s networking is designed from the ground up to take advantage of receive-side scaling, a type of hardware-accelerated load balancing. This parallel architecture allows each CPU core to handle a segment of incoming traffic efficiently. The team has tweeted that:

A demo and thread on Firedancer’s QUIC technical milestone can be found here.

Conclusion

Congratulations! In this article, we explored the fundamentals of network protocols, focusing on the roles of TCP and UDP and their evolution into QUIC. We also examine Solana’s implementation of QUIC, highlighting its pivotal role in enhancing the network. While Solana’s network resilience against spam and DDoS attacks has improved with QUIC, the network’s growth has unveiled the challenges and debates surrounding its compute efficiency and implementation nuances.

QUIC embodies Solana’s core objective of facilitating a high throughput and low latency network. Its multiplexing and packet loss recovery capabilities put Solana at the forefront of performance and scalability discussions. The Firedancer team’s implementation showcases QUIC's adaptability, which highlights the potential for bespoke optimizations to meet the network’s changing demands.

Understanding QUIC as a Solana developer helps you make more informed decisions on topics from application architectures to transaction errors. Solana is constantly evolving, and so is QUIC. Staying up to date with the latest network changes is the best way to build performant applications on top of Solana. Even if you aren’t a developer, a more technical understanding of QUIC can help you understand why Solana is a performant blockchain, renowned for its speed and scalability.

If you’ve read this far, anon, thank you! Be sure to enter your email address below so you’ll never miss an update about what’s new on Solana. Ready to dive deeper? Explore the latest articles on the Helius blog and continue your Solana journey, today.

Additional Resources / Further Reading