Page MenuHomePhabricator

Add a simplifygbt option to simplify parsing the block template for miners
Needs ReviewPublic

Authored by Fabien on Tue, Feb 11, 14:22.

Details

Reviewers
roqqit
Group Reviewers
Restricted Project
Summary

The current block template is convoluted for the miner fund and the staking rewards:

  • It is deeply nested, requiring lots of null checks in the miner code
  • The miner fund uses an array for a single value, and address instead of script which requires decoding on the miner code
  • The staking rewards includes a lot of debug information that are irrelevant for miners and causes confusion. E.g. it includes addresses even if any standard script can be used (so address might be absent, or multiple).

This diff adds an option, currently opt-in, to simplify the output for these objects:

  • They now live at the root of the block template object, so coinbasetxn is compliant with bip22
  • They only contain the data which is useful for miners, i.e. the script and the amount to be included in the coinbase output.

The choice of using an init option rather than a flag is to avoid having the miner special casing the calls for XEC, which would partially defeat the purpose of this diff.

Test Plan
ninja check-functional

Diff Detail

Event Timeline

Fabien requested review of this revision.Tue, Feb 11, 14:22
PiRK added inline comments.
doc/release-notes.md
8
roqqit requested changes to this revision.Tue, Feb 11, 16:32
roqqit added a subscriber: roqqit.

Is there a reason -simplifygbt is a command line arg and not a parameter to getblocktemplate?

This revision now requires changes to proceed.Tue, Feb 11, 16:32
Fabien requested review of this revision.Tue, Feb 11, 19:09

Is there a reason -simplifygbt is a command line arg and not a parameter to getblocktemplate?

Yes, I want to make the miner life easier. So requiring an argument to getblocktemplate will force them to special case the calls for XEC which is the opposite of what I want.
It's also much easier to retrieve the node config than it is to retrieve the rpc calls if we need to provide support.

How about naming it "-simplegbt" instead... seems simpler

How about naming it "-simplegbt" instead... seems simpler

I would argue that it's not simple but only simpler than before.