mas.s62 lecture 11 - mit opencoursewarebyte", one satoshi being 0.00000001 prioritize based on...

41
mas.s62 lecture 11 fees 2018-03-14 Tadge Dryja 1

Upload: others

Post on 22-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

mas.s62 lecture 11

fees

2018-03-14 Tadge Dryja

1

Page 2: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

today pset3 description

fees

CPFP / RBF

long term incentives

2

Page 3: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

pset03 grab utxos

install bitcoind, sync to testnet3

build transactions in code, submit to network

Block explorers aren't cheating. But they're also not as fun.

3

Page 4: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

pset03 try to get familiar with bitcoin-cli

use any scripting you like (bash, python, go, node -- or anything that can talk to bitcoind's rpc)

I will add more utxos to grab in the next few days

4

Page 5: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

transaction fees difference between sum of input amounts and sum of output amounts

implicit; not encoded in the transaction

paid to whoever mines the block containing that tx

5

Page 6: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

transaction fees fee rate expressed in "satoshis per byte", one satoshi being 0.00000001

prioritize based on tx size as space is limited

unrelated to amount transferred; fee is "flat"

6

Page 7: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

fee market fee rate set by transaction signer

txs chosen by miners

auction process

bid for space in future blocks

7

Page 8: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner side sort mempool txs by fee rate

choose the top ~1MB

compute merkle root, mine

but not that simple... why?

8

Page 9: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner side - CPFP tx dependencies make this into a much harder optimization problem

txs can depend on others

a "cheap" tx which allows a "expensive" tx to also be confirmed is called "child pays for parent"

9

Page 10: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

transactor side want to minimize fees

set to 1 sat / byte, sign and send

... easy right?

10

Page 11: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

transactor side want to minimize fees

set to 1 sat / byte, sign and send

... easy right?

it doesn't confirm!

11

Page 12: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

transactor side poor user experience

wallets with fixed fee per tx

fixed fee rates

user chooses fee rates (I dunno!)

low fee, outbid by other users

12

Page 13: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

transactor side many wallets are "stuck" once tx is sent, can't increase fee

child pays for parent - send a tx to yourself with high fee

13

Page 14: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

CPFP downsides inefficient - extra tx

exacerbates problem it's trying to solve! wastes space dealing with lack of space

dependency graphs are complex

14

Page 15: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

replace by fee double spend the tx with higher fee (lower change output)

simple, right?

15

Page 16: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

replace by fee double spend the tx with higher fee (lower change output)

simple, right?

default relay behavior is ignore double spends

(defined as any conflicting tx) 16

Page 17: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

replace by fee relay conflicting txs

require increase in fee; do not relay txs with same or lower fee

(why?)

17

Page 18: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

replace by fee relay conflicting txs

require increase in fee; do not relay txs with same or lower fee

DoS attack: make lots of conflicting txs with same fee, flood network

18

Page 19: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

RBF controversy hurts security of unconfirmed txs

could contact miners directly, but some effort to double spend if all nodes go with first-seen tx

RBF make double spends much easier (that's the point)

19

Page 20: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

RBF controversy 0-conf txs have no security anyway; that's the point of the blockchain

UI issue: show unconfirmed tx?

show unconfirmed tx in SPV?

connect to multiple nodes?

20

Page 21: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

RBF compromise "opt in" RBF. Flag in the tx (input sequence number) to indicate RBF

IMHO: ugly code. Can't even tell what RBF policy nodes have

21

Page 22: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

RBF compromise "opt in" RBF. Flag in the tx (input sequence number) to indicate RBF

IMHO: ugly code. Can't even tell what RBF policy nodes have

22

Page 23: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

inter mission 0x7f sec

23

Page 24: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

fees in practice highly variable!

very hard to predict!

further research needed

my favorite: locktime & RBF ramp

24

Page 25: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

fees in practice exchanges overpay

bitcoind wallet overpays

nobody cared for 7 years

gas price goes up, hummer -> prius

25

Page 26: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

long term incentive mining reward drops in half every 210000 blocks

eventually all coins mined (100 y)

rewards become negligible sooner than you might think!

26

Page 27: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

long term incentive no new coins to mine...

why mine?

tx fees

27

Page 28: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

long term incentive problem with tx fee only incentive:

tx fees are variable

without a backlog, fees are near 0

0 fees = no incentive to mine

miners stop

28

Page 29: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" you're a miner

no fees in mempool, no reward

turn off your chips, turn back on once the mempool fills up

29

Page 30: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" you're a miner

no fees in mempool, no reward

turn off your chips, turn back on once the mempool fills up

or...?

30

Page 31: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" that last block had a couple coins in fees

re-mine it yourself!

if you find another (maybe empty) block on top, you take the fees!

31

Page 32: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" instead of sequentially building the chain, miners keep fighting over the same block height

alice 2 BTC

bob 3 BTC

carol 2 BTC

dave 1 BTC

32

Page 33: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" instead of sequentially building the chain, miners keep fighting over the same block height

alice 2 BTC

bob 3 BTC

carol 2 BTC

dave 1 BTC

eve3 BTCeve 3 BTC

33

Page 34: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" instead of sequentially building the chain, miners keep fighting over the same block height

alice 2 BTC

bob 3 BTC

carol 2 BTC

dave 1 BTC

eve3 BTCeve 3 BTC

eve 0 BTC

34

Page 35: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" instead of sequentially building the chain, miners keep fighting over the same block height

alice 2 BTC

bob 3 BTC

carol 2 BTC

dave 1 BTC

eve3 BTCeve 3 BTC

eve 0 BTC

eve 1 BTC

35

Page 36: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" instead of sequentially building the chain, miners keep fighting over the same block height

alice 2 BTC

bob 3 BTC

carol 2 BTC

dave 1 BTC

eve 3 BTC

eve 0 BTC

eve 1 BTC

36

Page 37: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

miner "attacks" is this even an attack?

they're just trying to get paid

not a problem if low reward variance

which means... backlog

37

Page 38: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

scalability balance tx rate in Bitcoin, other systems

tradeoff:

too small -> few can have utxos, own their private keys

too large -> few can validate utxo set, verify rules

38

Page 39: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

scalability balance fee sniping / reorg is not harware related. Happens with arbitrarily powerful computers / networks

too large -> constant reorg races

largest miner wins (no longer memoryless)

39

Page 40: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

dawn of the fee we're just starting to understand fee markets

seems highly inelastic

people wasting millions of dollars

fun research area!

hope this works! 40

Page 41: mas.s62 lecture 11 - MIT OpenCourseWarebyte", one satoshi being 0.00000001 prioritize based on tx size as space is limited unrelated to amount transferred; fee is "flat" 6 fee market

MIT OpenCourseWare https://ocw.mit.edu/

MAS.S62 Cryptocurrency Engineering and Design Spring 2018

For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.