How to speed up Ethereum in the face of Crypto-Kitties
There were recently some calls on the Ethereum miners to raise the gas limit. I agree with others who say that unless it can be demonstrated that the block propagation times can be improved significantly, such raise will reduce profitability of mining, and therefore, unlikely to be adopted by the miners.
Today I deciced to look into why the propagation times could be what they are, at least for geth. So I cloned geth 1.7.2, inserted a few lines of code into the main.go (according to the instructions for the runtime/pprof), and synched last 5 days of blocks (from about block 4'649'381 to block 4'682'562), which should contain plenty of Crypto-Kitties transactions. I did it in a very quick and unscientific way, on my laptop (though with SSD), with default setting, while also watching La Bitcoin talks on YouTube and fiddling with some local web servers. After 3 hours of waiting, I got the results. Here is the summary:
The whole picture is quite big, so I will show the main bits. The numbers next to the arrows show cumulative times spent in particular places (the profiler probes the state of go-routines 100 times a second and builds such a statistics).
Most work in understandably in the applying of transactions:
What we can see next is that EVM interpreter itself takes only tiny proportion of the time (underlined), and is bottle-necked on the access to the SecureTrie state (blue oval):
If we now move further down, we will see the database compaction appearing. Most probably it is running on the background, but it might still have an effect by locking the database for the readers:
That is probably enough pictures, but at the end of all this there are bunch of system calls to the file system (presumably for reading and writing files).
Vitalik already suggested it here: https://youtu.be/Yo9o5nDTAAQ?t=29972
It is called “Stateless Clients”, and I believe it can be implemented already now, without any hard-fork, “simply” by changing the ethereum clients. When a miner creates a block, it also creates the “witness” block for it, which contains all the information (and their Merkle proofs) that is required for processing all the transactions in that block, and computing the next state root. This means that nodes do not need to access storage from files, and block validation times should drop significantly. Then, the gas limit can be raised to much higher number.