Skip to content

Instantly share code, notes, and snippets.

@mably
Last active January 25, 2016 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mably/6b6ce7b9b28e4d295b68 to your computer and use it in GitHub Desktop.
Save mably/6b6ce7b9b28e4d295b68 to your computer and use it in GitHub Desktop.
Bitcoin SegWit 4:1 ratio discussion on IRC Freenode #segwit-dev Saturday, January 23rd, 2016
09:52:49 <Tasoshi> I'm trying to understand the weighing of 4:1. If that is increased to 6:1 for example, does that mean an effective size of 6MB can be achieved?
10:03:23 → proslogion and AaronvanW joined
10:07:36 <•CodeShark> Tasoshi: that would be a worse case attack scenario
10:08:06 <•CodeShark> worst case attack scenario
10:08:43 <•CodeShark> "Effective size"is typical usage
10:09:01 <•CodeShark> Different kinds of transactions get different discounts
10:16:09 <Tasoshi> So if the discount is increased to something crazy, lets say 50:1, does that mean that in a worst case attack scenario a size of 50MB can be reached? What do you mean by worst case attack scenario by the way?
10:17:41 <•CodeShark> It means it's an absurd spam scenario
10:18:07 <•CodeShark> someone just filling blocks with useless stuff
10:19:17 <•CodeShark> An expensive attack...but not out-of-the-question
10:20:31 ⇐ cbit and ThomasV quit
10:25:27 <Tasoshi> Ah, I see. What do you mean by discount?
10:30:01 <•CodeShark> The cost reduction compared to the current limit as percentage of available space
10:31:00 <Tasoshi> by cost reduction do you mean the fee that you have to pay?
10:31:43 <Tasoshi> I'm just reading this and trying to understand it in plain language: "Blocks are currently limited to 1,000,000 bytes (1MB) total size. We change this restriction as follows:
10:31:44 <Tasoshi> Block cost is defined. The cost of each byte in the existing header and transactions is 4, while the cost of each byte in witness data is 1.
10:31:44 <Tasoshi> The new rule is total block cost ≤ 4,000,000. "
10:32:06 <•CodeShark> i.e. a transaction where half the data is witness data would cost 0.5 + 4*0.5 = 2.5 cost units per byte
10:32:46 <Tasoshi> Is this suggesting that in effect there would no longer be a maxblocksize limit, but this would instead be replaced with a block cost?
10:32:54 <•CodeShark> yes
10:35:53 <Tasoshi> I see, so if we increase the cost of header data then we can include more transactions assuming the witness data remains the same?
10:36:23 → ThomasV joined (~ThomasV@unaffiliated/thomasv)
10:38:08 <Tasoshi> And going back to your equation, what does 2.5 cost units mean? Is that 2.5 satoshis per byte?
10:43:25 <•CodeShark> No - it means we can fit 4,000,000 / 2.5 such transactions per block
10:43:53 <•CodeShark> I mean
10:44:18 <•CodeShark> 4,000,000 / (2.5*tx_bytes)
10:45:01 <Tasoshi> Oh, I see, so 2.5 MB?
10:49:15 <•CodeShark> the formula would be (b + 4w) / (b + w)
10:49:44 <•CodeShark> Where b is the nonwitness data size and w is the witness data size
10:49:55 <•CodeShark> For a 4:1 discount
10:52:03 <•CodeShark> So a transaction where a third of its data is witness data gets throughput increase (1/3 + 4/3) = 5/3
10:52:25 <•CodeShark> err
10:52:32 <•CodeShark> Sorry, messed that one up
10:53:01 <•CodeShark> 2/3 is witness data
10:53:31 <•CodeShark> 1/3 + 8/3 = 3
10:53:52 <Tasoshi> I'm not understanding what a cost unit is. Is that a fee, is that the size? So in your example formula earlier where the equation equals 2.5. When we are about to have the transaction, what do we do with this number (2.5)?
10:54:13 <•CodeShark> trying to type on mobile - sorry :)
10:54:24 <Tasoshi> no worries
10:55:44 <•CodeShark> So in the example of 1/2 the tx being witness data, we have 4,000,000 / 2.5 = 1,600,000
10:55:58 <•CodeShark> Which means an effective block size of 1.6
10:56:01 <•CodeShark> Mb
10:56:04 <Tasoshi> Ohhh, 2.5 is the discount?
10:56:18 <•CodeShark> 2.5 is the cost per byte
10:56:49 <•CodeShark> Each block has a limited amount of resources
10:57:12 <•CodeShark> The cost is how much of that finite resource is consumed
10:57:47 <Tasoshi> How is the cost paid?
10:57:56 <•CodeShark> free market
10:58:06 <•CodeShark> Miners can pick which transactions to include
10:58:15 <Tasoshi> I mean, in the formula.
10:59:07 <•CodeShark> The cost is not a measure of how much the sender pays - the fee is determined by supply and demand
10:59:57 <•CodeShark> at least assuming economically rational miners
11:00:33 <•CodeShark> Supply is limited to 4,000,000 cost units per block
11:02:13 <•CodeShark> I think the most useful number for comparison is the throughput multiplier
11:03:38 <Tasoshi> I guess I am confused by the word "cost unit" and I think you mentioned discount earlier
11:04:31 <•CodeShark> yeah - we're still formalizing the vocabulary ;)
11:04:55 <•CodeShark> "Discount" is the ratio of nonwitness cost to witness cost
11:05:25 <•CodeShark> "Cost" is how much of the 4,000,000 per block is consumed
11:05:53 <Tasoshi> I see, so cost means byte?
11:06:46 <•CodeShark> it's 4b + w
11:07:07 <Tasoshi> What's w?
11:07:51 <•CodeShark> b is size of the nonwitness data (the base data) in bytes, w is the size of the witness data in bytes
11:08:17 <•CodeShark> I mistyped some of the formulas above - damn touch keyboard
11:09:06 <•CodeShark> The most interesting formula is probably TM = 4(b + w) / (4b + w)
11:09:21 <•CodeShark> The throughput multiplier
11:09:57 <•CodeShark> This is the factor by which # of transactions per block is increased
11:11:07 <•CodeShark> So a transaction where 2/3 is witness data gets a TM of 4 / (4/3 + 2/3) = 2
11:11:36 <Tasoshi> 2MB?
11:12:00 <•CodeShark> 2MB would be the "effective block size"
11:12:44 <•CodeShark> The effective block size is the size a block would have to be if we have no witness discount
11:13:38 <•CodeShark> The effective block size is TM megabytes
11:13:55 <•CodeShark> Make sense?
11:14:42 <Tasoshi> Sort of, so what is the actual blocksize once the witness discount is included in your recent example?
11:20:23 <Tasoshi> Or are they both the same at 2MB?
11:21:13 <•CodeShark> yes
11:25:06 <Tasoshi> So, the effective blocksize is the same as the actual size of a block?
11:25:32 → Thireus joined (~Thireus@vps-92.197.170.217.stwvps.net)
11:25:43 <Thireus> hey guys, what's up
11:26:25 <•CodeShark> Hi Thireus
11:26:49 <•CodeShark> Tasoshi: the actual size of the block depends on all the transactions in it
11:27:42 <•CodeShark> and might be below the max
11:27:58 <•CodeShark> we should actually call it effective max block size
11:30:26 <Tasoshi> Sorry, I'm just confused because you said: "The effective block size is the size a block would have to be if we have no witness discount". So, presumably, if we include the witness discount the size would be different? I was wondering what size that would be as per your example
11:32:23 <Tasoshi> not sure if I am understanding correctly, but I used 0.33 + 4*0.33 = 1.65 | 4000000 / 1.65= 2424242
11:32:38 <•CodeShark> ok, so if 2/3 of transaction data is witness data, it means the effective max block size is 2MB - this means if we had no witness discount, we would get the same throughput as if we had a 2MB max block size
11:33:34 <•CodeShark> it should be 4*0.33 + 0.66
11:33:51 <•CodeShark> 4b + w
11:36:28 <Tasoshi> Oh, I see, you saying it would be same as if maxblocksize=2mb, right
11:38:11 <Tasoshi> So, if 2/3 of witness data gives an effective size of 2mb, then even if it is 100% witness data we would not reach 4mb?
11:39:32 <•CodeShark> No, if it's 100% witness data we get 4MB...but that's an attack scenario
11:39:48 <•CodeShark> More typical is 66% witness data
11:40:02 <Tasoshi> Oh yeah, because 4x0+1
11:45:08 → nullpt joined (~nullpt@40-225-25-217.inthome.vrn.ru)
11:58:38 <Tasoshi> So let me see if I have understood. Supposing we have a transaction with 500 bytes in non witness data and 700 bytes in witness data. Do we just use the formula of 4x500 +700 = 2700 | 4000000/2700 = 1481 bytes - So that's the maxblocksize when the actual size is 1200 bytes?
12:04:44 <•CodeShark> 4(500 + 700) / (4*500 + 700) = 4(1200) / (2700) = 4800/2700
12:05:03 <Tasoshi> I am not sure I have understood however because if we have a transaction or a set of transactions with 2700 bytes and only 100 bytes of witness data we get 4 x 2700 +100 = 10900 | 4m/10900=366
12:05:32 <•CodeShark> 4800/2700 ~ 1.77
12:05:51 <•CodeShark> that's thr throughput multiplier
12:07:54 <Tasoshi> What do we then do with the number you just provided, 1.77?
12:10:05 → aschildbach joined ⇐ nullpt__ quit
12:26:20 <•CodeShark> It means 1.77x increase in transaction throughput
12:26:51 <•CodeShark> 1.77MB effective max block size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment