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.
This is the end to end workflow of how a Hashi DVN Adapter will be used by an Oapp
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`
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 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.
Hashi DVN will listen to the following events and call HashiDVNAdapter.sol on destination chain.
- Listen to
PacketSent
(to get payload) andDVNFeedPaid
event - Listen to
MessageDispatched
(for messageId) event
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 setverify
mapping to true. - Executor calls
commitAndExecute
message
hashi/
: Hashi contracts, based on Hashi v0.1.1.layerzero-v2/
: LayerZero-v2 contracts, based on LayerZerov2 audit tag.interfaces/
: interface for Hashi DVN Adapter.test/
: Contracts used for testingHashiDVNAdapter.sol
,HashiDVNAdapterFeeLib.sol
,HashiRegistry.sol
: main contracts.
https://crosschain-alliance.gitbook.io/hashi/v0.1/application/hashi-dvn
- LayerZero v2: https://docs.layerzero.network/
- Hashi: https://crosschain-alliance.gitbook.io/hashi/v0.1/readme
$ yarn install
$ yarn hardhat compile
$ yarn hardhat test