<div dir="ltr"><div>Reserving my judgement until I&#39;ve though about it more (design by 
committee scares me, and this voting sounds expensive), I think the 
SPV-verifiable moving median can be done by binning the space of block 
size limits, and for each node in the UTXO tree, a value for each bin is
 stored which is the sum of the corresponding bins of each of the 
children.  The childless nodes - which correspond to the individual 
UTXOs - increment the appropriate bin of their parents according to the 
rules you mentioned.  The bin values in the root node of the UTXO tree 
would then be added to those, weighted appropriately, of the previous N 
blocks.<br>
<br></div><div>The hash of a node would be that of the bin values, 
concatenated with the child nodes&#39; hashes.  In this way, any step of the
 calculation of the median would produce a localized error in the UTXO 
tree that&#39;s easily verified.<br>
</div><div><br></div>The number of bins would have to be kept relatively
 small in order to keep this from adding too much data to the UTXO tree 
branches though.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 10, 2013 at 2:30 AM, Peter Todd <span dir="ltr">&lt;<a href="mailto:pete@petertodd.org" target="_blank">pete@petertodd.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jun 10, 2013 at 04:09:26AM +0000, John Dillon wrote:<br>
<br>
My general comments on the idea are that while it&#39;s hard to say if a<br>
vote by proof-of-stake is really representative, it&#39;s likely the closest<br>
thing we&#39;ll ever get to a fair vote. Proof-of-stake is certainely better<br>
than just letting miners choose; as you point out miners can always<br>
choose to decrease the blocksize anyway so we only need a vote on<br>
allowable increases. Proof-of-stake also clearly favors those who<br>
actually have invested in Bitcoin over those who only talk about<br>
Bitcoin.<br>
<br>
I&#39;ll also say that while I know people will complain about putting<br>
politics into a technical problem, as I keep saying, is *is* a political<br>
issue. The limitations may be technical, but the ultimate issue is a<br>
very political decision about what we want Bitcoin to be. Yes, there<br>
will be people campaigning left and right to get users to vote for<br>
various limits with their coins, deal with it. Democracy is messy.<br>
<br>
Voting would take a lot of the nastier politics out of the situation,<br>
perhaps somewhat ironically. It would quite clearly take control away<br>
from the core development team, and the Bitcoin Foundation, and put it<br>
back in the hands of the community; you can&#39;t argue conspiracy theories<br>
that the Foundation is trying to control Bitcoin when there is a<br>
completely transparent voting system in place. People will complain that<br>
big Bitcoin players are throwing their weight around, but the blockchain<br>
itself is a voting mechanism that is anything but 1 person = 1 vote.<br>
<br>
Of course I wouldn&#39;t be the slightest bit surprised if users happily<br>
vote themselves into something looking like a centralized PayPal<br>
replacement in the long run, but at least if that happens the process by<br>
which they get there will be transparent and relatively democratic.<br>
<div class="im"><br>
<br>
&gt; A vote will consist of a txout with a scriptPubKey of the following form:<br>
&gt;<br>
&gt;     OP_RETURN magic vote_id txid vout vote scriptSig<br>
&gt;<br>
&gt; Where scriptSig is a valid signature for a transaction with nLockTime<br>
&gt; 500,000,000-1 spending txid:vout to scriptPubKey:<br>
&gt;<br>
&gt;     OP_HASH160 H(OP_RETURN magic vote_id txid vout vote) OP_EQUAL<br>
<br>
</div>I just wanted to point out how general this mechanism is. Regardless of<br>
what the scriptPubKey form is, standard, P2SH, multisig, whatever to<br>
vote is to simply prove you could have spent the txout.<br>
<div class="im"><br>
&gt; vote_id is the ID of the specific vote being made, and magic is included to<br>
&gt; allow UTXO proof implementations a as yet unspecified way of identifying votes<br>
&gt; and including the weighted median as part of the UTXO tree sums. (it also<br>
&gt; allows SPV clients to verify the vote if the UTXO set is a Patricia tree of<br>
&gt; scriptPubKeys) vote is just the numerical vote itself.<br>
<br>
</div>Ah, you&#39;re assuming a direct Patricia tree. Keep in mind that<br>
scriptPubKey&#39;s can be up to 10,000 bytes long, and an attacker can use<br>
that (with 10,000 other txouts) to create some extremely deep trees. I<br>
said on IRC a few days ago about how skeptical I am of implementing<br>
consensus critical systems with such huge differences in average and<br>
worst case, but I&#39;ll admit this is a decent use-case.<br>
<br>
Having said that, proof to SPV clients leaves open the interesting<br>
possibility that a third-party holding Bitcoins on your behalf can prove<br>
that they voted according to your wishes, or even prove they voted<br>
according to all their users wishes. Basically we&#39;d add a rule for the<br>
UTXO tree where a specific OP_RETURN form is included in the UTXO tree,<br>
even though it is unspendable, and is removed from the tree if the<br>
master txout is spent. Note that in this case by &quot;prove they voted&quot; we<br>
mean the service actually taking the step of ensuring their vote was<br>
recorded in the blockchain.<br>
<div class="im"><br>
&gt; The vote must compute<br>
&gt; the median, rather than the mean, so as to not allow someone to skew the vote<br>
&gt; by simply setting their value extremely high. Someone who still remembers their<br>
&gt; statistics classes should chime in on the right way to compute a median in a<br>
&gt; merkle-sum-tree.<br>
<br>
</div>I think the definition of the median requires knowledge of all the points so<br>
it&#39;ll have to be a separate sorted tree - kinda complex unfortunately if<br>
you really do want to be able to do full proof to SPV clients. Maybe<br>
just putting the hash of the overall results in the coinbase is enough<br>
for now.<br>
<br>
The term to google is &quot;moving median&quot; - looks complex.<br>
<div class="im"><br>
&gt; Of course in the future the voting mechanism can be used for additional votes<br>
&gt; with an additional vote_id. For instance the Bitcoin community could vote to<br>
&gt; increase the inflation subsidy, another example of a situation where the wishes<br>
&gt; of miners may conflict with the wishes of the broader community.<br>
<br>
</div>Good idea on keeping the code general.<br>
<div class="im"><br>
&gt; For any given block actual limit in effect is then the rolling median of the<br>
&gt; blocks in the last year. At the beginning of every year the value considered to<br>
&gt; be the status quo resets to the mean of the limit at the beginning and end of<br>
&gt; the interval.  (again, by &quot;year&quot; we really mean 52,560 blocks) The rolling<br>
&gt; median and periodic reset process ensures that the limit changes gradually and<br>
&gt; is not influenced by temporary events such as hacks to large exchanges or<br>
&gt; malicious wallet software.  The rolling median also ensures that for a miner<br>
&gt; the act of including a vote is never wasted due to the txout later being spent.<br>
<br>
</div>Good points, although keep in mind you&#39;ve created a lot of consensus<br>
critical code that is easiest to implement with floating point... not a<br>
good thing.<br>
<br>
One way to mitigate that risk might be to take advantage of the fact<br>
that unless the rolling median code itself is buggy, a consensus failure<br>
in the calculation is likely to result in different implementations<br>
still having a close agreement on the limit. So maybe we write some code<br>
where we won&#39;t build on top of a block that is larger than, say, 95% of<br>
the hard-limit unless another miner does so too?<br>
<div class="im"><br>
&gt; Implementing the voting system can happen prior to an actual hard-fork allowing<br>
&gt; for an increase and can be an important part of determining if the hard-fork is<br>
&gt; required at all.<br>
<br>
</div>Step #0 would be to think about OP_RETURN actually. FWIW Jeff Garzik has<br>
a pull-req (<a href="https://github.com/bitcoin/bitcoin/pull/2738" target="_blank">https://github.com/bitcoin/bitcoin/pull/2738</a>) to enable it,<br>
although only one txout per tx, and only with a 80-byte payload.<br>
<br>
Even just some ad-hoc voting by the &quot;raise-the-limit&quot; crowd would be a<br>
good first step to gaging interest.<br>
<div class="im"><br>
&gt; Coercion and vote buying is of course possible in this system. A miner could<br>
&gt; say that they will only accept transactions accompanied by a vote for a given<br>
&gt; limit. However in a decentralized system completely preventing vote buying is<br>
&gt; of course impossble, and the design of Bitcoin itself has a fundemental<br>
<br>
</div>Is it really? There might be someone clever with a cryptographic voting<br>
protocol, although in the case of Bitcoin we have to let people vote<br>
with arbitrary scriptPubKeys, so almost anything less general than full<br>
on SCIP just means miners force people to use the protocol where<br>
vote-buying is possible.<br>
<div class="im"><br>
&gt; A voting process ensures that any increase to the blocksize genuinely<br>
&gt; represents the desires of the Bitcoin community, and the process described<br>
&gt; above ensures that any changes happen at a rate that gives all participants<br>
&gt; time to react. The process also gives a mechanism for the community to vote to<br>
&gt; decrease the limit if it turns out that the new one was in fact too high. (note<br>
&gt; how the way the status quo is set ensures the default action is for the limit<br>
&gt; to gradually decrease even if everyone stops voting)<br>
<br>
</div>Good idea. So it&#39;d decrease to the mean of the old and new limits<br>
basically, and if Bitcoin becomes &quot;too centralized&quot; users can simply do<br>
nothing and the process gradually reverses.<br>
<div class="im"><br>
&gt; As many of you know I have been quite vocal that the 1MB limit should stay. But<br>
&gt; I would be happy to support the outcome of a vote done properly, whatever that<br>
&gt; outcome may be.<br>
<br>
</div>Same here.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
&#39;peter&#39;[:-1]@<a href="http://petertodd.org" target="_blank">petertodd.org</a><br>
0000000000000068a8ad033afa763246fe451e840eae5215eb3a64e8101a46c3<br>
</font></span><br>------------------------------------------------------------------------------<br>
How ServiceNow helps IT people transform IT departments:<br>
1. A cloud service to automate IT design, transition and operations<br>
2. Dashboards that offer high-level views of enterprise services<br>
3. A single system of record for all IT processes<br>
<a href="http://p.sf.net/sfu/servicenow-d2d-j" target="_blank">http://p.sf.net/sfu/servicenow-d2d-j</a><br>_______________________________________________<br>
Bitcoin-development mailing list<br>
<a href="mailto:Bitcoin-development@lists.sourceforge.net">Bitcoin-development@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" target="_blank">https://lists.sourceforge.net/lists/listinfo/bitcoin-development</a><br>
<br></blockquote></div><br></div>