Ethereum: What is the different between CompactSize and VarInt encoding?

Ethereum: Understanding of compact coding and Varint coding

Blockchain Ethereum has long been harassed by issues related to compression and data coding. Two of the most commonly used codes in the ecosystem are compact and Varint (variable int), to which until recently they were reached interchangeably. In this article, we will delve into the differences between these two coding programs and examine why they were previously confused.

range coding

The definition of Pieter’s coding Wuille is a key point to determine transparency. According to his article “On the compactness of the Ethereum transaction”, compact coding is defined as a simple replacement of some signs in transaction data with shorter codes, ultimately reducing the size of the data while maintaining their basic information. This approach aims to minimize the requirements for storage of transaction data without devoting their security or integrity.

On the other hand, the definition of Varint Greg Walker coding emphasizes the use of a series of integers of variable length (VLI) for storing and transferring data. These VLI are used to represent complex data structures in a compact and efficient way. Varint is often seen as a more sophisticated coding scheme compared to CompactSize, but both coding can be used to reduce the size of transaction data.

Varint coding

Varint coding has been widely accepted in many blockchain networks, including Ethereum. According to Wiki Bitcoin, Varint is defined as a table of unsigned integers representing the data structure. The goal of Varint is to ensure a compact and efficient way of storing and sending large amounts of data on the network.

The key differences between Varint coding and compact coding are in their approach:

* Structure

: Varint uses the VLI board, while CompactSize replaces some signs with shorter codes.

* Target : Varint is designed for storing and sending complex data structures, while CompactSize is primarily used to reduce the size of transaction data.

Why confusion?

Ethereum: What is the different between CompactSize and VarInt encoding?

No wonder Wiki Bitcoin initially claimed that CompactSize was not associated with Varint. The reason is that the definition of Pieter Wuille clearly describes the compactness as the approach of “simple replacement”, while the definition of Greg Walker emphasizes the use of VLI and complex data structures.

In fact, both coding schemes can be used together or independently. Although Compactsize can be used to reduce the size of transaction data, Varint is still necessary to store large amounts of complex data, such as an intelligent contract code or network configurations.

Application

The differences between CompactSize and Varint coding are clear after understanding the correct definitions. While both coding is aimed at improving data compression, their approaches differ significantly. The definition of Compactsize Pieter Wuille emphasizes its simplicity and focus on reducing transaction data, while the definition of Greg Walker emphasizes the use of VLA for complex data storage.

Understanding these differences, programmers and users can choose a coding scheme that best suits their specific needs, ensuring effective data transmission and storage of blockchain ethereum.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *