Executor
The OPinit Bot Executor is a critical component in maintaining the communication and operational integrity between the Initia L1 and rollup blockchains. It handles and automates key tasks related to the OPinit Bridge, which facilitates cross-chain interactions and ensures that both blockchains remain synchronized and secure.
The primary responsibilities of the Executor include:
- Executing Token Transfers: Executing token transfers between Initia L1 and rollup
- Submitting Output Proposals: Submitting output proposals to the Initia L1
- Transaction Batch DA Submission: Submitting rollup transaction batches to the DA layer
- Relaying Oracle Update (Optional): Relaying oracle price feed updates to the rollup
Detailed Architecture
Transfer Token from L1 to L2 (Deposit)
When the initiate_token_deposit
event is detected in L1, the Executor submits a tx containing the MsgFinalizeTokenDeposit
msg to L2.
Transfer Token from L2 to L1 (Withdrawal)
The Executor compiles an output proposal for each L2 withdrawal, using a Merkle tree structure to ensure the integrity of the withdrawal data through cryptographic proofs.
For each initiated withdrawal, a leaf node is added to the current working Merkle tree. The leaf index corresponds to the L2 sequence number of the withdrawal minus the tree’s start index. The withdrawal hash is then calculated according to the OPinit spec.
If the working tree for the previous block does not exist, the system raises an error (panic).
For more details on Merkle tree creation, refer to the Merkle Tree Documentation.
This is the function used to generate the withdrawal hash:
When 2/3
of the submission interval has passed since the previous submission time, the Executor finalizes the current working tree and submits the output root created with the tree’s root as a storage root.
The current version used is 0
.
When the tree is finalized, the leaf nodes and internal nodes are stored to provide withdrawal proofs.
A query for a withdrawal sequence will return the following response:
This contains all the necessary data for finalizing a withdrawal.
Oracle Updates
Oracle data is crucial for keeping the blockchain updated with external information. When the oracle_enabled
setting is configured, the Executor relays oracle data from L1 to L2, ensuring applications depending on this data function without delay or outdated information.
Initia uses Connect to relay oracle data, which is stored in the 0th transaction of each block. The Executor submits a MsgUpdateOracle with the 0th transaction from an L1 block to L2 whenever a new L1 block is created. Only up-to-date oracle data is used, with older data being discarded.
Make sure the oracle_enabled
setting is true in the bridge configuration to enable this process.
DA Batch Submission
The Executor is responsible for batching and submitting transaction data to the Data Availability (DA) layer. It organizes the transaction data into chunks, ensuring efficient handling of large datasets. This process guarantees that all transaction data is correctly recorded and stored on the DA layer for future reference and audits.
The Batch
process queries batch information stored on the chain and submits it based on the account and chain ID. The user must configure the RPC address
, bech32-prefix
, and gas-price
, and ensure that the account is registered in the keyring. Each block’s raw data is compressed using gzip and divided into chunks of maximum size as defined in the config.
When 2/3 of the submission interval has passed, the Executor submits the batch header first, followed by the data chunks to the DA layer. The batch header includes the start and end L2 block heights, along with the checksums of each chunk.
- If a L2 block contains
MsgUpdateOracle
, only the data field is submitted empty to reduce block bytes since the oracle data is already stored in L1. - Batch data is stored in a
batch
file in the home directory until it is submitted, so be careful not to change the file.
If the batch information registered in the chain changes, such as updating the account or DA chain, the Host
module detects the update_batch_info
event and notifies the Executor. The Executor will clear the temporary batch file and resubmit the batch data from the last finalized output block number.
Was this page helpful?