1. Scaling Ethereum with Cairo

Starknet BootCamp · 32:14

Manmit Singh, a developer advocate at the Starknet Foundation, gives a recorded introduction for the Starknet BootCamp. He starts from the blockchain scalability trilemma, why decentralised networks struggle to be both secure and fast, and explains how layer 2 rollups and zero-knowledge proofs move computation off layer 1. He then shows where Starknet and the Cairo language fit, and closes with open research areas, application-specific chains and layer 3 ideas, and how newcomers can get involved in building on Starknet.

Speakers

Topics

From Starknet BootCamp, published by OpenBuild; community: OpenBuild.

Transcript

hey folks I'm really excited to be doing this darket and CYO 101 for our base camp with forite so my name is Man Singh and for those of you who are in college we might actually not be that far apart in age I only graduated with a degree in computer science last year and when I was in college I had the amazing opportunity to be had the amazing opportunity to be able to doch particularly in in Game Theory and defi after graduating I work briefly uh on a uh summer research Fellowship in crypto and then uh was lucky enough to be accepted in starware and then the starnet foundation who work as a

developer advocate for the us today I'm just going to be talking to you briefly about what stet is and what Cairo is and give you something to go offer for this journey that you're about to embark on if you ever feel like you have any questions or you want to talk to me about anything you can reach out to me on any of the socials provided at this link tree so usually I do these talks in a much more interactive fashion uh but since this is a recording I have a few talking points that I'd like to go over we'll be going over what blockchains are and why they're slow we might even skip fast what blockchains are presuming some amount of knowledge in your part then we'll talk about layer tools rollups and that's where startet really comes in

finally we'll talk about some of the issues and active areas of research for layer TOs and how you can get involved in building the future of stet and blockchain but before we start all of that I'd like to talk to you about the blockchain Paradox so sometimes this is also expressed as the blockchain scaling trilemma and what it means is that colloquially are based on the existing literature around block blockchains people think that there are three features which a blockchain architecture cannot achieve simultaneously these three features are decentralization scale and security though really these are two features

because no matter what system you use you always want it to be secure so let's say it slightly differently the blockchain Paradox says that a blockchain's got to choose between being scalable and decentralized and I suppose this difference is quite Starly highlighted in our existing Banking and recordkeeping infrastructure when we use banks for storing financial data or government offices or social media websites for storing personal data we're essentially delegating accountability to store and process this data to a central party but who we are really trusting is whoever is auditing the central party in

many cases this would be the government blockchains provide a more Global crossborder approach to this by leveraging distributed digital networks and allowing people to run these things called nodes where they can basically download and verify the state of the blockchain and have inclusive accountability so you can think of it as like moving the responsibility to store and process the data verify it uh with just one agent versus where several interested parties who can keep each other in check now I assume that you're already familiar with these Concepts but I want to highlight here that this distributed accountability model or

inclusive accountability model sacrifices scale because this network has to be designed in such a way that multiple parties are able to download and validate the various transactions on the network within a short duration of time which is also called the sync typee and that's really the biggest challenge that a lot of blockchains run into when they're trying to scale is it's almost like saying that the chain is as strong as the weakest link so to some degree blockchains have to account for a reasonable Assumption of compute and memory on behalf of each node operator another thing is the word accountability itself blockchains like the proof of

stake ethereum model rely very heavily on the assumption that if someone breaks their game theoretic guarantees the network can accurately identify that party also sometimes called an adversarial agent in Game Theory and in order to do this a lot of blockchains like proof of State ethereum sacrifice the privacy of individual transactions so that's that let's put a pin in this conversation and move on to this really exciting mathematical concept called validity proofs now I want to be clear validity proofs themselves don't really have much to do with blockchain that's not where they were born validity proofs were first introduced as an academic idea by applied cryptographers in the

late 1980s kind of came to life in the 90s and 2000s and the first industry applicable algorithms came out a little bit after 2011 but what's validity proof so skipping all the the fancy and well well actually quite interesting stories but you know just in the interest of brevity I'll explain what the V proof is so imagine you are someone running a computer program and you have certain inputs and a certain algorithm and you're running it locally on your computer for the purposes of this analogy we'll call you the pro and then let's assume that I in this case want to make sure that you actually run this

program correctly based on the inputs and the algorithm that you're claiming to have so I can be called the verifier what a validity proof is doing is it's allowing you as someone who's running the computer program to convince me by using a small computational object called a proof that you actually ran this program correctly given the inputs and the claims you made about the algorithm the alternative to having a proof object would be rather inefficient you'd have to send me all the inputs and the algorithm and the result and I would have to use my computer taking up time and of course computational resources to

rerun the entire algorithm with those inputs and compare our answers but sometimes when the algorithm is simply too big or the inputs are too varied or you want to preserve their privacy you don't want to go through that naive route you want to go through a proof um and so I suppose the catchy way of saying this is proofs enforce the idea that provs do the right thing even when no one is looking there various types of constructs or various types of styles of proofs including rank one constraint system proofs plon blish proofs and Stark proofs we'll be zooming in a little bit more on Stark proofs but for the moment I want to go over some of the important properties of a validity proof

so the first two are really just the same thing they are saying that if you're an honest prover that is to say you're someone running the computer program you're an honest prover you'll always be able to convince an honest verifier and never be able to fool an honest verifier if you're dishonest so it's kind of coming at the same guarantee of safety from two different angles and then lastly as you can see that you know we've B basically uh created a situation where the prover is giving a small computational object to the verifier this can allow the prover to do various things for instance the prover could op escate which is to say

that they could you know Hye some of the inputs or some of the details about the algorithm and still create a proof which can sufficiently satisfy the verifier and this is called zero knowledge basically the idea here is that the verifier the prover is able to create such a proof which can convince the verifier that they ran the computer program correctly but the verifier doesn't get to know certain inputs or algorithmic details which the prover doesn't want them to know through the means of cryptography now one thing that I'll note is that when I say always and never I I want to be very clear that this is all applied cryptography and applied cryptography is probabilistic in nature which means that always equals

something that's extremely probable and never isn't just never it means something that is extremely improbable so as I said we'll be focusing a bit on Stark proofs browny points for anyone over here who knows what Stark means or stands for but I think the way it's named is actually quite brilliant because it explains what the proof itself is so Stark stands for scalable transparent argument of knowledge all three words tell you something about what this is scalable what that means is that star proofs are constructed by using lean cryptographic methods which is to say that ex executing the cryptographic functions that make a star proof is very easy for a computer

and that makes the proven time or the proven overhead for a St proof quite low or in other terms if you're the Prov you're running your computer program you can generate a star proof very easily transparent what that means is that since you're depending on certain lean cryptographic methods such as Collision resistant hash functions you're not really worried that if some detail about the proof generation gets leaked someone else can recreate a false proof and you know collapse the whole system so there's no trusted setup in a the generation of a star grof and then finally argument of knowledge now argument of knowledge goes back to my

claim in the previous slide that all applied cryptography is probabilistic in nature because what an argument of knowledge means is that this proof holds against a computationally bounded adversary and a computationally bounded verifier that is say the proof is designed so computationally bounded verifier can verify it and it's safe against a reasonably computationally bounded adversary now I know that a lot of conferences and a bunch of talks about rollups often you know use the word ZK uh but as we spoke about in the previous slide zero knowledge is an optional property of validity proof not an required property and at least that's

stet because that's the context in which we're speaking we use star proofs not ZK star proofs which is to say nature because what an argument of knowledge means is that this proof holds against a computationally bound computationally bounded verifier that is say the proof is designed so computationally bounded verifier can verify it and it's safe against a Rec computationally bounded adversary um now I know that a lot of conferences and a bunch of talks about rollups often you know uh use the word ZK uh but as we spoke about in the previous slide zero knowledge is an optional property of validity proof not

an required property and at least at stet because that's the context in which we're speaking St proofs not ZK St proofs which is to say that we prove statements St proofs but we don't obfuscate any information about the underlying computation uh um I want to go over very the differences between Starks which is a popular construction of groups versus snarks which is another very popular constrution basically as I mentioned the proven time for proof is really fast because you're using lean cryptographic methods but this also means as opposed to a snark and because of that the verification par roof tends to be a

little higher in the sense that it grows poly logarithmically in the size of the proof itself whereas um a snark proof is constant to verify because it's constant sized um and as far as trusted setup goes we covered that Starks don't use trusted setup whereas snarks do and theoretically uh you know if we assume the uh I suppose the agerial model where we're not just dealing with bit based computers but Cupid based computers with uh orders of magnitude more computational ability uh stock proofs would still be secure against such adversarial models so now we've spoken about validity proofs and

we've talked about the decentral uh the scaling trilemma um let's put these two ideas together to tackle a problem that's been relevant in blockchain world for a few years which is a problem of scaling ethereum now there are two problems really over here when we say scaling first we already spoke about which is distributed verification everyone who runs a full node on ethereum has to download all of the transactions that have taken place in ethereum and have been put in blocks since and they have to maintain the state of the network fully which relatively High memory requirements but it's also time intensive because to sync and rat can take quite a bit of time um the other

thing that we is block size uh so ethereum has a fixed size of blocks and each block Can Only Hold so many standard ethereum transactions so as ethereum grows in size over time each TR have to wait longer and longer and longer to find an empty block to get into you can also think of this as being in a in in a really congested part of town and trying to get a taxi and you know the taxi may take a little longer for instance you do Uber or LIF and they'll just say you know we can't find you people because it's so busy and if you go to a more isolated part of town you get the Uber very quickly so the way we apply validity proofs to

scaling ethereum is that we basically allow a larger and stronger computer or perhaps just toiz efficient computational collect users transactions and validate them and provide them to the rest of the next Network in a morecraft so that the network can put this compressed form of these transactions into a block and save space also provide or I I should say the centralized efficient computer all validators with a stark proof that this new state which it has computed based on these new transactions is actually valid and so the validators can be represents

all of these transactions is actually a correct representation so you can see how a centralized or a set of smaller of of centralized more basically do the heavy lifting of syncing with the chain um and uh sequencing and new transactions without having to bother all of the other validators so one question might be well how does starnet do this um so for those of you who've looked at you know some other uh popular validity proof libraries out there you might have looked into

Socrates uh um and circum the same concept which is that they express that they want you to express your computational logic as a circuit and that circuit is then mapped to a polinomial and turned into a proof I won't go into that because this is not a math grated lecture uh but what you're essentially doing is expressing your program as a circuit now for most people who have a compter we not used to express in computations as circuits but expressing them as programs step-by-step logical programs that execute on a traditional V man CPU architecture and remodel um and so Cairo which stands for

CPU foration essentially allows people like you and I to write traditional looking computer in a language which is very much like rust and to assume um a a vman architecture in a ram based memory model write these programs and then Cairo which is a virtual machine compiles these programs into an uh an underlying form which is provable so essentially it abstracts away the its own back end and allows you to write provable programs not as circuits but as normal computer programs and further CYO vm's execution

can be now I just want to put the S out there to help you get a better metal picture of how efficient this is um we spoke the naive way of verifying a transaction versus verifying a set of transactions by using stalks see on this plot that as the number of transactions grow uh the poly logarithmic plot is significantly lower and compared to the linear one which would be to say for instance rerun transaction um so in a way validity proofs or to computation uh on on chain word zip files are to file sites for instance if you're ever attaching a file

to an email blockchain scaling validity proofs are used to scale blockchains um let's talk about the type of product class of product that this validity uh solution has produced it's often called a roll up or the layer tool um but before we talk about layer tools I'd like to have some formal understanding of what the word layer means so as for vitalic Lay is a blockchain which provide ability to another blockchain so if you're calling the blockchain it's scaling will be called the parent chain and who does this by essentially collecting

transactions and then uh Pro uh validating and submitting them to the under for ordering and uh block ifying them this alleviates the burden of having to uh validate transactions from the parent chain itself and the parent chain can be because of the proof that the layer 27 one uh but the way that you can think layer accepts transactions from you and those transactions um achieve finality on an other blockchain that would the roll up on that other layer so you could have a layer one layer two layer three and they

all keep settling on the layer beneath them so that's essentially the whole model over here um I suppose this diagram kind of summaries so far uh is that you have a big computer generating proof and various smaller computers with much lower computational and memory requirements being able to verify it um so this part of of well what exactly is startet and what is what it does uh the next part is a little bit more about what people are doing with starnet and we'll start with some of the open research questions um so let's go over the

security guarantees for a rollup the literature on rollups there are three main security guarantees data availability safe Transitions and censorship resistance I ran out of slide space so I just said sensorship last data availability is saying that U for a block for a rollup to be truly safe it needs to Pro chain that would mean that the layer you submitted to is a roll up on that other layer so so you could have a layer one layer three and they all keep settling on the layer beneath them so that's essentially the whole model over here um I suppose this diagram kind of sums the entire story so far uh quite concisely which is a big computer

generating proof and various smaller computers with much lower computational and memory requirements being able um so I guess that concludes this part of of well what exactly is startet and what is uh the next part is a little bit of more about what people are doing with starnet and we'll start with some of the open research questions um so let's go over the security guarantees for a rollup as for the literature on rollups there are three main security data availability safe Transitions and censorship resistance I ran out of slight space so

I just said sensorship less data availability is saying that uh for a block for a rollup to be truly safe it needs to provide enough of its state information to the parent chain so that if the rollup ever stops working properly pick up that state that is stored on the recreate the in this way if you had money or any it's not lost if the rollup stops working or if the original operator sto running ability to reun and recreate your state the second is safe transitions meaning that if the state of the rollup is being moved from one to another based on a batch of

transactions how how do we actually that these statements based on the transaction that is accepting are in which is really to say how do we know that the rollup isn't just accepting validating wrong transactions uh now on St sure of this because we using not just any bck guarantee or any stake guarantee but we using a cold mathematical proof to prove that the transitions are correct finally censorship resistance now what this is saying is okay anyone on ethereum can anyone put a transaction up on a rollup and ideally for a rollup should be as sensorship resistant as its parent chain in order to be consider reasonably

sensorship resistant now one way to to deal with this is if a rollup is making it State available on the layer one and chain uh and has a contract on the p and chain a user can always call the bridge contract on the parent chain and make their transaction themselves even if the nodes on parent chain on the role of aren't accepting their transactions but this is really research and stet is also researching uh you know I I really don't have the time to go over this in detail here or this will become an entire presentation about uh decentralized sequencing and proving but you can look at the detailed uh proposal for Stark Net's decentralization at this link we welcome your

feedback um so so far we talked about the research related stuff uh now let's talk about why people are so excited about star net you'll start with the most obvious suspect which is cheap computation basically now you can submit more transactions or how should I should I say you can include actions in an ethereum block for cheaper through startet than you would have by interacting directly with ethereum and this allows you to do things like building more complex D5 smart contracts um building autonomous worlds

with nfts and there's actually some great projects like uh the star which is a tool chain aous worlds as well as really cool games really like ocean which I've linked over here really U appreciate the complex uh the computational power that stet brings to users um let's talk about account extraction action is not at all a stocket only thing uh just means that you're able to write your own account as a smart contract as opposed to having to receive one out of the box and not being able to change it uh this allows you to create accounts which can do much more

flexible uh complicated things then accounts on ethereum have been able to do in the past like you could just you know off the bat uh make a multi- signature account uh or a multi- signature wallet without having to go through a third party provider to Outsource that work you can do it yourself uh you can also do something that's particularly close to my heart which which is you can a phone in a cold wallet most phones today have called a secure Enclave which is essentially uh an entire like you know uh CPU that's cut off from the uh the system use when you're actually running the applications on your smartphone and usually the

secure enclaves uh Implement a variety of signature schemes that aren't traditionally supported on blockchains and so so you can see for instance one of the signature schemes for Apple's phones is written over here and this scheme isn't traditionally supported on ethereum but with starnet because starnet supports account abstraction natively meaning all accounts are found which can verify the signature that is written by your phone and in doing so you can essentially turn your phone into a into a hardware wallet uh which can then and be used to sign transactions uh in in a much more intuitive and userfriendly

way um at also this briig which again is not just a stark net only thing but it's something that the field of do uh so right now if we assume that there chain a and chain and you're a user on chain a you want to send a message to chain B the way that generally works is you'll get that message published on chain a then people who are running nodes on chain a well you know of course get the update and they'll get your transaction pick it up from the M cool or whatever the architecture is is finalized the subset of these station committee or attestation subset test that this transaction is actually correct on chain a and provide that attestation to chain B so that chain B can then U and be

aized on chain a um validity proofs you're actually able to eliminate Network alog together and by doing so uh eliminate a s a a source of centralization because now chain a and chain B can effectively run light client nodes on each other and observe the transactions or the State updates on the other chain and verify them by using validity proofs um if you want to learn more about uh storage proofs and how they enable trustless Bridges there is an absolutely amazing project that's called Herodotus and I highly recommend this is also an application

set that is particularly close to my heart because coming uh from a defi research background uh you know we learned that one of the biggest problems of the rollup uh oriented road map for ethereum isation of liquidity U and very efficient and secure bridging goes a long way toward finally something that's exciting to almost everyone in the this market right now is verifiable Big Data um so I guess the most inovative way to think about this is if you use open AIS chat GPD currently there are you can choose from there's 3.5 and GPD 4 uh 3.5 is free whereas four is with a monthly

subscription uh now if you ask uh so say for instance you're someone who's paid for for that model and you go up to the website and you make query like you know uh at the beach or whatever um when you receive the response as a user how do you tell for sure that you got it from GPD 4 3.5 how do you even know that they're different um now I'm not trying to insinuate that open AI models aren't or do not uh provide the services that they they claim to be providing but in an onchain environment where the

motto of the user base is verifi don't trust youl model that you're using ml model you're using is actually inputs and certain weights of the model now this is arguably the single most active area of research at least where I live in the blockchain space which is here in in the Bay Area um and a highly um uh we have an amazing project uh on zkl Z and it's called Giza and you can visit their website and watch their tutorials in one of them they teach you how to build a neural network that can be proven in like less than 15 or 20 minutes and that's pretty and then

finally we talk about fractal scaling so remember how layer ones twos threes da d da d da uh well essentially why would you ever want to go one layer two right so if you have a layer one you have a layer two that collects all these transactions validates them blcks them up little spaces and then provides them to to layer one for finality why would you ever three on top of the layer two because intuitively if you think about it the layer three uh if it works in exactly the same way won't provide you any scaling that would still depend on on the to settle those transactions before going to layer one um but the idea is that Beyond Layer Two we actually start building not

General but highly optimized application specific chains and if you really think about it building application specific chains which cut whatever they can and are extremely optimize for a certain use case can achieve a much higher throughput than a layer two and can be designed in such a way that they enable much more frictionless user experiences than working directly with and so recommend that you take a look at the very very famous uh and and and one of our favorite projects in the stet ecosystem which is

Related talks