Provide fee data for all txs in RPC getblocktemplate response #2115

Merged
merged 3 commits into from Jan 10, 2013

Conversation

Projects
None yet
6 participants
Contributor

forrestv commented Dec 19, 2012

Having the fee data for every transaction returned by "getblocktemplate" was broken by the ultraprune commit (450cbb0). It made it so transactions that depend on other transactions in the block-to-be don't have fee data.

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/d42d932bed6b564cbfc00216d1c04cd5248ddeef for binaries and test log.

@luke-jr luke-jr commented on an outdated diff Dec 19, 2012

src/rpcmining.cpp
@@ -307,14 +307,15 @@ Value getblocktemplate(const Array& params, bool fHelp)
entry.push_back(Pair("depends", deps));
int64_t nSigOps = tx.GetLegacySigOpCount();
- if (tx.HaveInputs(view))
- {
- entry.push_back(Pair("fee", (int64_t)(tx.GetValueIn(view) - tx.GetValueOut())));
- nSigOps += tx.GetP2SHSigOpCount(view);
- }
+ assert(tx.HaveInputs(view));
@luke-jr

luke-jr Dec 19, 2012

Member

I dislike the possibility of bitcoind just aborting. Is there some reason not to make this an if() block as a failsafe?

Owner

sipa commented Dec 19, 2012

I think it would be better to have CreateNewBlock construct some meta-data object with fees in it, which can be used by getblocktemplate.

EDIT: this definitely needs fixing of course, but it seems silly to have GBT redo the fee calculation in an incomplete way, when CreateNewBlock perfectly knows all fees.

Member

luke-jr commented Dec 19, 2012

No reason it can't be optimized after merging this fix, IMO.

Contributor

forrestv commented Dec 19, 2012

/me is working on having CreateNewBlock return fee data in addition

Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/3a291f97f0dc1c98f980a3f5679000339416961f for binaries and test log.

This could happen for one of several reasons:

  1. It chanages paths in makefile.linux-mingw or otherwise changes build scripts in a way that made them incompatible with the automated testing scripts
  2. It does not build on either Linux i386 or Win32 (via MinGW cross compile)
  3. The test suite fails on either Linux i386 or Win32
  4. The block test-cases failed (lookup the first bNN identifier which failed in https://github.com/TheBlueMatt/test-scripts/blob/master/FullBlockTestGenerator.java)
Contributor

forrestv commented Dec 19, 2012

Okay, CreateNewBlock now returns a CBlockTemplate struct that contains the block and fee and sigop data.

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/0f927ceb5b90ec02be36ddb20b2f4cff82589265 for binaries and test log.

Owner

sipa commented Dec 20, 2012

Code looks good to me. I'll do some testing soon.

Owner

sipa commented Jan 4, 2013

ACK

Member

gmaxwell commented Jan 4, 2013

Been running this for almost two weeks on a node. Did basic sanity checks. ACK.

No objection (see 'ACK' in overall commit), but this construction "&tx - pblock->vtx.data()" seems quite unusual. Perhaps separate it into its own code line, perhaps with a comment.

Member

jgarzik commented Jan 4, 2013

ACK

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/f3d872d1eabeb5c999162f709626ee20c8789c42 for binaries and test log.

sipa merged commit 45a1ec5 into bitcoin:master Jan 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment