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

Loading player…

What Ethereum can learn from Cosmos by Ethan Frey

Ethereum DenverMon, Oct 9, 2023, 12:00 AM

As Ethereum moves closer to a Wasm-native runtime, it is good to learn from other technically strong Wasm projects. CosmWasm is a Cosmos-native smart contract engine based on Wasm, designed from the ground up with a security-first mentality. We learned much from Ethereum’s successes and failures and would like to share our experiences as well. Cosmos is a network of over 50 PoS Blockchains connected via trust-minimized IBC bridges. It has been a pioneer in BFT consensus algorithms, secure bridging technology, and the multi-chain / app-chain thesis since 2016. CosmWasm started in 2019 and is now the best smart contract platform made for Cosmos… but it’s not just for Cosmos. It is the reason many projects have migrated to Cosmos - Engima (now Secret) and dYdX from Ethereum; Burnt Finance and Katana from Solana; Datachain from Hyperledger and more. It powered Terra’s DeFi ecosystem. And Composable Finance is even running CosmWasm contracts on a Polkadot parachain. CosmWasm is also the first multi-chain native smart contract engine, allowing contracts to directly interact with other chains by defining custom IBC protocols. For example, a DAO on Juno can vote to issue an NFT on Stargaze, and place protocol-owned liquidity to it’s pools on Osmosis. It is also being used to build out Mesh Security, a decentralized, multi-chain future for PoS chains to share security bidirectionally. We would love to introduce the Ethereum community to CosmWasm and invite them to learn more; whether it is getting inspiration for eWasm, or potentially integrating CosmWasm alongside the EVM in a layer 2 rollup.

Transcript

because a lot of shared knowledge we can so first of all who am I I've been working on Cosmos since 2017 I worked on IBC which is inner blockchain communication I wrote the white paper and I invented cosmoasm which is another smart Contracting platform built in wasm obviously and targeting the cosmos so if you haven't heard of Cosmos it's one of the early projects it was white paper back in 2016 alongside polka dot it was about the thesis there was app chain a few thesis here which have proven the first is proof of stake it was one of the first proof of stake Byzantine fault tolerant Networks I think in definitely the first one to write it down and maybe the first one to launch it it's now proven the app change thesis that we don't have one change rule them all and we're competing to be the one major chain they have many chains that specialize and they connect to each other to launch progress and that's it seems to last few years people have accepted that thesis as well and the other one is that interchange communication inter-blocking communication is key to build that future were there many app chains so we need fast finality with BPF Byzantine fault tolerant proof of stake using inner blockchain communication to really have this app chain thesis and that's Cosmos IBC is the communication it's a layer Way Beyond Bridges it uses full light client proofs no multi-stige anywhere full like client proofs bi-directionally it's very extensible has a very high level semantics like TCP and HTTP allowing all the plumbing all the packet networking very very composable and on top of it you can build arbitrary app logic so you can on top of that build a token Bridge you can build a quash contract calls Atomic swaps across chains many many things and hearing the security composability of the base layer definitely check it out if you're interested in bridges anything cross-chain check IBC either the interrupt Summit early this week and it seemed like it was end goal a lot of bridges are out there looking at IBC as the end goal where they want to be eventually it currently only works on Cosmos soon between polka dot and Cosmos and I think they're looking for other ecosystems as well maybe one day to ethereum hopefully um and Kaza moazam is a wasm based virtual machine it's probably I invented this started working on 2019 2020 and now it's on over 25 blockchains in the cosmos and one on polka dot uh one parachain and it's probably the most widespread VM outside of the evm so evm is everywhere evm is king that's clear but every other VM Solana works on Solana right EOS has their EOS everyone has there's one this is probably the only other really really multi-chained VM outside of the evm and we worked hard from day one to make it multi-chain and to make it portable so you can plug in other ecosystems and just work on bring it to avalanche now as well as composable um and it's really tight about IBC so this brought these ideas in there so when doing all this from early days in Cosmos throughout building cosmoasm there's a lot we learned from ethereum I mean ethereum's King ethereum started the whole project smart contracts it invented that right so the developer Community I think is a key to ethereum why what theme was here and every ethereum killer has failed since 2007 there have been like 20 projects that claim to be ethereum killers and they never succeed because the developers are key the community around ethereum is amazing the network the tooling the whole environment is amazing and no one can kill that don't care what your Tech is how fast you go you can't kill it I think it's a really really important thing that people should learn from ethereum it doesn't matter what you're doing Tech wise you have the community here and ethereum is amazing in that way I think we have to look into more of that we're working on it but we need to learn more I think also composability ethereum allow this really really rich composability between contracts right not like this utxo model but this really powerful composability between contracts and demonstrated while using these contracts in these complex patterns the real world usage patterns what people do with it what do you do do you make fungible tokens do you make Dows what are what how D5 compose no one knew that in 2016-17 no one knew what would happen right make a talk about what else we do so these patterns of what people use how to upgrade contracts that came out ethereum just the experience from ethereum and classes of attacks as well how hackers break contracts right no one knew that when they're writing it so we've learned that in retrospect from ethereum you know the good and bad things about what will happen in the real world so when we were designing Plaza malls we took a big look at ethereum we want to build a wasm engine because we thought it was fun and was the next VM and so we targeted rust that was like our choice after that we looked at ethereum and figured composability is important but more important composability is safety there's a lot of features in ethereum they're very powerful but very dangerous re-entrancy attacks everywhere there's um overflow errors there's many different types of errors it's hard to test it I mean I came into solidity in 2017 and you couldn't really test it except by writing the point on a chain and run JavaScript tests there's no way of really doing uh clear testing powerful testing uh detail testing on lots of business cases I came from back-end development I understand if you're launching something secure you need lots of test coverage analysis on it and it just seemed like hard to do something as complex as D5 without having those tools so when he did this we thought about this heavily and we tried to make it as easy as possible Right secure applications we found all these errors people do because they oversaw one little line and their contract got hacked and tried to make that impossible as hard as possible and the other design we lot was interchange first you can't interchange later you cannot it's really hard to add interchange and afterthought because the whole design does not accept it everyone's thinking of synchronicity so I'm gonna just step back a bit and say what we've already gone so ethereum has looked at that vitalik actually does admire Cosmos as a tech on the tech wise and I think it's brought a lot of ideas into ethereum you know they I was at Devcon in 2017 they talk about proof of stake Casper I mean they're going to launch it took a few years to launch it um but they did and tender mint and Cosmos really pioneered this right they pioneered they brought Dominion they were doing the research for years before that and this is something that really eventually got into Theory and they realized hey proof of work is great we have it it works now let's launch with it very very practical but we need to make something better so they took this idea already multi-chain idea so there's not one of three I'm chained now we have you know binance chain we have arbitrum we have polygon and not just the Roll-Ups but all the other chains that were evm compatible that launched on near the evm compatible chain all of these ideas were kind of we only need one ethereum and this over the last few years has really come up that no we have a multi-chain world and once we have this multi-chain world recently ethereum is releasing cross chain is key once you have multiple chains we can't just ignore them and fight we have to connect them they're bridges over here they're Roll-Ups allowing much stronger proof guarantees but also Bridges between unrelated chains and this is actually key right this is like ethereum is moving into this now and realizes this is key of the future that all these different ecosystems interoperate and we can build collaborate over these chains however there's a lot to learn on that I think we can teach them customers are working that for a long long time I'd like to share a little little insights here the first one is complexity is hard like once you have writing four contracts they call each other or call arbitrary CRV 20 tokens is a bit tricky and handling all the cases especially when you call into arbitrary external logic but when you start doing over multiple change with possible timeouts really are synchronicity errors uh if you query something it's not the same as when you when you execute on it all kinds of error cases error handlings that's just very tricky especially composing of multiple chains so the already the tools for composability are is difficult to write many contracts together it's really easy to write a few contracts in solidity when you try to get these large large composition of contracts it's harder and harder with complexity and then we've interchanged contracts it's even trickier to reason about all the possible states that can happen over multiple blockchains so I think we realized that we need to make sure applications can scale in complexity right this is like a higher level of complexity and how do we tame complexity how do they make it easier so these are some of the things you've been doing on Cosmos particularly cosmoasm to make it easier to build these large applications this large composition at the scale um the first one is look at the needs of complex production apps you don't start with like let's make pet shop and crypto zombies really easy let's look at what people need to build of it right like that's our target audience people are building something like that right before they go in Cross chain and the second thing is making standard patterns bulletproof I'm kind of surprised like these proxy libraries been many attacks for many things like upgrade ability of contracts is essential but these kind of like delegate call attacks is It's Tricky there's a lot of trickiness there so it's almost like we need to standardize and not just in like libraries facility libraries but actually in infrastructure you could have GE have pre-compiles have support for these common patterns the same way we do um for IBC we build them into the blockchain so we don't have to write them in contracts they actually built into the standard blockchain as functionality so I think if you look in the future of ethereum maybe they consider these patterns actually as pre-compiles or as native functionality in the actually native Goa rust code finally I think that testing is essential so you can't you have to make sure you can test every level you can test your business logic you can test your math inside of it you test the contract itself you test a contract calling other contracts then you test a contract calling other contracts on their chains right these are all levels of testing and they should be easy as possible so people can cover the most use cases possible and run them quickly and I think that we must have the framework and Depend and tooling to make this happen so the tooling's gotten much much better the last five six years on solidity and running testing environments I think it's a lot more to do and a lot of it is actually I think due to the fact that it's not you can't really test it natively it doesn't has its own language doesn't come with tooling there's no solidity outside of ethereum whereas if you pull another language like rust in there or JavaScript they have a whole bunch of tooling whole testing libraries a whole set of mocks all this information you can bring um so I'll go look quickly here I mean here's Senator attack vectors ethereum you probably all know these ones if you're actually developers you probably had to make sure your contracts do not have issues here um so yeah re-entrancy the proxy Library call fallback functions default visibilities these are all things I pull them off of um I think open Zeppelin or consensus had a list of the top vulnerabilities to avoid and these are basically standard ones so in Plaza malls when we designed it we designed Security First we try to make all of those impossible to happen right like if you call if you execute a message another contract it will automatically abort your contract there's no way of not catching it unless you explicitly handle the error and then handle it some other way unless you explicitly catch the error it'll just abort your contract um no re-entrances possible you must explicitly list the public messages not have it like private it's not public as default it's private by default unless you make it explicitly public so it's a little harder for some devs but avoids a lot of these errors you can get and we have removed things like you know there's no fallback function you can't do certain things it can do in solidity but things are often used in attack vectors we just remove them so it's sometimes it makes a little harder to build we said hey it makes it easier to build your project in an unsecure way let's remove it so you have to spend a little more time building it but be secure at the end so there's a lot of design work done in here and I think as you're looking at new Frameworks new languages to replace validity like Viper and other languages I think is one important key to try to make it secure by default and testability so we have lots of testability as I covered earlier and finally as we're going this new world interchange first I want to say like this is another concept I see Bridges coming out I was at the summit the idea of bridges saying tokens make sense when you're calling another function I call a contract over here actually you make an error back a lot of these Bridges don't even pass it out there's like these new like actually I was doing some calls but they don't return the error or success there's no return value of the messages and there's no return value in another block it might happen 10 minutes later you get the result of what happened here and maybe you have to roll back the original transaction locally if it failed over there how do you handle that right like how do you manage to even model that mentally before you write in your contract so these concepts of how the state modeling when you actually have interchange composition and you say okay I'm not just gonna say a token that bounces back I'm going to go over here and I'm going to deposit my um I'm going to trade token the deposit and LP here and then use LP over here as collateral right um I'm gonna positive LP and then move that much collateral right like that's a complex thing if it fails the middle how do you avert it what do you stop how do we start it how do you expose that to users do you even have the tools to represent what's happening do you even have the workflow to represent it to test it but to understand it yourself so I think these are Concepts that need to be built into Frameworks it's hard to understand already and if your Frameworks don't give you the language to express it it's very very hard so I think as we're moving this new world especially as ethereum breaks interchange I really want it to be done well I don't want any more Bridge hacks I was just watching those in 2022 and sad so I think learning from these ideas and really learning how to build interchange first I think you have to use Cosmos keep using ethereum but I think learning from how Cosmos is working on these attempts and solving it I think is great and giving lots of knowledge back into ethereum into Roll-Ups and into Bridges between different different ethereum chains evm chains um so yeah that's basically my talk I want to explain some ideas here and how I see weekly in the future I'd like to see this collaboration um that I'd like to see more collaboration between Cosmos and ethereum that's really really a key point I think there's like they've been known Little Worlds I think cause was isolated itself a lot too in its own little Tech world but with interchange coming out there I really think these Bridges need to be more thought out and this especially the research aspect of it share between blockchains um and there's people working ewas I mean these other engines like bringing a secure a new languages the security first mentality like oh look we're actually really targeting extremely complex applications we're not 2017 anymore we've really really complex multi-chain applications going on here really complex composition on single chains how to make it secure how to build it into a framework that and talking building in Bridge and framework I love to see stuff like IBC built in to GE as a primitive you don't have to worry about it you'll try to build Bridges as contracts but actually the native code say hey here's code to do proofs and send packets trustlessly with like client proofs across chain is built into a blockchain your contract can just use it now you don't have to worry about anything else you can just use it this does exist on one chain called ethernet I think kantos also there are Cosmos evm compatible Cosmos chains allow the contracts to actually connect over IBC to other Cosmos chains it's a whole other Fork is nothing like geeth but I think you can look at these examples of where they're exposing these high-level Primitives of inter blockchain communication to the evm so I think the great thing to look at and hopefully these ideas get brought in to other evm chains um and I'd love to see cosmosm if this I don't even know it's possible but it's more and more Roll-Ups come out I'd love to see it like an execution environment on some you know ethereum roll up and see how we can do that and maybe Bridge IBC over it so if anyone's working roll ups and understands Roll-Ups really well I'd love to talk with you and see how we can kind of use Roll-Ups and IBC and it causes them also maybe Bridge some roll up to start bridging ethereum to the cosmos and inner chain okay and here are some websites if you want to check out cosmosm check our website out or chat like cosmo.com is it Discord it's very very Dev focused if you're a developer if you want techno information there's no when Moon we have no chain Cosmos is not a chain we're a library in 25 chains we focus just on core Tech here so if you want to um please check this out check the Discord out and you can learn lots of stuff you have a question back there thank you ah can I should I repeat I got it okay so what the question was was on evm you can go to block Explorer and verify the contract code what other things like Solana or this you cannot I think that is that's that's my biggest obstacle as developer yeah and because composability is okay but if I don't know what I'm composing to that's where this stops so understood what can you do about uh we can do it so the problem is we are one small company very low funding and we're not getting really much money from these large foundations or blockchains um so we can't do everything really like if someone said this we want to do this we started doing this ages ago we have scripts to verify you can verify in fact either scan I love to have Etheridge I'd love to build ether's guy for the cosmos ether's gun does not automatically verify your code what does is you have to upload the code it verifies that Salon of solidity source code is equal to this evm byte code right we can do this right now with Cosmos and we deterministic compilation since 2020 for ages we have scripts to do this that you that you can say given this rust package this version of code this game of brush code you compile it and it'll give you a hash if that matches the hash on chain this was a source code so it has to happen there's a few different compiler versions in there so if you compile the same version of the compiler as you did it it does work the problem is that no one has set the tooling on it the front-end tooling where you can upload the code it will do it for you and it'll stick like etherscan we have no UI for it you can manually verify it if I tell you in a contract you can manually verify it we have no quick verification no UI for it no explorers and I'd love to build that thing but yes there's only some of my hands I'm out of time but we can talk later thank you very much everyone foreign

Automatic transcript — names and jargon may be misspelled.