🍩Hashi DVN
Hashi integration of Layer Zero v2 DVN
Layer Zero v2 DVN provides customizable security stacks for developer to choose from. Developers can specify one or more DVNs for their Oapp according to their security preference. Learn how to configure DVN for your Oapp here.
Hashi, which aims to create "additive security" for cross-chain message bridging enable developers to choose which Hashi Adapters to use for their dapp's security preference. Message hash is relayed through Hashi Message Relay and stored cross-chain in Hashi Adapter contract.
This is a PoC of Hashi integration of LayerZero v2 DVN.
Workflow
This is the end to end workflow of how a Hashi DVN Adapter will be used by an Oapp
Configuration from developer
In order to use Hashi DVN for your Oapp, Oapp developer need to register the DVN in the source endpoint's config.
Oapp calls
Endpoint.setConfig
to add HashiDVN as one of the DVN. url
Configuration from Hashi
Underlying Hashi DVN is a combination of Hashi Message Relay and it's corresponding adapter. The addresses and fee is registered in HashiRegistry.sol.
set eid to chainID mapping
set Hashi Registry for hashi adapters addresses and fee.
Source Chain
Source chain workflow
Sender calls LzEndpoint (or Oapp that will call LzEndpoint eventually).
LzEndpoint calls SendLib (default to ULN302)
SendLib calls HashiDVNAdapter
assignJob
and pay HashiDVN fee (fee is fetched fromHashiRegistry. getFee
)HashiDVNAdapter calls
yaho.dispatchMessageToAdapters
to relay the messageHash.
Off Chain
Hashi DVN will listen to the following events and call HashiDVNAdapter.sol on destination chain.
Listen to
PacketSent
(to get payload) andDVNFeedPaid
eventListen to
MessageDispatched
(for messageId) event
Destination Chain
To verify the message, Hashi DVN owner will call HashiDVNAdapter.verifyMessageHash()
, with messageId
from Yaho contract, and payload
of the corresponding LayerZero packet. There are two steps of verification:
1st verification: If the messageHash stored in Hashi Adapters are matched.
2nd verification: If the messageHash from 1st verification matches the corresponding LayerZero's payloadHash.
Destination chain workflow
call
HashiDVNAdapter.verifyMessageHash(messageId, payload)
HashiDVNAdapterl calls
Hashi.getHash
to check if all adapters agree on the same hash for 1st verification.If true, check for 2nd verificaiton and calls
ReceiveLib.verify
to set verify mapping to true.Executor calls
commitAndExecute
message
Reference
Last updated