#because of course making a virtual security system wouldn't come with virtual problems of course
Explore tagged Tumblr posts
kohakuhibiki · 1 year ago
Text
French people: we have immigration problems, if only people took it more seriously 😡
Problem: don't worry we'll be gone in 60 seconds, don't even stress. 🥱
0 notes
wuggen · 3 years ago
Text
I mean I'm mostly just complaining but the EVM is legitimately an annoying architecture to work with. Haven't had to touch it in a while so my memory's a little foggy, but some things that I do remember:
It being a blockchain VM, every instruction directly costs literal money to execute. The more computationally expensive the instruction, the more money it costs you.
256-bit word length. What even the fuck, why do we need all that space. Is it really worth it just to be able to fit a SHA-256 into a single word? Those extra bytes also cost more literal money.
Until relatively recently, no bit-shifting instructions. You had to cobble that together with multiplications and divisions. And of course those are more computationally expensive than bit shifts, so have fun getting a particular byte out of one of those 256-bit words lmao.
Stack-based, rather than register-based. Which is not a problem per se, perfectly reasonable choice for keeping code size down, but it only provides instructions to access the top ~16 (I think?) slots of the stack. Which wouldn't be a problem, you can just spill local variables to memory if you can't keep them on the stack anymore, except that writing to memory costs more money than pushing to the stack. In practice this means you can't have more than about 10 local variables in a function without paying exorbitantly for it. (Compilers that target EVM will actually give errors if you use too many local variables.)
No instructions to query the amount of money the program's already burned on an execution. This is a really niche complaint that is probably only relevant for the very specific bullshit I was being paid to do with it, but it's weird nonetheless.
This one's more a problem with the compilers that target the EVM rather than with the EVM itself, but it's incredible what absolute garbage code they emit. You wanna save an in-memory array to non-volatile storage? Well the solidity compiler is gonna first copy that array to a brand new freshly allocated array in memory, and then write to storage from the copy, and then never use the copy again. For some reason. This is with optimizations enabled. This costs more money.
Also most of the compilers are written in javascript. Who the fuck writes a compiler in javascript. Ethereum developers, apparently.
And finally, as a very general pet peeve/source of amusement, EVM is in this family of virtual machines (WebAssembly is another) that were designed in theory to make it easy to produce safe and secure code, because the memory space of the code is completely segregated from anything else running on the host system. There's a quote from the paper that introduced WebAssembly that goes something like "At worst, a buggy program can only make a mess of its own memory." Of course the problem here is that, if the things in a program's memory are themselves meaningful then making a mess of it can still have disastrous consequences even if nothing outside of that memory can be messed with. Memory exploits that were completely eliminated in native code via hardware, OS, and compiler memory protections in like 1995 are relevant again in WASM, because no one thought they needed to implement those protections. EVM smart contracts lost people millions of dollars because no one thought to consider the consequences of smart contracts invoking themselves recursively. It's just absolutely, darkly hilarious to me that this shit keeps happening. "It can't be hacked, it's isolated!" But what's inside the isolation matters on its own, and in the case of EVM directly manages money. Like, come on.
I truly hate how much knowledge I have of the Ethereum virtual machine
87 notes · View notes