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

Loading player…

How I Learned to Stop Worrying and Love using Web3 Tenderly with Bogdan Habic

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

Web3 has a predictability problem. Even though the code in the case of smart contracts is the law, there’s a lot that goes wrong even before transactions end up on the blockchain. For some time now, we’ve been working on addressing these core issues and bringing more certainty to users by offering a simulated testing environment. We would love to show you how. Bogdan Habic Co-founder and CTO Tenderly Bogdan Habić is the co-founder and CTO of Tenderly, where he leads and mentors an eclectic team of talented blockchain developers. His blockchain career started in 2017. and since then he’s been a vocal Web3 advocate and enthusiast. https://twitter.com/BogdanHabic

Transcript

Can you start? Oh, good. Hi, everyone. Thanks for coming. I just heard that the happy hour started.

So, I see you as the people who are really in here for the web 3. For everyone joining us on the live stream and don't see the crowd, there's like around a thousand people in the crowd. So, again, everyone thinks yeah, that that person was a one mile away. Anyway, so the title of the presentation is battling anxiety. And I know this wasn't actually in the schedule this way.

alternative ways how I like to talk about this is how I love love love started to love using web 3 and stop worrying or how to make people feel more comfortable while doing web 3 but before we start I know there's not a lot of us here but let's start with a little exercise so I'm going to say a thing and if it applies to you please stand up and then please keep standing up until I finish this whole thing my speaking coach told me it's very very very important to get people moving for the presentation so uh if you're a signer on a multi-IG Please stand up. If you ever sent a transaction on chain that failed and cost you like 15 bucks or 10 bucks, can you please stand up? Okay, cool. So, I'm trying to make everyone feel anxious. So, if you were in a situation where you did a swap or did something on OpenC and the prices varied greatly from what you expected it actually to be, can you please stand up?

Cool. So half of the crowd which isn't a lot stood up but this is you can you can sit down and thanks for following in instructions to the point but why did I start with this? So today we're going to talk about four very vague sections of this presentation and they're vague by design but it's basically there is a problem that we're not tackling before a transaction isn't is sent. So I'm not talking about the user signing the transaction. I'm not even talking about like how it ends up in a memple or whatever.

And we're going to see what I'm actually talking about here. We're going to be talking about the solution. So we're going to focus on a particular problem that I'm going to talk about and we're going to see how we can tackle this specifically. The third one we're actually going to look at how this looks in the wild and probably some of you in the crowd actually we're using already something like this and the last one is the most technical part of the of the talk itself. It is how you can actually implement this.

So without further ado and actually being extremely vague. So before a transaction happens we usually talk about education. We talk about a lot of different things but basically we can divide this into three different parts. So the first one is making smart contract development easier, more accessible, more secure. Here comes your truffles, hard hits, foundaries of the world.

Here come your audits. Here you can also have for example the educational material used for developers how to write secure smart contracts etc. The second one which I think is tackled the most is actually educating you user. So someone comes to web 3 whatever and then like what's anonyic how to send a transactions etc. The third one which we're actually going to talk about and here by design it's very long again to make you feel a bit more anxious and I'm probably going to screw this up.

I I didn't practice enough but helping developers as well as retail users know what will happen before writing something into a ledger that will be there until the end of time. So let's remember something that we send on chain. It's there forever or until blockchain dies but we hope forever. But the third one basically is simulations. So today we'll be talking about simulations and how we can use simulations to make users most more safe.

And we're also going to tackle how you can do this yourself without using like an external party or service. Anywh who, let's start actually why web two sucks. Every good web 3 presentation should start should start with how the olden world is crap and how we're building a best thing. So a couple of months back I wanted to make a purchase. Now I come from Republic of Serbia and we have something called the Serbian dinar.

It was a very inflationary currency during the 90s. So for example a beer costed a couple of couple of million Serbian dinars. Anyway, a couple of months ago, I wanted to make a purchase which was 1,400 bucks. Now, the current the currency exchange ratio for the Serbian dinar is usually $1 equals 16 116 Serbian dinars. So, I went to my banking app, check the currency exchange ratio, like everything was completely fine.

Everything was working. So, I didn't click in the app to exchange the money. I swiped my credit card online and in the bank statement, what I did expect was for 162,000 Serbian dinars to be charged. So that's like 1,400 bucks. But the notification in the statement itself said it was 170K.

So I thought like what the [ __ ] Like where where am I missing? Why am I missing this money? And what happened is basically slippage. So what did what happened 6 years ago when I was opening my bank account and the bank is a great friend of mine. I basically signed if I do the currency exchange by hand I get a good exchange ratio.

If they do it automatically there is slippage. They take like 3 or 4%. So that is crap. I didn't know. I I didn't read like who who reads like 60 60 papers to to use a bank account and we can kind of look at the same analogy for smart contracts like did did you actually read all of the unis swap contracts no anyway so how can web3 make this better so same inflationary currency um the same purchase same currency exchange ratio but let's imagine I'm using a browser wallet for this I go I want to make the purchase and my wallet says stop this is 170k K Serbian dinars, are you sure you want to send this transaction?

And I can say, hey, this is more than what I signed up for. This is like 80 bucks more. I can go to my app, do the swap, and that's it. So, basically, the profit that I get is the 80 bucks that I didn't lose. Also, banks suck.

It's also a very important thing to say here. But the consequences of not knowing what would the transaction do before sending it are manifold. So, good examples that happen in the wild or maybe bad examples that happen in the wild. For example, there was a 1.7 million open sea fishing hack where people thought they were buying NFDs.

They were actually just sending them to other people. DNS hijacking, so someone can hack your front end and put malicious smart contracts to be contacted instead of the real ones. Blind multi-signing. We're going to be talk talk about this a bit more. And implicitly, I think a thing that's not tackled at all is that a lot of very very smart people that we could very very much so use in the in this space to make the space better think web 3 equals scam and that's it.

And we especially see this when hiring people from web 2 to web 3. I'm going to stop so you can take an image. This is an interactive show. Anyway, no, I'm joking. Anyway, so hi everyone.

My name is Bogdan. I come from a company called Tenderly. We're a developer platform. It has a bunch of tools and services helping blockchain developers, debugging, profiling, monitoring, alerting, a bunch of different stuff. But the thing that we definitely heard here today and we have a booth is that most of the people are using our simulations in this space as we were the first ones to make them.

So we're going to be talking about the solution to the actual problem that we have been talking about. So what does this actually mean? Let's extrapolate this point in time 10 years into the future. So let's say that we want to have safe and transparent transacting be a basic human right. Just as the access to internet, just as access to monetary things is a basic human right.

We should know what we're signing up for. We should know which transaction we're which which transactions we're sending. And this goal is much larger than a single company or a single product. I'm very glad that some people are joining the simulation space although two years later. And also democratizing this data was what got most of the people into this space itself.

And I think and I'm glad more people are thinking about this. But let's go very concretely. So what's the goal of this presentation? Before sending a transaction, how can we know what events will be emitted? How will the state change?

Which functions will be called? So the key word there is will in the future of course. So what do we need to achieve this is a for node custom state management and custom execution. So this was the teaser for section 4. But let's talk about the real case study.

So multi-IGS who here knows what the multi-IG is just so I know a couple of people. Okay. So for a couple of people who didn't raise their hand very briefly very high level multi-IG is a smart contract wallet where multiple people have to say hey this is good for for it to actually send it onchain. I kind of lied here but I think I got the gist of it. So there are a lot of mult moving parts when using a multi-IG.

Multiple people have to say this is okay. So we can have human error doing a couple of things in one transactions. Multi6 usually do like 10 12 14 transactions in a single transaction. So I can do a unis swap swap pay all of the employees inside of tenderly do something in git grant. So these things are very complex and have hundreds of smart contracts interacting usually have a they usually have a lot of funds locked inside of them.

So they're usually managed by Dows VCs or companies. So there's a lot of money locked. And finally the last one is it can be timesensitive. So we're this is kind of the human error part. Let's say for example I'm running an engineering team.

We find an exploit in 3:00 a.m. I wake up everyone and say guys please please please sign this quickly sign this quickly and they cannot even know what will happen. So why did I mention multiix? Let's look a real case study of safe or exagnosis safe.

So for anyone who didn't use it safe is the most widely used multi-yc you can say in the world. It's interesting now. But yeah, most widely used uh multi-IG in the world and it lets you do a bunch of interesting things. But the one that I like a lot is something called transaction builder. So coming back to my example of doing a unis swap swap and then paying out everyone in the company and then doing something else.

You can basically chain these transactions together and then instead of sending 10 transactions, you can send one transaction on chain. It looks like this. So by a show of hand can someone tell me what this transaction does or what these three transaction do correct you can't anyh who so for people on the live stream the silence was barely bearable so what the safe team actually came up with as an idea is to put the simulate button at the bottom right hand corner so what they do is I come up with these three things these three ambiguous things that nobody here in the room me included who did the screenshot like four months ago and you can click simulate and what you get back is basically a result and this will say hey this transaction will probably fail do you want to actually send it. So this can prevent me first of all spending a hundred bucks on gas as an example. But another thing that's very important what's worse than a transaction failing is a transaction transaction succeeding and doing the wrong thing.

Coming back to the anxietyinducing it's in the ledger forever. And from there they can basically click and see this is tenderly which cannot be seen on this projector but you have to trust me. There's a very nice UI here which shows you what exactly is happening in the transaction. And at the top I can see that the error message like unis swap invalid path. So that usually means I screwed something up integrating with unis swap.

And then if you're a developer you can do an even deeper dive and like figure out what was happening in the transaction. This was a small tenderly shield that just happened and you weren't aware of it any so what are the benefits of what the safe team got actually by integrating simulation. So every signer knows what they're signing. So that situation where I wake up someone in the 3 in 3:00 a.m.

they can actually in a minute know what will actually happen. You don't spend money on failed transactions. That one is quite straightforward. You can see the complex smart contract interactions that are actually happening. So let's say for example I touch unis swap one in and I don't know a chain link oracle that will be around 200 contracts participating in one transaction.

This is the best way to reason about these complex interactions. And finally, if the transaction is executed in a later time, we can be sure that the results are still going to be the same. What do I mean by this? I can schedule a transaction and say, "Hey team, sign this whenever." And the last person who is signing it 7 days later can still make sure that the intention I had 7 days ago is still going to happen on chain.

So, how did they actually do it? So, they needed to do a couple of things. The first one that they had to do is impersonate the person who's actually signing the transaction. So we need a way to basically fake who is sending the transaction and they can do just that. They can send transaction as anyone.

They need to they need to provide the transaction input data. That one is quite straightforward. Then how multi-IGS work. If it's like a five out of seven multisig that means that five people need to say yes this is good for it to actually happen. And what they do is something called a state override.

So they can lower the number of signers needed so the transaction passes. So they can literally lie to the smart contract in the simulation saying hey you only need one signer for this thing to actually pass. And finally you need to combine all of this data and serve it uh serve it to the user with the current chain state. So how does this actually work under the hood coming to like very very detailed tenderly shilling but this is our simulator. I'm going to tell you how you can build this yourself.

So it's not the full shield, but on the left I basically have the die smart contract selected over here. And I want to send myself some die in a simulation. Now you can see I pick the transfer function over here. I pick my wallet as the destination. And I say I want to send 1,000 units of dye to my address.

Now a thing I note here know here is that the wallet I'm sending this die from doesn't have any die. So the transaction will fail. But taking back the example of the state override, so changing the signers, the thing that I can do for this transaction is I can change the state of the D smart contract and I can suddenly mint myself 10,000 units of dice. So I can make sure that this transaction will actually pass. When I submit it, this is something that never touched the chain, but I can see exactly what would happen if I send it.

So how can you actually do this yourself? So the first thing is you need something like akin to a custom EVM. You can do this by for example forking G, forking Aragon, stripping it, ripping it and basically putting your code inside to instrument the VM to know what's actually happening inside. The next thing that we can do is custom state management. So if we remember we have the current chain state that's what's actually true on chain.

But the next thing that we actually have to do is take the user's input for example the state override I did for D right now and basically merge those two states the one on chain and the one that we're basically lying the virtual machine the current chain state is uh custom execution. So we have the custom EVM now we have that state that we're going to put underneath the EVM to lie to it. And the thing that we have to do is run the whole execution with that custom state and generate some data that we're going to use to actually surface this. And then finally, what we saw most people find useful is returning events, state changes, function calls, contra contra calls, and gas information. And there is so much more that you can actually do with a bunch of these things.

So for example, if you do simulations over tenderly instead of building your own, you have an API access, a lot of things that you use in the space, you aren't actually aware of doing simulations over tenderly. For example, I really like the safe integration here. Or for example, InstaDAP. When you go to Instadap, you can click simulation mode and use Instadep in a completely gasless way to test out how the how the DAP actually works. You can do a staging environment.

So instead of running a local node and clicking everything on your computer and forking a mainet node, what you can do is just by one click spin up a simulated cloud environment and do all of your staging things over there. You can do integration testing, which is basically running all your tests in parallel. You don't have to test in production. You don't have to test on arbitrum. You don't have to beg for gorly ETH and basically you can do all of these things free of charge.

You can do bug fixing. So if we can use simulations to see what will happen if I send a transaction on chain. We al also can do what if scenarios. So how would this transaction behave from a month ago if I actually change some parameter, change the input parameters, change the source code, change the state of the smart contract itself and figure out like if a bug fix that I wrote would have prevented the bug in the first place. And you can also do a bunch of like generalized bots and a bunch of other different interesting things on top of this.

So it's a very generic primitive which we see more and more being used in the space for very cool stuff. Anywh who, thank you so much. We have a booth over there where with a very very fun mind sweeper game which showcases simulations. I think it's a very nice way to reason about it. We also have a bunch of swag and we love to talk about infrastructure developer tooling in web3 in general.

So please join us there if you want and thank you so much for your attention.

Automatic transcript — names and jargon may be misspelled.