Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Luke-Jr on October 05, 2011, 04:23:12 PM



Title: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 05, 2011, 04:23:12 PM
Link to coinbaser pull request (https://github.com/bitcoin/bitcoin/pull/550#issuecomment-2298619)

My coinbaser branch adds a "setworkaux" method to allow miners to add arbitrary coinbase data to their blocks. This is mainly useful to implement merged mining (mining for both bitcoins and namecoins concurrently), but could also be used for miner voting in the future. As with any JSON-RPC change, adding this requires some kind of consensus. Please vote in support. :)

This is a backward compatible change.

Unrelated to this poll:
In addition to "setworkaux", coinbaser also adds (non-Windows only!) a "-coinbaser=<cmd>" command line option to specify a command to execute during "getwork" calls; the command may output data specifying where to assign the generated coins (this is how I do generated payouts on Eligius). It also adds a minor internal restructure of coinbase-creation code, which can be used to more easily implement automatic feature upgrades (OP_EVAL, for example) by miner adoption. These changes are also backward-compatible, and provide useful functionality.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 05, 2011, 05:46:22 PM
I'd love to hear why someone voted No.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Gavin Andresen on October 05, 2011, 06:11:22 PM
I voted no because of the fine-print in your original post.

I think setworkaux is OK, but I don't like "doesn't work on windows" changes to support one mining pool.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 05, 2011, 06:19:18 PM
I voted no because of the fine-print in your original post.
The poll was, as stated, unrelated to the "fine print". You asked for consensus on JSON-RPC changes, which has nothing to do with the fine print.
I think setworkaux is OK, but I don't like "doesn't work on windows" changes to support one mining pool.
It might work on Windows with a few changes, but I don't have a Windows system to test on. http://msdn.microsoft.com/en-us/library/96ayss4b(v=vs.71).aspx

Also, there's nothing Eligius-specific about it.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: simplecoin on October 05, 2011, 09:30:42 PM
So, how do you intend setworkaux to be used?


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 05, 2011, 10:22:23 PM
So, how do you intend setworkaux to be used?
From the code:
Code:
setworkaux <id> [data]
If [data] is not specified, deletes aux.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 05, 2011, 10:24:09 PM
I think setworkaux is OK, but I don't like "doesn't work on windows" changes to support one mining pool.
It might work on Windows with a few changes, but I don't have a Windows system to test on. http://msdn.microsoft.com/en-us/library/96ayss4b(v=vs.71).aspx
Ok, ported coinbaser to Windows. Surprisingly, the problem wasn't popen, but fdopen (for TCP support).


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: shads on October 06, 2011, 06:04:37 AM
I'm not going to vote until I understand it better.

I think it replicates some of the functions of getworkaux from vinced's merged-mining fork.  If so there should be some discussion of which to use before considering either for pulling into the main branch.

Given that merged-mining-proxy uses getworkaux along with a couple of other new rpc calls, and that merged-mining-proxy will most likely be the fallback option for pools using pushpool to become merged-mining capable... and that I'm currently implementing merged mining into poolserverj using these calls from vinced's fork it would seem likely that it's going to gain wider adoption.

I'm totally open to using your method if it's somehow an improvement on the vinced method but simply saying it allows you insert data into the coinabse doesn't really explain the workflow of constructing a merged mining block.  You still need a way to get the header hash of each aux chain block (getwork and hash yrself?), contruct a merkle tree then presumably pass the merkle root of this to setworkaux.  I can figure it out that far but how under your scheme do you submit a solution to an aux chain?


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 09, 2011, 06:11:36 PM
Gavin has apparently decided (for no reason) that he isn't going to merge this, even though this thread met his requirement of having "community support" for the new "setworkaux" JSON-RPC method. I doubt I'll bother maintaining this through the next version, so I guess pester Gavin if you want it (or hope it gets merged to post-0.5 git before it needs yet another rebase...)


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Mike Hearn on October 10, 2011, 09:32:33 AM
I'd really like to see something like this get in, but I agree with Steve - it's not clear why this is different to what Vince has already done.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 10, 2011, 01:08:26 PM
I'd really like to see something like this get in, but I agree with Steve - it's not clear why this is different to what Vince has already done.
Vince's stuff is a mess of unreadable code, that requires putting a proxy (additional point of failure/bottleneck) in front of bitcoind. This approach is much simpler (at least insofar as modifications to bitcoind) and has no effect on the stability of the primary Bitcoin mining operation (since the merged-mining manager runs parallel to bitcoind, not in front of it). These changes are also more abstract, not necessarily tied to merged-mining specifically.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Mike Hearn on October 10, 2011, 02:03:18 PM
setworkaux looks pretty much like what I'd imagined. You might want to split the command line option out, as that's a separate and unrelated change.

BTW, what's the backwards-time detection stuff about? I know time can sometimes go backwards on some machines, but you could add a comment explaining why this code is there (was it observed in the wild on eligius machines)? Also it doesn't currently log anything when extraNonce overflows - is that an exceptional condition or something that's expected to happen normally? If the former (it's a bug) maybe assert/terminate. If the latter does it need to be logged? If it's unknown, logging for a while seems to make sense.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 10, 2011, 02:14:51 PM
setworkaux looks pretty much like what I'd imagined. You might want to split the command line option out, as that's a separate and unrelated change.
They're very much the same change: they both together support customization of the coinbase transaction.
BTW, what's the backwards-time detection stuff about? I know time can sometimes go backwards on some machines, but you could add a comment explaining why this code is there (was it observed in the wild on eligius machines)? Also it doesn't currently log anything when extraNonce overflows - is that an exceptional condition or something that's expected to happen normally? If the former (it's a bug) maybe assert/terminate. If the latter does it need to be logged? If it's unknown, logging for a while seems to make sense.
Just a safety precaution. I don't know if it's possible or ever occurs. (otoh, it's very easy to see many existing code paths in bitcoind cannot possibly occur... ;))


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Gavin Andresen on October 10, 2011, 03:08:55 PM
This is why I don't pull additions or major changes to RPC commands without at least a couple of people looking at them and either saying "yup, that's exactly how I would do it" or "it'd be better if...."

I agree with Mike, the -coinbaser <cmd> should be separate from setauxwork.

Does setauxwork interact with the new getmemorypool RPC command at all?  Should it?

And should there be a listauxwork RPC command?


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 10, 2011, 03:33:05 PM
Does setauxwork interact with the new getmemorypool RPC command at all?  Should it?
No, getmemorypool has nothing to do with setworkaux, coinbases, or merged mining. It's a JSON-RPC command that was merged with even less review than coinbaser, and is only used by a single pool.

And should there be a listauxwork RPC command?
Possibly as a debugging tool.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Gavin Andresen on October 10, 2011, 03:38:11 PM
No, getmemorypool has nothing to do with setworkaux, coinbases, or merged mining. It's a JSON-RPC command that was merged with even less review than coinbaser, and is only used by a single pool.

Huh?  getmemorypool discussion is/was here:  https://bitcointalk.org/index.php?topic=39088.0 (https://bitcointalk.org/index.php?topic=39088.0)

I'll just note that I'm damned if I do pull stuff that has some discussion here (and no objections raised), but damned if I don't pull stuff that first had no discussion, and then had a little discussion with some dissent.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 10, 2011, 05:20:16 PM
No, getmemorypool has nothing to do with setworkaux, coinbases, or merged mining. It's a JSON-RPC command that was merged with even less review than coinbaser, and is only used by a single pool.

Huh?  getmemorypool discussion is/was here:  https://bitcointalk.org/index.php?topic=39088.0 (https://bitcointalk.org/index.php?topic=39088.0)

I'll just note that I'm damned if I do pull stuff that has some discussion here (and no objections raised), but damned if I don't pull stuff that first had no discussion, and then had a little discussion with some dissent.
1-2 people supporting getmemorypool vs 9 supporting coinbaser. hmm.

What dissent? I see questions, and some "no" votes (strangely, most of which just appeared today), but no arguments against this.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: 2112 on October 10, 2011, 06:13:19 PM
What dissent? I see questions, and some "no" votes (strangely, most of which just appeared today), but no arguments against this.
The argument that I have: it appears that "getmemorypool" is a step towards allowing the miner to record a reasonably accurate time of finding the block. Which is in turn a step towards more tight and accurate timekeeping in the whole block chain.

Your patch just perpetuates the existing bad situation where the block times are untrustworthy and acausal.

Thank you for your time and understanding.
 


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 10, 2011, 06:25:41 PM
The argument that I have: it appears that "getmemorypool" is a step towards allowing the miner to record a reasonably accurate time of finding the block. Which is in turn a step towards more tight and accurate timekeeping in the whole block chain.

Your patch just perpetuates the existing bad situation where the block times are untrustworthy and acausal.
Block times will always be untrustworthy to a degree, and are already trustworthy to a degree. It is impossible and unreasonable to force everyone to have the exact same system clock. "getwork" does not enforce the time header, anyhow, so "getmemorypool" does not change this reality in any way. (that is, "getwork" allows miners to change the time at will)


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: 2112 on October 10, 2011, 06:41:16 PM
It is impossible and unreasonable to force everyone to have the exact same system clock.
I think that Lolcust and ArtForz provided a good counter-example by their GeistGeld alt-chain that uses SNTP for time synchronization. The objective is not "exact-same" system clock, but the system clock differences that are within currently acceptable norms: I think it is still one minute in the insurance industry and in something close to one second in the finance industry.

I'm sorry I misunderstood the difference in time-keeping between "getwork" and "getmemorypool".


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 10, 2011, 07:31:56 PM
It is impossible and unreasonable to force everyone to have the exact same system clock.
I think that Lolcust and ArtForz provided a good counter-example by their GeistGeld alt-chain that uses SNTP for time synchronization. The objective is not "exact-same" system clock, but the system clock differences that are within currently acceptable norms: I think it is still one minute in the insurance industry and in something close to one second in the finance industry.
Notice that I didn't say it's impossible/unreasonable to actually have the "exact" (within reason) same clock. I said it's impossible/unreasonable to force it. But anyhow, it is indeed an off-topic discussion for this thread, which has nothing to do with block times. :p


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: shads on October 12, 2011, 09:33:31 AM
I've only got two concerns left with this patch.  Luke's done some good doco for both parts of it.  And now that he's explained how you'd use a bit better I can see this becoming an eventual replacements for most of vinced's implementation.   It is a much cleaner way in the long run.

The remain concerns are:  Does the -coinbase <cmd> enforce either a minimum tx output value or a max number of tx outputs?  If not it should.  The primary use case for this for pools to payout their miners and have invalid blocks dealt with automagically.  It there are no limits it's only a matter of time before some pools start paying out tiny balances to masses of miners.  This could bloat the coinbase a lot unless I'm missing something. 

My second concern is that Luke has made the following comment in the wiki:

Quote
Insert exactly one of these headers into the scriptSig of the coinbase on the parent chain. vinced's code always inserts an OP_2, 0xfa, 0xbe, 'm', 'm' in front of it, but you don't have to.

As far as I can see this patch doesn't deal with validation of the aux blocks.  Presumably this will be left to vinced's original code as you'd require an update to all namecoin miners to alter it's validation rules.  So the question is, will the absence of OP_2, 0xfa, 0xbe, 'm', 'm' before the aux header prevent vinced's validation from working?  If so then the rpc call should check this and return an error if it doesn't.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 12, 2011, 12:31:38 PM
The remain concerns are:  Does the -coinbase <cmd> enforce either a minimum tx output value or a max number of tx outputs?  If not it should.  The primary use case for this for pools to payout their miners and have invalid blocks dealt with automagically.  It there are no limits it's only a matter of time before some pools start paying out tiny balances to masses of miners.  This could bloat the coinbase a lot unless I'm missing something.
There is nothing anyone can do to stop block-makers from producing tiny coins. Coinbaser does prevent invalid outputs, though-- if the output is not consistent (ie, tries to pay too much, to an invalid address, etc) it fails over the the default behaviour.

My second concern is that Luke has made the following comment in the wiki:

Quote
Insert exactly one of these headers into the scriptSig of the coinbase on the parent chain. vinced's code always inserts an OP_2, 0xfa, 0xbe, 'm', 'm' in front of it, but you don't have to.

As far as I can see this patch doesn't deal with validation of the aux blocks.  Presumably this will be left to vinced's original code as you'd require an update to all namecoin miners to alter it's validation rules.  So the question is, will the absence of OP_2, 0xfa, 0xbe, 'm', 'm' before the aux header prevent vinced's validation from working?  If so then the rpc call should check this and return an error if it doesn't.
No, the reason I changed this to say optional is because I am successfully using it on Eligius without that magic prefix. Furthermore, while the name "setworkaux" might be the source of confusion, it can be used for adding any arbitrary data to the coinbase, not just for the particular iteration of merged mining. There can very well be future functionality (like advertising your fee schedule, for example) using the coinbase as well.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: shads on October 12, 2011, 01:27:50 PM
The remain concerns are:  Does the -coinbase <cmd> enforce either a minimum tx output value or a max number of tx outputs?  If not it should.  The primary use case for this for pools to payout their miners and have invalid blocks dealt with automagically.  It there are no limits it's only a matter of time before some pools start paying out tiny balances to masses of miners.  This could bloat the coinbase a lot unless I'm missing something.
There is nothing anyone can do to stop block-makers from producing tiny coins. Coinbaser does prevent invalid outputs, though-- if the output is not consistent (ie, tries to pay too much, to an invalid address, etc) it fails over the the default behaviour.
True anyone could create a monster coinbase transaction if they had the knowledge to construct a block from scratch and feed it into the network via p2p protocol.  But if you knew enough to do that you'd probably know why it's a bad idea.  A simple command line switch doesn't require any real knowledge of the network to use successfully and that's where the danger lies.  A relatively technically unskilled pool op decides to payout every single miner on every won block.  This is quite feasible and without any enforcement it just makes the problem accessible to people more likely to make the mistake.

Quote
My second concern is that Luke has made the following comment in the wiki:

Quote
Insert exactly one of these headers into the scriptSig of the coinbase on the parent chain. vinced's code always inserts an OP_2, 0xfa, 0xbe, 'm', 'm' in front of it, but you don't have to.

As far as I can see this patch doesn't deal with validation of the aux blocks.  Presumably this will be left to vinced's original code as you'd require an update to all namecoin miners to alter it's validation rules.  So the question is, will the absence of OP_2, 0xfa, 0xbe, 'm', 'm' before the aux header prevent vinced's validation from working?  If so then the rpc call should check this and return an error if it doesn't.
No, the reason I changed this to say optional is because I am successfully using it on Eligius without that magic prefix.

And those blocks without magic prefix are accepted by the rest of the nmc network?  If so that's my concern dealt with.

*If* a reasonable limit on coinbase outputs could be added then for what it's worth I'd be happy to add my vote in favour on the change.  Without said limits then my vote is in favour of the 'setworkaux' part of the change only.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 12, 2011, 02:15:40 PM
And those blocks without magic prefix are accepted by the rest of the nmc network?  If so that's my concern dealt with.
Yes, they are.

*If* a reasonable limit on coinbase outputs could be added then for what it's worth I'd be happy to add my vote in favour on the change.  Without said limits then my vote is in favour of the 'setworkaux' part of the change only.
And what reasonable limit would that be? There are at least legitimate circumstances for having tiny-amount outputs (I always include a single 1 Satoshi output so it shows up on my pool's listtransactions). I suppose there could be a hard-cap on total count of outputs, but what should that be? Maybe 1% of the current block size limit? That gives 294 outputs max at 1 MB (the current hard-coded block size limit)-- an average of ~0.17 BTC each.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: shads on October 12, 2011, 03:19:32 PM
*If* a reasonable limit on coinbase outputs could be added then for what it's worth I'd be happy to add my vote in favour on the change.  Without said limits then my vote is in favour of the 'setworkaux' part of the change only.
And what reasonable limit would that be? There are at least legitimate circumstances for having tiny-amount outputs (I always include a single 1 Satoshi output so it shows up on my pool's listtransactions). I suppose there could be a hard-cap on total count of outputs, but what should that be? Maybe 1% of the current block size limit? That gives 294 outputs max at 1 MB (the current hard-coded block size limit)-- an average of ~0.17 BTC each.

Well I can see two approaches to determining limit.  Both have issues but just because it's tricky to enforce a limit sensibly isn't a good reason to allow open slather...

1/ Tx outpoint size is relatively constant.  Yes it can vary but for 99% of use cases it will the same type of script which is the same length.  So from simple easy to enfore rule that would probably be the better option.  I notice eligius already has some notion of a payout queue and I thought that might be somehow related to this issue.  I was quite suprised when I started looking a eligius coinbases to find the number of outputs was always far far less than what I'd guess yr total miners would be.  That's actually what got me thinking about this as a potential problem.  When I saw that I thought you were limiting it for that very reason.

2/ min tx value would be easier from a pool ops point of view.  And whilst the size of the outputs would be more variable it would at least prevent extreme accidental abuse.

Those are the options I can think of... not sure which is the best or if there's a better one or if I'm even worrying about a non-issue.  Hoping someone else will step up with an opinion...



Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 12, 2011, 03:31:28 PM
*If* a reasonable limit on coinbase outputs could be added then for what it's worth I'd be happy to add my vote in favour on the change.  Without said limits then my vote is in favour of the 'setworkaux' part of the change only.
And what reasonable limit would that be? There are at least legitimate circumstances for having tiny-amount outputs (I always include a single 1 Satoshi output so it shows up on my pool's listtransactions). I suppose there could be a hard-cap on total count of outputs, but what should that be? Maybe 1% of the current block size limit? That gives 294 outputs max at 1 MB (the current hard-coded block size limit)-- an average of ~0.17 BTC each.

Well I can see two approaches to determining limit.  Both have issues but just because it's tricky to enforce a limit sensibly isn't a good reason to allow open slather...

1/ Tx outpoint size is relatively constant.  Yes it can vary but for 99% of use cases it will the same type of script which is the same length.  So from simple easy to enfore rule that would probably be the better option.  I notice eligius already has some notion of a payout queue and I thought that might be somehow related to this issue.  I was quite suprised when I started looking a eligius coinbases to find the number of outputs was always far far less than what I'd guess yr total miners would be.  That's actually what got me thinking about this as a potential problem.  When I saw that I thought you were limiting it for that very reason.
The original reason for that was simply to help miners avoid a lot of tiny payouts they have to pay large fees to spend.

2/ min tx value would be easier from a pool ops point of view.  And whilst the size of the outputs would be more variable it would at least prevent extreme accidental abuse.
As I said, valid values can be as low as 1 satoshi...


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: shads on October 12, 2011, 03:49:44 PM
*If* a reasonable limit on coinbase outputs could be added then for what it's worth I'd be happy to add my vote in favour on the change.  Without said limits then my vote is in favour of the 'setworkaux' part of the change only.
And what reasonable limit would that be? There are at least legitimate circumstances for having tiny-amount outputs (I always include a single 1 Satoshi output so it shows up on my pool's listtransactions). I suppose there could be a hard-cap on total count of outputs, but what should that be? Maybe 1% of the current block size limit? That gives 294 outputs max at 1 MB (the current hard-coded block size limit)-- an average of ~0.17 BTC each.

Well I can see two approaches to determining limit.  Both have issues but just because it's tricky to enforce a limit sensibly isn't a good reason to allow open slather...

1/ Tx outpoint size is relatively constant.  Yes it can vary but for 99% of use cases it will the same type of script which is the same length.  So from simple easy to enfore rule that would probably be the better option.  I notice eligius already has some notion of a payout queue and I thought that might be somehow related to this issue.  I was quite suprised when I started looking a eligius coinbases to find the number of outputs was always far far less than what I'd guess yr total miners would be.  That's actually what got me thinking about this as a potential problem.  When I saw that I thought you were limiting it for that very reason.
The original reason for that was simply to help miners avoid a lot of tiny payouts they have to pay large fees to spend.

2/ min tx value would be easier from a pool ops point of view.  And whilst the size of the outputs would be more variable it would at least prevent extreme accidental abuse.
As I said, valid values can be as low as 1 satoshi...

Well I just don't think encouraging/facilitating tiny payouts is a good idea... perhaps this is the way to go: "Maybe 1% of the current block size limit? That gives 294 outputs max at 1 MB (the current hard-coded block size limit)"

It's more tricky for pool ops to calculate but it is a sensible number.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Mike Hearn on October 13, 2011, 12:51:43 PM
Quote
And those blocks without magic prefix are accepted by the rest of the nmc network?  If so that's my concern dealt with.

That's weird. What is the prefix for, if Namecoin doesn't actually need it?


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 13, 2011, 12:55:44 PM
Quote
And those blocks without magic prefix are accepted by the rest of the nmc network?  If so that's my concern dealt with.

That's weird. What is the prefix for, if Namecoin doesn't actually need it?
It was originally proposed as a way to prevent multiple MM hashes in the same coinbase. After a few people (myself included) made a fuss over the inelegance of it, I presume it was changed to the current (not too much better) method of forcing a specific slot in the aux merkle tree.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Mike Hearn on October 13, 2011, 12:59:49 PM
I don't understand either approach to be honest. The alt chains wiki page laid out how that's supposed to work. You tie your aux block to the coinbase hash with a merkle branch to the value in the coinbase transaction and an index into that coinbase scriptSig. There's no need for magic markers or some kind of "uber-merkle-tree" for all aux chains.

Maybe there's something I missed, after all I haven't actually implemented this.
 


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: John Tobey on October 13, 2011, 05:36:27 PM
Maybe there's something I missed, after all I haven't actually implemented this.

This thread (http://dot-bit.org/forum/viewtopic.php?f=5&t=269&start=40) touches on it.  I'm curious what you'd think of it.

Quote from: johntobey253
Quote from: vinced
Quote from: nodemaster
Quote from: Luke-Jr
Why is it so hard to simply disallow a master-chain block from "vouching for" more than one block in each aux chain? :/
Mhmm, If I understand it correctly this might be undesirable because it might be (and is common) that you solve several AUX chain blocks and have one master-block vouching for them, right? This problem would only be solved if the difficulty of both blockchains draw levels.

This was solved in the current code by requiring each chain to appear in a specific (pseudo-random) spot in the aux chain merkle tree, based on the chain ID.  So for a specific chain ID, you would only be able to "solve" one aux chain block per parent block.

It's good to see you all evaluating the details of the implementation and I appreciate the feedback.  The more eyes on this the better.

There is a more flexible solution to the problem.

The problem is that, with MM as first implemented, a miner could cheat the proof-of-work system by putting more than one Namecoin block header into one Bitcoin block.  This "cheating" would not cause a problem if the Namecoin blocks all had the same previous-block hash: one or another would win the race, as happens when competing blocks enter the network.  The problem would arise if a linked series of Namecoin blocks all existed in one Bitcoin block's aux Merkle trees.  The miner could work on them all at once, getting more from his hashes than difficulty warrants.

Vince's solution is to constrain the paths by which Namecoin blocks may be embedded in Bitcoin blocks.  This works, but it complicates the picture for miners and chain designers in a future with many merged-mining chains.

A better solution for new chains is to prevent the existence of linked series of aux chain blocks which lack proof of work.  You might do that by requiring each aux chain block to refer (perhaps via its own coinbase or a new header field) to the "solution" (target-meeting hash of parent chain block) as well as the hash of the previous block in the aux chain.  In Bitcoin, these two are the same, namely hashPrevBlock.  Force blocks to refer not just to the previous block in the chain but to the proof of work on that block.  A series of aux blocks all being worked on would not make sense, because the second block in the series would have to reference the first block's solution, so the first block would have to have been solved.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Mike Hearn on October 15, 2011, 03:25:53 PM
Yeah, that solution does look better. It'd be good to put that on the Alternative Chains wiki page too.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: John Tobey on October 16, 2011, 02:25:47 AM
Yeah, that solution does look better. It'd be good to put that on the Alternative Chains wiki page too.
Thanks, will update in my Copious Spare Time.  :D

(off-topic, sorry) I think also Luke-Jr's proposal
Quote from: Luke-Jr
Why is it so hard to simply disallow a master-chain block from "vouching for" more than one block in each aux chain? :/
could use elaboration.  I take it to mean, have the aux chain software enforce uniqueness of its work-proving hashes.  I think that would work too and is a bit more elegant than sticking the value in the aux chain.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on October 16, 2011, 02:44:47 AM
(off-topic, sorry) I think also Luke-Jr's proposal
Quote from: Luke-Jr
Why is it so hard to simply disallow a master-chain block from "vouching for" more than one block in each aux chain? :/
could use elaboration.  I take it to mean, have the aux chain software enforce uniqueness of its work-proving hashes.  I think that would work too and is a bit more elegant than sticking the value in the aux chain.
I think the latter is a better solution: it doesn't require looking up the hash in all the past blocks.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: John Tobey on October 16, 2011, 04:21:32 AM
Yeah, that solution does look better. It'd be good to put that on the Alternative Chains wiki page too.
Done.  New section (https://en.bitcoin.it/wiki/Alternative_Chains#Protecting_against_double_proof); created merged mining (https://en.bitcoin.it/wiki/Merged_mining) page as redirect to Alternative Chains.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: maaku on October 16, 2011, 05:32:07 AM
Couldn't one of the rules of the aux-chains be to reject proof-of-works which have more than one aux-header in the Merkle tree for the same aux-chain?


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Mike Hearn on October 16, 2011, 11:40:27 AM
Right, I didn't think Lukes proposal through properly. It is simpler so I updated the wiki page to say that.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: John Tobey on October 16, 2011, 12:42:13 PM
Right, I didn't think Lukes proposal through properly. It is simpler so I updated the wiki page to say that.
As I would have done, had not Luke himself preferred the other way.  No biggie, I think they're both fine, and the wiki page links here for the truly interested.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on November 21, 2011, 05:51:13 PM
Back on topic, it's about time for 0.6 merging, and coinbaser is still cleanly mergable. Could we get the few people who voted against it to change their votes, or at least explain them?


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Gavin Andresen on December 01, 2011, 01:52:30 AM
I don't know nuthin about merged mining-- anybody have objections to Luke-Jr's pull?

My only concern is: will this be a "used by exactly one person (the Eligius pool)" feature?


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: ByteCoin on December 01, 2011, 02:49:37 AM
I don't know nuthin about merged mining-- anybody have objections to Luke-Jr's pull?

How about enabling it exclusively on testnet for the moment? It is possible that badly written merged mining systems might spam BitCoin with blocks of low difficulty while happily mining on their own chains. Having the DOS prevention code enabled would mitigate this risk.

ByteCoin


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Luke-Jr on December 01, 2011, 02:52:30 AM
How about enabling it exclusively on testnet for the moment? It is possible that badly written merged mining systems might spam BitCoin with blocks of low difficulty while happily mining on their own chains. Having the DOS prevention code enabled would mitigate this risk.
This is not made possible with Coinbaser. All coinbaser does is allow modifying the content of your coinbase. Nothing else with the usual mining stuff is changed.


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: Inaba on December 02, 2011, 03:58:49 PM
I am using it... so it's at least 2 people :)


Title: Re: Coinbaser branch's new JSON-RPC method
Post by: slush on December 02, 2011, 04:00:45 PM
I'm thinking to use it too, because nobody maintains original merged mining code. So yes, I vote for that, too.