Wolfgang Vitale - Ethereum protocol 101: from first principles to future development

EthereumZuri.ch 2024 · April 2024 · 57:36

Wolfgang Vitale gives an interactive introduction to Ethereum as a protocol, starting from first principles. The EthereumZuri.ch 2024 workshop runs as four mini sessions covering the fundamentals, the execution layer, the consensus layer and the research and development roadmap, with Q&A rounds for anyone curious about the inner workings of Ethereum who wants a base for going deeper.

Speakers

Topics

From EthereumZuri.ch 2024, hosted by EthereumZuri.ch.

Transcript

welcome everyone thanks for joining this 60 Minutes is an introduction to ethereum the protocol eum protocol 101 so it's for people who want to look a little bit more in depth at how etherum actually works but uh yes I'm covering the basics so to make it very very clear we have only 60 minutes so yeah let's go through it this disclaimer same I've shown yesterday so it's are just my opinions but still we talk about ethereum and yeah let's go ethereum protocol 60 minutes I have four sections and we start from fundamentals principle values like why do we even

need eum why are we here second execution layer consensus layer and future work road map what is hot in the research environment on etherum today okay then fundamentals first of all why are we here like sat day 10 a.m. why do we care about ethereum what's going on what's why it's important and uh my belief so this is my belief again the disclaimer at the beginning my opinions I believe and I think we all believe if you're here that there are at least some pairs of user bears and applications for which decentralized trust brings additional

value I'm not saying much really it's just there is a set of these pairs okay some users and some applications for which you actually get more from decentralized trust what is more either more value meaning that decentralized trust brings more value to the alternative that is only centralized trust second option is the only way to get value so in case there is no trusted third party then you have a pair of user based application for which you need the decentralized so there are different theories some believe that this is the only way like only in the case there is no trust at

third party than decentralized trust makes sense I also believe there are potential application user based pairs for which you actually have more value and I will Define what more value is we start from definitions this is the fundamental section so what is decentralized trust that's what you get when you identify minimize and remove all Central arties all Central authorities and or single points of failure so from decentralized trust you bring decentralized applications of different types and at the end of the day you have to bring additional value so what is value like what do the user want users don't want decentralization per se okay that's not the end goal that

what they want is what the centralization can provide and again it will provide to some users for set applications and our job over the years will be to find these pairs application on which are based for which this makes sense but what does the user want what what do I mean when I say more value I mean very concrete things like tangible things very clear fairness well fairness is not super clear I mean to be fair then safety cost efficiency must be cheap the application responsiveness it must be fast accessibility everyone in the world should be able to access the Serv Services add privacy I think it's super important okay so how do you get there I

said you start from the centralized trust that's the substrate but then what do you build to create these pairs of application and users for which there is additional value you need a decentralized state machine I mean this is what we are building and my theory my belief is that pretty much all the effort in blockchain technology development not only e pretty much everything if you go really to the core of what you're building buing at the end the goal is to provide a decentralized state machine and is again a very generic term you can do it in different ways but I think it's very important to put the subset down and the efficience down so what is the state a state is a word that we repeat very often a state is just a database I don't know people

sometimes they're ashamed of saying the state is a database like who cares about database well database are extremely important database can be anything when I say database I mean valuable information and we care about the data integ rity of this valuable information so state is valuable import information that is important state machine is a software that is able to change the state according to certain protocol rules and this centralized State machine is what you want to build and for that you need consensus among many nodes that will find an agreement on the updates to the database so we have this very important information there is the state and the way to operate on the state according to rules that are transparent

without anyone can that can change the rules or you know do bad stuff so that's what we are trying to achieve decentralized Global State machine synchronized at a speed of light ideally so why is that interesting this is done why decentralized because then the protocol rules are transparent everybody knows the game nobody can cheat and yeah no single Authority can even just change the rules that's very important otherwise will be decentralized and once you have that you can achieve efficient social coordination at a global scale and that's unprecedented because we have seen social coordination scaling from you know tribes to villages to nation

states but arriving really to a Global Network State we need this kind of technology and I mean we need blockchain technologies I'm not saying we need 1 million meme coins pumping I need we need blockchain technology so that's what we are trying to get and um yeah that's cool and that's the final state of etherum now I said we are building decentralized State machine and it's true but there are many different ways to do it and you can have some trade-offs and compromise on how you build this decentralized state machine there are some things that are you need them I mean it must be decentralized otherwise it's not decentralized State

machine but you can Define what decentralization means but let's focus on ethereum because it's an ethereum session and uh what ethereum optimizes for are different things so first general purpose we all know that but let's make it very clear when I say State machine and I say that the state is avilable information it doesn't mean that it has to be general purpose so Bitcoin is a general it's a this is like State machine as well but in that case the state is just a list of coins and the rules to spend the coins that's the database it's a database so and uh it's not general purpose because the only things you can do is to transfer coins ethereum wants to build or at least or Vision was to have a world computer so

when I say ger purpose you can do pretty much anything on this database other important values credible neutrality so when I say fairness and I said fairness is not very clear to Define some things that are important for fairness are credible neutrality so there is nobody that has an advantage like embedded in the protocol the protocol is built in a way to give advantage to certain parties that's neutrality credible means that it must be obvious like it must not be something very difficult to prove it must be very clear and the other component of fairness is censorship resistance it's pretty much connected but the idea here is that anyone can submit transactions

and if they follow the rules of the protocol then will be included in the chain we will see more in detail how it works then we have consistency like safety availability it must always be up uh that's uh important for ethereum and and the user verifiability which is something it will be more clear in the rest of the talk but it's definitely super important for ethereum like pretty much every user must be able to not trust but verify that the decentralized state machine actually works according to the the protocol without trusting anyone so this is in the trustless uh property you can also see that way but in practice it means and

user verifiability okay then what is ethereum ethereum is a protocol but you know what is the physical instantiation it's a network so you have many nodes that run the etherum protocol so let's uh go through some base definitions I told you what is the state in general in ethereum the state is again valuable information in a database this is uh what I have there for ethereum users so you see all the users around the state around the database because they care about this information they find Value from this kind of information and the way it's

processed then you have the nodes I said ethereum is a network network means it's a collection it's a peer-to-peer network of nodes that talk to each other to ensure that the protocol works so the what is node is the software running on certain hardware and this is what is needed to read the state and to write or at least request write to the state you care about this information so you want to be able to read it and ask to write it like modify it again according to the rules to do that you need a note your own note or you use a wallet and uh ask someone else but at the end of the day there is a note there

so when you see there number one user submits transaction to update the state there will be a node there because the node will send the transaction okay so network is a collection of nodes and that's the software and hardware needed to update the state or just read the state now the following sections of this Workshop we have execution layer and consensus layer so I want to introduce what the execution and consensus is let's start from execution so um what I have here there are other important Concepts that we need to know about are transactions the blockchain and the verification aspect transaction is what I uh mentioned before in the point one

in this diagram you have a user submitting a transaction to update the state so what is a transaction is a package of information that describe an operation that the user wants to be done on the state is on the database and the fact that ethereum is trustless and there is sensorship resistance means that any user with access to any note can make this request at any time they send the transaction the transaction then in the point two circulates among the nodes uh of the of the ethum network and at some point according to consent that we will see this transaction is included in the blockchain so when you see the blockchain there it's a list of

transaction append only so you canot only add the transactions you cannot remove them but you basically add the transactions to the blockchain and the blockchain is just a list of transactions what's the point of the blockchain is to have this in high integrity list of transactions such that you know that they cannot be removed from history once they are there they're forever there this transaction list and the whole point of execution is the that if you are new to the network and you download the blockchain and you execute all the transactions in the blockchain in this list that is high integrity then you know that you will end up to the same state that all the other nodes in

the network have so that that's very important you don't need to trust anyone you just get the blockchain maybe from more sources you execute the transactions and you know that at the end of the day you will get the same state as everyone else and why is that important because the state is important the state is this very valuable information for it users that to make it in more concrete terms for instance is even just the balance of ether token of all the addresses that's obviously very important right so you want to make sure that this state has very high data integrity and the blockchain is the only way to do it when you don't know if you can trust any other node that's the point that's the problem but we we'll see

that okay and then this other point yeah that's the verification that I said you can just verify that the state is correct if you reexecute all the transactions in the blockchain then consensus is something that sort of skipped from the second point to the third point so when you send a transaction to the network and the transaction is basically propagated to all the nodes then there must be some mechanism to decide which transaction is added at what point of the blockchain so what is the next transaction because here you see only one user they sending one transaction but in practice you have many users that are pushing transactions pretty much at the same time so how do you decide what is the next transaction

to be added to the blockchain again the blockchain is just a list an ordered list of transactions how do you decide if the transaction is even valid uh it follows the protocol rules you cannot just trust one node because you don't know if any one node is honest you cannot know so you need to have as many nodes and that's where the decentralization comes from and as many honest nodes as possible to actually achieve consensus and consensus really only means agreeing on what is the order of the transactions that are sent to the network okay so it's it's not just first come first served doesn't work that like that are more complex rules to achieve consensus

in a decentralized network with many nodes and you don't know who on is what not cool um yeah so okay I also have other definitions that are important for later that are the block proposer and the fork choice so on ethereum how it works you have many notes all the nodes see the transactions that is that that is sent by the user and then among all those nodes one node is selected or elected as a block proposer so basically this single Noe will decide what is the next transaction or at least will propose what is the next transaction and then all the others apply for choice Rule and decide if it's really part of the

blockchain or not so there are different roles but we have a full section consensus to look more in particular but yeah it's good to know block proposer and then all the other validators that uh actually finalize this Choice cool then let's start with the execution as I said the state is this very important valuable information this database that we want to make sure it has very high integrity because it's very important for all the ethereum users who are constantly looking at the database I want to make sure they still valid and nothing went wrong so what is inside this database the state we have a list of accounts I'm talking about the execution state to be

precise but this is the one that is really has the information that matters to the users in practice so here we have a list of accounts and Associated data so accounts with a specific address that is an identifier for the account and then some data related to this account so um we have for one account we have different fields we have the address that is the identifier we have a balance that says how much of the ether token is uh owned by this account then a fi for the code because etherum is a decentralized state machine this general purpose so it can execute any kind of code like

any kind of algorithm any kind of software can be executed on this world computer so you will have accounts that own code the code is stored in the account then you have a field for storage like generic uh data field that can be held by an account and then a nons that is just a field for avoiding spam avoing replay replaying transactions yeah so it's something that we need to ensure again that uh the state is has high integrity but it's not something that you really care about in terms of information as a user anyway what matters balance code storage now as

you can see the table I have two kinds of accounts so I have the contract account and an EA account is externally owned account so the contracts are controlled by code and actually have code in the field you can see there is a codee uh hash while externally owned accounts don't have code don't have storage and they're controlled by keys by users so normally when you think about accounts or ethereum you think about the EAS because those are like if you have a wallet and you have some e and you want to move e that's what you have EAS it's your account it's controlled by you your private key and then you have Smart contract accounts

this is what I mean here by contracts but uh yeah they're both accounts and um I almost see the contract as the real normal account and the OA the exception but it's it's up to you and opinions here but uh yeah let's not delve too much into that um what I want to say yeah so we have the state it's made of this uh list of accounts and then you need State machine operations because as I said this is a decentralized state machine you need to have a protocol to have operations on the state and update the state that's what execution is finding a way to update the state according to the rules so what kind of

operations you can do I said this is a general purpose State machine so pretty much anything but let's be a little bit more concrete so there are different things you can do one is just transferring ether it's very important operation you want to move ether from an account to another then you can do deploying code like you write code code software that you want to have executed on this word computer so you can deploy code on a new account on a new contract account and you can execute code so you can call code that has already been deployed and stored on ethereum these are the state machine operations on the execution

State and this allows you to do pretty much anything because again you can deploy pretty much whatever kind of code or software okay then then as I said we have state machine operations what do the state machine operations do is to update the state another word to say update the state is State transition I saying that because is what you usually hear uh people talking about State transitions so you have estate SI at a certain point in time and we will be more precise about time in ethereum but you have SI you apply a transaction and you have a state Trans State transition function that lets you go from the state I to the state I + one that's the very

generic way to talk about State transitions now what I write there is very important because I say that transaction data package I said that but signed by an EA describing a state machine operation so the transaction describes a state machine operation we said that but we didn't say that is signed by an EA what I want to say is that only externally owned accounts so the normal accounts that we use as uh we control with our keys only those ones can initiate transactions and can sign can initiate new things happening uh on ethereum so the execution will always be initiated only by keys and not by code not by contract a contract can call

other contracts but at the very beginning there must always be an EA so a normal account signing a transaction okay then State transition is the outcome of the transaction we said that and this then there is the etherum virtual machine concept that we need to know the evm and that's the general purpose virtual machine that is implementing the state transition function so here you see something very generic very abstract you apply stf State transition function to the previous state you add the transaction you get the new state what it means in practice is that you have a virtual machine so the uh a virtual machine that is executed by all the nodes to implement State transition function you

have the database you apply a transaction and you get an updated database that's it so let's uh move to the transactions more in practice because I was very generic very abstract transaction is an operation like the user says I want or at least a request to change the state in a specific way but uh yeah you know let's look more in practice at what actually what you can actually do what is inside the transaction okay so we have two addresses from address to address source and destination or source and Target source is you because the signer is always an

EA so it's controlled by users by keys so that's you and you have to apply a signature also for other people to verify that this was actually you and you actually own the private key related to The Source account then you have a destination account a value field that is how much ether you want to transfer it doesn't have to be I mean could be zero but the field is is there then you have uh field for data like input data and we'll see what it can be but for now it's generic fied with uh uh any kind of data you want to apply as input to the transaction then fields to calculate the transaction fees that you need to pay for using ethereum resources

and uh again the ANS and the chain ID for replay prevention now these are the fields that you find in a transaction depending on what kind of accounts you have in the from so the the source and the two destination uh Fields you have different types of transactions so that's very important thing to keep in mind if you are an eua and all you do like your destination is another EA there is no code involved because EAS don't have code to them storage so the only thing you do is transferring ether which is you know a very important operation so it's okay so you're moving ether from one account to another if you want you can also add the data but it

doesn't do much it's just a message that if you want you can do that but uh yeah because the fields are always the same then if you are an EA and you are always an eua so it's not an if they're always sign in transaction only UA if the destination is the zero address so let's say there is no destination what happens is that this transaction type is a creation transaction because you actually create a contract a contract account meaning you are deploying code that any node run in the ethereum virtual machine will be able to run or will need to run if someone is calling that code okay so the last type of transaction is what happens if you uh send a

transaction to a contract so to an existing contract that will have already existing code because it has already been deployed it has already been created by this other kind of transaction to the zero address and that transaction where you collect contract means execute the contract according to the data so when you send this transaction to the contract you have to add data this input data and this input data says I want to execute this specific function in the contract I didn't mention but when you create the contract yes um you put the code in the data field so now it's more clear why we have data field in the transaction either to deploy contract and say what is the code or to say which

function and which parameters you want to or arguments you want to send to the contract then let's look at uh how contracts looks like so uh as I said this is a general purpose State machine in principle you can call any kind of code like T in complete and uh this is written uh the the code is written in solidity or Viper anyway two incomplete languages they look this is an example uh written in solidity and this particular is very simple but important contract is a wrapped ether how to wrap uh ether and make it an erc20 or anyway a token that is composable with other

functions on ethereum but uh I I just want to look I just want to show how the contracts look like so they're described like um General code um and um what we can say that what we can see is that there are different functions so I I have different function names like I highlighting the deposit function or the withdraw function deposit means that you bring ether to this contract you are sending ether to this contract and it's locked there and then you get something in return there is this rupt eer and then you can withdraw by you know giving back let's say back to W ether and Unlocking The Ether or unwrapping The

Ether but all I want to say here is are different function names that's the code so when you call the contract in the data you have to say I want to call this function or this function or this function and you can see that different functions can have different parameters they might have parameters or not so if you call a function with a parameter you're also expected to send in the input data also the value of the parameter good um yeah just another detail the contracts uh also Define the specific U Storage related to the contract because remember in the account field you have code and storage so that's why here for instance you define storage and this just a map of all the ether that has been deposited by

different users you need to keep track of that and by the way Raper at the end of the day is just an entry in this database in this specific storage field okay now this is the last part of the execution section to talk about transaction fees because I said etherum is permissionless anyone at any time can just send transactions and request to update the state now if that was really true like literally anyone at any time then you know what would happen that the network would be spammed really to death like uh completely collapsing because everyone is requesting just to destroy the network for fun so uh it cannot work

um the fact is that executing transactions requires time and resources you have to be able to handle spam you have to be able to meter the resource consumption and charge it because even if it's a extremely small amount you have to do it it cannot be zero that's it so how do you measure which transactions are more demanding to the network because we have seen we have many different types of transactions it can be something as simple as sending ether but it can be something as complex as running a huge contract that is modifying the storage and it's asking a lot of these kind of operations very slow uh for the network very demanding so it's clear you cannot charge them at

the same price so you need to Define resources on ethereum and a way to measure the resource consumption now for a long time there was only one resource on ethereum that was called gas and uh now we have also another kind of resources a resource that is the blob that is related to data availability I will see that later but for you it's important to know there are two kinds of resources what I call execution gas and what I call data availability gas execution gas sometimes also just called gas and the availability gas can be blob gas or blobs but anyway you have two resources one more related to execution one more related to making data

available to the network and people outside the network in both cases you need to apply gas metering to know which operations are more demanding and uh basically the users will be charged so to send the transactions you have to pay in ether so that's now we see for the first time I think some use some use case for The Ether token we'll see more but to operate with this network yes it's permissionless but you need to pay with ether okay um so let's see uh how do you define then the cost of gas this is also very important because I said gas metering means that more complex

transactions will require more gas but what does it mean in terms of ether because so let's say one transaction cost 1,000 gas but what is the price of gas in ether that's the that's very important and that's a dynamic price it's not like for one gas you have to pay this much heat it's changing and it really depends on the level of congestion or the level of demand for the network so if there are a lot of request of transactions then this price will go up otherwise if the there is under demand for the network then the the the price will go down the price of gas you have a target for how much gas you want to spend how much gas you want to spend um on average in time if you're

above or below then the price will change um as I said we have different res resources uh gas and blob gas these resources are priced independently so if there is a spike of demand for blob gas then the price of blow gas will go up but the price of execution gas is independent um once you have then a transaction for which you know how much gas they're consuming and you know the price of gas then you can calculate the transaction fee so the price in ether that you have to pay this price is divided in two components there is a base fee and a priority fee they're both in eer but the base fee component is burned and the rest is paid to the proposer and we'll see more in detail

what this means but just to give an intuition pay to the proposer and the block proposer is one of the block one of the nodes in the network uh you need to incentivize the network to do this work so a part of this transaction fees will actually go to one of the nodes and uh yeah this the last slide for the execution to just to talk about blocks one second so I mentioned blockchain the blockchain is a list an ordered list of transactions but this uh list of transactions is segmented into packages of uh like Su lists and these Su lists are inside a block and I want to say this because the first slide I've shown that was very generic for the

state transition there was only one transaction but what is actually happening in ethereum is that you have many transactions executed uh as a block as a batch so you have a batch of transactions that are inside the block and then you have this actual State transition so it's not transaction by transaction but block by Block in a block you will have this list of transactions from tx1 to txn uh this ordered least and then you have the new state transition cool then uh let's let's start with consensus so is the second part and the the third section and uh to remind you what are we talking about we have this diagram with the user sending

a transaction now we know that they have to pay with The Ether token to uh basically demand this uh usage of network resources so you send the transaction the transaction is circulated in the network and the network decide the network executes the transaction very important so every knowde that sees the transaction will execute it to see is it actually a valid Transaction what is the ne what would be the next state but yeah after they make all the checks they need to do they find a consensus on whether this transaction is added to the next block or not and in which order so this is what we're talking about consensus and this is a a difficult problem because you cannot

know which nodes are trust like which noes are honest and and which are not so that's one of the first uh challenges that you have there but now how does it actually work on a team how do you find consensus among all these notes you have many notes and they have to agree on what is the next Transaction what is the next block how does it work the notes vote so there is a voting process it's really just that it's um an election basically or an approval for the next vote for the next block by voting so all the consensus participating nodes because here I've shown nodes in general but there are some nodes that have the specific role of participating to consensus and we'll see

how um but those notes vote on what is the right blockchain like what is the right ordering of transactions because all the nodes have seen these transactions coming from everywhere and somehow they all have to agree on what is the right order and since this is a decentralized network different notes might see things in different orders in different ways and you have to ensure that they all agree at the end how do you agree with voting so if you have many notes that say this is the right order of transaction then they win the the voting and that's the truth basically because everyone will know that if you follow that kind of order you will get to the same state so we have the voting component

and we have the block proposer I said before you have a block proposer who is the one that first proposes the block I said in my opinion this is the right order then the other votes so that know is the block proposal how do you decide who's the block proposer because it looks like a very very important role right it starts from there out of all the nodes there is one that says no this is the right order so how do you decide by random so you just select one node because you don't know who can be trusted you cannot know every node can be malicious at any time so you select one node randomly okay of course this over time you rotate and change but uh it's an

important mechanism to know this this random selection now consensus is difficult so so um we have challenges here it's not obvious to make all these nodes from everywhere in the world where you don't know who's controlling what node you don't know if they're honest or not how do you achieve consensus this is difficult there are challenges with open participation I have three uh main challenges that I summarize here one you might have too many nodes so let's say you have 10,000 100,000 1 million notes it might be very difficult to find an agreement when I say difficult it might even be just very time consuming very computationally expensive because

remember you're doing this voting you're and you have to check the votes from everyone you have to aggregate these votes and see who uh what is the truth of the blockchain and you have millions of notes this doesn't scale computationally because you said you remember at the beginning I said the end goal will be very nice to this state machine working at the speed of light so you know you cannot do this with 1 million nodes as for what we know today so this is at least a challenge I'm not saying impossible but it's difficult to find an agreement very fast the other problem you might have is that you might have not enough nodes because what if the protocol is just asking you to to work for free or for altruistic reasons

you might end up not having enough nodes so maybe you need to incentivize Network participation because you're actually doing some computationally expensive work work and or you are taking some risk or opportunity cost to work for the network maybe you end up not having enough nodes and if you don't have enough nodes you don't have decentralized trust and the beginning the thesis of everything why we here is the decentralized trust is actually useful so we need that and the last is that you might have too many bad nodes bad meaning faulty or even malicious like you might have no this is an open participation Network so imagine open anyone can partic I at at any time you might end up in a situation in which you

have many malicious notes and in that case it becomes really impossible to find an agreement so how do we deal with that on ethereum what is the approach of ethereum you have three important mechanisms or concepts one is civil resistance and that's something that you basically need uh in every blockchain because when I say uh open participation meaning really anyone can enter at any time and that's at any time then it's very easy for an attacker to create many nodes and dominate the network if you don't have any way to prevent people from just spamming the network or dominating the network with millions of nodes then it will fail I mean there is

no way around that so you need that sort of um mechanism to limit uh the entrance and this is what we call civil resistance avoid basically fake nodes uh that that are all controlled by the same to do that what ethereum asks is to provide for each voting right 32 ether so you need to have 32 ether tokens and you need to lock them and deposit them in a contract and once you do that for every chunk of 32 e that you deposit you have one vote as again consensus is based on voting what is the voting right it's not one node one vote but is one chunk of 32 ether one vote if you have a

lot of ether your voting power increases so CV resistance is good for two things one too many nodes because you cannot I mean you limit you put a cup to the number of nodes for sure uh because not everyone wants to Lock 32 eer and um there is really a physical C because there is a limited supply of eer by the way so you cannot have that many notes just because there is not much heater in existence and CV resistance also works for the too many bad nod problem because if you are um if you want to try to attack the network you need to have a lot of voting power and so you need to have a lot of ether and this makes things much more difficult

for the attacker other things done by the etherum consensus are incentives and penalties so this there are economic incentives such that good behavior is rewarded and that helps with not enough notes because you giving something back to uh the nodes that to the work to secure the network and uh the penalties are discouraging the attackers so bad behavior is penalized okay now before going more deep in depth on how the consensus actually works I just want to give some terminology uh that is important to know the difference between nodes and validators so the nodes are what physically make the network there are around 10,000 notes or at least that's

the the magnitude and then you have the validators and what I mean by validator is the voting power basically so if you have one note but you have 320 e then you can deploy 10 validators 10 by 32 and you will have 10 votes so the validators are really not the nodes but just the amount of ether that has been St the total voting power that will be distributed to the nodes according to how much ether they have put at stake because that's locking ether means staking yes you can see this is up only and there are theories According to which this will keep going up only until everything is St um another detail that

is important to know still is the validator que so I said it's open participation but there must be some limits otherwise it doesn't work and another constraint that they have is that you cannot just deploy um thousands of validators at the same time there is a rate limit because the consensus must be able to I mean you don't want to have sudden ly huge amount of new validators that might be malicious okay now um yeah a little bit more in detail I want to talk again about how etherum solves the consensus issues so I I've said there are certain mechanisms that etherum uses to make consensus approachable and feasible and

this was civil resistance incentives and penalties on top of that there are other things that make the problem approachable and easier and there are these properties so one is consolidation we don't agree on single transaction ordering but on blocks so as I said there are blocks and the state transitions don't happen transaction by transaction but block by block and why is that because we don't want to vote on every single transaction because otherwise everything is just too slow we have a compromise and we have this consolidation such that we put transactions together in a they still order it but we vote on that specific block not on the so we vote on ordering

of blocks not on ordering of transactions um then we have time synchrony so we have a constant rate of adding blocks we can add blocks every 12 seconds we only have new blocks every 12 seconds and that simplifies things a lot because imagine how tough it would be if you didn't have such Rule and it was open to it could be dynamic so this makes things easier time synchron uh we have this proposer Monopoly concept but what I mean here is that every round every 12 seconds you have a single note that is elected as block proposer again randomly and this block proposer has all the power to say this

time this slot we I propose this block if you like it you vote for it if you don't like it we wait for the next block proposer to send something that actually is like by the network so again this makes things much easier because if you had more proposers for the same slot it would be not impossible but more complex and then the fork Choice rule uh is deterministic so what do I mean by that is that if I tell you that the notes have to vote on what is the red blockchain it might look a little bit subjective or like how does it actually work it's very easy like you used the software one of the clients of the interium implementation

they look at the state of the blockchain and they can easily decide what is the right blockchain or not so if you're honest voting is very easy like it's it's not opinionated or anything and this again makes things easier because all the honest nodes will run the same software and will have the right decision they will all vote in the same way and everything works smoothly okay now we will see at consens at the different consensus mechanisms on ethereum and and um we have two consensus um well we have two components of consensus but in both cases the basics that we need to know is how time works in ethereum as I said one simplification

one thing that makes things easier is the fact that uh you have these time ticks uh every 12 seconds a new block and this is defined by the concept of slots so time on eum is divided in slots one slot takes 12 seconds so you have slot Zero from 0 seconds to 12 seconds 1 from 12 to 24 and so on forever that's how it works the it's time etherum is quantized like that 12 seconds 12 second and inside the slot you also have sub slots or subdivision of time for different uh um operations that are done inside the slot there is also some time synchrony there so at the first threshold of 0 seconds the block

proposer has to send the block so the block proposer has seen the transactions in the previous slot makes a block and he publishes it to the network and then from 0 second to 4 seconds all the other nodes will look at this block and will decide if they want to vote for it or not that's for second then you have from 4 to 8 an aggregation of the votes from 8 second to 12 second the aggregation is sent to the network and basically all the nodes upgrade update their knowledge of um the agreement between the nodes and and they will finally find the consensus but all yeah all this to say that you have this 12 second slots and there is some subdivision of time also inside the same slot but if everything goes smoothly one

slot one block now on top of that there is another division of time that is putting together slots into EPO and this another very important concept to know because you will see it's a building block for the second part of consensus so 32 slots uh 32 consecutive Slots make an Epoch you have uh this means uh 32 slots 12 seconds each you have 6.4 minutes for every Epoch and these are also consecutive uh ok zero eok one eok 2 why do we need EPO because I said that basically consensus is based on voting you want validators to agree on what is the right

order of blocks and basically the validators will need to say yes this is the next block that we want to append to a blockchain now e has a lot of validators because yeah we have 10,000 notes but almost 1 million validators that are they are voting they're all voting independent they're all sending messages and if you want to have 1 million validators voting every 12 seconds and you want to check all these votes every 12 seconds it just takes too much time it's too computationally expensive so it doesn't work what are you going to do is to divide all the validators in 32 groups again randomly and uh one

32 one divided by 32 of all the number of validators votes one on one slot then you have another uh group voting on the second slot and basically you need 32 slots because you have 32 groups and once you are done with the 32 slots then you know that all the validators had the chance to say their opinion about what is the right order of the blockchain so what an Epoch is in time is the time that you need to wait to ensure that all the validators could vote on what is the right order of the blockchain this happens over time in different slots but you need this 6.4 minutes after which you know that everyone had their say um yeah this that's

it and uh yeah that's the concept each validators votes once per EPO and that's why you need this uh longer time frame now let's look at the consensus mechanisms like how do you actually vote in practice in the ideal case where everything is super easy like very ideal and also I mean not true and it's not happening but you know ideally there is only one chain you have 12 these are in time you see on the x-axis you have one imag in the slots below the x-axis uh slot zero a proposer is randomly selected out of all the validators proposes block zero then there is slot one you have a new block proposer and

the block proposer builds block one and say the previous block was B 0 and the block one is a nice block it follows all the rules everyone votes for Block one because it's there is nothing to choose again B2 B3 B4 everyone is honest everyone is building on the previous block on the previous slot easy so you if you are the block proposer at the slot 7 you build your block based on the transactions that you have seen on the previous lot and then you add it to the one only blockchain it's very easy both to add the block and to vote for the blocks because there is nothing to do now in practice this this is what happens you have Forks so in this example you have we start from slot zero and you have a

block slot one you have a proposer that builds B1 on b0 so they propos block one and say the parent block is b0 but then at slot two the block proposer two is instead of building on B1 is building again on B 0 and say after Block B 0 we have to execute block B2 and not block B1 now you might ask how why why anyone would do that and you know it could be a malicious operator because again the network is not fully permissionless in the sense that you have to stake 32 e but still anyone can do it anyone want to be malicious they can do something like that but more often in practice what happens is that the block proposer

as slot two didn't see the block as lot one because maybe it was very late or for whatever connection issues again this is the problem because this is a fully decentralized Network spread all over the world with different latencies and everything so this situations can happen and again you can have other Forks uh you can see B4 B5 so now when you are at slot 7 you are the block proposer at slot 7even and you have seen the transactions coming and you have put them in the right order you still need to choose if you're building on B4 B5 or B6 how do you do that with the fork Choice rule so this is the the algorithm that is used lmd ghost uh Fork Choice rule for liveness and is ensuring

that the chain will always go on every 12 seconds you will have a new block so how does it work lmd ghost at each slot validators are voting on what they see as the right chain of the tip sorry right chain tip so the right U Leaf of this three uh the final block of the right blockchain and uh every validator also keeps track of the votes so if I am block proposer at slot seven I know that there were 20 votes for Block one 15 votes for Block two 10 votes for block three these are these numbers I put them are the number of votes that all blocks have accumulated over time during the aook and then what I do I am summing the

contributions from the leaves to the root of the tree of the the blockchain and uh I follow the heaviest observed sub three that's what ghost is and I'm suming 25 + 20 uh yeah I get um 45 + 15 I get 60 so I go from B 0 to B2 to B4 to B7 that's how you vote vote on what is the right block and how you decide to add the block to the blockchain you just apply this algorithm so it's very easy very objective it's defined by code if you're honest you will agree with the rest of the network unless of course there were problems of with latency communication because here I'm telling

you what B7 what the block proposer slot 7 is seeing other notes might have a different view of the network because maybe some blocks were not received or whatever other reason and then applying the same rule will have a different uh uh opinion and that's how Forks are created okay but otherwise for your view of the blockchain this is the rule and you will know for sure where to build um so where you have a fork then you have um block reorgs what I mean by that is that uh the block one that at slot one some people looked at it and said this is the next block after you apply um finalization finality that

we'll see you end up in a situation in which the right order of the blockchain is not B 0 B1 but is b0 B2 B4 so B1 is skipped and you can see it as a block reorg in the sense that up to a certain point in time you thought it was B 0 B1 but actually have B 0 B2 B4 B7 why this is important because what I write here you cannot assume that the block is finalized after 12 seconds so you cannot just see a block at a slot after 12 seconds saying okay this is the final history of the blockchain it will never change you need to wait for longer and you need to wait for and why because in 12 seconds you didn't have time to get all the votes because all the

validators are divided in 32 groups and you need to wait for all of them to vote to be sure that there is no malicious minority that is trying to um modify the history under their own Advantage let's put it this way so only 132 of the validators have voted on the slot you need to wait and for finality you need to wait you need to work on the neox base not on a slot base all right um five minutes so we have the last part is the how to achieve actual finality because I said lmd ghost is for liveness Casper FFG is for a finality finality means that once you achieve finalization then the history can never be reverted there is no block

there is no epor of finalized EPO unless the attacker is uh willing to destroy a huge amount of of their own ether so extremely high economic cost so how does it work you work with EPO and more precisely work with the checkpoint blocks that are the first block or at least yeah anyway the first block of of an Epoch and what you're trying to do is to establishing super majority links between um Source checkpoint and a Target checkpoint so you have Epoch zero and then you have Epoch one and at the first slot of OC one you start building this super

majority link that means you are voting on what is the right connection not between slots but between EPO or more precisely checkpoints first slot you don't you don't have all the validators voting you have only one out of 302 1 divided by 32 so you have let's say they all vote positively for this link you have 3% you can go you keep going you have 6% on the second slot if by the end of the slot of that Epoch you have more than 66% of the stake voting for this link then the previous Epoch that was justified becomes finalized and the new Epoch becomes Justified so what is finality it means two consecutive Justified epochs so this is another example I didn't reach 66% so the new

Epoch is not justified and the previous Epoch doesn't become finalized and then I keep going and I find another Super majority link and the new Epoch is Justified but not finalized yet because it's not too consecutive Justified uh um yeah EO checkpoints actually yeah then when why we care so much about finality that's what I said um once it's finalized you cannot revert the previous history unless you really destroy onethird of the total state it so not happening um yeah unfortunately I don't have more time but what I want to say is that there are incentives and penalties so there are ways to enforce

the protocol rules that depend on economics and yeah that's it I can do the last part [Applause]