Skip to content

Instantly share code, notes, and snippets.

View holiman's full-sized avatar

Martin HS holiman

View GitHub Profile
# Linux version
# Use this script to pipe in/out of the clipboard
# Usage: someapp | clipboard # Pipe someapp's output into clipboard
# clipboard | someapp # Pipe clipboard's content into someapp
if command -v xclip 1>/dev/null; then
if [[ -p /dev/stdin ]] ; then
package main
import (

Current (Istanbul) costs

With Istanbul rules, EIP-2200:, the following gas usages apply for the various scenarions below:

Code Used Gas Refund Original 1st 2nd 3rd Effective gas (after refund)
0x60006000556000600055 1612 0 0 0 0 1612
0x60006000556001600055 20812 0 0 0 1 20812
holiman / selfdestruct-2929.json
Created November 14, 2020 19:33
This is a statetest which focuses on the behaviour of selfdestruct. Passes on Geth, OE and Besu
"TestSelfdestruct": {
"env": {
"currentCoinbase": "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"currentDifficulty": "0x20000",
"currentGasLimit": "0x26e1f476fe1e22",
"currentNumber": "0x1",
"currentTimestamp": "0x3e8",
"previousHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
holiman / gist:2cc4ccf268bd45901aec741e06288cc4
Created May 4, 2020 15:27
I'm analyzing all contract code at block 9666637. I dumped out all code (22G), and am now doing a filtering: only code containing - At least one JUMP or JUMPI, - At least one BEGINSUB (0xB2) - And a JUMPDEST after the BEGINSUB
This file has been truncated, but you can view the full file.
{"code": "3fc6e06b433eba44326043a4bdc77d736320fb323ff85ea8dc766d9cd29faebdd8d29507b351b2e93f031f6fe65730d45797ddfd3c710241d47446783f695f12fe395235b76fc6ddc7ddccc8e159f956318cb0021d4bd650a33ca5360a6953efd8c727d331f63d6a6377b1f48ce7d04dc8dd7265562e203e311fee5726ed3cd9b4c9555ece2138a89deddda230d601b1fac8918e21efaf9d4540dbdc590f0239307bf103b68f9aa27b36122acdd76e4408f12cab335eff92bfc6b5fee222954922667ca42246547f32dd6eb651bc4e8de3b7034a65d831ec08cfdf6b32d235ad27ce3108954b93bf2f64a890bbd5161b32e395f6f9dd69f91e76aeea5d305073702cdca635b73870066495ed9e8f76dea5dbc945b689eeec35172535095829324b414982db4e8d16b3c6fdef3541a5169d8e9610edb927512fa6784329576c0e357e2e2ccffaa1194cd3e6722c5a90767346219334a194b58f4cedd63a619f5979fa59ba3058b3903458d5d3076a25b50365adc3cc53ab97b5b98b5137cd7da1e193c522218e67a833078d2bfb1d6287362e8fdccf8fb89aaa73bc2eebdf3e9d1af5695036655346eb803f72666820b04890fafd288f1a493679cdda3124144afeddb3cc3f063e3d2e7691d12862a084e13a7c6d53c58b9cdf90aec6d37c1f0f2b2850adb03a0c44c46334606b5c6a3a307eeb382adab553d9739a

Part one: Caching in consensus

The magic of caching

It's sometimes said, within software engineering, that there are no 'golden bullets' -- magical stuff that automatically fixes all of your problems. But actually, there is something that is pretty close to a golden bullet in many scenarios. After everything has been stretched to the limit, but the software still falls short of the demands being put on it, there's one thing that engineers will reach for: The Cache.

A cache layer can scale something orders of magnitude, it can and should be used wherever appropriate. When we can put in a caching layer, we suddenly have a shelve where we can put "stuff" that might be useful later. It's great.

Caching, and perhaps more specifically cache invalidation, is generally considered as a difficult problem, and it can of course be tuned and experimented with at length, before it's fully matured. Do we want least-recently-used eviction? Least-frequently-used? Do we want strict eviction guarantees, or is fuzz

holiman /
Last active April 21, 2019 14:44
This is taken during a fast-sync, in the phase where we download state/headers/bodes/receipts simultaneously. All lines that are leveldb-internal have been removed, thus the top item is empty -- that's the internal leveldb compaction routine. The second item is the init, which reads a lot on startup but does not grow over time.

2 GB from

115 MB from


These blocks have been mined on the old mainnet chain, presumably having failed to update the miner software for the Constantinople fork - a waste of money...

block 7280000 miner 0x06b8c5883ec71bc3f4b332081519f23834c8706e extradata .......geth.go1.10.4.linux
block 7280001 miner 0x96338149e9f6c262d4cb7aeec1cf4c652079a11c extradata
block 7280002 miner 0x28974b4a92e7be907418722b37446f2eb60184cc extradata .......geth.go1.10.linux
block 7280003 miner 0x06b8c5883ec71bc3f4b332081519f23834c8706e extradata .......geth.go1.10.4.linux
block 7280004 miner 0x96338149e9f6c262d4cb7aeec1cf4c652079a11c extradata
block 7280005 miner 0x8e59176cd996342da6fdf20c85cb02bca095d552 extradata .Grupo+58
block 7280006 miner 0x96338149e9f6c262d4cb7aeec1cf4c652079a11c extradata
"SstoreCallToSelfSubRefundBelowZero": {
"_info": {
"comment": "Test where accnt has slot 1 value of '2', is cleared, then calls itself and overwrites with '3', causing a refund-deduction in second call context",
"filledwith": "manaually filled by @holiman",
"lllcversion": "none",
"source": "none",
"sourceHash": "none"
"env": {
holiman /
Last active October 15, 2018 13:31

parity stateroot:0xa054d80c3c6192476447b6fdb3276af19400068432949c28431e5cc3e63d3c3f,, geth stateroot: 0x3ba0188e00002fd15395c3acca8cbbca76dbe56f5f2214d7fb12c1c348aaa965