From aj at erisian.com.au Tue Oct 27 05:40:29 2015 From: aj at erisian.com.au (Anthony Towns) Date: Tue, 27 Oct 2015 15:40:29 +1000 Subject: [Lightning-dev] Lightning fees vs miner fees Message-ID: <20151027054029.GA6185@navy> Hi all, A question that's been raised a few times in various places [0] is what the impact of a fully armed and operational lightning network on miners fees will be -- lightning depends on the security of the blockchain to be functional, but the blockchain will eventually rely on transaction fees to be secure, so lightning had better leave sufficient transactions for the blockchain! A trivial answer to this is "market forces will work it out" -- too many lightning transactions reduces security, reduces lightning transactions, so it will presumably stabilise at something sane, and everyone lives happily every after. But I think it's actually a tractable question, so we can probably actually work out numbers! Basic assumptions: 1. devs/miners limit the number of transactions per block 2. miners choose the transactions that pay the highest fees to fill blocks 3. bitcoin watch what miners accept, and all settle on the smallest per-transaction fee that will get them included in a block 4. some people would like to use bitcoin, but are priced out because there are cheaper alternatives at the given per-transaction fee. eg at 8c/tx, it might be cheaper to send 50c by paypal (at 5c+5%) than the blockchain; whereas at 7c/tx bitcoin would be preferred. If blocks were unlimited, miners would accept every transaction, no matter how small the fee (2), which would set the per-tx fee to ~1 satoshi (3). Rational miners will thus limit the number of txs they accept (1) to ensure fees don't go to zero. Market assumptions: 5. the only thing preventing bitcoin from replacing credit card transactions at point of sale is (a) adoption of bitcoin, and (b) the transaction fees -- ie, if Visa/Mastercard is cheaper, people will keep using it. 6. Visa does around $7e12 (7 trillion) in volume per year in the US; and about 60e9 (60 billion) transactions [1]; on average that's 1900 tx/s, and about $117 per transaction. 7. The micropayments market is very small by comparison, with only $1e10 (10 billion) in volume per year, counting anything under $12 as a "micropayment". 8. Imagine payments are distributed in a log-normal distribution, then we can use the figures from (6) and (7) to get parameters median=exp(mu)=77.669, sigma=0.9021. 9. Visa charges about 20c+2% per transaction 10. Lightning will charge 1% for a full transaction (eg, 8 hops, 0.125% per hop) Basic conclusions: A. First thing to note is that of the three alternatives, ie, Visa, lightning and blockchain; that Visa and lightning get more expensive as the transaction amount increases, but bitcoin doesn't. Additionally, lightning is (by assumption) always chepaer than Visa. B. Without lightning, then, the highest value N transactions will go via the blockchain filling it up, at a fee equal to about 20c+2% of the smallest transaction. (If the fee were any lower, smaller transactions would be eligible for the blockchain, and higher value transactions would bid higher fees to ensure they were included first) So if the fee turned out to be 40c, transactions above $10 would be in the blockchain, and smaller than that would be via Visa. C. Without lightning, as bitcoin adoption increases, either fees rise, or number of transactions per block increases proportionally. If 1% of people know about bitcoin, and use it whenever it's cheap; then 2% of people knowing about bitcoin gives twice as many transactions at any given price level. If blocks accepted 2000 txs, and there were 1000 $20 tx/block and 1000 $10 tx/block, then doubling adoption either means having 2000 $20 tx/block and a new fee of about 60c (versus 40c), or doubling the block size and keeping the fee. D. Without lightning, fees increase rapidly with adoption: there are 1900 tx/s on Visa with an average value of $120, so there are probably around 900 tx/s with a value greater than $100. With a 1MB block allowing 2000 tx every 10 minutes, 0.4% adoption of bitcoin allows everyone of those transactions to be worth over $100, which in turn means the per transaction fee could be up to $2.20 (compared to about 2c at present) E. Without lightning, by this analysis, miners fees are mostly subject to what the competition charges -- if Visa drops their rates from 20c+2% to 5c+1.5%, bitcoin transaction fees will drop correspondingly. F. With lightning, the only part of the above that changes is the comparison to Visa -- instead of the only alternative to putting your transaction in the blockchain being to pay 20c+2% to Visa; you can pay 1% to lightning nodes to route your payment; so the outcome to miners is exactly the same as if Visa dropped its rates to a flat 1%. If the number of transactions per block stays constant, the transactions actually selected will also be the same, but fees paid to miners will reduce by about half (ie $2.20 to $1, 60c to 20c, 40c to 10c) Numerical conclusions: G. 60e9 transactions per year is 164M transactions per day or 1.13M transactions every ten minutes. If each megabyte of block size allows 2000 transactions, then handling 1.13M transactions every 10 minutes would require 565MB per block. However this would also drive fees down to zero; so there is a smaller blocksize that induces optimal fees. H. Given the log-normal distribution in (8), at 100% adoption and 100% availability of lightning, this turns out to occur with a blocksize of about 83MB, and a corresponding fee of about $2.02. This implies a rate of 276 tx/second on the blockchain, and miner revenue of about $335,000 in fees per block (compared to the inflation reward of about $7500 per block, at 25 BTC and $300/BTC). J. In such a scenario, lightning would be cheaper for any transaction with a value under $202, by far the majority of transactions. Lightning nodes would thus take the remaining 1624 tx/second, and earn what works out to be about $107M in fees per day, or, for comparison purposes, about $750,000 in fees per block. Collectively, lightning nodes would be handling 5.8 times as many transactions for about 2.2 times as much in fees. K. In the same scenario as above, but without lightning (and thus Visa as the only alternative, pushing fees up), the optimal blocksize works out to be 90MB, with a corresponding fee of about $4 per transaction. That works out a rate of 300 tx/second, and miner revenue of $720,000 in fees per block. Visa would handle the remaining transactions, earning $232M per day, or for comparison purposes about $1,615,000 per block. L. If people adopt bitcoin and lightning independently of their transaction amounts, and the log-normal model above is accurate, those figures scale fairly simply: with lightning, $2.02 remains the revenue-maximising per-transaction fee for miners; optimal blocksize scales proportionally; ie with 10% adoption, an 16000 transactions per block or about 8MB is optimal, and with 1% adoption, 1600 transactions per block or about 800kB is optiomal. M. Varying the fee lightning nodes charge in the scenario above has a direct effect on the bitcoin fee, but does not change the optimal block size for a given level of adoption. So halving the lightning fee to 0.5% would result in the optimal fee also halving, with miners' revenue halving to about $168,000 per block. N. If lightning had fees at 0.22%, the optimal bitcoin fee would be about 45c per transaction (with lightning still cheaper for transactions below $200 in value); at 10% adoption, optimal blocksize would be about 8MB or 16000 transactions per block, which would result in about $7200 per block in fee to miners, which is about 24BTC per block given a price of $300/BTC. This might be a plausible set of figures to target -- reasonable volume, reasonable profit, still fairly cheap, and with wide but not completely crazy adoption? Caveats: Z. The log-normal distribution might not be reasonable. I've no idea of anything better though. Also, the numbers from Visa might be inaccurate or incomplete in the first place. They're also a couple of years old, don't include Mastercard, Amex, etc. Y. Visa, bitoin and lightning aren't exact subsititutes: * Neither Visa nor Lightning can execute "smart contracts" like bitcoin can; so the blockchain has additional demand on it beyond Visa's current market. * Visa is expensive or unsuitable for micropayments while lightning is designed for them, so the potential demand may be larger than estimated above (7). * Unlike Visa, lightning and bitcoin do not naturally support payments on credit or fraud protection for consumers, so some proportion of Visa's market is probably not addressable by lightning or bitcoin. * Lightning payments are confirmed immediately, unlike bitcoin transactions which take some time to be confirmed and can be unconfirmed for a short period afterwards, and unlike Visa where chargebacks are possible for month. X. Increased adoption probably has some correlation to transaction sizes rather than being completely independent; ie early adopters probably have a different distribution of transaction amounts compared to late adopters. No idea /how/ that's likely to differ though... W. Current fees of up to ~2c/tx differs wildly from the above estimates of $2 to $4 as the revenue maximising fees for miners above, given alternative methods of payment take 1%-2% in fees. Maybe that just means miners aren't maximising fee revenue at present (given low adoption, and high inflation reward that's probably reasonable); but maybe it means the distribution of payment sizes in bitcoin is wildly different to the estimated distribution of Visa transactions above (and skewed much lower). Alternatively, maybe it means that miners aren't an effective cartel, and thus can't force fees to rise to maximise revenue; that doesn't seem likely to me though... Cheers, aj [0] https://www.reddit.com/r/Bitcoin/comments/3n89cu/lightning_network_onion_routing_proposal/cvlvskx https://www.reddit.com/r/bitcoinxt/comments/3hf74y/lighting_network_ultimately_takes_fees_away_from/ http://lists.linuxfoundation.org/pipermail/bitcoin-dev/2015-October/011523.html [1] http://investor.visa.com/files/doc_downloads/annual%20meeting/Visa%20Annual%20Report%202013%20final%20website.pdf