Hyperlane 🛠Building with Hyperlane V3
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join us for a workshop titled, "Hooked: Building with Hyperlane V3". From November 17-19 2023, ETHGlobal welcomed developers from around the globe to take part in shaping the future of Ethereum at ETHGlobal Istanbul. Over $600,000 USD in prizes were given away at the prestige Istanbul Congress Center... thanks for an amazing weekend hackers! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com
Transcript
[Music] this workshop's about hyperlane uh title is hooked building with hyperlane V3 I'm Daniel I'm a software engineer hyper Lan's main features is really twofold so the first one is modal security uh of sending messages cross chain and the second one is permissionless interoperability so really anyone can take hypol Lane and deploy it between any chains two or more without asking us for permission or without having us run their infrastructure um to give you an overview of hyperlane you have you want to send a message between two contracts that live on different chains so you have chain a and chain B the way you do that is from the sending contract you call this mailbox contract that lives on the origin chain and you send a message to to it there is an offchain agent called a relayer that periodically scans the mailbox on the origin chain uh and when he finds new messages it will look for their destination chain and deliver them to the mailbox on the destination chain once arrived there um every message can have a different security configuration based on who the receiver is so the message has to pass through this interchange security module logic this logic can for instance be a multi like have enough signers sign this message for it to be considered valid and if it is considered valid it passes the interent security module verification then the message is forwarded to the receiving contract currently the status quo of interoperability is that if you integrate with a bridging provider so with their messaging interface you are tied to whichever security module they choose to use so later on if your security matures or like if there's new products on the market that improve interchain security you're not going to be able to just upgrade the security of your Bridge without breaking the interface of your contracts and having to release a new protocol version so the first Innovation that hyperlane brought about is to decouple security modules from the messaging interface so you all you have to do is just integrate with a hyperlink contract and your message can have its security module decided dynamically based on who the recipient is the content of the message and so on the way this works is that once the relayer calls process on the destination mailbox the mailbox will then query the recipient for the interchain security module it wants to use it will then feed the message into the interchain security module and if it turns out it passes security verification the message is forwarded to the recipient this allows you to do some really powerful um semantic routing um which is for instance If the message is low value you might be happy with you know a quicker and cheaper form of bridge security uh like a multisig maybe like a two out of two multisig or so but if the message is very high value you might want to be more precautious go through a more expensive security module such as maybe an optimistic one where you have to wait 7 days or or maybe a stricter multisig and so on uh that was hyperlane V2 we've very recently received uh released hyper V3 which introduces hooks uh which we believe is like the ultimate form uh of interoperability ux uh they allow you to pass messages cross chain not only via hyperlane but also via any Bridge provider out there be it native rollup Bridges or external inter interoperability protocols um you just select the hook you want to use when a message is dispatched and the message is routed through that external Bridge provider or rollup or hyperlane security module a hook is comprised of two contracts one that lives on the origin chain and another one that lives on the destination chain so in this diagram here you can see the hook and the hook ISM these essentially abstract over the interactions of the external Bridge provider um so you have the sender that calls the mailbox and when you call the mailbox you can specify the hook you want your message to use to be routed via um and then you know the mailbox will see the hook address and we'll call it with the message it's able to call this hook because it implements the I poost dispatch hook the hook will then call into the external Bridge provider smart contract you'll have the infrastructure of that bridge provider pass your message to the destination chain and ultimately the message will reach this hook ISM which is the destination of the message when it's passed to the external provider then the final step is for the relayer to call the mailbox with the ID of that message mailbox will call the hook ISM to verify whether that message ID was received and then it's forward to the recipient if it was indeed received to give you an example of a hook we already implemented it's the op stack hook the diagram look exactly the same um and what it does is we have this op stack hook on the origin chain that abstracts away over interactions with the L1 cross domain messenger you know of the op stack and then the op stack ISM which acts as a receiver from the L2 cross domain messenger say you wanted to use a new bridge provider that's not currently supported by hyperlane you can do that yourself uh it's fairly straightforward with the chain link ccip example you just need to abstract the way over sending a message and receiving a message and then the entire hyperlane infrastructure will manage uh delivery for you what this allows you to do and I think is really cool is it allows you to aggregate several Bridge providers or security modules that you configure via hyperlane so for instance you can say only deliver my message once both provider A and B bridged it um this greatly improves resilience because if provider a is hacked um the message won't get delivered because you need both of them to deliver your message or you may want just to have a provider a and a multi that uh maybe mainly your team controls the bridge is still not um centralized because you rely on both of them but like if provider a is hacked then your entire Bridge isn't hacked one implementation detail if you do decide to implement a hook of your own is that the mailbox makes two calls to the hook contract one is to quote uh is this quote dispatch call that reads the fees that the sender needs to pay uh so your hook has to call into the sending contract of the bridge provider read the estimate fee return it to the mailbox so it can charge it from the user and then the mailbox will call Post Dispatch which is this interface call uh with which the hook will then call into the in this example ccip send smart contract uh one of the main B we have in this hackathon is to build on hooks uh so my question to you is what will you hook that was the first part of the workshop modular security Now the second part is permissionless interoperability so the ability to deploy deploy hypol Lane everywhere um we'll cover permissionless deploying hypol Lan with our new CLI spawning offchain agent infrastructure with essentially one click with curtosis Cloud uh shout out to the the CTO Sy Ste here they work really hard to make this happen and then sending a cross chain message and you can have this entire infrastructure spawn up in less than 10 minutes um because internet tends to be unreliable I already have a recording of this entire flow so I'll just walk you through it we have docs in place uh but I'll just explain the let's see the flow to you so the First Command we're using is called hyperlane config create chain say you've just run a new rollup like it's a rollup you own and you want to have it supported by the hyperlane network the First Command you'd run is hyper config create chain to create artifacts for this rollup or new chain that you want to support using hyperlane and these are really the details you'd use to fill in um in metamask so it's a name a chain ID and domain ID which usually match the protocol type in this example is ethereum because we're bridging to ancient eight hyperlink currently supports ethereum salana and kosm and the provider RPC is again what you'd be pasting into metamask so this outputs one artifact for you called chains. yaml uh now say we want to use a security module just for the basis of this demo let's use a one out of one multisig and the command you run for that is hyperlane config create multisig uh it asks you okay which chain do you want to create this multis 4 we're going to say ancient a test the one we just created uh so the CLI reads from the artifacts you just created the most basic form is message ID multisig threshold will be one in this case because we're going to run a single validator of chain agent which signs uh messages and we're just pasting the account here and now we have another artifact with these two artifacts we can now deploy hyperlane so the command is hypol deploy core I'm just passing a private key in the environment to be able to pay for gas we're going to be prompted for a few details like which chains do you want to deploy hyper in between uh we're going to deploy between ancient a test and Gorly in this example so I'm going to select this and that and then let's see if there's any other questions existing contract addresses relates to exis artifacts but we don't have those so we're just going to say no and select the security ISM you want to use which is the multi we just set up is this deployment correct yes and now you know a whole range of contract deployment uh starts it takes about maybe 5 minutes on Hotel Wi-Fi which happened this morning so I'm just going to skip over this is quite a few deployed contracts so you know between Gorly and ancient 8 once this succeeds you get two more uh artifacts one is for the core deployment that's the address of the contracts that were just deployed and another one is the agent config to spin up your relayer and validator the relayer is used again to pass messages between chains and the validator is used to sign messages as part of the multisig uh with these two pieces the artifact we can now use a curtosis agents uh command as part of the hyperline CLI so that that's hyper deploy cryosis agents with a few you know command L arguments like origin chain is ancient a test uh for the validator we're passing the path to the artifacts we just got from the deployment and the relay chain field here relates to the chains the Rel are basically connects I think my first attempt here was unsuccessful because I pass the wrong path let me fast forward boom and basically this CLI command outputs a URL I'm going to take this URL copy paste it in my browser and with one click I'll be able to deploy the relayer and validator in the cloud without me having to do any sort of complicated setup the only thing I need to add is the private key for the validator and relayer so I get a pre-filled in uh form with all the details for the deployment I'm just going to copy paste the private key that I used when I sign signed up the validator earlier in the security module step I just click run and a lot of magic happens in the background um so like some Docker images I'll pulled in I guess some you know Cloud instances are created uh and now I have this environment called you know random name murky Meadow a validator and the relayer if you click on the relayer you can see it's command line logs uh it's currently scanning for events uh on both mailboxes on both chains and the validator as well is scanning for messages on um ancient dat to sign potentially so the last step of all of this is we now have a live hyperlane bridge between gorle and ancient dat right so now we can use another command hyperlane send message to send a message between gly and ancient eight uh with the new bridge infrastructure we've just spawn up uh again I'm passing a private key in the environment to pay for gas and I just do hyperlane send message from origin girly to destination ancient a test and I need to pass uh the artifacts from my prior deployment on Ancient 8 let's do that and and now the B the message is dispatched we're just waiting for inclusion in the blockchain we're going to get a message ID which the reler will be scanning for let's fast forward a bit that's the message ID right there this is me just looking through the logs in the end I decide let me just contrl F this message ID in the logs I wait for a bit and then I find a log from the relayer saying Okay found this message on girly I'm going to dispatch it to the destination you just told me to uh this is the message ID that I'm sending and then within a few seconds if I go back to my CLI I'm going to be able to see that the message was successfully delivered from gly to ancient 8 with you know deployment I just created in less than 10 minutes really um yeah so that's my uh Workshop let's see as to bounties for this hackathon we have four counties I invite you all to check them out um on the eth global website um yeah and happy to take any questions after this thanks so [Applause] much
Automatic transcript — names and jargon may be misspelled.