Introduction to Polkadot and Substrate Emre Surmeli
Ethereum Denver·Sun, Oct 9, 2022, 12:00 AM
Transcript
hello uh welcome everyone welcome good morning um today i'm going to be talking to you about polka dot and substrate my name is emre i'm from the web3 foundation there i'm a technical educator so hopefully some of you are maybe familiar with these things if not this is uh okay for you uh so our founders gavin robert and peter uh founded um polka dot uh well wrote the white paper in 2016 so it's been about five years six years almost gavin and robert are still working full time on this project peter has since moved on um so this web 3 paradigm we have a vision in that and we want to believe in a decentralized internet where people own their own data uh their identity and hence their destiny so this is our kind of philosophy that we share between the web3 foundation and parity between the two uh the development of polka dot research education grants and everything gets handled so polka dot is this layer zero heterogeneous multi-chain uh we believe the future is multi-chain and polka dot provides that foundational protocol for that future what we mean by that is we have things like ethereum we have things like bitcoin and these are these l1 chains that have applications running on them or they're you know like application specific services whether it's privacy identity uh defy whatnot um we see those as kind of these isolated networks that can't communicate with one another therefore you can't really compose them together to create new ideas so polka dot is going to be the layer that sits underneath these things and allows the interoperability of these l1s so the way that we handle that is uh with this scalable architecture that we've developed which is the relay chain and pair chains paradigm so we have the relay chain which is the main chain uh where we have validators running proof of stake nodes to create blocks and have transactions and so what is really special about the relay chain is it allows for ones to connect to it these are the pair chains so application specific uh blockchains that are you know consensus agnostic as well um can connect to the relay chain and now any of the connected l1s can communicate with one another and interoperate with one another and in web 3 what we would like to see is the composability of these l1s that's when the real power of these networks is going to really come come through and have more general adoption so the power of polka dot lies in its shared security before this type of architecture you had to either you know buy into a smart contract platform and release a token and you would have to kind of abide by their rules or you would have to build your own network from scratch which takes a lot of time and development effort et cetera polka dot allows any idea to just connect to it this therefore shared the security of polkadot which is already established so if you have an idea this is a really good way to test out your ideas right so you don't need to build your own network anymore you don't need to abide by certain rules of smart contract platforms anymore you can develop your own consensus and uh application specific chain and then just connect to the security of polka dot uh scalability this is kind of our version of sharding these pair chains right charting is kind of a topic and a a way of scaling blockchains which we need to be able to do uh with paired chains we're able to scale um quite indefinitely even if we you know go to 100 pair chains on the relay chain we're thinking about ways to create nested relay chains so uh the the ceiling of scalability is quite high um and and the interoperability think of interoperability as kind of like what tcp did for the internet in the 70s right so tcp allowed ips to pass back and forth data packets and it was like kind of the shared protocol right this is exactly what polka dot is trying to do as well with xcm which is the cross consensus messaging uh format uh you can create any type of messages uh you know arbitrary data uh transaction data then data proof of something and pass it around to the between these pair chains to the relay chain um etc uh and one huge improvement that polkadot brings to the table is this idea of forkless runtime updates right before you had to fork your chain uh to create breaking changes uh what we use is uh wasn't blob so webassembly blobs you can have your runtime as a wasmblob you upload it to the chain and then it goes through governance which we'll talk about and if it gets accepted by the token holders it's going to get included in one of the upcoming blocks and as soon as that block happens your runtime is kind of happening there's no fork needed and we also have this really cool network called kusama some of you might have heard of it it's our canary network it's that it's been talked about as kind of like this value bearing test network right with these blockchains we have these economic ideas these game theoretic um things that need to happen for us to test actual ideas and and test networks just don't cut it right so we need to have like real value networks in which we can test these ideas this is what kusama does and kusama is actually starting to become its own kind of full-fledged network some projects are actually choosing to stay on kusama and not go on to polka dot not the other way around so there's no projects that wouldn't uh go go directly to polka dot before testing on kosama hopefully we'll see so the dot token is really like the center of all these things it's a utility token that allows for participants to stake their token become validators to participate in governance so like voting for these runtime updates and ability to participate in pair chain slot auctions and crowd loans so we're gonna dive into that as well so pair chains pair chains uh require slots right so the relay chain has these slots so how do we give away these slots we need to make sure that the the the ones that are participating in these uh pair chain slots are you know chosen by the community valuable projects you know um so so what what they can do is run a crowd lawn you know a crowd loan is a way for them to signal their communi the community's interest on how much they want this prayer chain to be a part of the network so they they fundraise through the crowd loan and then they're able to take part of the auctions uh using these funds that they raised through the crowd loan uh and they auction we are the the the polka dot network auctions off lease periods so um uh there's a certain amount of time the parrot chain stays on the relay chain and then when that lease period is over they have to keep uh occupying it by running into new auctions so governance this on-chain governance idea of polka dot is super powerful you know token holders are able to now have say in how the network gets developed and this is really powerful because any changes to the network any runtime updates has to pass governance first this is uh decentralizing further than you know let's look at bitcoin for example you know developers are able to create updates all the time depending on like what they see fit but with this model token holders actually have a voice so you they do this through public referenda and we use the the network uses adaptive core biasing so it's a way to adjust the uh quorum based on voter turnout uh so if you know if it's low it adjusts if it's high turnout it adjusts if it's regular turnout it adjusts so that makes it a little bit more fair so that the quorum is not just some arbitrary value that's set by something and then there's the on-chain treasury so this is a really powerful funding mechanism for on-chain funding there's been ideas there's been projects there's been books that have been funded through this mechanism so the consensus on polka dot is a nominated proof of stake it's that's the kind of the validator election mechanism and then we have what we call babe which is the block creation mechanism and then we have grandpa which is the finality module so this all together works together to be a hybrid consensus so it's a deterministic finality with grandpa it's able to make sure that you know it has some like assumptions baked into it and uh if there's like two-thirds of the nodes that agree to something that's good enough for grandpa to start adding blocks but let's say there's less than two-thirds some nodes are misbehaving the network is able to fall back to a probabilistic longest chain finality with babe okay so that's polka dot let's dive into substrate so substrate is the framework that polka dot is built on um it's written in the rust framework uh rust language and it provides all the core components that a blockchain might need in what are called pallets so over the course of you know the decade that has passed since bitcoin developers have realized that there is some of these pieces of code that need to be repeated so substrate provides pallets and those are like the database layer the networking layer the consensus layer the transactions the runtimes those are all included in pallets so frame is also a framework within substrate so a framework within a framework um frame allows uh a set of pallets and supports libraries uh to simplify the runtime development and so storage dispatchable events errors and configuration can be done easily with the frame framework so pallets are these things like babe grandpa elections multi-sigs assets you can kind of use these as building blocks kind of like legos to develop your pair chain so your runtime aka your state transition function is a collection of these pallets and essentially with these you can develop any type of application specific blockchain and it would be able to run on polka dot or xamar so adding pallets is quite simple you can just include it into your config we'll look into that when we run our own node in a second and the layer of granularity that substrate gives you is pretty large so you can either run a substrate node use frame to develop your own pellets or you can use substrate core which is kind of you can ignore frame with that and you can write your uh code in any webassembly supported language and it can run on substrate so let's run a node cool so i have two templates here it's a front-end template and a node template these are kind of like out-of-the-box starter packs for substrate so first what i had to do is i had to compile the substrate node template before coming here because it takes a little bit of time so i'll include like resources at the end of this people if they want to like install rust run substrate but i'll just start the node in developer mode so out of the box what comes uh is a proof of authority network so you have pseudo power uh your node single node is able to run uh it has an account the alice account is kind of like the super user account so you can do whatever you want right now we're building blocks um on this proof of authority network and then um polkadot when it first started was a proof of authority network and then web3 foundation ran the nodes and then introduced governance and slowly as there was enough signal for interest to become validators from the community we saw that you know okay this is decentralized enough now the network is uh up to the token holders um and uh with governance uh nominated proof of stake was released and proof of uh authority was removed so right now we're building blocks let's start our front end so this is a simple front end to just kind of like show us exactly what's going on on this node that we're running so with the node um you're going to um see the blocks generation and accounts that get created so what's interesting here is we can see the pallets in our metadata so remember the pallets are these building blocks like the lego blocks right so we have a palette called account we have a pal called extrinsic count so one thing that's interesting in uh substrate is we have this um uh idea of existential deposit uh if your account has uh less than a certain amount of tokens in it it gets reaped kind of like this garbage collection log hash brand hash digest so all of these are modularized um kind of portions of the blockchain that are doing these things and you can pick and choose what you want to include in your blockchain when you're building with substrate great so let's do something so let's say we just want to transfer some funds from alice to eve right transfer the minimum amount one unit great so what's going on here is we're gonna see some events uh substrate is a very event-based uh programming um uh paradigm so you can include events in your palettes uh these events are really helpful for kind of your runtime right so we're going to see the balances palette use the transfer function right so there's a transfer going on here and then all of these function calls in substrate are called extrinsics right so these extrinsics are going to be um uh defined within your palette your palette is going to be able to define any custom extrinsic that you want and then you can actually build events around that and based on those events your code might want to do something else right so you also want to make sure that there's solid air handling there we can dive into one of the pallets in a second but so this [Music] extrinsic was a success and now the funds have been transferred to eve okay so let's use one of the other palettes right there's the systems palette right so the with this palette interactor we can see all the extrinsics on a palette so if we go to let's say system we have a remark so system.remark uh is a way to include data inside of a block that's not included on the on-chain try which is the database so substrate uses um some optimized blockchain optimized database solutions uh mostly it's just uh trees so um with this it's not included in that database uh it's included in the block so if a node is going to start running a full block it's going to be included in the blocks database rather than the uh the try that takes care of like transactions and so it's going to on this ui expect some bytes so i'm gonna actually just [Music] write something so i'm just going to say emre was here in bytes as a signed transaction and we're going to see that this extrinsic was a success and it's in the block and we're going to wait for um a grandpa finality right now to tell us which block that it was included in finalized block hash cool now we have some data that's baked into that block right so we should be able to go open that block and see what's in there so i'm going to open up my favorite tool polka.js so polka.js is a ability it's a ui it's polka.js is actually a collection of tools it has an api it has a ui it has a extension but it also allows you to connect to that local node that you're running so this is great for development great so i can actually look at the network network through the explorer and i can see my blockchain live developing uh creating blocks i can actually look at this block that i put the remark in and you can see all the extrinsics that happened in a block so you know function calls are included in blocks and we can see this system.
remark extrinsic that i called in which the bytes that represent emery was here is included right so essentially i'm baked in history so with these things it's pretty easy to just spin up a blockchain now pretty powerful stuff like you don't have to worry about network development you don't have to worry about uh anything that has to do with networking you just focus on your application and what you're trying to solve with your blockchain cool that's it from me thank you everyone [Applause]
Automatic transcript — names and jargon may be misspelled.