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

Loading player…

Wasm Precompiles for Eth 1.x by Guillaume Ballet (Devcon5)

DevconFri, Oct 9, 2020, 12:00 AM

Easily deploying precompiles with immediate support in all clients is one of the most exciting proposals of Eth 1.x, and something that could be carried over to Eth2 as well. This talk will present how this is achieved in details, give an update on the work that has been accomplished, demonstrate a prototype and present the roadmap to get this feature integrated in mainnet.

Transcript

[Applause] yeah I would like to talk about that it's actually at least when you're old the first time I heard about it I was at DEFCON 4 and it's about please help me including warp it was written it wasn't so what is it because well well it's some kind of specific contract that is present in every client and if you it's like if you run your regular contract that you want to perform a test that it's a bit repetitive it needs to be performed a bit faster than the usual the execution of an interpreter you jump from your from your contract into this specific contract into the native code and then you return and so and you continue as if you never left the environment so there are four main research four main goals that this about this proposal three of them are East one relates it to the last one is easy to relate it the the first one of them is to speed up feature adoptions so when people want to add more features so it's the problem every open source project project everybody wants to offload maintenance of their code to the open source communities have this Minister know it happens everywhere so you wanted but you want to do that but of course there's a lot of pushback because the client maintainer czar the ones who will have to do the work if something goes wrong they are the ones staying up late to try to fix to fix the problems so there's some kind of pushback in us that's pretty confidentially what you want to do is make this like try to go against this this phenomenon by making sure that when you create a new feature you provide one template that will be yet that you just drop into your your clients you don't have to rewrite it in every single language so that's - what right wants running everywhere joke was about you you heard that before offshore of course I'm sure it doesn't work as well as in the marketing campaign but it's still it's still pretty useful if you could get closer to that yes so the goal is to reduce the the word for point maintainers because if you have one boy consider from program you can cease it once and for all so it's everybody's participating it's not like you have to fix it on every client so hopefully it's going to come to that the state grouse is the biggest problem in his theorem at the moment like the last test I made I found that the states was 50 gigabytes and that's not including all the overhead to extract the pure state you have big winners like like you get to coquí's there they're huge and then already because you know if one contract is over 800 megabytes you can't store that on the mobile phone so that means already half the half of the people on this planet are shut off from running it at a node that's the problem if you want to this this community this super system to be accessible to everybody and you want everybody to be able to validate so the end goal of this approach is to help with moving as much state as possible out of the chain cell just save enough that you can keep the guarantees of blockchain of the safe safe high speeds approaching without getting the the big problem of having to secure my future so this also the question of gas cost you should have a very complex operation so actually I'm not really happy all the sudden with the fact that you escort as the stores are being run but you have one instruction in media that is fairly that is loose simple when you compile the program but actually behind it you have lots of execution so the gas code that has been chosen for a store is somewhat arbitrary and the idea is that if you manage to keep to break it down into some instructions that are lower level there are two closer match to what is actually executed you can meter this this contract what this this new piece of code and hopefully it will be more accurate and the last the last step is indeed to make it look a bit more like Y is 2 so it is 2 it's a lot about like a lot of execution department studies do it's about getting as is it's like light based so you only score the roots of an execution of partner what's called an execution environment on on the chain and the rest is all done offline what sort of chain that offline there's one plan to take each one and to bring it into one of the shards nice too so so the next thing that you have at some point that when you forth you want to manage that's possible so this transition with Brittany opinion much easier if the size of the big deficit was reduced so the requirements to to perform this change this solution would be to handle Westminster quarters in each client's it's actually not that hard wesa has been pretty trendy recently so everybody wrote their language there's there's actually multiple in google there's at least one exhaust Pete there's money suppose first of course so you could do this you just included into your client and then you're done almost there's almost a lot of details like the Devils in the details so there's there are couple challenges that I want to address that at least a couple questions one of them is is it is that going to be slow if you're going to use little plans so huge if you're going to use wasn't for me sometimes so yeah there's no question we don't want to replace current people files that are currently written in the native language of each client with with wasn't make any sense there's nothing prevents you from rewriting the code once the people file has been accepted you can perfectly rewrite it into your own clients language but the advantage here is that first you can include Aditya clean so in the run and then you can take your time to memorize it you split it and then you also have the reference to compare it to so you can first your annotation against the word wasn't real problem and see if everything you did was was correct well as it turns out interpreter performance is not so bad so there was talk about this yesterday that he was an achievement yeah we talked about it so if you are interested you should go check the and yeah there are plenty of tricks that we can still use to performance so you can use that compiled wasn't sexually no need to provide so much after all but you can also use what's called almost function so you you have your Western interpretation but you call into a native implementation one of those things that is knowing that execution how you 256 are implemented so you could serve those functions that are in the nineteen eighty week and there's the proposal by by Paul fifty was achieved that to write some kind of assembly register so in fright some indication of how the the compiler to compile your code and synthetic produces and produces an output that that makes sense in the context yes the other piece is the people file explosion like ever like I was saying in the beginning you have a lot of people that just want to upload their their code to to the community to keep [Music] minutes colonel and yeah thankfully there's a lot of healthy douchebags and applying containers because we don't want to yeah we want to make sure that this thing is actually useful and so there's a couple I think that proposed a couple of acceptance criteria that are just common sense really if you want to be compelled to be able to the list of people as well you have to provide tests obviously you have to demonstrates a willingness to keep maintaining the recompile once it's integrated because I said we don't okay the only ones they are going to fix and and there's the last yet last two things are a bit more yeah imprecise but they yeah like the focus would be to like I said focus on us on state management that we don't want people file for everything it would be able to focus on key teaching as much data of chain as possible and of course it's not about just getting your code we have to understand that went out when you have a pick up already usually the gas cost is going to be cheaper than if you were actually running it's like running the EPM version of it so if it's even look at work is subsidizing the it's not about getting everywhere - pilot cheaper version of their code is really it has to be like this has to be a proven case that people processors more than that one time that one purpose one application ok so I'm going to skip over this one but yeah basically why not PDF well the tuning and it's closer to whoever to be stupid best visual 10 SEC's so I wanted to cover a couple examples that are in the works so how would you implement such a use case and what would you need click the place so you need to you have what's called a real area so instead of sending your transactions directly to a validator equivalent of the liner what you do is you send event to some kind of full node and the full node takes all your all use transaction log answers of the transactions backed them into let's say may get reception or at least a certain summarizes them and then send them to the validator and that's and that gets included in the block so what you could do is to create the contracts who state is only three things the roots of the country the total took in supply it's not necessary but it's better for example when you go to eat ether scan they tell you you have this token this is the total supply you don't want to be in fact in the tree or you don't want to necessarily be running your own timer a full note for each token so just having an access to the supplier will be useful and of course there's enough to make sure that you don't and you use the pre-compiled to check the tree so you're let me show you oh right I never that first is like to compare the difference and I realize there's a big mistake and that's like so here it should be at 62 so normally if you've read your meter see 28 okay you've got you've got like good match between your address which is 32 bytes and append the value which is also a YouTube just assist here and also sort of they're not sorry about that so if you compare to the steepness version you just have the tree roots you have the tools while you have to dance and so that's 26 bites against 32 times number of entry I was a sixty-four times day another adventure so if you have the transaction formats you just give the proof of the before and after execution you give the advance and of the sender the receiver to give how much talking you want transfer and of course your same thing and the overall algorithm in the contract is you just attracted to transaction you can read in fact there's a chamber step signature of the transaction that you validates that three that the routes you are given is the correct one you validate that the unit is the correct one also you check the balance that you notice the new rules at the contract state and the three plots in green are actually can be performed on compiling the signature shake is definitely one of them that is article presence so you can factor this thing and if you do that you can support like most of of year C 20 so there's clearly we use this for for person so yeah but the advantage is that you need less storage space you don't need to rewrite your c20 code every time this is a small position that you can have if there's difference between what you have said and what you receive that's taken as a reward to the either to the relayer so this is how you how you would incentivize relators to do this this one for you the problem of course is you have cannot be a lot of states that needs to be clarified how do you spread to state and more for me how do you extract the funds if you look at cryptokey be you could always prepare your keys somehow but to agree to a different model but the money that is stored in that contract that is a product that is done or what needs to be fixed yes so then I like so far so the intention you can attend all the way I provided before with the possibility to add storage and construct in your in your of of chain3 the thing is it's going to be a bit more expensive complex to do the validation but if you can that also provides you the ability to change the storage model so right now the state is storing in a victory okay Tricia tree what if you want to use a linear storage maybe it makes sense maybe instead makes things faster so that's that's a nice way to upgrade the storage model without changing much in in the machine but yeah I also get validation is that to make things would be more costly and complicated so it's really interesting if execution rarely happens yes so that was a demonstration of what I was talking about you can have your own check storage service then you have someone like you keep the parts you're interested the parts of the tree you're really interested so you can prove that's like the pre routes and then you have a storage so you can that you just keep the parts that you need and if you want you can so it's the same thing instead you can change the storage model you just get the simple list of key values yeah so then out of this I had a conversation with Hyuna unfortunately not in a second but yeah kudos to him he came up with an idea he came up with an idea to to refrigerator in a way that you just create reimbursement contracts you also because it's contracts you give the state channel support so it's not just took also more complex execution are the boss and so when you want to open a channel you create those two contracts in in in the tree that is kept offline and all you need to do is well you said you sign the proof that's the others transaction it is with the other update to the trees correct and in the end when you want to close the channel interest and approve with the update the execution happens only once and again so you basically have written without actually using now using too much data storage yes so I'm going to finish on this the magnets are interested to dance of course I would like to try to to run a test net before the end of the year with an initial list of little piles by the end of next year so it started next year I would like to have fully specified year C 20 but a stateless version of B or C 20 and hopefully by May next year so March next year there will be some proper discussions about this all for death calls be nice yes so that's that was pretty much it in a nutshell please you're interested in that topic if you're interested to help if you want to discuss even if you just want to make good beer as well call my contact me I'm available here this is my kid give up /p back-end oh and yeah thank you for you [Applause] you

Automatic transcript — names and jargon may be misspelled.