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

Loading player…

The Road to ETH 2.0: How to Build EWASM DApps with Embark v5 (Devcon5)

DevconFri, Oct 9, 2020, 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/5/the-road-to-eth-20-how-to-build-ewasm-dapps-with-embark-v5 In this workshop we will be building step by step a modern DApp step that uses the latest Ethereum 2.0 technologies with the aid of Embark & Cockpit. Speaker(s): Michael Bradley, Iuri M, Eric Mastro, Pascal Precht, Richard Ramos Skill level: Intermediate Track: Developer Infrastructure Keywords: technical 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 5 was held in Osaka, Japan on Oct 8 - 11, 2019. 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

[Applause] all right okay so so before we started I guess a couple of things to clarify first of all of us kind of them my name's Eric steps we're gonna mark and you probably noticed already that the title of this talk here building your deaths with a Barbie five a little bit different from what you see in your application this is due to some reasons so basically the description of the top is in the entire the match what we do you because we have to change a little bit based on some time constraints so we basically were we were to our talking workshop and then we get to cut down to the 40 minutes things around change out of the 10 points that we listed in the solution you might get maybe one or two and also that at the same time also changed the format a little bit so it's not really gonna be a shop where you you know cover yourself it's more gonna be like a little bit of a theory session and then an optimist would read there was some stuff that maybe want you to through some code and have some questions answers our goal this wasn't it's you expert sunny weather so it wasn't question strong will probably answer them hopefully he tries best our goal this was to integrate us and contract into barb so just to help developers okay any any questions at this point okay so then maybe like yeah first up was anybody at the you wasn't he was he was talk yesterday so we've been to that talk and it actually turned out that you know there's a lot of things still in the making and so so what we're going to show you today is you know no that works for the demo purposes but probably not like you know production-ready States so just keep that in mind it's more like an exploration want to show you how you can extend it work to do just about anything you want including some very very experimental stuff like you guys all right so you just just to give a little bit of an agenda so what we talked about today so we talked about it wasn't just a little bit then we're gonna talk about the new programming language given everybody min before and then there is a very mysterious project called Newton play which actually enabled us to write smart contracts in him and then we will show you how that works and then this is actually what's going on using eventually and all right so let's start off with if you were suddenly towards mr. restricted subset of webassembly to use for Spartan contracts in interior and now if you if you like you to this stuff or experts or whatever you wonder what tell us what was sembly actually into first place so what assembly for those who don't know is a binary star format stick based so it's actually has been standard for the web that aims to provide developers a like an API in a way to to to my very fast programs and who needs it it's very portable as well so basically in YouTube you can imagine you can you can write programs and any language that transpile to webassembly so you will never write about assembly yourself which after all and then computers are really good at translating that web assembly code to CPU instructions which is why it turns out to be very fast yeah so that in general about about webassembly there's actually a couple of browsers that already ship that I believe in Firefox already have some of you know degrade it so we can run some assembly in the browser today so this is basically everything and so what it means in practice you have your your source code turn it to into wasn't code in some way you know there must be some sort of and then ideally since you have this wasn't quote you can run on different CPU architectures they can translate that code easily which also means that that car is very portable it's good there's generally a textual format and a binary format so the textual format is like the assembly code that you can actually read as a human being again this is not the code that you would action right it's a code that you can do the code that you can actually inspect them and yeah so coming coming back to he wasn't so now that we know I like that we like a rough idea of what web assembly is he wasn't is a restricted subset of a web assembly so I'm not actually sure the wording is quite correct maybe somebody seriously that's fine yeah so essentially what that would mean is that if you write it wasn't code it's automatically also valid but you know what does it mean the restricted subset so there's obviously there's some very specific semantics to he wasn't that make it wasn't what is compared to web web assembly and there are a couple of things so we have so there he was on the I'm kind of like comes with like certainly yeah semantics specific for for if you don't have to read this you're there so that there's we're sent a website with all sorts of resources about he wasn't so so basically what makes your USB code you wasn't vote is the environment that runs it eventually because it comes with a certain semantics that also whose things like a it was no contract interface basically interface that allows you to have what some code that knows how to talk to that contract smart contract get you guys and a couple of other things sorry there's also building system contracts and if you look at that that's quite interesting I'm not sure about today that still is but there's like central central contract EVM transfollow the Transpo pilot contract so like different addresses that are already available in that environment that your code Hudson that could also mean that for example you know have like certain functions like promises the best contracts that's all I understand that you can call them contracts within that environment again right so this is obviously stuff that would not be in and plain webassembly available you have it wasn't an army coming back to the semantics non-deterministic behavior basically removing 40 points from apartments and then there's my guess if the performance of webassembly is close to native was the producing assistant contractor are coded like well the prequel calls so the the reason for that system is basically the US and team wasn't able to make it as fast and also because of gas costs they missed price so if you're gonna look at how much a shot two four six a shot three costs you and you had to implemented where the same control it would be no surprise so you suddenly be spending like take time to focus was about as - is basically using precompile than using optimized interpreter the speed [Music] basically theory of one is just as just as fast as he wasn't that's an AMA not optimized to us that's how I understood it so at this point I'm thirty using freaking files and optimized interpreters really fast speeds but so what I understood right now that when we write a smart contract we provide it we will have let's say not buy them it's in between the EVM is gonna interpret that whole however the awasum is a didn't code that's gonna be compiled to be native code it means to me that there is a hacking to the virtual machine itself that should run that code which means that when it reach the area of the native code it's gonna stop executing it is this correct so this is not a compiled so that's what they were talking about it in the talk yesterday they all serve the problems with using like a compiled via especially like a security consoles with like most attached at former decisions based on actually could we bring this up Krista next time is kind of like visualizing this a little bit so from a technical standpoint of view like that the weight the way we like will depths today with like you know solidity and stuff so for example where salinity code we've run it through silicon compiler and then you get an API and a byte code and then eventually the byte code is what ends up maybe I'll go to the chain that's you like talk to you to your contract instance actually very similar is this what happens with you wasn't as well so you just that it's said already your code and so that although you can write in this ability to it doesn't really matter as long as a transpiler truck policy he wasn't eventually so you have your code as if when you can use like C C++ rust board in which we touched on in a second you get Yui wasn't code out of that and then you know that's gonna get running inside of that you as an environment you still get an API code as well so it's not about no graphic right now but you get hideous over well promote like flow point of view is kinda like still the same process you're just dealing with a different language and a different format I just well he wasn't itself between DirecTV PM story you'll do live literally do dual stack so like at the point that they visualize this it would be that you have a marker when you deploy and it provides us amendment or a dual stack via our switch I'm talking about compilation so he was imparted to be understood by with epi well by the yes so that it it's like so it's it's it's just actually another Weiser front on connects okay so from C to e was oh there is a some sort of compilation yes that's going to generate a code that could be understood by the EVF well the West stole ur kasdim runtime that has given oxidized functions [Music] sure alright so eventually what that means given what we just learned the benefits of using us a would be first of all we can actually write or your smart contracts in any language anything that has files will compile he wasn't just kind of person you don't you know necessarily just time to submit it to you or whatever so originally it's going to be a fast execution there's also been a library support because you know again since since you can use any language you probably can't take advantage of a very big ecosystem of libraries and park instead your language supports and then after all there's also available community since wasn't as an open Stephanie so we have a lot of people who talk to myself all right so given that we will touch a little bit on one language home in that's the thing that nobody has heard what and also there's another expert here in that language and so nimitz just yet another language that the attendant is Palo Alto to us so it's it's one potential candidate for you to write there's more progress in the future so what is it numerous aesthetically type of compound systems program language could you look at the language of Moodle to see some code in a minute it looks a little bit like it makes them I would say like JavaScript you like smash it together and then so the idea is that men aims to be very expressive Italian have a very intuitive syntax and it aims for neither who performs as well so if you people give the the website English website here there's this feature section and being able to see over here so go there basically it you know in claims that it has native performance with the state of the optimization so then the point here is that they've actually also compiled to two like C code which means there's a pretty good thing I guess so yeah that's why we have here you know translation targets like possible ones are seats people to us JavaScript three wasn't even JavaScript so so that's also pretty cool like if you should like to build web applications when you don't like JavaScript or text or whatever you can you could use them you know that's your that's your agenda and what's also really cool about the language itself which is kind of like a key point here of this whole thing is that it supports me to programming using generics and macros now why is that interesting so first of all some some dim code just to get a general idea what the language looks like all right I thought JavaScript especially together it looks kind of like that with some weird indentation syntax as well I think if you don't used to that looks really fun I think [Music] just never been used to it so you see there's like different things like iterators and you can create your own types and object structures and there's important statements as well you know if you use any other language you should probably get an idea important this up here means so now the macros you being one feature of that language is anybody use special functions that execute a compile time so you can basically define functions that expands to language that you're using and that expansion happens at compile time and that essentially enables you to create custom domain specific languages which is a very very powerful thing and yeah so here's probably not the best example you don't have to read and understand this code I just put up on the website just to give an example what a marker could look like in them this is a debug macro and you see like you defined with a macro keyword and then you know so someone's rated tell what to do and eventually once you've defined macro you can you can like call it like that we can find an area here at string and and then we pass it to that function so it looks like a mobile function at this point so you might wonder like what's the point really I'm gonna just use both functions for that but then it turns out you can actually go go way beyond that again like if we if we come back to the the idea of creating a DSL custom language that we do with its own semantics like this very powerful and there's there's this project that this guy who's working on it's called limp link the new play is exactly that right it takes the power of macros and creates a Thea ESL for for smart contracts again keep in mind like trans files to - you must as well so you basically get smart contracts in them but you can trust transpile - he wasn't and then so right new place a domain-specific language already smart contracts using them macros again doing what we've learned before essentially that means new place just a set of macros and it takes care of lightly expanding it to engineer all right so another cool illusion realization so you write your new play contracts they get expanded to new code so you actually you write them but you use the macro sometimes you spend it to be actual new code again at compile time macros are next critical time that code so that sort of make it your country all right all right it's gonna look more familiar to you and easier to write contracts [Music] by itself so it's kind of like a convenience injury yeah right so once we expended that to new move again that the whole process starts all over scene LT wasn't from there and again you know just just to stress it once more like essentially this could work with any language pathology was Amelia support something like my first I trust for example it's the same thing and here's a Houston sample code our or go to example for like a very simple smart contract that simply score some very simple storage like sets and get some value this is this a civil storage contract pretty named in play essentially so just that you're gonna been dealing there's probably some things here that don't really you know I think the main functions of this part doesn't really support at this point like an already aware that will show this are going to be in there but just and it takes a patience that's good the important thing to look at in the first few minutes you promised to set in yet when you're doing a set you're just sitting a local variable stored data to whatever your value is and when you do again until you imagine this is a contract employed in theory maybe just calling the set method to set the value of the contract and in order to get some acidity set transaction and calling again to get your value up it's very simple I'm originally it's the main well we don't have I haven't done the constructor project because it requires the deployment so the main is distribution here actually two points is usually just like salinity or white gradient which is never entirely chases some taxes a specific it's the little works [Music] because black man is a bad word to use for disability and instead that you don't have entry point yes we're done for you just it's kind of disabilities we got the interview because of the way the language Casa Caribe it works and it just cost executing from the beginning but in the West we have an entry point which is like it's using the main yeah like a main export okay cool so so there's this thing it's more for all spoiler so you know if you take a look at the installation instructions and if you happen to run other machines than netbooks this elation of limp leg can be hard so there's like this whole process and now to kind of draw the line back to that mark you know that the tool that worker who's this used in mark before but was a pretty fun at work before here who's not okay that's really cool check out yeah okay then we ready to get going all right but so so basically what we want to do is 15 15 minutes I want to slow down so since this set of us that's kind of hard to do we want to help with apart which between a second it's basically a tool that helps you building a centralized application so when you write your smart contracts when compile them deploy them and test them you want to have your front end you know that talks to them and so on so forth I can Bart use the tools it like a belt if you want that gives from like all the different features that you need to to make that process very easy and one thing that comes with it is is basically a parking ecosystem and a bucket API that enables you and us also you to extend an arm and its features and so you can basically also create a plugin that you know instantly so soon I think whatever looks like it's come out of a tool if you want any command line and the mark project you get like this dashboard that tells you who the contracts that that we're complying and deploy you can like learning output some you know transaction caches and gas costs and everything so it's like you know you know it's a hole into your deputy one if what's in that Red Bull yes yes good point there's actually there's a replica yes you can interact with your contractor contracts through that interface one you get top level of weight as well yeah oh by the way this Mike a little bit there's all right I took the wrong train or train going down directions I should see that's the father of the Marquis as well Richard another team member so did talk to all of us speaking of carpet there's also web interface that comes with the bar so when you learn your project with apart you can erase you see it spins up for you web server with the carpet which is on a web slide and basically that's you tell you the same way but knew which bit more rich way I would say stuff a triple there yes it's kind of like would you get this GOI just on steroids all right so and then again this it's like a mark on Zimmerman's people think of the park ends there's an API you people partner your pockets for ringing Steve the scans the nurse narcs thanks yeah with exit just like tons of stuff you can build your own we have ducks here so if you in case you haven't heard about the part before so good about that status but I am and then there's like a you know a lot of time making our interpretation as good as possible so there's lots of talks about how they do things like creating Parkinson's and so yeah so getting back to the point what what cool to be if we could use the mark and new play and create a plug-in it makes this whole process easy so that you can actually go ahead and write your smart contracts and like which like then ideally it will look something like this right so like step one you would install packages we wouldn't install it marker you create a new project with it there's a new comment right the party my project you would CD into it you would install a plugin something like a mark new compiler for example configure it and then you've done an ideal world by the way this is that kind of with the market information could look like there's an M bar Jason file coming with every of our project if you have other plugins usually they come with their own custom properties that you know figure them in this case we don't even need to do and yeah they go over to Harry horizon so I am going to show you a demo first I'm going to show you the demo first and then with the remaining title heading into like some of the turtles but up and then you know I don't think I forgot to pay for this everything some of this is gonna take a little while so okay elevator music I'm cute alright so okay so what we're going to do is we're going to do some before there was an unmarked CLI command apart over to the floor mark new so we're gonna run we're gonna do a barn run that's actually going to spit up our death so I'm just going to do a bar Brun oh yeah that good so what this is gonna do is it basically spins up all the services that we need to run our debt so you can see like a like a scale shown in the slides here's our dashboard and this is basically starting up it's starting to go before us it's starting up any storage services we might need with your dummy educational services like whisper without need ENS services as well again we don't need that for this demo but it'll do that all for us based on our configuration with them so as you can see what it's also done after starting up the note is it's deployed our contracts for us well it's top here it's deployed the simple storage one this is our solidity on trapped into the top one now the one underneath is the exact same thing that came okay so the code that we saw before with the simple storage written in that's this guy and it's just a little while because it's just yeah we are connected to the things to our own little private thing now I'm pretty sure it's the Wi-Fi it's gone is the bar all that and it has to be the right one say another washer you can try once again them not efficient markets begin so the you also test net currently is very small [Music] yeah there's not a lot of those and you know things can go wrong yeah it's one of the downsides of this right now a lot of it has to do with the fact that he wasn't so they're going a lot of changes and anybody go to the e awesome workshop yesterday see also yes silica just showing the code other good starts got the receipt okay so just going to show you the file system of our death this is actually not just give me a sec I want all right five five it was like a fart moves and I'm like my stupid [Music] all right so let's check it out so basically you can see here we've got a web server that's spun off this is for our front-end is for the death and also we have a web service over for company that was the screen shot that has military force if you want to go into the back kick of things that Co things these are working like all the services are working who drafted them you could do that using this link we're not going to be that today we're just going in front of our demo which is really really small reactive Oh beautiful motor maybe but so green lights okay all right all right all right okay so these slow untested consuming same on that as well so we have two tabs here one is for the solidity contract which is this one they're showing right now and then we have an in contract so we're just interacting with two different contracts this is all using wooded park does in the background as it co generates an object for us like a contract out there that we can then call with it's inside of our contract so for example we get a value that's stored if you guys remember where the contract looks like just getting a value that's stored in the contract our current value is 100 so if we then change that to 3 we said that we'll eventually get it set just a bit slow with some system at some point it's going to change silently yes is it because you're using the quality of evidence apparent psychic functions yeah this is a good question yes so the question is like do you not need to use my Damascus on transactions and the way of art works right now is you can configure all accounts inside of your configuration for your death so when you want to go create a transaction on the front end instead of signing a transaction using minimize and mark we'd like to stay in the transaction through impartial proxy and empower people to get up and say hey you're trying to send the transaction is this from an account that and our control to the wallet if it is and course we have access to product even it's not a transaction in development a very wooden bar becomes your wallet at that point so this is just was working this wrong he mentioned that the belly was resented you can call let's try this one let's get sciences money yeah [Music] I'll show you I say is up so basically this is all right you know what I need to do all right so this is the contractor we're looking at but I'm gonna show you a little bit first so doing the top level or a pile system there's a few components here we have a front-end stuff in it under app we've got our configuration file under config hundreds of your contracts Adisa Teno front-end the only meaning really until the speed years the white races home what about see where to set up we've got this plugin here this stop schism we don't actually need this but again it's best I was mentioning you can add any custom options prettier custom plugins to it so don't worry about that one for now but you just see that we have the embark in monitor plug-in said oh that's right install it so once you have installed into your edit just enable it to see I'm gonna test it as an object of plugins so in our contracts we've got our civil storage slew the contract so constructor accepted value and it's stored added to that value and then you can also do the same thing that sets of a connection since we're done on YouTube when we pass in and then the get we just pull it up I'll be crazy and looking at name it's exactly the same thing so you can send a value using this set function get the value the gate function we've really made config I mean there's configuration for watching so how do you want to configure know it and use accounts it was Molly counter talked about earlier so we can basically add into the money and sign transactions that way communications like whispered these I mean I want to get into these once you start again it's a lot to cease or any burning questions I guess well just wondering is it possible currently for this simple storage name contract to read you know like for simplicity that's more HIV so the delirium or like how do these two vs circle Harrington tastemakers into the stock so you know okay currently but I think that deal I will have to point them and they may switch and then yes especially at you when you think about my you're gonna have to artful at some point so then you'd have to run four themes so you'd have to that's all right sorry and that's going to show you just between as the last two minutes we have and it actually doesn't matter this is we just works mobis it works it's right that you say is dislike one thing that you might be interested in great talk so you're gonna stay here all right you can see this wonderfully so you see there's this message values I did not just okay yeah well you see this worse anything is a bush okay follow me good point this is a me okay because some development version that you don't have right now now install like at this point it's a version that's like late to semester running huh you can see all the departments yeah so these are the two W changes and then so you can own recent transactions you can see where the contract was deployed the you buy the test metacommunity and then the two set functions that code one earlier anymore looking and then he called the one of 100 actually cited 100 and 101 for money yeah it's quite cool you can pay your boss you all other contractor to re-explore nine yeah I think the storage tab yes this is actually cool because we did some of the things that is discussed before [Music] and then if you check the West curve consists of a most about a gas injection you can control will see this is the coals in entirety of publications so they do a single clause and make these and they're basically if your contract fell together they just like terms a little bit use gas [Music] any other questions [Music] okay well then yes it's because you don't want to write your own so it was I don't know why they did it specifically but I think it because they wanted to taste all the fussin and interpreters a compile-time available and not all of them expungement or two different for the county so drink it this way about them to taste a little [Music] you found the star [Applause] you

Automatic transcript — names and jargon may be misspelled.