Geir Harald Hansen [ARCHIVE] on Nostr: 📅 Original date posted:2012-03-04 📝 Original message:On 04.03.2012 02:04, ...
📅 Original date posted:2012-03-04
📝 Original message:On 04.03.2012 02:04, Luke-Jr wrote:
> On Saturday, March 03, 2012 6:51:34 PM Geir Harald Hansen wrote:
>> Long polling as currently implemented in pools has a race condition.
>> Does the miner reconnect first or does another block change happen
>> first? "Double" block changes are common with merged mining and I'm
>> doing all sorts of tricks in my pool backend to reduce this problem.
>
> How would you suggest addressing this? I presume if a share solves blocks on
> multiple chains, you just longpoll once when that's successful?
If the client doesn't tell you which block change it saw last, you can't
avoid this problem completely.
>> How about another entry "longpollid" in long poll responses. The last
>> seen longpollid should be included by the client in future long poll
>> requests. This enables the server to see if the client has missed any
>> block changes. The ID could perhaps be submitted in an HTTP header
>> (X-LongPollID?) if we wish to keep the JSON-RPC params empty, or params
>> could hold an object with a key "longpollid". Could be a string or
>> number, like "workid".
>
> Hmm, the problem is that adding any parameters to getmemorypool itself breaks
> compatibility with bitcoind 0.5, and using HTTP headers makes it HTTP-specific
> again. Any ideas?
I think long polling and reconnecting to LP is an HTTP-specific problem
anyway? So it may be best to go with an HTTP header. See below for an
idea for a capabilities reporting system, though, which would allow
putting this data into JSON.
>> Another useful value in the getmemorypool response would be "height", so
>> the miner can include the correct height in the coinbase. I would like
>> that in bitcoind as well. One JSON-RPC call instead of two, and no race
>> condition between getmemorypool and getblocknumber.
>
> Good catch. Should this be required (since it might be necessary for future
> Bitcoin blocks), or just "should" for compatibility?
I think "should" makes sense.
>> It should be explained how target vs. fulltarget works.
>
> What is unclear about this?
Reading through it again it is mostly clear except for one thing, how to
submit "share/merkle" style. It doesn't say exactly how to submit this data.
It says merkle tree, but a merkle branch should suffice. Also, I believe
the coinbase must always be the first transaction of a block? So we
won't need the transaction's index in the merkle tree (it's always index
zero). This would then be just an array of sha256 hashes making up the
merkle branch for the coinbase.
I'd prefer if block header, coinbase tx and merkle branch were submitted
in 3 pieces. When merged mining and submitting a block generating proof
to the aux backend you put an auxiliary proof of work between the block
header and transactions. So the header and transactions are not
necessarily adjacent. Also, there's no merkle branch in a regular
bitcoin block.
>> Perhaps some things should be optional for a client to implement?
>
> Doing this safely needs some way for clients to communicate capabilities to
> the server, which has the problem of passing parameters to getmemorypool.
Let's add an optional "servercapabilities" key on the server side, the
value being a space-delimited list of what's supported by the server. If
that list contains "clientcapabilities" then the client may, instead of
sending an empty request, send an object where one of the keys is
"clientcapabilities", and the value is a space-delimited list of extensions.
Those names are a bit long, maybe "caps" is better.
Ok, this is not entirely clean. For the first request the client won't
know what the server supports. For subsequent requests I guess always
assume the last caps the server reported.
>> I think "noncerange" is of limited use and there's a good chance of getting
>> the endianness wrong.
>
> There is no mining hardware to date that exhausts even half the nonce space,
> so I'd really prefer to see this as a required feature on the miner side. On
> the other hand, it's merely an extension for getwork, so I can see the problem
> so long as we're using getwork proxies.
Yes, you can end up getting half a nonce range from an upstream server,
and not being able to make use of it because your downstream clients
don't support it.
A single GPU can make full use of the noncerange if you allow the
timestamp to slip a few seconds into the past. I believe most miners do
that today.
Also worth including are the "hostlist" and "switchto" getwork
extensions. I think those can fit right into the JSON response, to keep
with being transport-agnostic, but otherwise look like they do for getwork.
Regards,
Geir H. Hansen
Published at
2023-06-07 03:12:12Event JSON
{
"id": "7c852b9305f5058705b2021d14dd6bcd344aed6f2f1d2a799e37b75cffcf064b",
"pubkey": "b04dd51d5d295382c4c68bc7c8c13b04c80b4467ef06288a623121fbb7c9cfd3",
"created_at": 1686107532,
"kind": 1,
"tags": [
[
"e",
"3c851c8f17df1dd68608e4374d6cde0ed02a6a2268be0433e6610590ab1017ab",
"",
"root"
],
[
"e",
"a454421122a120644d95a58e2652485aaf43afb47604330a5f9b0f8dee454155",
"",
"reply"
],
[
"p",
"6ac6a519b554d8ff726a301e3daec0b489f443793778feccc6ea7a536f7354f1"
]
],
"content": "📅 Original date posted:2012-03-04\n📝 Original message:On 04.03.2012 02:04, Luke-Jr wrote:\n\u003e On Saturday, March 03, 2012 6:51:34 PM Geir Harald Hansen wrote:\n\u003e\u003e Long polling as currently implemented in pools has a race condition.\n\u003e\u003e Does the miner reconnect first or does another block change happen\n\u003e\u003e first? \"Double\" block changes are common with merged mining and I'm\n\u003e\u003e doing all sorts of tricks in my pool backend to reduce this problem.\n\u003e \n\u003e How would you suggest addressing this? I presume if a share solves blocks on \n\u003e multiple chains, you just longpoll once when that's successful?\n\nIf the client doesn't tell you which block change it saw last, you can't\navoid this problem completely.\n\n\u003e\u003e How about another entry \"longpollid\" in long poll responses. The last\n\u003e\u003e seen longpollid should be included by the client in future long poll\n\u003e\u003e requests. This enables the server to see if the client has missed any\n\u003e\u003e block changes. The ID could perhaps be submitted in an HTTP header\n\u003e\u003e (X-LongPollID?) if we wish to keep the JSON-RPC params empty, or params\n\u003e\u003e could hold an object with a key \"longpollid\". Could be a string or\n\u003e\u003e number, like \"workid\".\n\u003e \n\u003e Hmm, the problem is that adding any parameters to getmemorypool itself breaks \n\u003e compatibility with bitcoind 0.5, and using HTTP headers makes it HTTP-specific \n\u003e again. Any ideas?\n\nI think long polling and reconnecting to LP is an HTTP-specific problem\nanyway? So it may be best to go with an HTTP header. See below for an\nidea for a capabilities reporting system, though, which would allow\nputting this data into JSON.\n\n\u003e\u003e Another useful value in the getmemorypool response would be \"height\", so\n\u003e\u003e the miner can include the correct height in the coinbase. I would like\n\u003e\u003e that in bitcoind as well. One JSON-RPC call instead of two, and no race\n\u003e\u003e condition between getmemorypool and getblocknumber.\n\u003e \n\u003e Good catch. Should this be required (since it might be necessary for future \n\u003e Bitcoin blocks), or just \"should\" for compatibility?\n\nI think \"should\" makes sense.\n\n\u003e\u003e It should be explained how target vs. fulltarget works.\n\u003e \n\u003e What is unclear about this?\n\nReading through it again it is mostly clear except for one thing, how to\nsubmit \"share/merkle\" style. It doesn't say exactly how to submit this data.\n\nIt says merkle tree, but a merkle branch should suffice. Also, I believe\nthe coinbase must always be the first transaction of a block? So we\nwon't need the transaction's index in the merkle tree (it's always index\nzero). This would then be just an array of sha256 hashes making up the\nmerkle branch for the coinbase.\n\nI'd prefer if block header, coinbase tx and merkle branch were submitted\nin 3 pieces. When merged mining and submitting a block generating proof\nto the aux backend you put an auxiliary proof of work between the block\nheader and transactions. So the header and transactions are not\nnecessarily adjacent. Also, there's no merkle branch in a regular\nbitcoin block.\n\n\u003e\u003e Perhaps some things should be optional for a client to implement?\n\u003e \n\u003e Doing this safely needs some way for clients to communicate capabilities to \n\u003e the server, which has the problem of passing parameters to getmemorypool.\n\nLet's add an optional \"servercapabilities\" key on the server side, the\nvalue being a space-delimited list of what's supported by the server. If\nthat list contains \"clientcapabilities\" then the client may, instead of\nsending an empty request, send an object where one of the keys is\n\"clientcapabilities\", and the value is a space-delimited list of extensions.\n\nThose names are a bit long, maybe \"caps\" is better.\n\nOk, this is not entirely clean. For the first request the client won't\nknow what the server supports. For subsequent requests I guess always\nassume the last caps the server reported.\n\n\u003e\u003e I think \"noncerange\" is of limited use and there's a good chance of getting\n\u003e\u003e the endianness wrong.\n\u003e \n\u003e There is no mining hardware to date that exhausts even half the nonce space, \n\u003e so I'd really prefer to see this as a required feature on the miner side. On \n\u003e the other hand, it's merely an extension for getwork, so I can see the problem \n\u003e so long as we're using getwork proxies.\n\nYes, you can end up getting half a nonce range from an upstream server,\nand not being able to make use of it because your downstream clients\ndon't support it.\n\nA single GPU can make full use of the noncerange if you allow the\ntimestamp to slip a few seconds into the past. I believe most miners do\nthat today.\n\nAlso worth including are the \"hostlist\" and \"switchto\" getwork\nextensions. I think those can fit right into the JSON response, to keep\nwith being transport-agnostic, but otherwise look like they do for getwork.\n\nRegards,\nGeir H. Hansen",
"sig": "f45b4ed6cf24edf3a210ec7871c7d39ea406a4b2b824e204950dff5a3e2ac223b30a4cade8f5eb81b828e169aff1c448821713fe883ca8e02558dad257df17e0"
}