In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use the PAT tree in Bytom". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Why use the PAT tree?
PAT tree has the characteristics of [cardinality tree] (https://en.wikipedia.org/wiki/Radix_tree)), and its content can be tracked quickly.
PAT tree has the characteristics of [merkle tree] (https://en.wikipedia.org/wiki/Merkle_tree)), which can be quickly proved by data.
In distributed systems, consistency and effectiveness are critical points. Bytom uses the PAT tree, in which the data can be quickly proved, and each state machine can be quickly proved to be consistent. The content can be tracked quickly, which enables bytom to quickly find its data and verify the validity of the data in each snapshot state.
How does Bytom use PAT trees?
Ethereum's PAT tree is a 16-byte tree, which is divided into two tiers. The first layer manages all accounts, and the second layer manages the storage content of each account.
The PAT tree of Bytom is different from Ethereum?
Bytom's PAT tree is a binary cardinality tree.
Bytom's PAT tree is used to manage unspent outputs.
UTXO
Why use UTXO?
UTXO was born in Bitcoin, and like RMB in the real world, from the moment the central bank was born, he transferred the accounts of countless people, but his face value was always the same, so that he was coin-centric rather than people-centric, and his assets were easy to monitor and count. Bytom is used for asset publishing and management, so the asset-centric design pattern of UTXO is very suitable for asset management on Bytom.
How to use UTXO?
Compared with Bitcoin's UTXO, bytom's UTXO has three more fields.
Assertid, because bytom is a platform for multi-asset publishing and management, use this field to uniquely identify various assets.
Accountid, which is convenient for each account to index and manage utxo, bytom compared to bitcoin, introduced the account model, which will be described later.
Program, the account that owns the utxo can write the program you want in Ivy language and put it in this field, so that Turing's complete BVM will execute the program when trading.
BVM
BVM is started during the transformation process of the state machine, that is, the step of excute (transaction).
Why do I need BVM?
The non-Turing complete stack scripting language in bitcoin has very few functions, so it is difficult to achieve some slightly complex functions, such as verify_spv (cross-chain anchoring verification function, such as btc_relay), and simply to achieve multi_lock (M-person encryption, as long as the collection of N-person private key can be decrypted, 0 < N < M) function.
Evm in ethereum can simply write programs in Solidity to achieve these functions, but EVM is too complex because it is called a super-world computer and is not necessary for bytom, a blockchain that is only interested in assets.
How to use BVM?
When you send each transaction, you can write the program you need. When the transaction is packaged into a block, BVM will execute the code. Since BVM is a complete virtual machine of Turing, you need to add a feed pricing mechanism (feed is equivalent to gas * gasprice of ethereum) to solve the downtime problem.
Account model
Why use the account model?
The account model is easy to manage relevant data, is people-centered, and is very intuitive. It is also very convenient for BVM to execute based on the account code. In addition, we introduce the asset model, which is similar to the account model, so that it is easy to supervise and query assets.
How does bytom implement the account model?
The account model in bytom is also divided into two categories, but different from individual accounts and contract accounts in ethereum, it refers to asset accounts and personal accounts.
Asset account:
Assetid is the globally unique asset identification id.
Alias is an alias for an asset that is easy to remember, such as (gold, silver).
Vmversion is designed to achieve dynamic overshoot when soft bifurcation occurs.
Program refers to the program that needs to be executed when the asset is published.
Initialblockhash refers to the height at which the asset is registered.
Signer manages the public and private key pair so that it can be signed with the private key of the asset, and only the person who owns the private key of the asset can publish the asset.
Definition's explanation of the asset, etc.
Personal account:
Accountid globally unique identifiable account id.
Alais account name.
Signer, a private key pair, is used to send transactions.
* utxos the index of all unspent transactions in the account to facilitate quick management of assets under the account.
Program, which can be inserted into the required program when sending transactions.
Summary
The physical structure of UTXO is stored in memcache. The logical structure of UTXO is managed by a binary PAT tree.
Personal accounts can quickly index their related utxo according to AccountId. Asset accounts can quickly manage related utxo according to AssetId.
Bytom uses the PAT tree to organize utxo as the world state tree.
There are two account models, asset account and personal account, which can be indexed to manage their related utxo.
The UTXO pool will use an in-memory database such as memcache, the off-disk database will choose a relational database, and the data will choose protobuf to serialize.
When trading an account, each account can find and select its own utxo from the world state tree, and write its own asset program as a TxInput.
When the transaction is packaged into a block, the verification node de-instantiates the BVM and executes the programs in all the TxInput in the transaction.
This is the end of the content of "how Bytom uses PAT Tree". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.