-
Notifications
You must be signed in to change notification settings - Fork 36.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BIP22: getblocktemplate #936
Conversation
What does @forrestv think? |
I don't see any reason to separate submitblock, further cluttering the RPC interface, if the old way will continue to be supported. Other than that, looks good! |
I only kept the old way in there for backward compatibility. There's really no reason to use the same method for two different functions - it's like sending coins using getbalance. More importantly, "getmemorypool(<data>)" doesn't provide any way to communicate the reason for rejections. During BIP discussion, some developers expressed interest in keeping the JSON-RPC protocol HTTP-independent, and abusing HTTP headers like getwork does violates this. There is also a need for passing "features supported" from clients to getmemorypool() so that clients can opt to not implement "noncerange" and inform the server on their support (or lack thereof) of other features (so it might possibly optimize its own processes based on that). So far, nobody has come up with a backward-compatible way to do this; perhaps it would be desirable to ignore non-string , so that a future draft can turn it into an options Object? |
Ah, I see. ACK then. |
Too late in the 0.6 release cycle for a new RPC call. I think we should pull this early in the 0.7 release cycle so it gets lots of testing. |
I disagree with the term bugfix here, but ACK on the changes. |
ACK (and agree w/ sipa on term) |
Rewrote based on recent BIP 22 revisions, including longpolling support. |
Moved longpolling to #1355 |
ACK, now. |
Eligius has been running this from block 179513 (56 blocks found) and EclipseMC from 180573 (11 blocks), totalling 67 valid blocks with no problems found. |
Rebased, plus the changes to BIP 22 discussed on IRC (getmemorypool now requires exactly one argument, the parameters Object, but tolerates the old calling methods for compatibility) Also stripped whitespace when parsing JSON Object in bitcoind-CLI-test-tool (while it could just convert input to Object regardless, it seemed sensible to keep the CLI working with older servers). |
I've been trying to send a mail to the mailing list about BIP22, but it doesn't seem to come through. As it's a bit too long to paste here, you can read it on https://gist.github.com/2909725. |
@sipa can you pipe that through "fmt -72" or similar? Even 'raw' requires a horizontal scroll bar, which is unreadable in these modern times... |
@jgarzik done |
@sipa Hope this addresses everything:
|
@gavinandresen "Overcomplicated" is relative based on what it needs to do. I think for the most part (there are exceptions, which I hope to simplify based on sipa's suggestions) BIP22 as it is can't get too much simpler with its given requirements. |
I guess @sipa and I think maybe you're throwing in too many requirements. I say start simple, and if there is demand for a feature add it later. I'm OK with planning ahead with a design that allows stuff like adding/removing transactions, but that's a feature I've never heard "dumb miners" say they want. Also: being explicit about the requirements in the BIP might help. I see only a very vague description of them in the 'motivation' section. |
Optional things means fewer requirements, not many. "Dumb miners" don't care about any of this, they're fine using getwork with centralized pools. BIP22 is aimed at "smart miners" which want to (at least) audit the blocks they're working on to keep Bitcoin secure against potential poolop attacks. One practical superiority of decentralized mining is that miners are restored the freedom to choose their own minimum fee policies - that requires being able to pick and choose transactions that go into their blocks. At the same time, pools negotiating bulk fees has been an accepted "plan" for a while, and BIP22 can support that also. I will try to expand on the Motivation section. |
Updated BIP22 based on @sipa and @gavinandresen 's suggestions. Unless there are problems with the subset of BIP22 supported by bitcoind (in this pull request), however, let's move BIP22 discussion back to the mailing list. I don't think it makes sense to hold up this pullrequest due to unrelated concerns. |
transactions.push_back(HexStr(ssTx.begin(), ssTx.end())); | ||
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); | ||
|
||
static Array*paMutable = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being cached? If it really needs to be cached, then I'd suggest static Array mutable; if mutable.size == 0 ... then initialize.... to avoid memory-leak-checking tools complaining about leaking paMutable at shutdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make it slower by not caching it? Adding the static Array idea to rebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt caching it helps a lot, as the values need to be copied into the output Object anyway. Doing that directly is probably just as slow as copying it from a cached value. That said, I doubt it's the only place where we use allocated objects in static variables, so I don't really care.
Rebased addressing Gavin's most recent comments. |
One thing that still bothers me in the implementation is that is supports different decompositions for transactions. I understand the fee/sigops/dependencies/size meta-data is necessary, but do we really need to retain the origin (hex) encoding as well? Sure, dumb miners don't need this, but the protocol is aimed at non-dumb miners. |
Smart miners don't necessarily have a transaction database available either. In fact, I'm not aware of a single getmemorypool client that has easy access to one right now. |
Also, support for fetching transaction list as hashes exists for non-mining tools (I find it handy via the CLI as a human, to see what transactions are in the mempool). Support for fetching them as hex only is mainly a backward compatibility thing. |
@luke-jr What I was talking about in my latest comment here, is the availability of {"tx" : "hex"}, as {"tx" : "obj"} provides a strict superset of that. It would indeed mean breaking backward compatibility, indeed. |
So... seems nobody has anything else that needs addressing - time to merge? |
Conditional NAK[1]: pick one of DM_OBJ or DM_HEX, not both. ACK, if one of those is removed. [1] Red Hat's "conditional NAK" means that if the described condition disappears, then the NAK disappears. |
Looks good to a quick review. I'll have to apply the patch and read to be thorough. Please edit the OP to indicate name change and consensus "why?" opinion. |
Will do as soon as we have a final on the new name. I emailed @gavinandresen so hopefully he'll provide input next time he's got email access. |
Encore on the name. Gavin Andresen On Aug 2, 2012, at 11:02 AM, [email protected] wrote:
|
The following review comes from reading the code directly, and may or may not reflect a change you made. Regardless, it is something that warranted a note.
|
|
- Replaces getmemorypool with new getblocktemplate - Add missing keys: coinbaseaux, target, mutable, noncerange, sigoplimit, sizelimit, and height - Accept and send parameter Objects, checking "mode" key if present - Return rejection reason "rejected" for submit mode
Conflicts: src/bitcoinrpc.cpp
5,6) The pooled mining sections are moved to BIP 23. coinbasetxn is not required, since coinbasevalue is provided, and it's not very trivial to add (it would break the template caching).
|
ACK |
…atch PROTOCOL_VERSION 411ad29 Bump NO_BLOOM_VERSION and SENDHEADERS_VERSION to match PROTOCOL_VERSION
…er been used. ac8a1d0 [RPC] Remove field in getblocktemplate help that has never been used (Conor Scott) Pull request description: [BIP 22 - getblocktemplate](https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki#Transactions%20Object%20Format) specifies an optional flag, `required` if the transaction must be in the block. Luke's implementation #936 did not include this flag, and it was later added to the help description in #3246 (more than a year later) but the field was still never actually implemented. As far as I can tell, bitcoin core would have never actually included this in a `getblocktemplate` call, so it seems logical to remove it from the help description. If I am missing something or this is considered harmless - I can close the PR. Tree-SHA512: f25dda51cc4e1512aff69309be04e3053bdccc1cf03c8d58e8866aa1fdf9d86cc57df872e85528351fc8a8d6d64a8f46a36c513680834762d854f368fbeb0f44
…r Signature 6cf4922 [Bug][Wallet] Guard chainActive access in GetMintMaturityHeight (random-zebra) 95c1532 [Build] Fix CMake linking order (random-zebra) 46f1e53 [Build] Add CoinRandomnessSchnorrSignature to CMakeLists.txt (random-zebra) 183bce4 [zPIV] Add schnorr pk to challenge hash (random-zebra) 0178bbc [Tests] Additional cases for zc public spends v4 (random-zebra) 64efc69 [Tests] Add v4 Spends to zerocoin_valid_public_spend functional test (random-zebra) 3398090 [Refactor] add BN_THREE hardcoded constant for CBigNum(3) (random-zebra) 95952f1 [Cleanup] Fix non UTF-8 chars in ParamGeneration comments (random-zebra) 6288bb7 [Tests] PublicCoinSpend v4 / CRSchnorrSig unit tests (random-zebra) 7b81e54 [zPIV] Remove v2 serials from serialized v4 PublicCoinSpend (random-zebra) a9b8aa0 [Consensus] PublicCoinSpend v4 enforcement (random-zebra) ecd9bcd [zPIV] PublicCoinSpend v4 definition (random-zebra) 0f1f881 [zPIV] CoinSpend: define getCoinVersion() (random-zebra) 5a2ab57 [Consensus] set placeholder for nPublicZCSpendsV4 (random-zebra) e346308 [zPIV] CoinRandomnessSchnorrSignature class definition (random-zebra) 5f9de6d [Refactor] Use hardcoded constants for CBigNum 0, 1, 2 (random-zebra) Pull request description: This PR proposes (as hard fork) a new PublicCoinSpend protocol suitable to be used also with zerocoins version 1. Closes PIVX-Project#937 Motivation and overview in the following document: https://github.com/random-zebra/PIVX-Wiki/blob/master/Developer-Documentation/Specs/zPIV/CoinRandomnessSchnorrSignature.mediawiki Enforcement height uses placeholder values (one million blocks after the activation of spends v3 for main net and testnet, and 100 blocks for regnet). Changes - replaces many instances of `CBigNum(0)`, `CBigNum(1)`, `CBigNum(2)` throughout the code with fixed constants defined in bignum.h. - defines the `CoinRandomnessSchnorrSignature` using the algorithm described in the [wiki](https://github.com/random-zebra/PIVX-Wiki/blob/master/Developer-Documentation/Specs/zPIV/CoinRandomnessSchnorrSignature.mediawiki). - defines the temporary activation height and also defines an helper function `Zerocoin_PublicSpendVersion` which returns the version active at a given block height. - defines a convenient method to retrieve the coin version from a `PublicCoinSpend` class (now that coin version and spend version are different). - defines `PublicCoinSpend` behaviour for v4. - enforces the PublicCoinSpend version in `ContextualCheckZerocoinSpendNoSerialCheck`. - provides unit tests for the new v4 `PublicCoinSpend` class. ACKs for top commit: furszy: We can merge this already, ACK 6cf4922 . Mrs-X: utACK PIVX-Project@6cf4922 (unfortunately cannot really test it) Tree-SHA512: 56a4e796323862453e593035d2ee9c1148e67db85bd90af015916c5e2be71e586aad289ebcfa63dc076bd4a6be9a5430ae01b5d42c8f9df7027bfee908dfdb99
e06f7b6 [Tests] Minor optimizations in zerocoin_valid_public_spend test (random-zebra) cdc18ea [RPC] fix parameters check for spendzerocoin (missing ispublicspend) (random-zebra) 72bc39a [Tests] Add zerocoin_valid_public_spend to testRunner (random-zebra) 26045d3 [Consensus] Set zc PublicSpend version v3/v4 via SPORK (random-zebra) Pull request description: This follows bitcoin#936 It sets the required version for zerocoin PublicSpends via SPORK instead of having it height-based. When `SPORK_18_ZEROCOIN_PUBLICSPEND_V4` is not active (default), the required version is v3 (where old version 1 serials cannot be spent. ref: bitcoin#891 ). It also fixes the relative functional test `zerocoin_valid_public_spend.py` and adds it to the test_runner. ACKs for top commit: furszy: utACK e06f7b6 Warrows: utACK e06f7b6 Tree-SHA512: 07f18e77a91503f5d48dafad32364cc6292ffd1f9a3f9286a78de72dafc98b07342e6abd96eaabe55d20193f10be383c8d5bbac1b33c45712ade8c522e457b3f
Replacement for getmemorypool compatible with new BIP 22 specification.