The Indexer is a critical component of Neon’s functionality. Understanding it is key to comprehending the way the Neon EVM interacts with the Solana network, as it is responsible for matching Solana transactions to Neon transactions. This introduction will give you a high-level overview of Neon’s Indexer.
索引器是Neon功能的关键组件。理解这它对理解Neon EVM与Solana网络的交互方式至关重要,因为它负责将Solana交易与Neon交易进行匹配。本介绍将从较高维度概述Neon索引器。
什么是索引器?(What is the Indexer?)
Neon’s Indexer is part of Neon’s proxy architecture, which is a multi-process program. The Indexer’s purpose is to cancel ongoing iterative transactions sent from blocked Neon accounts, as well as to save the Neon EVM transaction history from all proxies (by maintaining a database of all Neon EVM transactions).
Neon的索引器是Neon代理架构的一部分,它是一个多进程程序。索引器的目的是取消从被封闭的Neon帐户发送的,正在进行的迭代交易,以及保存所有代理的Neon EVM交易历史记录(通过维护所有Neon EVM交易的数据库)。
工作原理 (How It Works)
The Indexer runs by executing a constant cycle of sequential operations. The steps of this cycle are as follows:
索引器如此运行:执行恒定循环的连续操作。该循环的步骤如下:
第1步:获取 Solana 交易 (Step 1: Fetch Solana Transactions)
In this stage, the Indexer fetches all new Solana transaction signatures that involve the Neon EVM, and requests the transaction details based on these signatures.
在这个阶段,索引器获取所有涉及 Neon EVM 的新 Solana 交易签名,并根据这些签名请求交易细节。
第2步:处理交易 (Step 2: Process Transactions)
The Indexer then proceeds to process all the transactions it fetched, starting with the oldest and proceeding in chronological order. The transactions that involve the Neon EVM are singled out for more comprehensive processing down the line. Solana transactions consist of three fields: data, accounts, and destination contract address.
然后索引器继续处理它获取的所有交易,从最旧的开始并按时间顺序进行。涉及到 Neon EVM 的交易被挑选出来,以进行更全面的处理。 Solana 交易由三个字段组成:数据、账户和目标合约地址。
第3步:重建 Neon交易 (Step 3: Rebuild Neon Transactions)
Based on the information the Indexer received from these Solana transactions, it will begin to construct Neon transactions that mirror the activity on Solana. These transactions are analyzed to determine what kind of request was made to the Neon EVM contract. There are three types of requests that the Indexer is interested in:
根据索引器从这些 Solana 交易中收到的信息,它将开始构建反映 Solana 活动的 Neon 交易。分析这些交易,进而确定向 Neon EVM 合约发出的请求类型。索引器对三种类型的请求感兴趣:
- Neon account creation Neon账户创建
- Non-iterative transactions (executed in one Neon transaction) 非迭代交易(在一个 Neon 交易中执行)
- Iterative transactions 迭代交易
迭代交易 (Iterative Transactions)
If an iterative transaction is required, it can be constructed based either on the data from the accounts involved, or based on the Solana transaction data alone if it is under 1280 bytes. In the case that the account data is used, the Neon transaction is written into a special account (used only for this purpose), and this information is subsequently sent to the Neon EVM for iterative processing.
如果需要迭代交易,可以基于所涉及账户的数据构建,如果小于 1280 字节,也可以仅基于 Solana 交易数据构建。在使用账户数据的情况下,将 Neon 交易写入一个特殊的账户(仅用于此目的),随后将此信息发送到 Neon EVM 进行迭代处理。
In this case, the Indexer keeps track of transactions that record data into an account and, in cases where one Neon write transaction requires multiple Solana transactions, the correct order that the instructions should be implemented on Solana. This data is then used to help process the next iterative transaction involving that account.
在这种情况下,索引器会跟踪将数据记录到帐户中的交易,以确保在一个 Neon 写入交易,需要多个 Solana 交易的情况下,其在 Solana 上执行指令的正确顺序。然后,此数据用于帮助处理涉及该帐户的下一个迭代交易。
If an iterative transaction is not marked as “completed” but all the accounts involved with it are blocked, the Indexer will cancel this transaction.
如果一个迭代交易没有被标记为“完成”,但所有与之相关的账户都被封闭了,索引器将取消这个交易。
非迭代交易 (Non-Iterative Transactions)
If a non-iterative transaction is required, all the necessary information can be extracted from the Solana transaction. This information includes the accounts involved, changes in the balances of these accounts, and the execution result (e.g. “success” or “error” and how much gas was used). The Indexer will need to trace future transactions with the same data to add it to the same Neon transaction.
如果需要非迭代交易,则可以从 Solana 交易中提取所有必要的信息。这些信息包括涉及的账户、这些账户余额的变化以及执行结果(例如“成功”或“错误”以及使用了多少gas)。索引器将需要使用相同的数据跟踪未来的交易,来将其添加到相同的 Neon 交易中。
第4步:为 Neon 代理准备数据 (Step 4: Prepare Data for the Neon Proxy)
Once the Neon transactions have been built based on the Solana transaction data, the resulting data and logs are stored in a database. This database can then be queried by the proxy to get information such as contract code, transaction details, logs, and more. The proxy uses this to process requests it receives from the client.
基于 Solana 交易数据,构建 Neon 交易后,生成的数据和日志将存储在数据库中。然后,代理可以查询该数据库以获取合约代码、交易详细信息、日志等信息。代理使用它来处理从客户端接收到的请求。
结论 (Summary)
Neon’s Indexer, by fetching and processing Solana transactions for the Neon EVM, is crucial to the way the Neon EVM interacts with Solana. It cancels those transactions that are “stuck” in an incomplete state with all their accounts blocked. It also keeps a database of all the Neon EVM transactions it has processed. In doing so, the Indexer allows the proxy to provide important transaction information to the proxy users.
Neon 的索引器通过为 Neon EVM 获取和处理 Solana 交易,对于 Neon EVM 与 Solana 的交互方式至关重要。它会取消那些“卡壳”在不完整状态且所有账户都被封锁的交易。它还保留了它处理过的所有 Neon EVM 交易的数据库。这样做时,索引器允许代理向用户提供重要的交易信息。