Skip to content

Instantly share code, notes, and snippets.

View holiman's full-sized avatar
💭
<i>foo</i>

Martin HS holiman

💭
<i>foo</i>
View GitHub Profile
#!/bin/bash
# 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 (
"fmt"
"math/rand"
"os"
"path/filepath"
"strconv"
)

Current (Istanbul) costs

With Istanbul rules, EIP-2200: https://eips.ethereum.org/EIPS/eip-2200#test-cases, 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
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
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.

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
holiman / dbreads.md
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

ethdb/leveldb/leveldb.go:93
core/rawdb/database.go:47
node/service.go:47

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 .......Parity-Ethereum.1.30.1.li
block 7280002 miner 0x28974b4a92e7be907418722b37446f2eb60184cc extradata .......geth.go1.10.linux
block 7280003 miner 0x06b8c5883ec71bc3f4b332081519f23834c8706e extradata .......geth.go1.10.4.linux
block 7280004 miner 0x96338149e9f6c262d4cb7aeec1cf4c652079a11c extradata .......Parity-Ethereum.1.30.1.li
block 7280005 miner 0x8e59176cd996342da6fdf20c85cb02bca095d552 extradata .Grupo+58
block 7280006 miner 0x96338149e9f6c262d4cb7aeec1cf4c652079a11c extradata .......Parity-Ethereum.1.30.1.li
{
"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
holiman / result.md
Last active October 15, 2018 13:31

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