Andra Fecioru - Why diffs matter?

EthereumZuri.ch 2024 · April 2024 · 8:29

Andra Fecioru argues that storage diffs, the changes to contract storage on EVM-compatible blockchains, are an overlooked layer of blockchain analytics, which usually stops at events and calls. Fecioru explains why accessing and decoding them at scale is hard and shows how fully indexed and decoded storage data can track token supplies and streamline DeFi accounting.

Speakers

Topics

From EthereumZuri.ch 2024, hosted by EthereumZuri.ch.

Transcript

as I was presented I'm Andra from token flow we are let me figure out which one to use on well in the meantime token flow is an advanced blockchain analytics company we are providing data sets for advanced use cases so not what you would find on Dune or flip side or things like that but much more in depth and I'm going to yes I'm going to be talking about data and analytics first starting why analytics matter blockchain has a lot of data and by a lot I mean billions and billions of

row and you can build these types of things pretty charts whether you want to find your board ape token how it moves or Bitcoin or ethereum or everything else who holds which Tok at what point in time a lot of charts require a lot of data and they are cor to understanding what blockchain is all about but what if they are wrong it happens because you can Li very easily with data you can make charts that look pretty but are completely wrong because their assumptions are completely outdated so let's look a bit on how things are done today and what's

wrong with it and I'm going to take an example of weet rap eer a very simple smart contract how many of you have seen smart contracts before given that this is a more technical room so okay nice how many of you have you sequel before okay so here what we're looking top 10 top five actually top five we holders pretty addresses numbers you can see that the first one one has over half a million and this data would be done with this SQL query normally I would write the query real time but in the interest

of time already prepared running that query would give me these numbers and as you can see my top one has 6.5 million can anybody tell me what I have done wrong I looked at events and I took the transfer event into account maybe this would help this is the actual smart contract the events are lines 9 through 12 and as you can see there's a few other events that should be taken into account like deposit and withdraw and if we are ignoring those you get the 6.5 million top one

holder but if you're taking that into account you would get the right numbers so analytics based on events are prone to errors and depend very much on your understanding of a smart contract also events cause gas so there's a tendency of people stop emitting events because they want to save gas so there was an actual discussion yesterday on Twitter where unisoft contracts on V4 spend 1% of their gas cost on IM meeting event 1% for Unis swap is a lot of money so maybe they would stop emitting event what would be an

alternative going back to the same we contract all the way to the bottom you see two lines balance off and allowance those are storage variables pretty much they tell you balance of how much what's the balance of a particular account in we with the data that we are doing you're able to do something like that fancy SQL plus value whatever contract address which is we variable variable balance off excluding reverted and you would get the same numbers now take into account that we is

a very simple contract the more complicated the contract is the more complicated it is to understand the the logic of events and to make sure that you're doing your data correctly also storage is always correct and always available on chain why I'm saying always available on chain there's this tendency of doing Shadow events let's put events somewhere else because they cause gas on chain we put them somewhere else we're able to get our analytics but they're not visible for anybody else to use so another error prone mechanism storage both regular storage so your s store and your transient storage that

has been added post dun can be decoded we are already doing that and we are able to do analytics so just a recap blockchain data is always correct analy is well it depends events give you some answers when emitted and when use right events are not incorrect by definition they serve a very good purpose and they're able to give you the information you need but you need to use know how to use them and to wrap up State and storage are always correct and always on chain and we have managed to find a way to make storage accessible in a human readable format because before it was

hashed so not very usable for analytics and that's pretty much it normally this would have been longer just because I would write the SQL but I wanted to make it more flowy so leave you some room for questions thanks a lot Andre and we actually have plenty of time for questions um so um feel free to ask away uh you mentioned your decode the balance right and um so according to erc20 standard balance office just the

function right so uh are you actually executing uh like evm code when you are uh parsing it I'm close enough that I don't actually need a mic but anyway um so I've actually worked on on bitcoin as well as as on ethereum uh and and utxos are horrendous like I hate utxos I I actually really like like ethereum because it it's you know you just keep the balance now my question to you is is

that is that of course if if uh because there's actually one of the talks that that will be held here um is is about UT exos and and trying to to to to to get UT exos on ethereum and I absolutely detest that but when when it comes to utxos my question is that that does this add complexity and and how do you deal with this complexity and maybe you could you could use examples um does this basically mean that that people get tainted for for example how do you deal with that that that tainted of of of um of transactions and and such um yeah so if you I I know that's a very loaded question but yeah with Duty EXO style transactions uh if

you if you already do that um so that that's the first question the second thing is that um is there issues with with transactions tainting other transactions and how do you deal deal with with that because uh you didn't really get into the the actual analytics of it like like ownership is is fine like you can say it's ownership but what happens if if certain tokens or contracts get tainted by by transactions um yeah