New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Polygon 🛠 Breaking down the Polygon zkEVM Bridge

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join Tony Olendo for a workshop titled, "Breaking down the Polygon zkEVM Bridge." and learn how to build cross chain hacks using Polygon’s native bridge solutions. This workshop is part of ETHGlobal's flagship online event: ETHOnline 2023! ETHOnline 2023 has grown into one of the most exciting events on our calendar, anticipated by hackers all over the world. ETHOnline is a three week long online hackathon with over $200,000 USD in prizes as well as a series of curated summits, celebrating some of the most significant happenings & learnings from the past 12 months in web3. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

foreign [Music] polygon Labs um and I'm Julia Lindo Twitter and you can pick me anytime uh if you have any questions related to the polygon and what we're doing but before we begin I guess let's start by introducing like the base of why we're all here and what need all of this possible and that is the polygon DK EDM so on March 27th the polygon dkvm went live um uh there's a QR code to the announcement and it was like the work uh basically jordy's life's work and like a lot of people work towards this particular goal and we were able to achieve a launch on mainnet um well I mean it beta and uh as we all know what the stages of that would look like um we thought that we are progressively moving towards a fully trustless system but at the at the base of understanding all of this is understanding like just what the ZK VM is and it basically represents the next chapter of ethereum scaling so for ethereum developers polygon KVM allows you to seamlessly deploy your code uh while while basically retaining the internal security of the area um but just first of finality and lower cost so you could think of like uh what we're building in the ZK VM as like a an expanded execution there for ethereum and it's a zero knowledge roll up and what Zeke Roll-Ups essentially do is that they are scaling solutions that are designed to just increase the throughput on Auditorium Mainland by moving computation and State Storage to Layer Two um and ZK Roll-Ups were considered like the the Holy Grail of um the ethereum protocol and um it's it it took quite a bit of time most people did think it was it was going to be possible within the timeline that we expected but it's it's been amazing to see the various teams come together and um and this is just a Beyond even us just uh in terms of the whole ecosystem and seeing various various um l2s launch um are really really complicated pieces of Technology um and seeing like Solutions being actually built and we are very very proud to be a part of that whole journey and story and ethereum's development and um how how it essentially works is basically a blockchain is a public database and it's a shared about it's a shared um computation layer and uh the way we think of the evm essentially is that the evm is like a shared uh State machine or or like the world computer and um specifically on zkvm we have transactions that are Basel processed and so they come through so you have the initial step here where you have the your transactions that just come in commit and then they are sequenced we have uh through um uh we have a sequencer that essentially um sequences all of those applications Aggregates them and then a validity proof is essentially generated which is a zero knowledge proof that computes like the all of the state transitions it produces a um that we then store on L1 but we also um uh we also make we also use to actually compute like the brand new state given a batch of transactions so the way that you the way that you could think about it is imagine if you have like a very large receipt so if you go like to Target or the Costco or something or that sort and you buy very many items um what what what um what each of those items represent is like um a single transaction and what we do is that inside of the ZK VM we basically batch all of those transactions and give you um a zero knowledge proof that represents all of these transactions so you so basically producing summaries of transactions on chain using zero knowledge proofs and the reason why we use EK is because you could actually trust it without necessarily being afraid of any kind of fraudulent transaction because it's all done trustlessly and is using room for the uh on the back end um so why would you use the polygon dkvm uh you basically inherit ethereum security um you have almost com uh full evm equivalents um there's certain op codes and different things that we should build net support and if you check out our Wiki it actually has information around that um additionally um uh we uh the ZK VMS generally are a considered to be fast and performance and eventually gonna they're actually gonna get to a place where they will power a lot are much much more lower cost transaction that should as we move ahead um but enough about like the zkvm so once we have the zkvm what what we kind of begun to see a polygon is the capacity to build what I call an importing but none of our marketing has picked up um um sadly it's called the ZK verse in my books um but imagine if imagine a future in which you could have um a a host of teams that are secured using zero knowledge technology and that is essentially what polygon 2.2 basically represents is a uh a uh a secure ecosystem of chains that are all connected together using digital knowledge technology and it represents it uh once we actually got through them the the bigger hurdle of just deploying the zkvm um and um we've seen usage and adoption increase um we then have to step back and look at okay so what what is the next evolution of this given that we have um ZK now closer and with that we're essentially able to build like uh the next stage of evolution for for the protocol so it's essentially a protocol that is allows us to basically unify scalability and liquidity and the biggest piece of this is think of app change right so individual chains that people could deploy at will um that's what the ckvm kind of um Powers through the polygon chain development kit and so if you're building a protocol or you're building a particular tool imagine you could use up the the you could actually deploy your own chain um and once you deploy your own chain you could actually decide how um how uh how you wanted to function do you want to be do you want to have purely gasless transactions do you want to have your native token do you want to be able to power um different use cases um somebody's building in gaming we have lots of differenties for from a team that's building D5 and so on and so forth and so which is why we have this kind of solution that basically is is essentially comprised of a proving layer which which actually gives us the the security that supports the execution and the internal player that allow house for cross Shield communication and um I'm crossing um proof proof generation which secures the entire network and then we are taking uh that enables us to um maintain the the uh ecosystem of nodes and the various actors that are needed to ensure that that would be the the uh the protocol is actually functioning but if you find this is a bit difficult to understand okay cool um let's break it down even simpler and Mark Myron who's our CEO um let's just simplify this or tweet right so if you look at what you're saying that's essentially if you seem to understand polygon 2.0 but here's the simplification so for you for most people who know polygon they know polygon as polygon POS which is a chain that brought up which is one of the the the most adopted Chains It's fastest and cheapest and polygon then you have zkvm which has a zero knowledge and we have a killer proofer that is um proving to be really great um yeah the polymer feedback and then polygon of the future is the polygon of today plus polygon Biden which is uh which is uh coming up soon and it'll be on Tesla soon and then the polygon end game is essentially where we headed is polygon future plus all of the app change that people will actually deploy and if you follow the the um announcement of the polygon DK um polygon chain development kit you know that we have a couple of uh Partners like Palm um no CSP um at different other uh Solutions who are building polygons and uh we also submit to the governor's proposal to settle see if they would like to run their CD their their layer 2 using the polygon cdk so it's like um zkevm um as a as a service essentially and all of those things will be connected using the lxly bridge so that you allow transactions to move across the chains and um once we're able to actually connect all of that then we have um unified liquidity right so um it'll be really sad if we have all of these app chains being developed a lot of these various Solutions and then we don't have a simplified way to bring everything together um and so the nfts that you meant on a-stars um cdk cannot be bridged to ethereum which is very sad but what we want to do is just enable all of that to become really really um useful and and portable so if you're looking at like what what what this will enable is that we have the zkvm mainnet which essentially allows us to um uh have like connection to the ethereum in it but every other app team will also have the ability to communicate with with the um with the uh ethereum mean um and you also have polygon model which is a really cool privacy Focus chain privacy performance chain that is launching so you could think of this uh closer to like Stockton or um Beyond so this is what it currently looks like but in the future we're going to be upgrading the LX L by bridge to be fully cross-chained so you'll be able to not only just terminate to there but terminate to any other chain any other app chain that exists within our ecosystem um let's go through so let's start with the base definition um what is a blockchain bridge it essentially enables two blockchains to facilitate um biscal connects to uh blockchains and facilitates secure and verifiable communication between those two parties right and you could actually you could and and the two main things that it actually Powers is messaging and it Powers um a transfer of assets so you could think of like erc20s or any kind of digital asset that's based on the blockchain can be transferred using the lxl library um if you want to think about it there are many types of bridges that actually exist um and they could be broadly classified into into two types so you have trustless Bridges uh which is like the lxly so they operate using decentralized systems such as smart contracts with embedded algorithms um and the benefits is that um uh the security of the bridge is the same as that of the underlying blockchain and so you have native blockchains and every delivery L2 implements it's native blockchain um and so if you if you check out the arbitrum um Bridge um uh and various other Pages you'll find on their own their own implementations and they basically enable users to remain control all of their fans basically through smart school culture and then you have trusted Bridges which depend upon a central entity or system for their operations so you could think of like external um layers you know they're very very many and what they do is that they depend upon a centralized entity or system for their for their operations and the big trust assumption that you're making when you're using any of these students as you're saying I trust this team and therefore I will submit my funds to them and I will assess that they do have the funds on the destination chain that I want um that I want my my liquidity or my message to actually appear um and so you'll be making you're making that kind of a you're making that kind of assumption there and if you know to summarize like the different types of chains um or the different types of bridge um trustless Bridges essentially trust minimize Bridges where um you will minimize the need for you to trust the bridge because it basically inheriting the security of the of the underlying blockchain and the accessor bridges that you're making trust assumptions and so that those are those are the challenges that you actually kind of have to navigate if you're thinking about how to how to build those bridges Beyond um but now let's delve a bit into LX of Y so I'll just go through the process because I actually don't want to spend too much time on Theory and then we'll jump a bit into the code where I'll take you through like the the code sample um but essentially the printing process is basically defined in like five different stages and steps um and so the very first one is you deposit tokens on the L1 and once you deposit tokens um you you you essentially um then go in a and append like um um uh your particular or rather your particular transaction is basically appended to the exit leaf and the and the global exit route and they're not the uh the bridge smart contacts to take care of that and then it's synced on the uh L2 so the sequence that then eventually picks up that uh that transaction and it synced on the L2 and then you mix it available for you to actually claim the assets and once you're done claim it um the process is then validated and then completed um um on the on the back end so essentially how this works is [Music] um for you as the as the user or or as any user you would initiate a transaction on ethereum network to deposit your kids to the orgas the KVM Bridge contract and that would trigger the bridge asset function of the polygon ZTV amperage right because uh what you're essentially doing I mean the place for you to fundamentally start unless you medically had just let it is that you're going to look for ether you're going to look for some kind of erc20 to be able to transact on any uh any uh al2 that's your that's your first step right um otherwise you won't be able to pay for class um so it basically triggers the bridge asset function of the polygon dkvm contract and once you do that um the bridge asset function internally calls the deposit function which calculates a lease value based on the deposit and adds it to the Mercury of the pending deposits right so you don't have to do this that happens uh internally and when you look at the code debate with ci.post um and then after that after after a certain period of time um the beauty of uh of l2s and not like uh uh ZK ZK VMS and ZK Roll-Ups is that it's just a small period of time as opposed seven days or something like that so um a certain period of time the global execute is updated on the uh on the L2 and the sequels are essentially fetches the latest route um and uh ensures that uh uh at which which would uh which ensured that uh the the amplitude is is study the designated sorry slot of the global Institute um and essentially this is the next stage of the that requires user interaction the user can now construct a local proof for the deposit e for left two and submitted transaction to call the cleaning set function um and what's it called the claim asset functionally then exists on the end uh above the uncle essentially and on the back end uh once you trigger the clean asset function policy gave you a bridge contract um uh follows the steps that will verifies the provided medical proof and then shows that you have the depositories authenticity is like a bit of a mouthful so I'm gonna spend the rest of the time here um just I'll spend five minutes and leave a couple minutes at the end there for anybody who has questions just give me one second right so sorry do you have any link or or you do or whatever that it would help me to understand how CK really works um I know it's crashings I know there is American tree but I never studied correctly so if you have any good introduction to share it would be good right so um again let me let me just share this online yeah sorry one second and so um I'd encourage you first of all if anybody's looking to um submit to the lxly Bounty please scan the QR code and this QR code will show you we'll take you to the to the code base that I'm showing you now which essentially um gives you an idea of what that looks like um for you to be able to actually build like a cross chain solution right um and this is the official documentation so I think Mariano was asking like um if they want to get started you could actually scan this QR code and it'll take you to the zkvm docs and show you how to how to use it but to be entirely clear unless you're doing anything super complicated the vast majority of smart contracts just simply be deployed to the ZK EDM in the very same way you've been deploying to any other chain um and so um it's important for me to to to let you know that you don't need to you don't need to do anything to be able to use the ckv and you could use it exactly similarly use any other chain not fully but but yes something thank you yeah yeah you could uh you could delve into the docs and then go to bed um so I'll I'll go to the pill uh to the ping pong code example um I will spend too much time here um but we have the three KVM contracts and so you could Implement a sender or a receiver on your end um and let's let's start looking at the sender um and what that does is that essentially um you're pulling in a couple of interfaces so you're pulling in the the uh the message receiver and then you're pulling in the zkvm bridge which is the actual implementation and when you initiate this um when you when you deploy the contract you have to provide the zikarian bridge adjuster that you can look at um and once you get to the uh this is the this is just for messaging um you could you you only need to specify these uh these three parameters and you could deploy right so it basically comes down to these three parameters the destination Network so this is the chain ID um whether or not you want to force an update of the of the global route which you usually do and then the value that you want to pass right so the value is um is is essentially um encoded and it's passed here so you can see the Ping message here and then polygons Bridge message and you have all of those and that's essentially it like it's not that difficult for you you want to send messages from polygon uh zkdm to uh ethereum L1 uh and if you're using a girl you then you can use that as well and on the receiver side you also have um you're basically extending the same receiver and and the bridge and um once you once you implement that bridge um uh in the Constructor you actually pass in the address and then the network ID of the all the drinks that you actually uh you actually implementing and um and that becomes like the place that it will be receiving events from uh on message received is just the main Handler that you need to be able to to transact to it and uh it'll it basically gets the original address the original Network then the data that was passed um and then just a basic require here that ensures that um that uh just I need message came from the zkvm bridge that you specified and then um this here could only be called by the sender on the other network so it's so the the pink Center place to uh what's the origin address that you passed here um and yeah the pink value you would decode that value and that just ping right so really durable and simple example that shows you how you could um send messages across chain um and if you go back into this repo um you'll have there's a there's a custom yeah C20 that goes into into what that looks like for like uh erc20 asset transfers um for the sake of this presentation I won't go into it I'll just download the description um but oh yeah the deployment so you would deploy you deploy uh the bridge and then you verify the mean at contract so once you deploy your your uh your your instance about this network um Beyond them is essentially uh need available and then you could provide your own um for you to be able to actually start to build GRCC tokens and once you're done with the deployment um you can verify the contracts on me net or Borelli or gkvm and um once you go into the scripts here the scripts show you how to bridge essentially um uh the messages from from a designation Network so if the network name is the KVM testnet or is it gave your name um and there's essentially um uh deploys this deploys the the uh basically contacts the bridge that was already initialized um and the bridge Factory and from there just starts around the founder transaction that we actually accustomed to so you want to be approved and you could you could initiate the the actual there and then you could also initiate like the branch which allows you basically to bridge the token and once you place the token after so I'm hoping that this is provided just some basic understanding um of what that would look like for you um given that we have 30 minutes I can't go slowly into like the all of the code examples um but I hope that this was useful

Automatic transcript — names and jargon may be misspelled.