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

Loading player…

Devcon2: Ethereum in 25 Minutes

Devcon 2DevconSat, Oct 7, 2017, 12:00 AM

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/2/ethereum-in-25-minutes Ethereum Foundation Chief Scientist, Vitalik Buterin, describes Ethereum. Speaker(s): Vitalik Buterin Skill level: Beginner Track: Society and Systems Keywords: explanation, summary, origin, timeline, bitcoin, namecoin, mastercoin, solidity, contract, state, code, storage, balances, nonces, history, receipts, stack, merkle Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 2 was held in Shanghai, China on Sep 19 - 21, 2016. Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

Transcript

[Music] um let me check oh this one okay let me try this what what's happening to it um no it's just coming slowly how do I go back oh up up yes okay great thank you so I heard people in the audience complaining on WeChat about the mic being too quiet so I'm going to try to keep it closer to my mouth this time around we'll see if it works great so this is the one of the sort of standard presentations I give when people wants just like a quick overview of the entire ethereum protocol so chances are listen through this you'll catch some things you won't catch other things but at the very least you'll kind of understand what the broad structure is and if there's any particular piece that you don't fully understand we have quite a few materials online that going that tell you about the rest so we have our GitHub Wei the website if you are a developer you can even read things like the yellow paper and the ethereum source code if you wants to get like that deep an understanding as of uh sort of how the ethereum protocol works I highly recommend doing those things if you have specific questions I also highly recommend even going into some of our public channels so if you go to a g. IM git r.m ethereum for example you can actually like literally just talk to our developers and they're like right there and you and uh you can ask questions we're generally a fairly friendly Community I hope so anyway ethereum in 25 minutes so first of all how did the project start start so project started back in 2013 at the time people were very interested in blockchains people were looking at Bitcoin people were excited about Bitcoin but people were also realizing that blockchains are useful for things other than just money so back in 2011 there was a project called namecoin which was trying to make a blockchain based domain name system in 2013 there were projects called colored coins which were trying to like digitize arbitrary digital assets or assets and put them on the blockchain there were protocols called Master coin that were trying to integrate all sorts of Fairly complex features so there's a cons consensus that you can do lots of different really cool things with Bitcoin or and or you know with other blockchains asset issuance crowdfunding title registration lots and lots of stuff problem is most blockchain protocols were designed like this pocket calculator single purpose device Works reasonably well for all you care about is adding and multiplying numbers but it does nothing else Ure someone with a computer with an advanced computer science degree with a good calculator can kind of hack it to play a video game inside of it but do you really want to do that so after this in 2013 there were people who are making protocols that looked like this so Swiss army knife basically you come up with a list of 10 or 20 features he wants to have make a little tiny thing for each one of them stick them together into a knife and there you go that's your product or in this case you know that's your blockchain so back at the end of 2013 there were lots of projects that looked like this they just said okay you know we want blockchains to be usable for asset issuance crowdfunding bets prediction markets identity registration title registration pick a list of 20 different things have a list of 20 different transaction types and have a little piece of the protocol that supports each one so this is all well and good problem is what if you come up with your list of 20 applications publish a protocol then the next day some guy says oh look I discovered a 21st blockchain application how am I going to fit it in and in 2013 this is exactly what started to happen so this is the um the ethereum [Applause] [Music] way so why do we why do we love smartphon so much basic basically because a smartphone is nice and generic you buy it once and download immediately comes with 50 or 100 applications if someone comes up with a new application they write the code they upload it to the uh Google App Play Store and if you want it to be accessible in China you can upload it to the Huawei store as well and um then if anyone wants to use your application they don't need to buy a new phone they don't need to buy a new hardware dongle they just download the app and they can start immediately running it very simple and the cost of actually developing an application all you have to do is write code you don't have to make your own Hardware you don't have to have your own manufacturing you don't have to have your own distribution just write a piece of code upload it and let people download it and you're done so this is the kind of abstraction and simplicity that I wanted to bring to the blockchain blockchain world with ethereum so ethereum is a blockchain I'm sure if uh people here are familiar with blocks I'm sure people here are familiar with uh transactions and these are all one good but Bitcoin has them too namecoin has them too Litecoin has them too Dogecoin has them um I'm not sure if paycoin has blocks though I don't know paycoin might even run on a server I haven't even checked proof of server the best kind of POS but we have a few tiny additions so the main thing that makes ethereum tick is this built-in programming language so basic concept is if you have some new kind of application then what you would do is is you would write the rules of your application in a piece of code take this piece of code you you would call this a contract upload it to the blockchain and now you have a special type of account and this type of account is sits sits on the blockchain and anyone can send a transaction to this account in order to interact with this account so two types of account one type of account is a user account controlled by people like you and the other type of account is a contract which is controlled by a piece of code if you send one unit of ether to an account that is controlled by code then no no person controls it anymore the only thing that can actually move that ether is the execution of that contracts code itself so it basically is an automaton sitting on the blockchain that's executing exactly as it's the code on the blockchain says it's going to execute so this is all well and good let's try an example so the the hello world of a theum is sort of basic a minim sort of DNS system so the idea here is you want to store a mapping of basically domains so you have you know something like uh I don't know vitalic doeth george. eth um ethereum eth um ask me about my cool ethereum hacking services. eth so you have a bunch of domains that people might want to register and for each one you want to store the IP address that it points to and you want to store who owns that that domain that particular time so we have two functions one of them is for registering a domain and the logic is pretty obvious if the domain has not yet been registered then you set the owner to yourself and another function that says set the IP address if you own the a domain then you can set the IP address and this is like the basically the minimal thing that's like all you all you need in order to have like a maximally simple domain name system now as I understands Nick Johnson is going to be presenting about a kind of much more complete and better one at some point over the next three days but this is sort of the kernel this is is what you start with so you have this piece of code then what you would do is you would compile it you would get some bite code then include the code in a transaction push the transaction up onto the blockchain now what you have created is a contract and a contract has an address it has some you know 20 by string that represents sort of the location of the contract and look like 0x 357c whatever if you want to register a domain what you would do is you would send the transaction and you would specify this transaction is going is going to be talking to this contract now what can the transaction do well it can do it can try to register or it can try to set the IP address so let's say you want to register a domain what you would do is you in the transaction you would encode some information that says I wants to call the register function and I wants to call the register function with like some particular piece of data like uh know george.

e or whatever take this transaction include this data publish the transaction when the transaction gets included the code runs and you notice it says self. Dooms address. owner equals ms. sender so what that line of code basically does is it says whoever whatever address sent that transaction record that address in the contract storage as the owner of that particular uh domain so you you notice at the top of the contract here it says like data domain so it basically stores a mapping going from a domain to the owner and the AP address of each domain so the code and the storage like both of these things are what we call sort of part of the ethereum state so what we mean by the state is sort of current information associated with the ethereum protocol so stuff that you have to care about right now this includes account balances how much ether you have uh nones it includes contract code and it includes contract storage so for example right now this uh this piece of code is nowhere in the state if I send a transaction publish a transaction which creates the contract the contract's code is now in the state now if I send another transaction which then talks to this contract and registers a domain then the process of executing that transaction is going to change the state and the new state is going to contain some storage keys that basically say this particular domain has some particular owner in some particular IP address so that's kind of what the state means so it's stuff that you have to kind of care about now so in Bitcoin for example this state is pretty simple it's just like how much money everyone has at some particular point in time the second thing is history so history is things that happened so transactions are part of the history receipts are part of the history don't have time to go into them but feel free to research them more so this is kind of important because a lot of people ask things like oh you know who stores like uh the the transactions or if a contract executes then like crew executes the contract so like where are the results stored and like the answer at this point basically is that if you are a full node then as a full node what you do is number one you download all the blocks you download all the transactions when you receive a block what you would do is you would see what the state was before the block then you would execute all the transactions in turn and you would update your own state so all full nodes basically execute all transactions they'd execute all they would uh execute all contracts and full some of themore the history some of them don't the history so like there are clients that are increasing coming out that let you sort of not store large portions of the history and this is good because it saves you hard drive space um so the state in ethereum consists of basically a key value mapping so in basically the state in ethereum is like a bunch of account objects and account objects once again two types of accounts one of them is just an account controlled by a person or some external user controlled by a fridge controlled by a dog the other kind of account is a piece of accounts controlled by code so these accounts have four pieces of data one of them is the nons and that's basically just a kind of Highly technical thing that's used to prevent transaction replay attacks second thing is a balance so how much ether the account has third thing is the code and the fourth thing is storage tree rout which basically points to kind of the storage of that particular contract so every contract has its own kind of sub database that it can kind of read and write to as it wishes now contracts cannot write to other contract storage databases so a contract storage kind of is its own property the contract only that only the contract can actually like read and write the storage that of belongs to itself so also important so code execution every transaction specifies a two address now if the two address is just some regular account that doesn't have code then all you're doing is moving ether around if the two address has code then the code runs and the code can do things so the code can send ether from that contract to other contracts the code can read the contract storage the code can write to the contract storage and contracts can even talk to other contracts so once again every full node processes every transaction every full node stores the entire State and this is actually fairly similar to how Bitcoin Works um it's bold because it's important as Vlad likes to say in the previous Devcon SO gas this is another one of those sort of important misconception points so basically one of the problems with with a kind of extremely free anding complete scripting engine is the halting problem and the halting problem basically says given a particular program if you start running it there is absolutely no sort of guaranteed way to tell in advance whether or not the program is ever even going to stop so you might have one program a which just like does a few things and then stops program B which is an infinite Loop program C which is like some kind of Highly disguised in infinite Loop and you can basically come up with programs where like there is no sort of automated mechanism that can tell which programs are infinite loops and which of them are just going to Halt after like a billion steps so what we do in ethereum is we have this concept of gas and the idea basically is that we when code executes we counts the number of computational steps that code takes and every transaction assigns itself a budget so a transaction might say this transaction is allowed to consume a maximum of 1 million gas so what does that mean so let's say that this transaction goes to some contract the code starts running and one of two things can happen one of them is before the million steps run out execution stops in that case everything is fine second case is it gets to a million computational steps then you get what's called an out of gas error oh look this transaction budgeted a million steps but it already took up a million steps and it looks like it's going to execute some more it might even run forever I have no idea so what I'm going to do instead is we're just going to Halt execution right there and just revert the whole thing and the transactions essentially failed now for like some technical reasons even if your transaction kind of fails for this reason you still have to pay pay the transaction fee for it but this is the point of this mechanism is basically that like no matter what kind of weird code you have in the transaction like it's all it's guaranteed that nodes will be able to process it within some deterministically within some fixed amount of time now there are other blockchain projects that try to solve the problem with timeouts so they say try executing the code for one second and if like and if after one second it's still running then you halt the problem with this approach is that it's not deterministic so like one computer might take 0.9992 seconds to run a particular piece of code another computer might take 1.

08 seconds to run a piece of code and if the two disagree then the two disagree with each other then your blockchain has a fork gas completely deterministic a resource man a computational resource control so another important thing is that we for every transaction you you have to pay a transaction fee for each unit of gas that you consume so heavier computations cost more but one important point is that like these two things are separate so there is like the notion of gas and thetion of gas is basically just a deterministic method of metering computational resources and then separately from that there is protocol economics and the rules of protocol economics say that if you want your transaction to be included you have to pay for it and so on the if you want to send a transaction to the ethereum public chain you have to pay for each unit of gas if you are doing some kind of like ethereum based private Network you do not need to have ether so just one important thing that lot of people get wrong that would be kind of good for people to remember so gas limit so the equivalence of the block size limit in Bitcoin is kind of the gas limit in ethereum 4.7 million gas per block now gas isn't just about counter computational steps you also get charged gas for writing to the state reading from the state bites in your transaction bites that you um bites that you add add into receipts um Bloom filter topics so you get charged gas for kind of almost every resource that you can consume inside of ethereum and out of all of those things together there's this limit that you can't consume more than 4.7 million so the G limit actually does kind of adjust automatically and miners can vote on it so if ethereum blocks start getting full then basically miners are going to be able to kind of just vote the gas limit up and like no one needs to download any new software um transactions seven parameters non so basically prevents replay attacks so for example if I send you 10 units of ether then what stops you from taking my transaction and just and including it in a block 10 times to try and drain 10 ether from account my account over and over again the answer is every transaction has to include a unique number and if once the number once a transaction with a particular nonsense processed the nons in the state goes up and if it tries to verify the second transaction well the non mismatches now and so the second time around you can't include it anymore um gas price so the amount of ether you pay for every gas start gas is like the amount of gas that you budget yourself destination address the amount of ether that you send data so if you're if you're just sending ether you don't need to care about data if you're talking to a contract then data is readable by contract code so data is how you specify what function of a contract you're calling what parameters you're calling it with anything sort of more complex with that and vrs elliptic or of digital signatures um feel free to research them yourself I think elliptic orve math is cool receipts not going to bother with those so ethereum virtual machine we have a stack we have a concept of memory storage um environment variables so contracts have access to things like the time stamp and this is great because you can have contracts that say if the time is greater than you know something like January 1st 2018 then do something and there's lots of wonderful use cases for this logs calling contracts calling other contracts now in general if you're a contract writer you're not going to be writing in like ethereum virtual machine code directly you're going to be writing in higher level languages so solidity is the most well supported one right now you can also write code in serpent there's also something called lll so there are kind of other languages that you can write your code in and then the idea is you would write your code in these languages and it comp plows down to ethereum code so the Lang the code that you write is like nice and readable the code that is ethereum code is like extremely compact fast fast to execute blockchain friendly so ABI so this is basically that if you know I wants to call some contracts and if I wants to register a domain name then how am I going to do that well over in theant example you might notice that I want I might want to do something like uh call the set IP function with some particular address and with some particular IP address so the way that you do the way that you actually do a call is by sending a transaction the way that you specify what you're calling is in transaction data and there exists this nice standardized algorithm called the ABI by which you can um encode the data so the first four byes represent the function ID then 32 bytes for the first argument then 32 bytes for the second argument if you have variable sized arguments it gets more complex but feel free to research this so we have a new mining algorithm and this mining algorithm strives to be kind of memory hard and GPU friendly so the goal is to sort of prevent um as6 or prevent specialized Hardware from like being the dominant force in mining because that would make mining too centralized but at the same time CPU mining has other issues so we have this sort of GPU mining that's a nice middle ground it's a it's a fairly pretty algorithm once again it's called eash um so fast block times Merkle trees so this is also a kind of very important piece of the ethereum protocol so the reason why I have this picture here is because about a year ago there was this cover in the New York Times that basically you have BL Masters that's saying it's all about the blockchain and personally I think it's not just about the blockchain it's about the Merkel tree and I think Merkel trees are like awesome and really important so so we should have Ralph Mel saying it's all about the mgle tree and you should have some does because does are cool um I hope it's not a violation of security law to say that Dogecoin is awesome and if you want to buy it you can cool so merel Tre is the point basically is so this is how the ethereum light client works so the problem is okay if you have the entire database if you have the entire state if you have all the transactions then you can know let's say what your account balance is what some particular contracts code is what some particular contract storage is what some particular log says but what if you're a like client what if you're on a phone what if you're on an iot device and you don't have enough resources to process the entire blockchain so the blockchain itself right now the blockchain is three bytes a sort of State size is something around uh between like 5 and 20 bytes depending on which client options you use so it gets pretty big for a phone so if let's say you have a tiny device that has like 50 megabytes in very low processing power then what do you do so this wonderful fellow came up with this algorithm where basically what you do is you store this kind of really clever hash tree where you store the pieces of data at the bottom then you like have hashes of those and you have hashes of hashes and hashes of hashes and the end is if let's say all that I care about is getting key for let's say some like this particular key of you know this particular account 175 then you don't actually have to download the entire blockchain yourself instead all you do is you download this what we call kind of this Merkel Branch you verify that the hashes in inside of the branch are consistent and as long as you have the block headers you just kind to verify the Merle Branch against the block headers and what you're doing is you're essentially allowing the minor to kind of help you verify that this particular piece of the state actually is what what the node says it is so if you see if a node gives you a mer this sort of Merkle proof that says this particular key in this particular count is 45 if you have if you can verify the proof of work and you can verify the hashes then basically you can verify that unless like all the miners are some are at that particular time conspiring to screw you over this actually is what the state of the blockchain is in this particular place at that time so the light client there was like a test of an alpha version that was released a couple of weeks ago I've tried it it works great um so block headers contain Three Trees so we Bitcoin uses merel trees just for transactions we use merel trees for transactions for the state so this includes account balances contract code contract storage um receipts so we have petricia trees which allow you to kind of effic update the tree very efficiently and um so those are kind of the basic building blocks of the ethereum protocol right now now there's also very fun stuff that we're working on in the future so things like proof of stake that I'm going to and scalability that I'm going to talk about in my presentation later today um privacy support so basically with privacy you don't have to actually build things into the base protocol because the ethereum protocol was still in complete you can basically like Implement any kind of advanced cryptography on top of it now for like VM efficiency reasons there are still sort of protocol tweaks that we have to make but even still it's uh something where like the vast major of the work actually does sort of happen on the higher levels um virtual machine upgrades sort of more flexible use of storage and scalability and these things are great and just to set a good example I'm going to stop now because the Glock tells me to stop now so thank you

Automatic transcript — names and jargon may be misspelled.