{"id":"bF8PCJ3nU-Y","title":"Wasm in Web3 Workshop with Maksym Zavershynskyi","description":"Maksym Zavershynskyi is Head of Engineering at NEAR Protocol.\n\nIn this talk at the Wasm in Web3 workshop series sponsored by Fluence, Max covers the role of Wasm on the NEAR platform, covering key design choices and topics that are relevant to anyone building dApps on NEAR or considering contributing to other areas of the platform.\n\n---\n\nFollow the latest from NEAR Protocol on:\nWebsite: https://near.org/\nDiscord: https://near.chat/\nBlog: https://near.org/blog/\nTwitter:   / nearprotocol  \nGitHub: https://github.com/near  https://github.com/nearprotocol\n#Blockchain #FutureIsNEAR #NEAR #nearprotocol","channel_name":"NEAR Protocol","published_at":"2021-09-24T00:00:00.000Z","thumbnail_url":"https://img.youtube.com/vi/bF8PCJ3nU-Y/hqdefault.jpg","transcript_text":"hey everyone my name is max uh just like anna told you um i'm a head of engineer engineer and for those of you who don't know nier is a sharded proof of stake blockchain with a special focus on developer friendliness and um sharding is just one of the ways why how we achieve developer friendliness uh because chardonnay allows us to be scalable you know high dps low confirmation time cheap transactions and so on but another way how we achieve developer friendliness is by using a web assembly virtual machine because webassembly allows people to develop contracts in a large variety of languages so currently we support two languages rust and a sandwich script so most of you are familiar with rust and most of the web assembly enabled blockchains they actually use rust as their primary smart contract development language for many good reasons so one of them is that rust is the first class citizen as a web assembly language not surprisingly because the community that develops wasm and rust is heavily overlapping so it's frequently the same people who work on rust and wasm also brust is a very safe language as we all know has drawn typing and lifetimes and prevents all kind of ways of shooting yourself on a food uh so that's why we default to rust as our primary smart contact language but we also allow people developing an assembly script and uh for those of you who don't know assembly script is a dialect of typescript it has been developed by a small group of people that we are the biggest sponsor of and what they're trying to do they try to get the right balance between having a developer friendly language uh for uh for people coming from the web and mobile development so many people coming from web development they're already familiar with typescript so assembly script is just a dialect of typescript it looks almost exactly the same as typescript but it has some extra annotations for type safety and whatnot and it tries to also be as close to webassembly as possible so it tries to be easier to compile to our assembly than typescript and many people many developers come into our blockchain they're uh with only the knowledge of typescript they're able to develop an entry and a centralized application um just in typescript you know like write a contract an assembly script front-end and typescript you know they deploy it on a minute in a matter of minutes or hours depending on the complexity of their project the other two languages that we are going to support very soon as our smart control development languages is green and sick so for those of you who don't know grain grain is the very recent language um that uh gained quite a lot of popularity because it tries to be a web development focus language but as a language that's also very easy and a native uh easy to compile turbo assembly native to us native to web assembly development uh we also uh sponsoring them and they have already and a better uh sdk uh on near uh that is gonna soon to be productionized and a grain also strikes really good balance between like rust and typescript kind of language it doesn't have manual memory management which is kind of a strength of rust because with manual memory management you don't have this spikes of cpu usage when you're garbage collector kicks in but for most of the languages they're going to explain to you later that have non-manual memory management we actually just disable garbage collection because smart contracts are short-lived anyway and we can afford to never delicate memory in the first place so the grain is the case coming very very soon in the next week or a couple of weeks and zig is another language that we've been developing sdk for zig is also quite popular it compiles the web assembly quite easily and um yeah so this we're going to have four languages um as a smart contract which is so near blockchain soon so the question is um how many languages are we going to have in the near future what are our plans and our plans us to have like every single language that compiles to assembly and every language that we can lay our hands on as language for smart contract development and near and it's just a matter of time and the matter of the resources but we're going to get to all of them we have already been experimenting with c plus plus python java go and uh there are various reasons why we're not we don't when we don't have sdks for all of them uh specifically with c plus plus is because uh we are intimidated by its complexity specifically of the m scripting i am scripting has been around for quite a long time it's quite a big code base so once we get more uh clarity and confidence with using apps script and we're going to have c plus plus sdk on near java python and go turn out to be very heavy in the compilation to web assembly uh specifically python programs uh their order of magnitude larger when compiled webassembly than equivalent programs written in rust and that's because python is not meant to be compiled to web assembly it has pretty heavy runtime and the contracts that i would usually be like 100 000 bytes in size they become like two megabytes in size when compiled when written in python and compiled web assembly but we'll we'll figure something out in the future we might uh narrow down these languages you know again use some kind of a dialect uh to make them easier to compile to webassembly or we might even raise the minimum the maximum contract size on on near blockchain to be able to accommodate all of these languages so if you're a fan of any specific webassembly language whether it's a you know a general uh purpose language like python or like a new language like rain or zig please write us and we might work together on sdk for near there are various uh virtual machines that we are using uh to run web assembly program set near so right now we're using wasmer and single pass and wasam time and light beam so these are both non-optimizing um back-ends for web assembly compilation there are reasons why we don't want to use optimizing compilers uh first of all is that optimizing compilers like lvm and crane lift they are they're quite large in their code base size and we want to be very confident with the webassembly back-end that we integrate in into our blockchain client and so we just try to stay away from them for now but also optimizing compilers they have much more complex behavior um they prone to compiler bombs sometimes and we just don't want to deal with it yet so we we still use uh we use wasmer and single pass and vasem time plus light beam right now uh so right now we're using wasmer 0.17 as as our default execution environment but we are slowly migrating to osmo 2.0 osmore 2.0 has a faster compilation uh time of loading the module into memory and faster execution of webassembly code in general so we're going to have at least twice faster contracts once we migrate to osmo 2.0 we've just been extra careful with fixing all safety issues uh in wasmer 2.0 before migrating to it we also have azam time and light beam integrated an engineer blockchain we don't use it by default however any validator can switch to we're using wasm time plus slide them if they want to um and the reason we have it there is just in case you know we find any kind of bug and wasmer and single pass we will be able to signal to our leaders to switch to azam time plus light beam while we're fixing this bug but this hasn't happened yet uh surprisingly even though wasmer and single pass and bosom time plus light beam have very different code bases entirely different approaches to compilation light beam as a streaming compiler their performance at least for asmr 0.17 is quite similar on most of our benchmarks so that was a very interesting discovery we are also looking into the interpreters so parity has been used in wasmi uh since the beginning uh there is also wasn't free and very um popular interpreter right now we might be looking into using them because the advantage of the interpreter is that they have a very a simple warm-up unlike the compilers that need you know a complex module loading um before you can start executing the smart contracts interpreters are really easy to start up even though they're much slower when you actually execute wasm code so we might add them in the future and allow people to choose which which wasn't virtual machine to use when executing the smart contract so they might be able to use interpreters for really really tiny contracts and pay even smaller fees for them uh we're also going to be looking into the optimizing compilers too uh so we talked to um crane lift core developers and it seems like there is a way to run crane lift in an optimizing way get rid of some optimization stages i need to make it also smaller in code size that might allow us to have crane lift as as another as another webassembly back end for webassembly execution at near the interesting thing is that running charted proof of stake blockchain actually has strong advantages um so one of them is that we have an inherent incentive for validators to run uh multiple virtual machines so right now you know that uh some virtual machines uh they have implementations of their protocols back in different languages but what frequently happens is players do not really have incentive to diversify the clients that they're using and frequently the bloc the network just converges to one client because which is you know the cheapest or the faster so whatever has better um configuration parameters which undermines the whole point of having multiple implementations because um you know if 50 percentable leaders are running the same light client the same client then you know if you have coordinated error it's going to go down anyway with sharded blockchains you frequently have a mechanism flashing that allows you to run uh shards optimistically where you kind of put phase into the charging validators on each chart to produce valid blocks but then at the same time you supervise them and if you notice that the blocks are invalid you slash them so what has happened on some short blockchains and what you want to avoid is that that when slavishing happens because of some bug which happened hasn't happened to near we also haven't enabled sharding yet but if validators want to really avoid being slashed because there is a bug in the in the code or because they have messed up the devops um the setup then they might have an incentive to run multiple clients with different implementations side by side and if they disagree on the block production then they would terminate their clients without producing any block so there is an inherent incentive on the blockchains with slash into for the layers to run multiple clients and uh maybe even the same client but uh the same client that uses different virtual machines it can also be an alternative for validators so there are many uh difficulties with running web assembly virtual machines on the safety side that we have discovered so the biggest one is the strict separation of deterministic and ephemeral errors so uh what i mean by deterministic versus ephemeral errors is that the deterministic error is the kind of an arrow that has been introduced by the contract developer let's say they have written a program that you know does division by zero or exceeds the the maximum allowed stack sizing in web assembly uh non-deterministic ephemeral error is this the stuff that happens um because there is a fluke i don't know like you you run in some other programs on your uh on your uh in cloud instance and you know node runs out of memory or you have this corruption and this is something that can be happening just only on your evaluator machine or it can be happening on for instance on all the little machines that run in the same kernel version this is something that has happened in one hour testnets and so it's extremely important to be able to separate these errors that are being piped to you by the virtual machine into these two strict categories because if you make a mistake and you confuse deterministic error for fmero because of some bug in a virtual machine then what might happen is that someone might be able to craft a smart contract that triggers a deterministic error and causes uh all the nodes think that there is an ephemeral arrow and what we do with the femoral errors is that we just shut down the node we don't want to deal we don't want to have a special cover mechanism when you have a discorruption uh happening so we just shut down the note in this case and if we make a mistake and miss categorize humanistic air force primaril then someone can crush the entire network which hopefully doesn't is not possible to happen if you miscategorize a femoral error for deterministic error then what might happen is that some nodes they might think that they produce a valid block but is actually invalid and if if this happens uh on all let's say versions of the same kernel across a subset of the nodes in your network then you might have a network split or you know a bunch of nodes being kicked out which is also nasty and you don't want to happen so it's it's the top of our mind to the separate deterministic and ephemeral errols very precisely for the buzzing virtual machines and occupies a lot of our time uh doing it correctly uh full compatibility with violism standard also turned out to be not super trivial because there are very tiny corner cases around trap handling that we found out are not handled precisely on about the virtual machines and um this is something we had to we noticed only post facto uh forward compatibility with wasm's turner is also important for us so i'm gonna be talking later on how we do the gas injector and instrumentation vason contracts and the new way of doing the gas injector makes a strong assumption that certain parts of azam standards are not going to be extended in the future and so that's basically an assumption so forward compatibility wasn't standard that we're going to talk about later then you also want to canonicalize the floats uh this is something that we do for all our contracts initially we decided to just sanitize uh our contracts and uh prohibit deploying the contracts on on your blockchain that uses use the floats but we very very quickly found out that this leads to very bad developer experience because like ras developers they just want to import libraries um when they develop smart contracts and surprisingly even if you're importing some library that doesn't use flows for like math operations let's say you're importing some cryptographic library it still might be the case that you will have some float operations in there because uh of how for instance um rust does string formatting uh you know for for panics um so we decided to allow floats uh in in a near smart contract but now we can equalize them and uh finally this entanglement implementation of other virtual machines from the protocol uh turned out to be also not super trivial uh there are some minute details about how the uh stack handling is is being done by it was in virtual machines or how how was virtual machines interact with your um uh instrumentation that made some of these details leak into a protocol spec and ties to a specific implementation of the vason virtual machine that we're currently slowly removing um we also had lots of challenges with determinism in virtual machine well first of all as all of you know here the worst case scenario um in in a virtual in the blockchain spaces is basically what determines the the fees usually it's not the best case scenario because if you if you optimize your fees to target for the best case scenario then your blockchain is going to be vulnerable someone might be able to trigger the worst worst case scenario so um yeah the the worst case scenarios dictate the fees which did dictate tps on your blockchain at the end of the day you can try to special case best case scenario and say for instance that if your contract hits doesn't hit some corner cases then the fees are generally lower unfortunately that leads to bad devex well first of all your fees might be unpredictable so uh if developers find out that in certain cases uh the smart contract execution is much more expensive than in other cases based on some so like super low level internal mechanism and how webassembly virtual machine functions then the box is going to be uh pretty bad but also special case in best cases will lead to increased complexity of the protocol which we also want to avoid we try to keep our protocol pretty simple we also want uh the execution time to be similar on similar platforms we have a target hardware at near but we want people to be able to run our notes on almost any uh four core cpu plus 16 gigabytes of ram machine uh so we don't want the execution time to vary drastically across different platforms and finally um big challenge with determinism is how do you decide what are your fees and this is a completely separate topic that i'm gonna get to soon oops sorry sorry skip the slides um there are performance challenges uh with virtual machines so one of them is the time to start um it's just the time that it takes for your virtual machine to warm up before it starts uh running the smart contract and uh there are multiple factors that contribute to time to start one of them is this visualization time so it does matter what kind of the serializer you use to store your compiled module and there is also the contributing factor of the io cost so in most cases you're probably not going to be storing your compile module in memory you're probably going to be storing it on the disk as so the the time that it takes to load it is a big contributing contributor to the execution time on the smart contract the the loading of the module is also depends on many many variables in your virtual machine and any smart contract it depends on the size of the code it depends on the size of this data section in your wasm a number of the methods in wasm surprisingly also frequently contribute to the time it takes to load the module and obviously a number of the imports also contribute to that then call contracts is is a big problem someone can deploy a contract that they never call for many years and then they try to call it two years later and uh it can be living in a cold storage so the question is do we separate cold and hot storage in in a blockchain is a pretty big question uh right now we don't which means that the fees for the cold contracts dictate the or fees for all all of the contracts but in the future we might start separating them because certain contracts are going to be executed all the time like exchanges and we want them to be cheaper than contracts that executed very rarely and finally the compilation time the compilation time is is a challenge uh even with single pass and streaming compilers compilation takes slightly different time and so what we had to do we had to go all over the wasmer code and remove things like randomly seated hash maps and um like some multi-threading to make the compilation time uh consistent um yeah so there are also um safety oh wait one second my presentation is lagging i'm sorry for that yeah so finally uh how how do we decide the fees so this is the big problem for every blockchain because obviously every operation on a blockchain should take certain amount of uh money right you don't want stuff to be executed for free on your blockchain so how do you decide what costs what and especially when it comes to the virtual machine that has a very complex internal mechanisms so the way many blockchains uh address it they either do the educated guess sometimes because um if they if you have host functions which are cryptographic primitives you might be able to guess uh how much it should cost but most of the time the way blockchains do it is by running time-based benchmarks like they execute uh operations over and over and over and time them and determine based on the timing how much they should cost so we found out that this is um not as precise as we want it to be very frequently time-based benchmarks even when they run for days uh produce very high spread of execution time for the same fees and so what we did uh we we took a big part of our node uh which is runtime and roxdb and virtual machine and we're running it on the cpu emulator qmu and uh i told you we also removed a bunch of the sources of non-determinism and so now we just count the actual cpu instructions that our node takes to execute those various separations and we were able to achieve precision and represent reproducibility for most of the fees to be within five percent and for a couple of fees that are specifically involved with io uh it's within 10 15 precision which i think is a is a good result i mean estimating diffuse is still very difficult well first of all something that we haven't addressed yet is that different cpu operations obviously have different complexity and different execution time uh we do treat them the same right now we uh run lots of files and to make sure we are not abusable in this way that someone cannot really easily construct a contract that abuses certain cpu operation and also iu operations are really difficult to benchmark and assign the fees um to it it's a well known that uh benchmarks for ssds are especially tricky so we don't even try to write our own ssd benchmark we use third-party benchmarks uh to estimate it and uh finally i mean just running things in emulator is extremely slow and um we do want to run stuff for many iterations uh even inside emulator for several reasons uh one of it is just to reduce the volatility in case we forgot you know some of them randomly seated hash maps and stuff like that but another one is to catch the corner cases so we try to uh generate a wide array of the input and uh just to make sure we didn't forget some of the corner cases that can have a disproportional computation time that our fees are actually deterministic so yeah these are tricky uh then as i promised i want to talk about the gas injector as we know instrumentation for web assembly is is quite expensive uh for some uh for some cases if you use pivaz motels which is one of the most popular instrumentation libraries out there the the cpu instructions caused by the instrumentation code itself can be 90 95 of the cpu instructions of the entire smart contract so the instrumentation can be dominating the cost of running the smart contract and this is mostly because the uh the go-to instrumentation uh approach right now is to inject host function call on every uh wasn't block which is of course expensive because you're crossing guests and guest host boundary every every wasn't blocked and so what we did here we looked at uh what wasmer two is doing and what they do is um they inject a global variable uh that they modify without crossing the uh host guest boundary um and they just modified on every wasn't block and they do this injection in the middleware so we we took the same approach we just modified pivaz materials in our fork uh to do this kind of instrumentation so anyone any blockchain that uses wasm you guys are welcome to use this modify and pivazo motels um it allows us to reduce the cost of running wasn't smart contracts uh four times according to our most recent benchmarks and also it doesn't tie you to any specific webassembly virtual machine so that's why we're not using a wasmer's version of the of this instrumentation because we wanted to also work quasim time and other kind of virtual machines because instrumentation needs to be vm agnostic unfortunately uh gas injector design does leak into the protocol spec not something that we wanted to have and this is because uh when you inject a different amount of assembly code into your webassembly smart contract uh now your contract might run out of memory earlier or later uh or like might might hit the stack size limit earlier or later so it does um kind of leak into the protocol spec which is quite unfortunate we haven't figured out what to do with it yet and but the good news is that you can actually write a very suboptimal uh gas injectors uh at least at near uh we don't uh do gas injection on upon the contract execution we do it upon the contract deployment um and the contract compilation and contract deployment is already quite expensive so you can run a very simple and suboptimal gas injection there and not don't don't worry too much about its performance yeah so as i said uh we have a whole bunch of languages currently four that have as the case either um pending or already been used for quite some time by the community uh interestingly for us we did have uh some requests from the community to have std and nostalgic versions of the sdk most of the time a community actually wants to use std version of rast sdk because they do want to import lots of rust libraries and not all of the rust libraries support as the no std mode and so we had to really optimize an std version of rast sdk and there are also alternative libraries written by the community that you can use the cool thing about um languages that do not have manual manner memory management like assembly script and grain is that you can actually just turn off their garbage collection because the contracts as i said are short-lived and we can totally afford uh allowing them using mini megabytes of memory if they need to without delocating it so that's an upside of using languages like that and actually we haven't made our mind whether we're going to support a garbage collection on a protocol level yet because i mean garbage collection is coming to the web assembly spec so we have an opportunity to support a garbage collection on a particular level but we haven't made our mind yet about it we had to do lots of sdk site optimizations because people writing contracts are near they want their contracts to be smaller in size because that means the fees are going to be smaller for compiling such contracts or for executing such contracts technically it is possible to run extremely tiny contracts on near if you use rust you know if you if you do not use std and if you use all the best guidelines for writing tiny code you can you can actually have less than one kilobyte contracts when once they compile to have assembly but your developer experience will suffer greatly so most of the projects even projects that care a lot about the performance and about the size they actually still use our as the case with std so the main contributors to the size actually for these contracts turn out to be obviously strings errors and uh you also got to be very careful with std because it has different code for x86 and wasm so you want to sometimes dive into the std implementation and make sure that when you compile to webassembly you're compiling exactly what you want to compile because it can be complete different code and uh the other interesting thing is that we don't actually use uh all these cool tools that web assembly ecosystem has for optimizing the uh web assembly like wasm opt and wasn't snip and mostly because we don't want our developers to shoot themselves in the foot wasn't snip is a very aggressive tool and someone can accidentally over do optim contract optimization and just cut too many things so we just don't advise our users on using it yeah um there are interesting things to be said about using basm tailored languages like assembly scripting green they have pros and cons so pros obviously is that they made to be efficient when compiled to webassembly as i said like assembly script even has a self hosted compiler like you can compile assembly script with assembly scripts which is amazing and and grain was designed specifically to be uh efficient when compiling to webassembly um so it means you can write in some cases highly optimized contracts with with assembly script in green the disadvantages of course uh of these languages is that they have they still have small community that means you have uh very few libraries and it's still the case that uh when you want to write a smart contract an assembly script you need to import assembly script library like you cannot at least not on near you cannot import a library written in another language in compiled web assembly yet we haven't enabled this um a possibility yet and also they haven't been battle proven unlike rust you know that large companies like google and mozilla are using uh for their uh uh browser development uh assembly script and grain haven't been battle proven so we just don't advise uh our defy projects on using them yet the other interesting thing is that we learned quite a bit from ethereum um experience with the assembly we liked the idea of the execution environments in ethereum and while we don't exactly have execution environment we have several layers of virtualization people can run solidity contracts on near because our evm which is splitting vm is just a web assembly smart contract that runs on top of our web assembly virtual machine and so people can already run up to 4 million gas contracts on inside our evm and very soon this number is going to increase by several x maybe form x that will allow you to run pretty much any transaction that you can run on ethereum on on near without any constraints and we haven't even uh piped the host functions from the uh all of the host functions from the evm into into our host functions so many of the host functions inside the edm are actually run in web assembly um which makes it quite optimal but it still works and obviously like rust assembly script and grain and zig they're all executed as the first class citizens without extra layers of virtualization directly on our wasm virtual machine finally i wanted to tell you how we're planning to um test these contracts so we do have already um quite a few tests and frameworks that peop that various projects used to test web assembly contracts on nir but we we came up with this cool idea of having a unifying unified testing approach to any kind of contracts that people are deploying on your blockchain and this is achieved by basically test and web assembly assembly contracts like there were live contracts so you would take you would take a test test and you would compile it together with the contract in such a way that the tests themselves are basically your contract cost functions then you would deploy uh this stuff to uh to your node and then you would interact with with test as if there was contract functions which allow you to unify lots of the experience around the run and the contra code and make your testing experience as close to production to production as possible so your code and test is going to be highly reproducible in production too um so that was it uh that was not a very long presentation but if you have any kind of interest in wasm languages if you like not just grain and zig but there are other languages that you like and you want um and you want them uh and you want to build an sdk for them or you like some web assembly virtual machine a compiler please write us and we might give you a grant to work on it so thanks everyone are there any questions in the chat so thank you so much maxim that was very interesting and we have one question uh why would you need to support that many languages isn't rust enough for all purposes well so nier is a i mean developer focus blockchain so we want people coming to near to have zero barrier when they develop on us and you know people have developers have all kind of backgrounds some people used to work mostly with c plus plus some people used to work with python so we don't want to force them to use rust we want them to be able to come to near and just find whatever language they've been using all their life as a language that we support and start developing on it it's basically reducing the barrier for the developers that's the goal but also we like supporting open source projects like we sponsor an assembly script with sponsoring green and zig and and and uh wasmer so why not help all these languages if we can it's amazing to hear that you're helping those projects you know like they're they really need it and it's great for the developing the whole infrastructure of the ecosystem the next question do you have any plans for enabling cross chart contract to contract contract to contract interaction so this is something that's been working from from the start so right now we have a single chart but in test environment we run in like eight shards and we're gonna roll out eight shards very soon in the next couple of months um so this is not something that we add later this has been already built in from the start when people develop smart contracts on near they don't even think which chart the smart contract is running on this is very similar to how you write javascript programs like when you write javascript program and use promises you don't think which cpu core is running which part of your javascript program right now you just you know use promises and it somehow gets executed behind the scenes so it's really very similar to when you write a decentralized app on on near and have various uh and you have it partitioned in various contracts or you interact with exchange or swaps you don't even know either right on the same chart or are they running on different charts and there is like no incentive in here to collocate uh to collocate contracts on the same chart we don't want to have any kind of perverse incentive for people to try to fight and and co-host on the same chart with some exchange or something like that it's all exactly the same exactly the same fees exactly the same finality time uh for cross-contract interactions when they talk either within the same chart or across different charts and actually uh in a in a year or two we're going to enable dynamic resharding that is going to be rebalancing our shards to be of the same size and in that case even if you're on the same chart with some contract right now in the next hour it might change and it might be resharded and you might end up on different shards uh so inherently at near there is no distinction on whether you're on the same chart or whether you're on different charts from the developer perspective okay thank you so much um i think that's it for the questions thanks everyone at least for now thank you so much maxine","transcript_synced_at":"2026-11-04T04:10:14.123Z","segments":[{"start_seconds":0,"text":"hey everyone my name is max uh just like anna told you um i'm a head of engineer engineer","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=0s"},{"start_seconds":7,"text":"and for those of you who don't know nier is a sharded proof of stake blockchain with a special focus on","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=7s"},{"start_seconds":15,"text":"developer friendliness and um sharding is just one of the ways why how we achieve developer friendliness uh because chardonnay","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=15s"},{"start_seconds":22,"text":"allows us to be scalable you know high dps low confirmation time cheap transactions and so on but another way how we achieve developer","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=22s"},{"start_seconds":30,"text":"friendliness is by using a web assembly virtual machine because webassembly allows people to develop contracts in a large variety of","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=30s"},{"start_seconds":38,"text":"languages","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=38s"},{"start_seconds":41,"text":"so currently we support two languages rust and a sandwich script so most of you are familiar with rust","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=41s"},{"start_seconds":48,"text":"and most of the web assembly enabled blockchains they actually use rust as their primary smart contract development language for many good reasons so one of","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=48s"},{"start_seconds":57,"text":"them is that rust is the first class citizen as a web assembly language not surprisingly because the community","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=57s"},{"start_seconds":65,"text":"that develops wasm and rust is heavily overlapping so it's frequently the same people who work on rust and wasm","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=65s"},{"start_seconds":74,"text":"also brust is a very safe language as we all know has drawn typing and lifetimes and","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=74s"},{"start_seconds":82,"text":"prevents all kind of ways of shooting yourself on a food uh so that's why we default to rust as our primary smart contact language but","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=82s"},{"start_seconds":91,"text":"we also allow people developing an assembly script and uh for those of you who don't know assembly script is a dialect of","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=91s"},{"start_seconds":99,"text":"typescript it has been developed by a small group of people that we are the biggest sponsor of and what they're trying to do they try","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=99s"},{"start_seconds":107,"text":"to get the right balance between having a developer friendly language uh for","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=107s"},{"start_seconds":115,"text":"uh for people coming from the web and mobile development so many people coming from web development they're already familiar with typescript so assembly script is just a dialect of typescript","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=115s"},{"start_seconds":124,"text":"it looks almost exactly the same as typescript but it has some extra annotations for type safety and whatnot","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=124s"},{"start_seconds":132,"text":"and it tries to also be as close to webassembly as possible so it tries to be easier to compile to our assembly than typescript","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=132s"},{"start_seconds":140,"text":"and many people many developers come into our blockchain they're uh with only the knowledge of typescript they're able to develop an","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=140s"},{"start_seconds":149,"text":"entry and a centralized application um just in typescript you know like write a contract an assembly script front-end and typescript you know they","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=149s"},{"start_seconds":156,"text":"deploy it on a minute in a matter of minutes or hours depending on the complexity of their project the other two languages that we are","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=156s"},{"start_seconds":164,"text":"going to support very soon as our smart control development languages is green and sick so for those of you who don't know grain","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=164s"},{"start_seconds":173,"text":"grain is the very recent language um that uh gained quite a lot of popularity because it tries to be","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=173s"},{"start_seconds":181,"text":"a web development focus language but as a language that's also very easy and a native uh easy to compile turbo","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=181s"},{"start_seconds":190,"text":"assembly native to us native to web assembly development uh we also uh sponsoring them and they","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=190s"},{"start_seconds":199,"text":"have already and a better uh sdk uh on near uh that is gonna soon to be productionized","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=199s"},{"start_seconds":208,"text":"and a grain also strikes really good balance between like rust and typescript kind of language it doesn't have manual","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=208s"},{"start_seconds":215,"text":"memory management which is kind of a strength of rust because with manual memory management you don't have this","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=215s"},{"start_seconds":222,"text":"spikes of cpu usage when you're garbage collector kicks in but for most of the languages they're going","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=222s"},{"start_seconds":231,"text":"to explain to you later that have non-manual memory management we actually just disable garbage collection because smart contracts are short-lived anyway","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=231s"},{"start_seconds":240,"text":"and we can afford to never delicate memory in the first place so the grain is the case coming very very soon in the next week","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=240s"},{"start_seconds":248,"text":"or a couple of weeks and zig is another language that we've been developing sdk for zig is also quite popular it compiles","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=248s"},{"start_seconds":256,"text":"the web assembly quite easily and um yeah so this we're going to have four languages um as a smart contract","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=256s"},{"start_seconds":264,"text":"which is so near blockchain soon so the question is um how many languages are we going to have in the near future","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=264s"},{"start_seconds":271,"text":"what are our plans and our plans us to have like every single language that compiles to assembly and every language that we","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=271s"},{"start_seconds":279,"text":"can lay our hands on as language for smart contract development and near and it's just a matter of time and the matter of the resources but we're going","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=279s"},{"start_seconds":287,"text":"to get to all of them we have already been experimenting with c plus plus python java go","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=287s"},{"start_seconds":295,"text":"and uh there are various reasons why we're not we don't when we don't have sdks for all of them uh specifically with c plus plus is","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=295s"},{"start_seconds":302,"text":"because uh we are intimidated by its complexity specifically of the m scripting i am scripting has been around for quite a long time it's quite a big","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=302s"},{"start_seconds":310,"text":"code base so once we get more uh clarity and confidence with using apps script","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=310s"},{"start_seconds":317,"text":"and we're going to have c plus plus sdk on near java python and go","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=317s"},{"start_seconds":325,"text":"turn out to be very heavy in the compilation to web assembly uh specifically python programs uh their","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=325s"},{"start_seconds":332,"text":"order of magnitude larger when compiled webassembly than equivalent programs written in rust and that's because python is not meant","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=332s"},{"start_seconds":339,"text":"to be compiled to web assembly it has pretty heavy runtime and the contracts that i would usually be like","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=339s"},{"start_seconds":348,"text":"100 000 bytes in size they become like two megabytes in size when compiled when written in python and compiled web","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=348s"},{"start_seconds":355,"text":"assembly but we'll we'll figure something out in the future we might uh narrow down these languages you know again use some kind of a dialect uh to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=355s"},{"start_seconds":364,"text":"make them easier to compile to webassembly or we might even raise the minimum the maximum contract size on on near","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=364s"},{"start_seconds":373,"text":"blockchain to be able to accommodate all of these languages so if you're a fan of any specific webassembly language whether it's a","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=373s"},{"start_seconds":381,"text":"you know a general uh purpose language like python or like a new language like rain or zig please","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=381s"},{"start_seconds":389,"text":"write us and we might work together on sdk for near there are various uh virtual machines","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=389s"},{"start_seconds":397,"text":"that we are using uh to run web assembly program set near so right now we're using wasmer and single pass and wasam time and light beam","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=397s"},{"start_seconds":406,"text":"so these are both non-optimizing um back-ends for web assembly compilation there are reasons why we don't want to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=406s"},{"start_seconds":414,"text":"use optimizing compilers uh first of all is that optimizing compilers like lvm and crane lift they are","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=414s"},{"start_seconds":421,"text":"they're quite large in their code base size and we want to be very confident with the webassembly back-end that we","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=421s"},{"start_seconds":428,"text":"integrate in into our blockchain client and so we just try to stay away from them for now but also optimizing compilers they have","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=428s"},{"start_seconds":437,"text":"much more complex behavior um they prone to compiler bombs sometimes and we just don't want to deal with it yet","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=437s"},{"start_seconds":444,"text":"so we we still use uh we use wasmer and single pass and vasem time plus light beam right now","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=444s"},{"start_seconds":454,"text":"uh so right now we're using wasmer 0.17 as as our default","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=454s"},{"start_seconds":461,"text":"execution environment but we are slowly migrating to osmo 2.0 osmore 2.0 has a faster compilation uh time of loading","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=461s"},{"start_seconds":470,"text":"the module into memory and faster execution of webassembly code in general so we're going to have at least twice","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=470s"},{"start_seconds":477,"text":"faster contracts once we migrate to osmo 2.0 we've just been extra careful with fixing all safety issues uh in wasmer","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=477s"},{"start_seconds":486,"text":"2.0 before migrating to it we also have azam time and light beam integrated an engineer blockchain","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=486s"},{"start_seconds":493,"text":"we don't use it by default however any validator can switch to we're using wasm time plus slide them if they want to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=493s"},{"start_seconds":500,"text":"um and the reason we have it there is just in case you know we find any kind of bug and wasmer and single pass we will be able to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=500s"},{"start_seconds":507,"text":"signal to our leaders to switch to azam time plus light beam while we're fixing this bug but this hasn't happened yet","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=507s"},{"start_seconds":515,"text":"uh surprisingly even though wasmer and single pass and bosom time plus light beam have very different code bases entirely different approaches to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=515s"},{"start_seconds":524,"text":"compilation light beam as a streaming compiler their performance at least for asmr 0.17","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=524s"},{"start_seconds":531,"text":"is quite similar on most of our benchmarks so that was a very interesting discovery we are also looking into the","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=531s"},{"start_seconds":539,"text":"interpreters so parity has been used in wasmi uh since the beginning uh there is also wasn't free and very um popular","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=539s"},{"start_seconds":548,"text":"interpreter right now we might be looking into using them because the advantage of the interpreter is that they have a very","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=548s"},{"start_seconds":556,"text":"a simple warm-up unlike the compilers that need you know a complex module loading um before you can start executing the","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=556s"},{"start_seconds":564,"text":"smart contracts interpreters are really easy to start up even though they're much slower when you actually execute wasm code","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=564s"},{"start_seconds":572,"text":"so we might add them in the future and allow people to choose which which wasn't virtual machine to use when","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=572s"},{"start_seconds":580,"text":"executing the smart contract so they might be able to use interpreters for really really tiny contracts and pay even smaller fees for them","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=580s"},{"start_seconds":588,"text":"uh we're also going to be looking into the optimizing compilers too uh so we talked to um crane lift core developers and it seems","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=588s"},{"start_seconds":596,"text":"like there is a way to run crane lift in an optimizing way get rid of some optimization stages i need to make it also smaller in code size","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=596s"},{"start_seconds":605,"text":"that might allow us to have crane lift as as another as another webassembly back end","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=605s"},{"start_seconds":612,"text":"for webassembly execution at near the interesting thing is that running charted","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=612s"},{"start_seconds":621,"text":"proof of stake blockchain actually has strong advantages um so one of them is that we have an inherent incentive for validators to run","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=621s"},{"start_seconds":629,"text":"uh multiple virtual machines so right now you know that uh some virtual machines uh they have implementations of their","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=629s"},{"start_seconds":637,"text":"protocols back in different languages but what frequently happens is players do not really have incentive to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=637s"},{"start_seconds":644,"text":"diversify the clients that they're using and frequently the bloc the network just converges to one client because which is","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=644s"},{"start_seconds":652,"text":"you know the cheapest or the faster so whatever has better um configuration parameters which undermines the whole point of","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=652s"},{"start_seconds":659,"text":"having multiple implementations because um you know if 50 percentable leaders are running the same light client the same client then you know if you have","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=659s"},{"start_seconds":667,"text":"coordinated error it's going to go down anyway with sharded blockchains you frequently have a mechanism flashing","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=667s"},{"start_seconds":675,"text":"that allows you to run uh shards optimistically where you kind of put phase into the charging","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=675s"},{"start_seconds":683,"text":"validators on each chart to produce valid blocks but then at the same time you supervise them and if you notice that the blocks are invalid you slash them","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=683s"},{"start_seconds":691,"text":"so what has happened on some short blockchains and what you want to avoid is that that when slavishing happens because of","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=691s"},{"start_seconds":699,"text":"some bug which happened hasn't happened to near we also haven't enabled sharding yet but if validators want to really avoid being","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=699s"},{"start_seconds":707,"text":"slashed because there is a bug in the in the code or because they have messed up the devops um the setup then they","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=707s"},{"start_seconds":714,"text":"might have an incentive to run multiple clients with different implementations side by side and if they disagree on the block production then they would","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=714s"},{"start_seconds":723,"text":"terminate their clients without producing any block so there is an inherent incentive on the blockchains with slash into for the","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=723s"},{"start_seconds":730,"text":"layers to run multiple clients and uh maybe even the same client but uh the same client that uses different","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=730s"},{"start_seconds":738,"text":"virtual machines it can also be an alternative for validators so there are many uh difficulties with","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=738s"},{"start_seconds":747,"text":"running web assembly virtual machines on the safety side that we have discovered so the biggest one is the strict separation of deterministic and","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=747s"},{"start_seconds":755,"text":"ephemeral errors so uh what i mean by deterministic versus ephemeral errors is that the deterministic error is the kind of an","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=755s"},{"start_seconds":762,"text":"arrow that has been introduced by the contract developer let's say they have written a program that you know does division by zero or exceeds the","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=762s"},{"start_seconds":770,"text":"the maximum allowed stack sizing in web assembly uh non-deterministic ephemeral error is this the stuff that happens um","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=770s"},{"start_seconds":779,"text":"because there is a fluke i don't know like you you run in some other programs on your uh on your uh in cloud instance and you","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=779s"},{"start_seconds":788,"text":"know node runs out of memory or you have this corruption and this is something that can be happening just only on your evaluator","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=788s"},{"start_seconds":796,"text":"machine or it can be happening on for instance on all the little machines that run in the same kernel version this is something that has happened in one hour","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=796s"},{"start_seconds":805,"text":"testnets and so it's extremely important to be able to separate these errors that are being piped to you by the","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=805s"},{"start_seconds":812,"text":"virtual machine into these two strict categories because if you make a mistake and you confuse deterministic error for fmero","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=812s"},{"start_seconds":820,"text":"because of some bug in a virtual machine then what might happen is that someone might be able to craft a smart","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=820s"},{"start_seconds":828,"text":"contract that triggers a deterministic error and causes uh all the nodes think that there is an ephemeral arrow and what we do","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=828s"},{"start_seconds":836,"text":"with the femoral errors is that we just shut down the node we don't want to deal we don't want to have a special cover mechanism when you have a","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=836s"},{"start_seconds":844,"text":"discorruption uh happening so we just shut down the note in this case and if we make a mistake and miss categorize humanistic","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=844s"},{"start_seconds":851,"text":"air force primaril then someone can crush the entire network which hopefully doesn't is not possible to happen if you miscategorize","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=851s"},{"start_seconds":859,"text":"a femoral error for deterministic error then what might happen is that some nodes they might think that they","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=859s"},{"start_seconds":867,"text":"produce a valid block but is actually invalid and if if this happens uh on all let's say versions of the same","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=867s"},{"start_seconds":876,"text":"kernel across a subset of the nodes in your network then you might have a network split or you know a bunch of nodes being kicked out which is also","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=876s"},{"start_seconds":883,"text":"nasty and you don't want to happen so it's it's the top of our mind to the separate deterministic and ephemeral errols very precisely for the buzzing","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=883s"},{"start_seconds":892,"text":"virtual machines and occupies a lot of our time uh doing it correctly uh full compatibility with violism","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=892s"},{"start_seconds":899,"text":"standard also turned out to be not super trivial because there are very tiny corner cases","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=899s"},{"start_seconds":907,"text":"around trap handling that we found out are not handled precisely on about the virtual machines","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=907s"},{"start_seconds":915,"text":"and um this is something we had to we noticed only post facto uh forward compatibility with wasm's turner is also important for us so i'm","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=915s"},{"start_seconds":924,"text":"gonna be talking later on how we do the gas injector and instrumentation vason contracts and the new way of doing the gas","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=924s"},{"start_seconds":932,"text":"injector makes a strong assumption that certain parts of azam standards are not going to be extended in the future and so that's basically an assumption so","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=932s"},{"start_seconds":941,"text":"forward compatibility wasn't standard that we're going to talk about later then you also want to canonicalize the floats","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=941s"},{"start_seconds":949,"text":"uh this is something that we do for all our contracts initially we decided to just sanitize uh our","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=949s"},{"start_seconds":956,"text":"contracts and uh prohibit deploying the contracts on on your blockchain that uses use the floats but we very very quickly found","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=956s"},{"start_seconds":965,"text":"out that this leads to very bad developer experience because like ras developers they just want to import libraries","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=965s"},{"start_seconds":973,"text":"um when they develop smart contracts and surprisingly even if you're importing some library that doesn't use","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=973s"},{"start_seconds":981,"text":"flows for like math operations let's say you're importing some cryptographic library it still might be the case that you will","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=981s"},{"start_seconds":988,"text":"have some float operations in there because uh of how for instance um rust does string formatting","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=988s"},{"start_seconds":996,"text":"uh you know for for panics um so we decided to allow floats uh in","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=996s"},{"start_seconds":1003,"text":"in a near smart contract but now we can equalize them and uh finally this entanglement","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1003s"},{"start_seconds":1011,"text":"implementation of other virtual machines from the protocol uh turned out to be also not super trivial uh there are some minute details about","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1011s"},{"start_seconds":1019,"text":"how the uh stack handling is is being done by it was in virtual machines or how how was virtual machines interact","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1019s"},{"start_seconds":1027,"text":"with your um uh instrumentation that made some of these details leak into a protocol spec","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1027s"},{"start_seconds":1034,"text":"and ties to a specific implementation of the vason virtual machine that we're currently slowly removing um","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1034s"},{"start_seconds":1043,"text":"we also had lots of challenges with determinism in virtual machine well first of all as all of you know here","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1043s"},{"start_seconds":1051,"text":"the worst case scenario um in in a virtual in the blockchain spaces is basically what determines the the","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1051s"},{"start_seconds":1058,"text":"fees usually it's not the best case scenario because if you if you optimize your fees to target for the best case scenario","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1058s"},{"start_seconds":1065,"text":"then your blockchain is going to be vulnerable someone might be able to trigger the worst worst case scenario so um yeah the the worst case scenarios","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1065s"},{"start_seconds":1074,"text":"dictate the fees which did dictate tps on your blockchain at the end of the day you can try to special case best case scenario","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1074s"},{"start_seconds":1082,"text":"and say for instance that if your contract hits doesn't hit some corner cases then the fees are generally lower","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1082s"},{"start_seconds":1091,"text":"unfortunately that leads to bad devex well first of all your fees might be unpredictable so uh if developers","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1091s"},{"start_seconds":1099,"text":"find out that in certain cases uh the smart contract execution is much more expensive than in other cases based on some so like super low level","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1099s"},{"start_seconds":1108,"text":"internal mechanism and how webassembly virtual machine functions then the box is going to be","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1108s"},{"start_seconds":1114,"text":"uh pretty bad but also special case in best cases will lead to increased complexity of the protocol which we also want to avoid we try to keep our","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1114s"},{"start_seconds":1123,"text":"protocol pretty simple we also want uh the execution time to be similar on similar platforms","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1123s"},{"start_seconds":1132,"text":"we have a target hardware at near but we want people to be able to run our notes on almost any uh four core cpu plus 16","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1132s"},{"start_seconds":1140,"text":"gigabytes of ram machine uh so we don't want the execution time to vary drastically across different platforms","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1140s"},{"start_seconds":1147,"text":"and finally um big challenge with determinism is how do you decide what are your fees and this is a completely separate topic","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1147s"},{"start_seconds":1156,"text":"that i'm gonna get to soon oops","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1156s"},{"start_seconds":1164,"text":"sorry sorry skip the slides um there are performance challenges uh with virtual machines","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1164s"},{"start_seconds":1172,"text":"so one of them is the time to start um it's just the time that it takes for your virtual machine to warm up before","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1172s"},{"start_seconds":1181,"text":"it starts uh running the smart contract and uh there are multiple factors that contribute to time to start one of them","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1181s"},{"start_seconds":1190,"text":"is this visualization time so it does matter what kind of the serializer you use","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1190s"},{"start_seconds":1197,"text":"to store your compiled module and there is also the contributing factor of the io cost so in most cases you're probably not going to be storing","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1197s"},{"start_seconds":1204,"text":"your compile module in memory you're probably going to be storing it on the disk as so the the time that it takes to load it is a","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1204s"},{"start_seconds":1213,"text":"big contributing contributor to the execution time on the smart contract the the loading of the module is also depends on many many variables in","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1213s"},{"start_seconds":1221,"text":"your virtual machine and any smart contract it depends on the size of the code it depends on the size of this data section in your wasm","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1221s"},{"start_seconds":1230,"text":"a number of the methods in wasm surprisingly also frequently contribute to the time it takes to load the module","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1230s"},{"start_seconds":1237,"text":"and obviously a number of the imports also contribute to that then call contracts","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1237s"},{"start_seconds":1245,"text":"is is a big problem someone can deploy a contract that they never call for many years and then they try to call it two years later","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1245s"},{"start_seconds":1253,"text":"and uh it can be living in a cold storage so the question is do we separate cold and hot storage in in a blockchain is a pretty big question","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1253s"},{"start_seconds":1262,"text":"uh right now we don't which means that the fees for the cold contracts dictate the or fees for all all of the contracts","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1262s"},{"start_seconds":1270,"text":"but in the future we might start separating them because certain contracts are going to be executed all the time like exchanges and we want them","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1270s"},{"start_seconds":1278,"text":"to be cheaper than contracts that executed very rarely and finally the compilation time","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1278s"},{"start_seconds":1287,"text":"the compilation time is is a challenge uh even with single pass and streaming compilers","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1287s"},{"start_seconds":1295,"text":"compilation takes slightly different time and so what we had to do we had to go all over the wasmer code and remove","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1295s"},{"start_seconds":1302,"text":"things like randomly seated hash maps and um like some multi-threading to make the compilation time uh consistent","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1302s"},{"start_seconds":1311,"text":"um yeah so there are also um safety oh wait","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1311s"},{"start_seconds":1320,"text":"one second my presentation is lagging i'm sorry for that","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1320s"},{"start_seconds":1330,"text":"yeah so finally uh how how do we decide the fees so this is the big problem for every blockchain because obviously every operation","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1330s"},{"start_seconds":1339,"text":"on a blockchain should take certain amount of uh money right you don't want stuff to be","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1339s"},{"start_seconds":1346,"text":"executed for free on your blockchain so how do you decide what costs what and especially when it comes to the virtual machine that has a very complex","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1346s"},{"start_seconds":1356,"text":"internal mechanisms so the way many blockchains uh address it they either do the educated guess","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1356s"},{"start_seconds":1363,"text":"sometimes because um if they if you have host functions which are cryptographic primitives you might be able to guess uh how much","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1363s"},{"start_seconds":1371,"text":"it should cost but most of the time the way blockchains do it is by running time-based benchmarks like they execute uh","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1371s"},{"start_seconds":1379,"text":"operations over and over and over and time them and determine based on the timing how much they should cost so we found out that this is um","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1379s"},{"start_seconds":1388,"text":"not as precise as we want it to be very frequently time-based benchmarks even when they run","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1388s"},{"start_seconds":1394,"text":"for days uh produce very high spread of execution time for the same fees","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1394s"},{"start_seconds":1401,"text":"and so what we did uh we we took a big part of our node uh which is runtime and roxdb and virtual machine and we're","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1401s"},{"start_seconds":1408,"text":"running it on the cpu emulator qmu and uh i told you we also removed a bunch of the sources of non-determinism","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1408s"},{"start_seconds":1416,"text":"and so now we just count the actual cpu instructions that our node takes to execute those various separations and we were able to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1416s"},{"start_seconds":1424,"text":"achieve precision and represent reproducibility for most of the fees to be within five percent and for a couple of fees that","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1424s"},{"start_seconds":1433,"text":"are specifically involved with io uh it's within 10 15 precision which i think is a is a good result","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1433s"},{"start_seconds":1442,"text":"i mean estimating diffuse is still very difficult well first of all something that we haven't addressed yet is that different cpu operations obviously","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1442s"},{"start_seconds":1450,"text":"have different complexity and different execution time uh we do treat them the same right now we uh run lots of files and to make sure","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1450s"},{"start_seconds":1458,"text":"we are not abusable in this way that someone cannot really easily construct a contract that abuses certain cpu operation","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1458s"},{"start_seconds":1466,"text":"and also iu operations are really difficult to benchmark and assign the fees um to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1466s"},{"start_seconds":1473,"text":"it it's a well known that uh benchmarks for ssds are especially tricky so we don't even try to write our own ssd","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1473s"},{"start_seconds":1481,"text":"benchmark we use third-party benchmarks uh to estimate it and uh finally i mean just running things in emulator is extremely slow","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1481s"},{"start_seconds":1490,"text":"and um we do want to run stuff for many iterations uh even inside emulator for several reasons","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1490s"},{"start_seconds":1497,"text":"uh one of it is just to reduce the volatility in case we forgot you know some of them randomly seated hash maps and stuff like that but another one is","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1497s"},{"start_seconds":1506,"text":"to catch the corner cases so we try to uh generate a wide array of the input and uh just","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1506s"},{"start_seconds":1515,"text":"to make sure we didn't forget some of the corner cases that can have a disproportional computation time that our fees are","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1515s"},{"start_seconds":1524,"text":"actually deterministic so yeah these are tricky uh then as i promised i want to talk","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1524s"},{"start_seconds":1532,"text":"about the gas injector as we know instrumentation for web assembly is is quite expensive","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1532s"},{"start_seconds":1539,"text":"uh for some uh for some cases if you use pivaz motels which is one of the most popular instrumentation libraries out there","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1539s"},{"start_seconds":1548,"text":"the the cpu instructions caused by the instrumentation code itself can be 90","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1548s"},{"start_seconds":1555,"text":"95 of the cpu instructions of the entire smart contract so the instrumentation can be dominating the cost of running","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1555s"},{"start_seconds":1563,"text":"the smart contract and this is mostly because the uh the go-to instrumentation uh approach right","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1563s"},{"start_seconds":1570,"text":"now is to inject host function call on every uh wasn't block which is of course expensive because you're crossing guests","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1570s"},{"start_seconds":1577,"text":"and guest host boundary every every wasn't blocked and so what we did here we looked at uh what","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1577s"},{"start_seconds":1584,"text":"wasmer two is doing and what they do is um they inject a global variable uh that they modify without crossing the uh host","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1584s"},{"start_seconds":1593,"text":"guest boundary um and they just modified on every wasn't block and they do this injection in the middleware so","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1593s"},{"start_seconds":1601,"text":"we we took the same approach we just modified pivaz materials in our fork uh to do this kind of instrumentation","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1601s"},{"start_seconds":1609,"text":"so anyone any blockchain that uses wasm you guys are welcome to use this modify and pivazo motels","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1609s"},{"start_seconds":1616,"text":"um it allows us to reduce the cost of running wasn't smart contracts uh four times according to our most recent benchmarks","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1616s"},{"start_seconds":1625,"text":"and also it doesn't tie you to any specific webassembly virtual machine so that's why we're not using a wasmer's version of the","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1625s"},{"start_seconds":1634,"text":"of this instrumentation because we wanted to also work quasim time and other kind of virtual machines","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1634s"},{"start_seconds":1641,"text":"because instrumentation needs to be vm agnostic unfortunately uh gas injector design","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1641s"},{"start_seconds":1648,"text":"does leak into the protocol spec not something that we wanted to have and this is because uh when you inject a","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1648s"},{"start_seconds":1655,"text":"different amount of assembly code into your webassembly smart contract uh now your contract might run out of memory earlier or later","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1655s"},{"start_seconds":1664,"text":"uh or like might might hit the stack size limit earlier or later so it does um kind of leak into the protocol spec which is quite unfortunate we haven't","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1664s"},{"start_seconds":1673,"text":"figured out what to do with it yet and but the good news is that you can actually","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1673s"},{"start_seconds":1680,"text":"write a very suboptimal uh gas injectors uh at least at near uh we don't uh do gas injection on upon the contract","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1680s"},{"start_seconds":1688,"text":"execution we do it upon the contract deployment um and the contract compilation and contract deployment is already quite expensive so you can run","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1688s"},{"start_seconds":1696,"text":"a very simple and suboptimal gas injection there and not don't don't worry too much about its performance","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1696s"},{"start_seconds":1706,"text":"yeah so as i said uh we have a whole bunch of languages currently four that have as","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1706s"},{"start_seconds":1714,"text":"the case either um pending or already been used for quite some time by the community uh interestingly for us","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1714s"},{"start_seconds":1722,"text":"we did have uh some requests from the community to have std and nostalgic versions of the sdk most of the time a community actually","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1722s"},{"start_seconds":1731,"text":"wants to use std version of rast sdk because they do want to import lots of rust libraries and not all of the rust","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1731s"},{"start_seconds":1739,"text":"libraries support as the no std mode and so we had to really optimize an std","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1739s"},{"start_seconds":1746,"text":"version of rast sdk and there are also alternative libraries written by the community that you can use","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1746s"},{"start_seconds":1754,"text":"the cool thing about um languages that do not have manual manner memory management like assembly script","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1754s"},{"start_seconds":1763,"text":"and grain is that you can actually just turn off their garbage collection because the contracts as i said are short-lived","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1763s"},{"start_seconds":1771,"text":"and we can totally afford uh allowing them using mini megabytes of memory if they need to","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1771s"},{"start_seconds":1778,"text":"without delocating it so that's an upside of using languages like that","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1778s"},{"start_seconds":1787,"text":"and actually we haven't made our mind whether we're going to support a garbage collection on a protocol level yet because i mean garbage collection is","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1787s"},{"start_seconds":1795,"text":"coming to the web assembly spec so we have an opportunity to support a garbage collection on a particular level but we haven't made our mind yet about","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1795s"},{"start_seconds":1802,"text":"it we had to do lots of sdk site optimizations because people writing contracts are near they want their contracts to be smaller","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1802s"},{"start_seconds":1811,"text":"in size because that means the fees are going to be smaller for compiling such contracts or for executing such contracts","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1811s"},{"start_seconds":1818,"text":"technically it is possible to run extremely tiny contracts on near if you use rust you know if you if you do not use std and if you use all the best","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1818s"},{"start_seconds":1826,"text":"guidelines for writing tiny code you can you can actually have less than one kilobyte contracts when once they compile to have assembly but your developer experience will","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1826s"},{"start_seconds":1835,"text":"suffer greatly so most of the projects even projects that care a lot about the performance and about the size they","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1835s"},{"start_seconds":1843,"text":"actually still use our as the case with std so the main contributors to the size","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1843s"},{"start_seconds":1852,"text":"actually for these contracts turn out to be obviously strings errors and uh you also got to be very careful","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1852s"},{"start_seconds":1858,"text":"with std because it has different code for x86 and wasm so you want to sometimes dive into the std","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1858s"},{"start_seconds":1865,"text":"implementation and make sure that when you compile to webassembly you're compiling exactly what you want to compile because","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1865s"},{"start_seconds":1873,"text":"it can be complete different code and uh the other interesting thing is that we don't actually use uh all these","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1873s"},{"start_seconds":1880,"text":"cool tools that web assembly ecosystem has for optimizing the uh web assembly like wasm opt and wasn't snip and mostly","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1880s"},{"start_seconds":1889,"text":"because we don't want our developers to shoot themselves in the foot wasn't snip is a very aggressive tool and someone can accidentally over do","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1889s"},{"start_seconds":1896,"text":"optim contract optimization and just cut too many things so we just don't advise our users on using","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1896s"},{"start_seconds":1904,"text":"it yeah um there are interesting things to be said","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1904s"},{"start_seconds":1911,"text":"about using basm tailored languages like assembly scripting green they have pros and cons so pros obviously is that","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1911s"},{"start_seconds":1919,"text":"they made to be efficient when compiled to webassembly as i said like assembly script even has a self hosted compiler like you can","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1919s"},{"start_seconds":1928,"text":"compile assembly script with assembly scripts which is amazing and and grain was designed specifically","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1928s"},{"start_seconds":1935,"text":"to be uh efficient when compiling to webassembly um so it means you can write in some cases highly optimized contracts with","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1935s"},{"start_seconds":1944,"text":"with assembly script in green the disadvantages of course uh of these languages is that they have they still have small community that means you have uh very","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1944s"},{"start_seconds":1953,"text":"few libraries and it's still the case that uh when you want to write a smart contract an assembly script you need to import assembly script library like you cannot","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1953s"},{"start_seconds":1962,"text":"at least not on near you cannot import a library written in another language in compiled web assembly yet we haven't enabled this","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1962s"},{"start_seconds":1970,"text":"um a possibility yet and also they haven't been battle proven unlike rust you know that large companies like google and mozilla are using","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1970s"},{"start_seconds":1978,"text":"uh for their uh uh browser development uh assembly script and grain haven't been battle proven so we just don't","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1978s"},{"start_seconds":1985,"text":"advise uh our defy projects on using them yet","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1985s"},{"start_seconds":1991,"text":"the other interesting thing is that we learned quite a bit from ethereum um experience with the assembly","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1991s"},{"start_seconds":1999,"text":"we liked the idea of the execution environments in ethereum and while we don't exactly have execution environment we have several layers of virtualization","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=1999s"},{"start_seconds":2008,"text":"people can run solidity contracts on near because our evm which is splitting vm is just a web assembly smart contract that","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2008s"},{"start_seconds":2017,"text":"runs on top of our web assembly virtual machine and so people can already run","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2017s"},{"start_seconds":2023,"text":"up to 4 million gas contracts on inside our evm and very soon this number is going to increase by several x","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2023s"},{"start_seconds":2032,"text":"maybe form x that will allow you to run pretty much any transaction that you can run on ethereum on on near","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2032s"},{"start_seconds":2041,"text":"without any constraints and we haven't even uh piped the host functions from the uh all of the host","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2041s"},{"start_seconds":2048,"text":"functions from the evm into into our host functions so many of the host functions inside the edm are actually run in web assembly","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2048s"},{"start_seconds":2056,"text":"um which makes it quite optimal but it still works and obviously like rust assembly script and grain and zig they're all executed as","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2056s"},{"start_seconds":2065,"text":"the first class citizens without extra layers of virtualization directly on our wasm virtual machine","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2065s"},{"start_seconds":2073,"text":"finally i wanted to tell you how we're planning to um test these contracts so we do have already um quite a few tests","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2073s"},{"start_seconds":2080,"text":"and frameworks that peop that various projects used to test web assembly contracts on nir but we we came up with this cool idea of","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2080s"},{"start_seconds":2088,"text":"having a unifying unified testing approach to any kind of contracts that people are deploying on your blockchain","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2088s"},{"start_seconds":2095,"text":"and this is achieved by basically test and web assembly assembly contracts","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2095s"},{"start_seconds":2105,"text":"like there were live contracts so you would take you would take a test test and you would compile it together with the contract in such a way","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2105s"},{"start_seconds":2113,"text":"that the tests themselves are basically your contract cost functions then you would deploy uh this stuff to uh to your","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2113s"},{"start_seconds":2120,"text":"node and then you would interact with with test as if there was contract functions which allow you to unify lots","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2120s"},{"start_seconds":2128,"text":"of the experience around the run and the contra code and make your testing experience as close to production","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2128s"},{"start_seconds":2135,"text":"to production as possible so your code and test is going to be highly reproducible in production too","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2135s"},{"start_seconds":2144,"text":"um so that was it uh that was not a very long presentation but if you","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2144s"},{"start_seconds":2153,"text":"have any kind of interest in wasm languages if you like not just grain and zig but there are other languages that you like and you want um","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2153s"},{"start_seconds":2161,"text":"and you want them uh and you want to build an sdk for them or you like some web assembly virtual machine a compiler","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2161s"},{"start_seconds":2169,"text":"please write us and we might give you a grant to work on it so thanks everyone","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2169s"},{"start_seconds":2177,"text":"are there any questions in the chat so thank you so much maxim that was very","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2177s"},{"start_seconds":2185,"text":"interesting and we have one question uh why would you need to support that many languages isn't rust enough for all","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2185s"},{"start_seconds":2194,"text":"purposes well so nier is a i mean developer focus blockchain so we","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2194s"},{"start_seconds":2201,"text":"want people coming to near to have zero barrier when they develop on us and you know people have developers have all kind of backgrounds some people","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2201s"},{"start_seconds":2210,"text":"used to work mostly with c plus plus some people used to work with python so we don't want to force them to use rust we want them to be able to come to near","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2210s"},{"start_seconds":2218,"text":"and just find whatever language they've been using all their life as a language that we support and start developing on it it's basically reducing the barrier for","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2218s"},{"start_seconds":2226,"text":"the developers that's the goal but also we like supporting open source projects like we sponsor an assembly script with sponsoring green and zig and and and uh","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2226s"},{"start_seconds":2235,"text":"wasmer so why not help all these languages if we can","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2235s"},{"start_seconds":2243,"text":"it's amazing to hear that you're helping those projects you know like they're they really need it and","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2243s"},{"start_seconds":2251,"text":"it's great for the developing the whole infrastructure of the ecosystem the next question do you have any plans","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2251s"},{"start_seconds":2259,"text":"for enabling cross chart contract to contract contract to contract interaction so this is something that's been working","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2259s"},{"start_seconds":2268,"text":"from from the start so right now we have a single chart but in test environment we run in like eight shards and we're gonna roll out eight shards very soon in","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2268s"},{"start_seconds":2276,"text":"the next couple of months um so this is not something that we add later this has been already built in from the start when people develop smart","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2276s"},{"start_seconds":2285,"text":"contracts on near they don't even think which chart the smart contract is running on this is very similar to how you write javascript programs like when you write javascript","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2285s"},{"start_seconds":2293,"text":"program and use promises you don't think which cpu core is running which part of your javascript program right now you just you know use promises and it","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2293s"},{"start_seconds":2301,"text":"somehow gets executed behind the scenes so it's really very similar to when you write a decentralized app on on near and have various","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2301s"},{"start_seconds":2309,"text":"uh and you have it partitioned in various contracts or you interact with exchange or swaps you don't even know either right on the same chart or are they running on","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2309s"},{"start_seconds":2317,"text":"different charts and there is like no incentive in here to collocate uh to collocate contracts on the same chart we don't want to have any kind of","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2317s"},{"start_seconds":2327,"text":"perverse incentive for people to try to fight and and co-host on the same chart with some exchange or something like that","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2327s"},{"start_seconds":2334,"text":"it's all exactly the same exactly the same fees exactly the same finality time uh for cross-contract interactions when","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2334s"},{"start_seconds":2342,"text":"they talk either within the same chart or across different charts and actually uh in a in a year or two we're going to enable dynamic resharding that is going","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2342s"},{"start_seconds":2351,"text":"to be rebalancing our shards to be of the same size and in that case even if you're on the same chart with","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2351s"},{"start_seconds":2358,"text":"some contract right now in the next hour it might change and it might be resharded and you might end up on different shards","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2358s"},{"start_seconds":2365,"text":"uh so inherently at near there is no distinction on whether you're on the same chart or whether you're on different charts from the developer","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2365s"},{"start_seconds":2373,"text":"perspective okay thank you so much","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2373s"},{"start_seconds":2382,"text":"um i think that's it for the questions thanks everyone at least for now thank","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2382s"},{"start_seconds":2388,"text":"you so much maxine","url":"https://www.youtube.com/watch?v=bF8PCJ3nU-Y&t=2388s"}],"youtube_url":"https://youtube.com/watch?v=bF8PCJ3nU-Y","url":"https://near-pedia.xyz/videos/bF8PCJ3nU-Y"}