Skip to main content
This page provides comprehensive technical documentation for DVN (Decentralized Verifier Network) contracts, including interfaces, methods, events, errors, and data structures.

Core Interface

All DVNs must implement the ILayerZeroDVN interface to integrate with LayerZero’s Message Libraries.

ILayerZeroDVN

interface ILayerZeroDVN {
    struct AssignJobParam {
        uint32 dstEid;          // Destination endpoint ID
        bytes packetHeader;     // Packet header containing routing info
        bytes32 payloadHash;    // Hash of the message payload
        uint64 confirmations;   // Required block confirmations
        address sender;         // OApp sender address
    }

    /// @notice Assigns a verification job to the DVN
    /// @param _param Job parameters including destination and payload hash
    /// @param _options DVN-specific options
    /// @return fee The fee charged for this verification job
    function assignJob(AssignJobParam calldata _param, bytes calldata _options)
        external payable returns (uint256 fee);

    /// @notice Returns the fee for verifying a message
    /// @param _dstEid Destination endpoint ID
    /// @param _confirmations Required block confirmations
    /// @param _sender OApp sender address
    /// @param _options DVN-specific options
    /// @return fee The fee in native tokens
    function getFee(
        uint32 _dstEid,
        uint64 _confirmations,
        address _sender,
        bytes calldata _options
    ) external view returns (uint256 fee);
}

DVN Contract Methods

The LayerZero DVN contract extends the base Worker contract with multisig capabilities. Below are the key methods organized by access control.

Public / View Methods

getFee

Returns the fee for verifying a message to a specific destination.
function getFee(
    uint32 _dstEid,
    uint64 _confirmations,
    address _sender,
    bytes calldata _options
) external view returns (uint256 fee)
ParameterTypeDescription
_dstEiduint32Destination endpoint ID
_confirmationsuint64Required block confirmations
_senderaddressOApp sender address (for ACL checks)
_optionsbytesDVN-specific options
Returns: Fee amount in native tokens.
This function will revert if the sender is on the denylist or not on the allowlist (when allowlist is enabled).

hashCallData

Generates a hash of execution parameters for signature verification.
function hashCallData(
    uint32 _vid,
    address _target,
    bytes calldata _callData,
    uint256 _expiration
) public pure returns (bytes32)
ParameterTypeDescription
_viduint32DVN instance identifier
_targetaddressTarget contract address
_callDatabytesEncoded function call data
_expirationuint256Expiration timestamp
Returns: Keccak256 hash of the packed parameters.

OnlyMessageLib Methods

These methods can only be called by authorized Message Libraries.

assignJob (ULN302)

Assigns a verification job for ULN302 messages.
function assignJob(
    AssignJobParam calldata _param,
    bytes calldata _options
) external payable onlyRole(MESSAGE_LIB_ROLE) returns (uint256 totalFee)
ParameterTypeDescription
_paramAssignJobParamJob parameters struct
_optionsbytesDVN-specific options
Emits: None directly (fee calculation delegated to DVNFeeLib).

assignJob (ULNv2 Legacy)

Assigns a verification job for legacy ULNv2 messages.
function assignJob(
    uint16 _dstEid,
    uint16 _outboundProofType,
    uint64 _confirmations,
    address _sender
) external onlyRole(MESSAGE_LIB_ROLE) returns (uint256 totalFee)
Emits: VerifierFeePaid(uint256 fee)

assignJob (Read/CmdLib)

Assigns a verification job for lzRead commands.
function assignJob(
    address _sender,
    bytes calldata _packetHeader,
    bytes calldata _cmd,
    bytes calldata _options
) external payable onlyRole(MESSAGE_LIB_ROLE) returns (uint256 fee)

OnlyAdmin Methods

These methods require the ADMIN_ROLE.

setDstConfig

Configures fee parameters for destination chains.
function setDstConfig(DstConfigParam[] calldata _params) external onlyRole(ADMIN_ROLE)
ParameterTypeDescription
_paramsDstConfigParam[]Array of destination configurations
Emits: SetDstConfig(DstConfigParam[] params)

execute

Executes a batch of signed instructions. This is the primary method for submitting verifications.
function execute(ExecuteParam[] calldata _params) external onlyRole(ADMIN_ROLE)
ParameterTypeDescription
_paramsExecuteParam[]Array of signed execution parameters
Behavior:
  • Skips instructions with invalid VID
  • Skips expired instructions
  • Validates signatures against quorum
  • Prevents replay attacks via hash tracking
  • Emits events for failures but continues processing
Emits:
  • VerifySignaturesFailed(uint256 idx) - if signature validation fails
  • ExecuteFailed(uint256 index, bytes data) - if execution fails
  • HashAlreadyUsed(ExecuteParam param, bytes32 hash) - if instruction was already executed

withdrawFeeFromUlnV2

Withdraws accumulated fees from ULNv2 Message Library.
function withdrawFeeFromUlnV2(
    address _lib,
    address payable _to,
    uint256 _amount
) external onlyRole(ADMIN_ROLE)
ParameterTypeDescription
_libaddressULNv2 Message Library address
_toaddress payableRecipient address
_amountuint256Amount to withdraw

OnlySelf Methods

These methods can only be called by the contract itself (via signed execute).

setSigner

Adds or removes a signer from the multisig.
function setSigner(address _signer, bool _active) external onlySelf
ParameterTypeDescription
_signeraddressSigner address
_activebooltrue to add, false to remove
Function Signature: 0x31cb6105

setQuorum

Sets the required number of signatures for multisig operations.
function setQuorum(uint64 _quorum) external onlySelf
ParameterTypeDescription
_quorumuint64New quorum threshold
Function Signature: 0x8585c945

Quorum Methods

quorumChangeAdmin

Allows the signer quorum to change the admin role without going through the standard execute flow.
function quorumChangeAdmin(ExecuteParam calldata _param) external
ParameterTypeDescription
_paramExecuteParamSigned instruction with new admin address encoded in callData
Usage: The callData field should contain abi.encode(newAdminAddress).
This function ensures signers maintain ultimate control over the DVN. Even if the admin role is delegated to a service like Essence, signers can immediately reassign it.

Events

Core Events

EventSignatureDescription
VerifySignaturesFailedVerifySignaturesFailed(uint256 idx)Signature verification failed at the specified index during batch execution
ExecuteFailedExecuteFailed(uint256 index, bytes data)Execution failed at the specified index with return data
HashAlreadyUsedHashAlreadyUsed(ExecuteParam param, bytes32 hash)Attempted replay of an already-executed instruction
VerifierFeePaidVerifierFeePaid(uint256 fee)Fee paid for ULNv2 verification job
SetDstConfigSetDstConfig(DstConfigParam[] params)Destination configuration updated

Inherited Events (from Worker)

EventSignatureDescription
SetWorkerFeeLibSetWorkerFeeLib(address feeLib)Fee library address updated
SetPriceFeedSetPriceFeed(address priceFeed)Price feed address updated
SetDefaultMultiplierBpsSetDefaultMultiplierBps(uint16 multiplierBps)Default fee multiplier updated
WithdrawWithdraw(address to, uint256 amount)Fees withdrawn from worker

Errors

DVN Errors

ErrorSignatureDescription
DVN_OnlySelfDVN_OnlySelf()Action requires the contract to call itself (via signed execute)
DVN_InvalidRoleDVN_InvalidRole(bytes32 role)Specified role is not valid for the operation
DVN_InstructionExpiredDVN_InstructionExpired()The signed instruction has passed its expiration timestamp
DVN_InvalidTargetDVN_InvalidTarget(address target)Target address is not valid for this operation
DVN_InvalidVidDVN_InvalidVid(uint32 vid)VID in instruction does not match this DVN instance
DVN_InvalidSignaturesDVN_InvalidSignatures()Signature verification failed (invalid or insufficient signatures)
DVN_DuplicatedHashDVN_DuplicatedHash(bytes32 executableHash)Instruction hash has already been executed (replay prevention)

DVNFeeLib Errors

ErrorSignatureDescription
DVN_EidNotSupportedDVN_EidNotSupported(uint32 eid)Destination endpoint ID is not configured (gas = 0)
DVN_INVALID_INPUT_LENGTHDVN_INVALID_INPUT_LENGTH()Array lengths do not match in configuration
DVN_TimestampOutOfRangeDVN_TimestampOutOfRange(uint32 eid, uint64 timestamp)Read request timestamp is outside the valid retention window
DVN_UnsupportedOptionTypeDVN_UnsupportedOptionType(uint8 optionType)DVN option type is not supported

Inherited Errors (from Worker)

ErrorSignatureDescription
Worker_OnlyMessageLibWorker_OnlyMessageLib()Caller is not an authorized Message Library
Worker_NotAllowedWorker_NotAllowed()Sender is on denylist or not on allowlist

Data Structures

DstConfig

Configuration for a destination chain’s fee parameters.
struct DstConfig {
    uint64 gas;              // Base gas cost for verification
    uint16 multiplierBps;    // Fee multiplier in basis points (10000 = 100%)
    uint128 floorMarginUSD;  // Minimum margin in USD (scaled)
}
FieldTypeDescription
gasuint64Base gas units required for verification on this destination
multiplierBpsuint16Fee multiplier (0 uses default, 10000 = 1x, 12000 = 1.2x)
floorMarginUSDuint128Minimum fee floor in USD to ensure profitability

DstConfigParam

Parameter struct for setting destination configuration.
struct DstConfigParam {
    uint32 dstEid;           // Destination endpoint ID
    uint64 gas;              // Base gas cost
    uint16 multiplierBps;    // Fee multiplier
    uint128 floorMarginUSD;  // Minimum margin
}

ExecuteParam

Parameters for executing a signed instruction.
struct ExecuteParam {
    uint32 vid;              // DVN instance identifier
    address target;          // Target contract address
    bytes callData;          // Encoded function call
    uint256 expiration;      // Expiration timestamp
    bytes signatures;        // Concatenated signatures
}
FieldTypeDescription
viduint32Must match this DVN’s VID
targetaddressContract to call (often the receive MessageLib)
callDatabytesABI-encoded function call (e.g., verify(...))
expirationuint256Unix timestamp after which instruction is invalid
signaturesbytesConcatenated 65-byte ECDSA signatures

AssignJobParam

Parameters passed when a verification job is assigned.
struct AssignJobParam {
    uint32 dstEid;           // Destination endpoint ID
    bytes packetHeader;      // Full packet header
    bytes32 payloadHash;     // Hash of message payload
    uint64 confirmations;    // Required block confirmations
    address sender;          // OApp that sent the message
}

FeeParams (DVNFeeLib)

Parameters used for fee calculation.
struct FeeParams {
    address priceFeed;           // Price feed contract address
    uint32 dstEid;               // Destination endpoint ID
    uint64 confirmations;        // Required confirmations
    address sender;              // OApp sender
    uint64 quorum;               // Current quorum setting
    uint16 defaultMultiplierBps; // Default fee multiplier
}

Access Control Roles

The DVN contract uses role-based access control inherited from OpenZeppelin’s AccessControl.
RoleDescriptionControlled By
ADMIN_ROLECan execute signed instructions, set configs, withdraw feesAdmin (or quorum via quorumChangeAdmin)
MESSAGE_LIB_ROLECan call assignJob to request verificationsSelf (via signed execute)
ALLOWLISTAddresses permitted to use the DVNSelf (via signed execute)
DENYLISTAddresses blocked from using the DVNSelf (via signed execute)

Constructor Parameters

constructor(
    uint32 _localEidV2,      // Local endpoint V2 ID
    uint32 _vid,             // Unique DVN instance identifier
    address[] memory _messageLibs,  // Initial Message Libraries
    address _priceFeed,      // Price feed contract
    address[] memory _signers,      // Initial multisig signers
    uint64 _quorum,          // Initial quorum requirement
    address[] memory _admins        // Initial admin addresses
)
ParameterDescription
_localEidV2The endpoint ID for this chain (used for lzRead)
_vidUnique identifier for this DVN instance (typically eidV1 or eidV2 % 30000)
_messageLibsArray of Message Library addresses granted MESSAGE_LIB_ROLE
_priceFeedContract providing cross-chain gas price estimates
_signersArray of addresses that can sign verification instructions
_quorumNumber of signatures required for execution
_adminsAddresses granted ADMIN_ROLE for operational management

State Variables

VariableTypeVisibilityDescription
viduint32public immutableUnique DVN instance identifier
localEidV2uint32public immutableLocal endpoint V2 ID
dstConfigmapping(uint32 => DstConfig)publicFee configuration per destination
usedHashesmapping(bytes32 => bool)publicTracks executed instruction hashes