Build your own L2 with the Polygon CDK - ETHGlobal Brussels 2024
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join Jarrod Watts from Polygon, for a workshop titled, “Build your own L2 with the Polygon CDK.” Ever thought about making your own L2 chain? In this workshop, we'll walk through how to ship your own layer 2 ZK-EVM using the Polygon CDK. This workshop took place during ETHGlobal Brussels, a 3-day hackathon held in Brussels, Belgium from July 12 to 14, 2024. ETHGlobal Brussels brought together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! ---------------- Follow us: x.com/ethglobal Website: https://ethglobal.com Email us at: hello@ethglobal.com
Transcript
[Music] hey everyone my name is Jared representing the polygon Labs team uh as developer relations engineer uh just in case you want to reach out to me ask me any questions and for whatever reason you don't want to ask me in person probably the best way to reach out to me is on uh Twitter just send me a DM and I I'll be able to reply but uh I'll be around like everyone house all weekend so don't be afraid to come up to me and ask me any questions uh related to this talk or just polygon in general I'm happy to have a chat with you so I thought about what I wanted to present at eth Global and you know I'm a an audience member a lot of the time myself and I kind of find myself scrolling tter messaging people and not really paying attention to what's being presented because uh I don't know whatever it is like my my brain rot or or whatever it is I'm just not paying attention so I tried to keep it as like brief as possible I think there's like 20 words Max on the whole slides um and just link out to a bunch of resources that I've created to help you uh understand what the poon cdk is so hopefully I can keep keep your attention for uh the presentation all right so just tldr like what actually is the polygon cdk it is our chain development kit so cdk chain development kit and and it is a way to build your own ZK powered layer 2 blockchains so specifically ZK EVMS um and the story behind it is essentially we open- sourced our ZK evm uh production main net chain around a year ago and then we've been running it in production ever since and we said you know what we already have all these components we spent the time and resource Research into uh ZK and the issues that you run into running a production DK evm why don't we just open source each of the individual components and create a kit to combine all of those components to make your own L2 just like the polygon ZK evm the idea behind it is that you can kind of plug and play different modules like data availability uh you can choose what type of ZK evm Behavior you want like type two type three Etc and essentially just pick and choose and configure and customize each of the aspects of the chain that you want to build um but the kind of default behavior is it is essentially copy pasting the zkm and changing the data availability module to be a validum instead of a rollup but all of that is configurable all right so here's what we're probably all here for uh at East Global is to make some money so I put this slide nice and early um this is South Bounty for the polygon cdk so you can see we have eight grand us over five different projects uh the first prize winning three grand us so um some money to be won I wanted to put that nice and early to keep your interest up all right so with the cdk uh like I said the main goal is to build your own l2s but the pathway to get there can be kind of split up into two different uh categories one is with no code so I'm going to show you a quick little demo of a platform that'll allow you to ship your ZK evm in just a couple of clicks and then for our more hardcore devs I wanted to show you how you can get started locally running all of the components like the sequencer the aggregator the bridge inside of Docker containers on your local machine which is uh a bit more fun to kind of configure and customize the behavior of the L2 so first I'm going to show you through uh the process to do it in no code so you don't have to scan the QR code but on my channel if you just search my name or search build a ZK evm you should be able to find this uh on YouTube and pretty much what I do in this video and I'm about to show you is literally in like 5 minutes you can launch all of the components required for an L2 in testnet and if my demo works I will show you that as well in this presentation but just in case it doesn't I have pre-recorded uh the exact step-by-step tutorial on how to launch your own L2 test net and show you each of the components and then also show you how to build apps on the test net that you create as well so just before I show you the demo the way that this works is typically polygon Labs doesn't run the infrastructure for uh whoever wants to build the l2s we've kind of uh partnered with these implementation providers and kind of vetted uh expert teams who are qualified to launch these l2s and run the infrastructure for you and maintain that over time so these are often called roll up as a service providers or Ras providers and like I said it literally deploys all of the components the aggregator the Prov the sequencer Bridge RPC and even the developer tools that you need if you're kind of kickstarting your ecosystem like a faucet and a block Explorer etc etc all right so my little man over here didn't quite fit on the screen but what I wanted to show you now is one example of these implementation providers and this is called Gateway so I'm going to Tab out here and make this little full screen so this is Gateway one of our implementation providers who can launch a zkm with the polygon cdk and I want to show you how easy it is I realize I'm not signed in so I might have to do that but I literally just click deploy you don't have to uh get a credit card you don't have to put in any personal information all you need to do is just click deploy I've just signed in sorry click deploy and I already have one so I will show you what it looks like once it's provisioned so it'll go you literally just click deploy you click through a couple of options this is the default Behavior here here and here is mine called uh it gives you a little demo name but these are all of the components that it deploys so you can see I have my own RPC I have my own chain ID I have my own URL here is the information about the gas so before you actually get to this page you'll go through a couple of different configuration options and reach a point where you say yeah I'm happy with the configuration of the chain that I'm about to launch and you'll reach this page after a couple of minutes of provisioning uh the resources required to host each of those components for you behind the scenes so this is like the easy route I would say if you don't want to run it all on your local machine but like I said you get the bridge you can actually go to this URL I think this one is hosted that doesn't look good does it that's the demo effect right there but what you would hope to see is the uh Bridge from the L1 test net to your L2 test net of course the demo effect is uh in play here but that is like the uh easy route as I was saying so this is really no code and like I said you just click through a couple of pages configure uh the options that you want like the gas settings uh what L1 you even want to host it on is customizable as well so it's pretty cool customizations but the other route that you can go through is to launch everything locally on your machine as well inside of Docker containers so this is pretty fun uh I've been playing around with this for like a couple months now and this video will show you the first hour I know two hours is kind of scary but the first hour is just concepts of like what is an L2 uh what why would you want to make your own L2 what are the different configuration options like data availability different kinds of provas all these like fundamental concepts of stuff that you would probably want to know if you don't already if you're launching your own L2 so that is also you don't have to scan the QR code you can just search that up on my channel as well but that will walk you through what this is here which is our ketosis package so the kosis cdk package is it's ketosis is an open source Dev tool that specializes in uh kind of orchestrating these containers for you so you specify what steps you want to occur and how those pieces that you launch should interact with each other so for example in the default Behavior it will launch a local L1 it will deploy the rollup smart contracts to the L1 it will deploy the node containing the sequencer the aggregator uh the bridge from the local L1 to the L2 all of these components and it'll kind of like sequentially go through them and build the relationships between each of those components and then you just swap over to your Docker and you can view each of the components running sorry each of the components running and then uh kind of shell into each of those instances so for example if you shell in into the RPC you'll be able to see all the requests firing off the effect of how much each should those transactions cost in terms of gas and you'll be able to track those transactions just from the logs running on your local machine which is pretty cool as you'll see uh in the video as well so I know it sounds scary to run all of these components like the sequencer the prover the aggregator but it's actually super simple it's literally two lines of code with a massive caveat of having a bunch of stuff installed so it assumes you have uh Docker and python and a couple of like basic Dev tools installed on your machine and all you need to do is clone the repository change into that repository and the second command is the ketosis run command so basically ketosis is a CLI tool it's going to inspect uh a file that tells well basically tells it what to run and in our case it's going to run each of those components launch them and kind of deploy each of the require smart contracts in sequential order so yeah like I said to get started massive caveat you must have a bunch of stuff installed like uh Docker and python uh couple of other CLI tools but once you get it uh your environment running it's literally one command and it's going to deploy every single component instantiated inside of Docker containers for you the one cool thing I'm just going to check what okay so this is what I wanted to show you is like a preview from the video and the reason I didn't do it live is because it takes around 15 to 20 minutes to deploy and with the Wi-Fi I uh didn't trust the process to go very smoothly so I just took a little screenshot of what happens when you run this command from the video um where I skipped through all of the all the braks and explain what's actually going on so you can see in this example it basically literally just goes step by step through his every single thing that needs to happen when you're launching your own L2 so for example here you can see this is adding the synchronizer it's deploying the smart contracts it's then going to deploy the components of the node like the uh sequencer and the aggregator and basically it just goes step byep prints out the logs of what's happening in that deployment process and at the end you'll get either a big giant red error message that says what's gone wrong or you'll get a green error message to show you here is the docker um container IDs of each of the services and I think what I wanted to go through before I I know I'm going back and forth sorry this ps. yml file is like hundreds of lines of configuration options so uh there's a couple of config files like pam. yml that you can configure uh how often you want to post batches of transactions to the L1 how often you want to post proofs to the L1 uh what the gas limit is like what token you want to use for gas there's like hundreds of lines of codes hundreds of lines of configuration Flags in this one file and then you can even go deeper and configure the behavior of each of the services like the aggregator and the prover and the sequencer and configure um pretty much like at a very granular level what's actually going to happen when you run this ketosis run command cool so I just put this here at the end I know it's kind of like scary but I want wanted to talk about what you're actually shipping so I keep yapping away about all of these components like the sequencer aggregator Etc but what actually happens when you run this command is you pretty much instantiate all of these pieces and this is even simplified of what you launch so there are a lot of moving pieces but what's going to happen is you launch the first you launch a local L1 but you can also swap to sapoia which is what I do in the video you deploy these smart contracts here so basically you deploy a rollup smart contract that is responsible for receiving the batches of transactions as well as receiving the zero knowledge proofs to verify those batches of transactions so the steps are deploy the L1 which is optional you can choose to deploy to ethereum test net if you are rich in the ethereum test net funds you then deploy the bridge smart contract and then essentially I'm simplifying it here but you deploy uh a trusted node and a trustless node which contains the aggregator it contains the prover and it contains the sequencer here so the sequencer basically reads these transactions from the L1 takes them in executes them so it's like is this transaction complete garbage is it uh a duplicate with another transaction in the pool that's been submitted is it uh going to conflict with another transaction in the trans ction pool basically it just does a couple of Sanity checks and then executes them or discards them and then it gets sent so there's a uh kind of sub component of the sequencer called the sequencer sender I think and that is going to send the batches down to the L1 and then this kind of second process gets kicked off where the aggregator says hey I see you've got some nice looking juicy batches for me let me go ahead and prove those sends it to another component that you've deployed inside another container who proves generates a zero knowledge proof sends it back to its buddy the aggregator and posts it back to the smart contract that you've deployed on the L1 so there is a lot more pieces like the the bridge and the RPC and the block Explorer and out of the box you also get this awesome stuff to kind of inspect what's going on to see how many people have bridged how much funds have been bridged uh the block time the the time that has elapsed since you've last proven the blocks all of this cool information is kind of ready for you out of the box just with this two commands that I showed you in one of those previous slides nice so one of my goals before coming to CC was to ship some new cdk docs um so I just chucked this right at the end to say we've just shipped like a week ago uh new overview page new getting started New Concepts all brand new fresh docks uh ready for the hackers to kind of play with in case you're sick of listening to me in these videos as well you can just read the text uh it's pretty much exactly what I'm doing in the videos is just going through the process in these documentation so yeah that's that's pretty much all I had like I said very text uh light so hopefully it kept your attention but um yeah $88,000 available to be awarded for projects building their own l2s I've been saying to a couple of teams already some strategies for teams is to ship a cool product build it on a couple different l2s why not slap on your own L2 and ship it there as well it's uh like I said very very easy to do but if you want to go more granula get some cool customizations you have a cool idea for creating custom L2 uh you can experiment with the local deployment as well yes Mr Blake since we only have one weekend the time ising guess you have any recomendations as to are a lot of are a lot of IDE the best place to start a team discuss Ida getting into the where should I start icture yeah know one very yeah so just to repeat for the stream the question is like what's the best resources to get started with the cdk for the hackathon um I think there's a couple I think the obvious ones just come speak to us like uh see if your idea is feasible if you have a crazy one um if you run into any issues like just come and speak to us I know uh some of us are a bit scary but no we're we're very I'm super Keen like I've been working on this for a couple of months trying to improve the developer experience so I would love to hear if you think it's complete garbage please come and tell me if you can't get anything running please come and tell me um what you should also do is we have a ton of our Engineers who are about a hundred times smarter than I am in our developer Discord or R&D Discord so you can jump into our Discord server and speak directly with the engineers that actually built the tools that I'm trying to uh Shi to you here today as well um and I mean if you take it a step further we also just shipped our grants program so I mean there are kind of Pathways to develop this more seriously um if you're looking for kind of financial rewards after the hackathon as well so happy to come and talk about that at our booth too round two yeah are there any um use cases that you would of like you know Solutions problem stats that like you would like to see Sol or someone yeah I think there's there's like like you said there's options to go completely off the deep end and try and ship something combining I don't know maybe like you could combine one of the D tools that is here and ship a a new roll up with a different da tool I think a cool one that's pretty simple to customize is like changing the gas token of the L2 that you ship so something that would be sick would be like if you launched your own L2 with usdc or something like just kind of one simple change that doesn't exist today um for example changing the gas token or or changing what um where you send the data to or or things like this that's you know it is approachable you could go completely off the deep end but within 36 hours uh I realize it's probably probably a lot to ask to go too crazy but um yeah like I said I think the best approach would be pretty much just common talk to us see if your idea is feasible um the whole idea of this is is meant to be customizable so um we Keen to see pretty much anything that people come out with uh and if you think like I said it's it's terrible it sucks I don't want use this anymore that's also amazing please come and tell us so we can improve it uh for for future iterations as well sweet no more questions awesome thank you [Music]
Automatic transcript — names and jargon may be misspelled.