A comprehensive template for creating LayerZero V2 Executors on Tangle Network
This project provides a template for creating LayerZero Executor Blueprints on the Tangle Network. Executors are crucial components of the LayerZero protocol, responsible for committing and executing cross-chain messages, ensuring the reliability and efficiency of inter-blockchain communications.
Blueprints in Tangle are specifications for Actively Validated Services (AVS) that run arbitrary computations for a user-specified period. This template enables developers to create reusable Executor infrastructures, allowing them to participate in the LayerZero ecosystem and potentially monetize their work.
Before you begin, ensure you have the following software installed:
Install cargo-tangle
, our CLI tool for creating and deploying Tangle Blueprints:
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/tangle-network/gadget/releases/download/cargo-tangle-v0.1.2/cargo-tangle-installer.sh | sh
Or, install from crates.io:
cargo install cargo-tangle --force
- Create a new project using the Executor blueprint template:
cargo tangle blueprint create --name my-executor-blueprint --repo https://github.com/tangle-network/layerzero-executor-blueprint-template
- Navigate to your project directory:
cd my-executor-blueprint
-
Implement your offchain Executor logic in
src/lib.rs
and onchain Executor incontracts/src/
, building upon the provided template functions. -
Build your project:
cargo build
- Deploy your Executor blueprint to the Tangle network:
cargo tangle blueprint deploy
The Executor has two main off-chain workflows:
- Listen for the
PacketSent
event. - Wait for the
ExecutorFeePaid
event to confirm assignment. - Listen for the
PacketVerified
event. - Perform an idempotency check using
ULN.verifiable()
. - Based on the
VerificationState
, either wait, callcommitVerification()
, or terminate. - Perform a final idempotency check to confirm workflow completion.
- Listen for the
PacketSent
event. - Wait for the
ExecutorFeePaid
event to confirm assignment. - Listen for the
PacketVerified
event. - Perform an idempotency check using
endpoint.executable()
. - Based on the
ExecutionState
, either wait, callendpoint.lzReceive()
, or terminate. - Perform a final idempotency check to confirm workflow completion.
Your Executor contract must implement the ILayerZeroExecutor
interface:
interface ILayerZeroExecutor {
function assignJob(
uint32 _dstEid,
address _sender,
uint256 _calldataSize,
bytes calldata _options
) external payable returns (uint256 price);
function getFee(
uint32 _dstEid,
address _sender,
uint256 _calldataSize,
bytes calldata _options
) external view returns (uint256 price);
}
assignJob
: Called as part of_lzSend
.getFee
: Used by applications to estimate fees before sending a packet.
PacketSent(bytes encodedPacket, bytes options, address sendLibrary)
ExecutorFeePaid(address executor, uint256 fee)
PayloadVerified(address dvn, bytes header, uint256 confirmations, bytes32 proofHash)
If you encounter any issues or have questions, please open an issue on our GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions! Please see our Contributing Guidelines for more information on how to get involved.
Special thanks to the LayerZero team for their support and contributions to this project.