The Next Frontier in Blockchain Performance:Unlocking Rust for Smart Contracts | Mahsa-Offchainlabs
Ethereum Denver·Thu, Oct 9, 2025, 12:00 AM
Enabling Rust for smart contracts brings blockchain closer to traditional developers, diversifying the ecosystem. We'll discuss cross-language tooling, performance, and security, comparing Rust's potential to existing approaches like Solidity, along with key challenges and solutions. 🚀 Get Ready for ETHDenver 2025! 🚀 We're already hard at work preparing for next year's biggest Web3 event! Keep your eyes peeled for more info on ETHDenver 2025—it’s going to be epic! 🌟
Transcript
[Music] all right uh thank you uh hi everyone welcome uh to the talk and uh I I'm really happy to be back on stage again for E denber 2025 and today uh we're going to talk about uh unlocking Ross uh for smart contract all right so a little bit about me um my name is ASA I'm an integration engineer adop chain Labs uh we're the initial Builders of arbitrum uh it's arbitrum for those of you that you don't know uh it's an optimistic rollup solution for scaling ethereum so we have been scaling ethereum for years and now offchain Labs is uh the service provider to the Dow so we work on uh codebase protocol upgrades uh we provide tooling and those things I'm also doing PhD on defi uh and security risks at Concordia University in Montreal and these are my social uh feel free to reach out to me after the talk if you have any question about the talk or you want to talk about arbitrum uh in general all right uh so uh who here have written code in Ross except those two who have worked on silus for a while okay all right okay so for those of you that you did and those who didn't uh I have to say that Ross is all about memory safety and performance so it has uh a lot of great advantages uh including memory safety as I said so in Ross there's no null pointers uh there's no buffer overflows and there's no undefined uh behavior and this is a huge Security deal and Rost is also incredibly fast uh so it has an execution speed really high even close to C and uh it has great tooling around that we have cargo crates.io and we have extensive debugging and testing Frameworks that allow developers to write code in Ross and they're also able to debug really easy and on top of these uh Rost has been widely used in major system programming for years including uh Linux and uh browsers like Firefox all right so uh if r is such a powerful tool why haven't we used it for smart contract from the beginning and the answer lies in how etherium was designed so ethereum runs on top of ethereum virtual machine evm which itself uh initially was designed around solidity and wiper so if you want to run a smart contract on top of evm uh you have to actually write it in either of these languages um I mean solidity and wiper and then it compiles down to evm M by code and the problem is rust doesn't get compiled to evm by code and instead it's compiled down to wasm or machine code and uh these are not directly supported by evm and because evm was uh designed around compatibility rather than performance it has a lot of uh gas restrictions and computational overhead that make a lot of smart contract the heavy ones especially uh to uh to be really expensive to run on chain uh yeah so now we have arbitrum Stylus it is the next Generation programming language uh for all of the arbitrum chains and it actually enables uh smart contract developers to write smart contract not only in solidity but it's in Rost C C++ and more and Stylus is actually a GameChanger cuz uh we just talked about Rost a lot of advantages and uh we know that solidity is all about security and decentralization so with silus developers get the best of the both word so they're able to run uh smart contract uh in a very fast and cheap environment uh while on uh ethereum compatible chain and uh it is fully decentralized of course so does that mean that uh you have to choose between wasm and evm and the answer is absolutely not so what is really cool about Stylus is that it enables multilanguage smart contract on a single chain so you have one single chain you can write as many smart contracts in any of those languages solidity Ross C and then these contracts uh although they're written in different languages they're fully composable so they can talk to each other they can interact they can call each other uh without any without you even noticing that and uh what is really important is that Stylus is not a new chain it's not a new L2 and instead stylus runs inside arbitrum Nitro stack the technology behind the arbitrum chains and uh because arbitrum chains are fully interoperable with ethereum uh any any smart contract that you write uh in stylus would be composable with other applications that are on are running on ethereum blockchain and we call this evm plus and that means we don't want to replace or we don't want to abandon solidity and instead we want to extend the ecosystem we want to open the doors and bring a lot more Community inside and uh let them write code uh on evm uh compatible chains and yeah so as I said uh we this evm plus because stylus introduces two composable VMS that they run next to each other so on one side we have like the evm the traditional one that runs 3D Smart contract and on the other side we have the wasm that is that runs Rost C and C++ and these two they basically share one state tree and one database so honestly like there's seamless execution that is going on between them and they're fully composable yeah so some breakthroughs uh as I said uh Rost is incredibly fast so Stylus is really fast and uh it has faster run time with wasm execution and it has better compiler optimizations with Rost and c and uh we did a lot of experiments and benchmarking and we found that Stylus is around 70 times faster in execution than solidity this is huge and because of all these great uh advantages stylus enables what was previously Impossible on chain so right now with stylus you can do a lot of heavy cryptographic functions that were not previously possible you can do Bridges at lower cost you can do more efficient execution for gaming and Ai and you can even do a one pre-compile experimentation for advanced ethereum research this is really more targeting researchers and uh more breakthroughs uh right now there is around 20K solidity developers in the world but we have 3 million Ross developers and 12 million C++ developers so as I said we're not uh abandoning solidity and instead we want to open the door we want to expand our community and users and we want to bring more users on chain all right so now that we understand why stylus is exciting and all uh we have to know how it performs in terms of uh execution and cost uh in a real world scenario compared to its solidity counterpart and the best way to do that is through benchmarking and you can do that by running the same exact same computation both in solidity and stylus and then you compare the gas cost and execution speed and for the sake of this presentation I chose Matrix multiply ation because it's just such a very heavy uh computational task that uh I I thought it would be cool to see how uh it kind of differentiates stylus from solidity in terms of um performance and gas cost so here's the QR code that takes you to the repo it contains all the code uh for both solidity and stylus implementation I also included two scripts that uh encapsulates everything for you you just read need to run the script and it does everything for you you're able to get those numbers that I'm going to walk through uh uh in the next slides all right so let's start with the solidity implementation so uh we had to uh generate Matrix matrices online right so we implemented onchain pseudo random generator uh on solidity to populate these matrices on chain and it uh the result show that it failed Beyond 40x40 due to out of gas errors and that comes from costly dynamic memory allocation and computation in sidity and on the other side we have the stylus implementation that we implemented the same onchain pseudo random uh generator for populating the Matrix and stylus leverages Ross swm execution and it like inherently avoids solidity high gas cost from uh dynamic memory location and our results show that Stylus is 99% lower gas cost compared to sidity this is great and it can even scales uh scale Beyond sidity limit and it could handle really larger uh matrices a lot efficient more efficient than S did so in like when implementing these two instances I I uh faced some challenges uh especially when I was working on a stud code uh so first off it turned out that M Matrix generation alone burned too much gas so onchain Matrix generation was so expensive that it didn't even let me get to the multiplication so uh it hit the gas limit so the solution that I attempted was I tried to separate the generation from the multiplication but still generation failed so the solution for that that I uh came up with was in in inad of storing those matrices in Contra contract storage which is really expensive I used event logs uh to avoid high gas fees uh so that made generation feasible but still multiplication failed at size 40x 40 and yeah so it turned out the multiplication as I said at the beginning it is a really heavy computational task and is it is the real bottleneck so it cost too much gas even with those storage optimizations that I did and uh I was not able to go beyond size 40x40 and it makes larger large scale computation INF feasible in solidity so yeah the these are the challenges that I faced expensive Matrix generation on chain uh I used event logs even did didn't really fully solve the problem and uh it turned out the multiplication was the real bottleneck so sidity struggles with large large unchain computation and there's it it is really not practical for heavy workloads uh we have the example here which is matrix multiplication so how stylus tackles all these challenges that I just walked you guys through first off uh stylus had very efficient Matrix generation and because it is Rost and BM execution makes on chain uh random generator really cost efficient I didn't have any problem with that stylist dynamically allocates memory and it avoids all those really heavy storage costs that solidity had and uh yeah we were able to generate those matrices on chain without hitting any gas limit and uh yeah we had optimized storage management so as I said silus efficiently stores matrices in memory instead of relying on expensive contract storage uh so there was no need for me to that take that extra step of uh using event logs as a workaround so storage costs remain low even though like we used a very large Matrix unlike solidity and stylus even solved the real bottleneck which was the multiplication itself so it executed matrix multiplication at a fraction of solidity gas cost and uh successfully multiplied uh large matrices it can go even Beyond 70 by 70 without hitting the gas limit and storage cost remain low even for large matrices uh unlike sidity and uh what is really exciting about Stylus is that we have Smart caching so stylus itself introduces something called cach manager which uh which what it does it kind of stores the frequently accessed contract in memory and so every time you call that contract it loads it from memory rather than storage so it makes the costs really cheaper uh than normal yeah so this is the product I got for the gas cost for doing the matrix multiplication for both stylus and solidity as you can see stylus uses very lower gas for the same operation on chain and solidity is gas cost increases exponentially uh as the size of matrixes uh grow and like like I honestly I couldn't go beyond 40 by 40 it I I got out of gas error and I hit the gas limit as well but stylus could go beyond 70x by 70 yeah so stylus exploded H in gas cost uh and failed at 40 by 40 uh and yeah if you run those scripts that I the CCO was there you can see that silus can go beyond so there's no honestly there's no limitation for that and uh yeah stylus scales smoothly handling even 70 by 70 matrices efficiently with much lower gas costs and yeah so it stylus gas usage is orders of magnitude lower than solidity so our numbers show that it is around 97 to 99% cheaper and again as I said this is the repo please feel free to go check it out and run the code and contact me if you have any ideas or like any feat backs or anything and we have some tooling and resources for stylus so stylus has been alive for quite a while now we're actively working on that we have a great documentation around that feel free to go check it out uh we have Stylus bu examples where you can find basic and a little more complex examples in stylus if you want to start experimenting we have Stylus SDK that uh makes things really easy for you to to experiment and uh there there are some examples in that repo as well I do encourage you to go check it out and at the end if you have any question any feedback or anything in general about stylus do feel free to check out our stylus chat and uh yeah we regularly check do check the chat and we try to be helpful to the community uh so that you can try stylus and with that I conclude the talk thanks for listening
Automatic transcript — names and jargon may be misspelled.