L1 - Demystifying Layer 2 | by Samarendra | BlocSoc Lecture Series

BlocSoc Lecture Series · 20:45

Samarendra introduces Ethereum scaling and the tradeoffs between throughput, cost and decentralization. He surveys state channels, Plasma, sidechains, optimistic rollups and zero-knowledge rollups.

Speakers

Topics

From BlocSoc Lecture Series, published by BlockChain Society IIT Roorkee; community: Blockchain Society IIT Roorkee.

Transcript

uh so yeah so basically today's topic is demystifying Layer Two so many of you might be knowing about Layer Two but U yeah it's it's a bit easy concept uh relating relative to all the things we'll be discussing in the lecture series um so let's get started so basically the first question is what is Leu so we see many many of the chains such as polygon arbitrum optimism linear znc and all so all these chains are called dear to scaling Solutions uh these are basically scaling solutions for ethereum layer one uh so what is a layer two uh scaling solution so

basically uh layer one uh itself is not that much capable uh when it comes to transaction speed uh when it comes to transaction throughput and also the in terms of uh the gas Fe so these are few drawbacks that a layer one always poses and there are Layer Two present to solve that issues so first of all what is the need of Layer Two so before going into that uh let's discuss few questions so first of all the first question would be why to scale a blockchain so what is the need of getting a and and the second question would be uh why

ethereum layer one is not scalable and the third question would be how can Layer Two solve the scalability issues and as you can see this meme over here uh so this is basically a screenshot taken from a video clip that that was issued by uh I guess some peeps at Solana mocking ethereum uh l1s uh like they said that in this video like uh the ethereum chains always need various layer layer one layer two layer three layer four over there so in order to function so so that was a funny meme over here uh so let's uh move to the first question uh why to scale a

blockchain so basically over here I have put two examples uh the first uh being the 2017 bull market um in 2017 there was a trend of icos icos you might be knowing uh initial coin offerings so B basically various projects uh like started offering their own coins and tokenomics and they were able to pause the uh entire L1 for a while because of the large volume of transactions uh the iOS had caused uh and the second example would be uh again the 2020 bull market uh in the 20 W Market there was a D5 boom so

basically the decentralized finance and the yield farming stuffs are in Trend uh in 2020 and basically people went for like performing transactions uh in order to gain uh profits and uh yield high aprs so basically that caused uh uh the L1 to Surge the gas fees up to 500 to 700 g that is insanely High basically as you can see uh we might see over here I think my screen is not visible for the other tab just a minute yeah

so we can see over here the current uh like gas phase over ethereum L1 is around 16 G and I was talking about uh 500 to 700 g uh during that uh crypto Market boom uh so yeah basically these were the problems that need to be solved uh while scaling a blockchain like uh the layer one poseses uh these kind of slow transaction issues as well as high gas fee issues and as well as the the chain might get Haled for very few time very few seconds that may cause uh

like instantly transaction pause and Etc you might have heard that uh recently Solana uh chain had faced a chain halt of for a few seconds and that uh basically caused 75 or 80% and transaction to be uh paused for a while and they didn't get processed so moving on to next question why ethereum L1 is not scalable so ethereum by its like on its design uh performs around 12 to 15 transactions per second that is its current transaction per second of TPS and also uh considering the price of ethereum ethereum token the average gas

fees uh that is being charged for an uh transaction is around $1.5 per transaction but uh uh it's not like limited to $1.5 per transaction it can go up to thousands of dollars for like complex code executions such as uh any governance uh proposal execution uh like I have seen around, 1200 $1,500 of gas fees for a single execution so this is the the gas phase is very much High uh when considering L1 the ethereum L1 also uh so why cannot we just scale the L1 to use like higher performing nodes

so basically like like if anyone can argue that uh uh we can use very high performance nodes and make the transaction processing very faster but uh that would basically cause a problem um that is the blockchain trma blockchain scalability trma uh anything you can say uh so basically when we try to scale up the uh L1 uh using high performance nodes the initial capital investment uh to run a node basically increases and causing uh the like the verification power and node running

power to a specific group of like Elite people and that would basically reduce the decentralization uh also there would be uh less number of nodes running uh because of the limitations because of the resources needed so the chain would be vulnerable to various attacks uh like you might have heard 51% attack uh that is caused when the 51% of your chain uh 51% of your validators or nodes uh is basically being hijacked uh so they can change any transaction or any values or any data on the Chain uh to whatever they would like so basically scaling the

layer one uh directly would not be possible as that would uh basically uh decrease the decentralization and security of the chain so how to scale a blockchain without compromising on security and decentralization so the answer is L2 basically L2 provides his his solution uh by like basically L2 is not changing the L1 at all L2 is on the top of L1 and it tries to uh uh like bundle the transactions over it tries to bundle the transaction over the L2 uh and after bundling it it puts it into L1 and verifies it so basically it uses all

the Securities uh security features of the L1 and also it doesn't uh like like harm the decentralization of the chain so moving ahead so why Layer Two so Layer Two as I mentioned doesn't require any changes on the base CH and it leverages the security of the layer one while providing the higher TPS so basically Layer Two as you can see uh like as you might be knowing uh in arbitrum or in polygon like the transtion per second is around around uh like in thousands so in polygon last I remember was 65,000 transaction per second uh when compared to eum M1 that is 5 to 15 or something like that also

Le to provides lesser gas price because because like U they because like they run on like higher uh capable machines uh their nodes are on higher capable machines and the transaction speed therefore increases and also they provide higher transaction throughput because uh like uh what do you mean by throughput like uh what kind of number of transaction uh at a single time uh can be verified so this is uh basically L2 provides and L2 can be for general purpose uh for example proving any smart contract or uh

like running any function on Smart contract or swapping tokens etc etc and the L2 can also be application specific for examples uh in case of Bitcoin we do have lightning Network that is an L2 uh that is only specifically made for payments and that is an example of application specific L2 and general purpose L2 can be arbitrum optimism polygon Etc that is uh basically based on ethereum L1 so moving on to the next part uh how how Layer Two works so there are various uh architectures in which like the layer tws are implemented uh in order to

implement the layer two uh we do have few architectures listed over here such as state channels uh side chains optimistic rollups as well as JK rollups so let's uh go one by one like with the list and before moving on to the list uh let's uh uh see the table over here so basically this table signifies the transaction per seconds for example Bitcoin have seven transaction per second ethereum is around 12 and the lighting Network that is a layer two of Bitcoin is around 1 million transactions per seconds that is estimated around and in polygon around 60,000 as I mentioned earlier and

optimism arbitrum around 100 to th000 per second and yeah the Z rollup such as Stark and ZN around 1,20,000 and so on so basically also these are the fees uh per transaction so as you can see uh transaction in the ethereum and Bitcoin network has bit higher transaction fees are a bit costly uh whereas uh in the l2s uh they are pretty cheap so moving on to the various type of layer tools first of all is State channels so what are State Channels

State channels are uh basically a type of layer to solution in which there are two or more parties involved and they can perform multiple offchain transactions uh like uh person a trying to send uh like multiple transactions to person B and vice versa uh but they basically uh submit only one or two transaction at the end uh to the chain so by doing this basically they are uh like uh reducing the number of transactions uh that is put on the chain and hence reducing the transaction cost as well as reducing the uh the speed uh

settlement time and all so in order to uh perform this state Channel transactions you need to be a multi so basically you need to stake uh few of your Bitcoin or in case of lightning Network few of your Bitcoin and basically then you can start doing this multiparty transaction uh that is being verified offchain and then you can put only single transaction or two transaction to the Bitcoin Network and hence uh verify the transactions so as as I mentioned lighting network is a like very good example of State channels so let us move ahead uh with plasma so plasma was basically a scaling

solution of like it was introduced by vitalic buin the founder of ethereum uh but it's not that popular among the layer to Solutions basically in plasma what happens is there is a parent chain and there are various child chains or children chain and um the children chain and the parent chain can be uh can communicate whenever required so the child chains can basically broadcast uh uh broadcast whatever like information they want to uh into the parent chain and it is a bit uh like technically difficult to understand plasmas uh so these are not that much

used and we see very less examples of plasma so let us move ahead with side chains uh side chains as you might have heard of polygon and basically side chain is a chain basically as the name justifies uh for a parent chain side chain is a chain U that basically have its own consensus mechanism as well as it can have their own validation facility or own validators or miners for proof of work or like proof of proof of stake they have validators so basically polygon is a POS Network proof of stake Network and while ethereum was a proof of work Network polygon used to be a proof of State Network then and

basically they had their own validators uh that is a different consensus mechanism from the L1 and like they had their own way to reward their minor or validators basically side chains compromises on the security in order to gain a largest speed of transactions so basically uh the main chain uh is linked to the side chain and vice versa the parent chain can work independently but the side chain cannot work without a parent chain so basically it helps in interoperability uh how the side chain function is like uh you basically uh Bridge some of your assets from the

parent chain to the side chain and you perform your transactions and then you put the transactions uh and the remaining assets uh to the L1 uh so basically for example we have Matic Bridge or also Circle cctp that uh acts as a federation or Bridge uh in order to provide us access to the side chains and in side chains basically you lock your tokens on the L1 and basically you release the token uh when uh basically whenever your transactions are complete on L2 and these locking and releasing mechanisms are done uh by the Federation and since the involvement of this

Federation uh the side chains basically are considered less secure uh for a few examples are like polygon as I mentioned and XD or nosis in today's day so let us move ahead with optimistic rollups uh so optimistic rollups are uh basically a type of so before going into optimistic rollup let us discuss about rollups itself so rollup as the name justifies uh a lot of transactions are rolled up uh into a piece of paper uh like uh just imagine and then it is put into the L1 uh so basically it is bundling of lots of transaction and then putting it into the

L1 so in rollups basically transactions are not directly put into the L1 uh instead the transaction data is there so instead of uh transaction putting uh transaction uh getting uh registered on the L1 we basically just put the data of a collective transactions uh to the L1 and hence uh we verify uh all the transaction in the bundle so optimistic rollup is a type of rollup uh rollup solution basically optim in optimistic rollup the uh name justifies itself uh so we become optimistic about the transactions happened in the bundle and

we think that we basically assume that all the transactions are correct and we basically uh have a like what do you call call it U um a dispute time uh in which someone can just uh create raise a dispute that the following transactions are wrong and if they are found wrong they are removed and the remaining bundle is uh like put into the L1 but uh if the dispute time is passed and no transaction is found uh like malous then the whole bundle gets passed into the L1 and the transaction data is registered there so few examples are arbitrum optimism and base network

uh let us move to Z olops so Z olops basically mostly Z snars so here I have written the full form of Z snars ZK snars refers to zero knowledge suin non- interaction argument of knowledge so we don't need to know all of that uh at the beginning we are going to learn about in the next series uh so ZK rollup basically as the name justifies uh provides zero knowledge about the transaction in the bundle uh basically U like understand like that uh in the transaction uh suppose a sends Few e to B but uh while we just put the

transaction into the L1 uh there is no mention of a or b or the amount of e that is being transfer for so how zups work zups basically uh basically they generate offchain proof uh validity proof and the validity proof is then submitted to the L1 and hence the transaction is verified in that way also ZK rollups are pretty fast uh when compared to optimistic rollup because optimistic rollup has that dispute raising time and yeah so ZK rops also the robic zik rollups posesses are they do not support smart contracts yet whereas optimistic

rollups have their optimistic virtual machine uh that can support smart contracts so zik rups basically works on circuits and not smart contracts so that is a drawback to get started with but uh few examples that have successfully implemented Z rups are ZK sync uh starnet Linea and polygon zkm Etc so that's all for a brief about the l2s we'll see about ZK rollup and optimistic rollups in the next uh few lectures in detail so yeah that's all