LayerzeroImplementation
Introduction
This contract is used to allow Superform to send messages via LayerZero.
Core Concepts
LayerzeroImplementation
builds upon AMBImplementation
to formalize certain methods specific to LayerZero. The application is notably nonblocking, to ensure that Superform's destination LayerZero Endpoint will never be blocked. You can read more on nonblocking applications here.
Trusted Remotes
Trusted remotes establish a secure connection between the LayerzeroImplementation
on source chain and the LayerzeroImplementation
on destination chain. They are configured by the LayerzeroImplementation
contract on the LZendpoint which validates it upon sending and receiving payloads. You can read more on Trusted Remotes here.
Receiving payloads
LayerZero attempts to call lzReceive
function on Superform's LayerzeroImplementation
contract after the successful validation of a message at the bridge end. Upon delivery, certain mandatory input validations are made by the lzReceive
function.
lzReceive
Receives a payload from the LayerZero endpoint and forwards it to the appropriate state registry by decoding the payload header. The lzReceive
function can only be called by the LayerZero endpoint and each nonce_ can only be used once.
name | description |
---|---|
| uint16 identifier of the chain from which the cross-chain message is sent |
| trusted remote that sent the message |
| unique identifier used to prevent replay attacks used by the message bridge |
| the cross-chain message send by the |
Retrying Payloads
As mentioned in the AMB Implementations section, messages can be retried by calling retryPayload
with a bytes hash of relevant data. In the case of LayerZero, the data is the following:
Configuration Setters
There are multiple bridge related configurations to be made on the LayerzeroImplementation
contract. These configuration functions are gate kept and can only be called by addresses with PROTOCOL_ADMIN_ROLE
setChainId
Each messaging bridge uses their own chain identifiers, different than the blockchain's native chain identifier (a uint256 value). Hence a mapping is introduced to map the chain id of the bridge to Superform protocol's internal chain ids.
name | description |
---|---|
| internal chain id used by the Superform protocol. |
| uint16 chain id allocated to each chain by LayerZero |
setLzEndpoint
This setter function updates / sets the LayerZero endpoint contract. The LayerZero endpoint is where cross-chain messages are sent/received by LayerzeroImplementation
name | description |
---|---|
| the address of the LayerZero's endpoint contract |
setConfig
name | description |
---|---|
| uint16 version of the configuration |
| uint16 LayerZero |
| uint256 type of configuration |
| bytes config data to set |
Last updated