Skip to content
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

Fix bip9 signalling #842

Merged
merged 3 commits into from
Aug 26, 2023
Merged

Conversation

rithvikvibhu
Copy link
Member

Currently, it is not possible to signal for deployments which are force: false. This PR changes that by reverting 2 previous commits:

The way it's supposed to work is:

  • chain.computeBlockVersion opts into all deployments
  • GetBlockTemplate then opts out for those not included in rules

But,

  • getwork and other software (b/hstratum) that depend on Miner directly, do not opt out at all
  • and implicitly signal for all

To prevent this, the 2 temporary measures taken ~3 years ago:

  • hard-coded Miner (used by getwork) to version 0 to skip calculating from chain, and
  • made chain.computeBlockVersion only set force deployments bits
  • which makes it impossible to signal non-force ones.

Potential Breaking Change for miners

  • Miners using getblocktemplate aren't affected, and can use rules to signal
  • Miners using getwork will start signalling for all by default (including hardening)

Since getwork now activates hardening, it needs to be explicitly disabled in claim tests that use domains with weak keys (cloudflare, nlnetlabs, dnscrypt, etc.)

h/t @nodech who found all of this

@coveralls
Copy link

coveralls commented Aug 25, 2023

Coverage Status

coverage: 68.641% (+0.006%) from 68.635% when pulling ab0fa43 on rithvikvibhu:fix-bip9-signalling into 500d638 on handshake-org:master.

@rithvikvibhu
Copy link
Member Author

Tested this:

GetBlockTemplate

No signalling (v=0):

❯ ./bin/hsd-rpc getblocktemplate
{
  "version": 0,
  "rules": [],
  "vbavailable": {
    "hardening": 0,
    "icannlockup": 1
  },
  "vbrequired": 0,
  "height": 187170,
}

With icannlockup (v=2):

❯ ./bin/hsd-rpc getblocktemplate '{"rules": ["icannlockup"]}'
{
  "version": 2,
  "rules": [],
  "vbavailable": {
    "hardening": 0,
    "icannlockup": 1
  },
  "vbrequired": 0,
  "height": 187170,
}

With icannlockup and hardening (v=3):

❯ ./bin/hsd-rpc getblocktemplate '{"rules": ["icannlockup", "hardening"]}'
{
  "version": 3,
  "rules": [],
  "vbavailable": {
    "hardening": 0,
    "icannlockup": 1
  },
  "vbrequired": 0,
  "height": 187170,
}

getwork

Signals all/both by default:

❯ ./bin/hsd-rpc getwork
{
  "network": "main",
  "data": "000000008c97e96400000000310350e263534903d8194fcf35eb69f3bbf5c82d00000000000000082f75e18de7b77385757b685791d99a0f9488fcaa445988cd310350e26353490bf76cae42d25c1a76ce8ea07abbd5f5fb93ad6b54764de3b3626937333e52c8b69115ae5ce121a67cba117c2ff82432dd0a9618994b1491bd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbac9de7fded5561d39537c5058f9f3a5ff6f317b3511339b0a796dd627828e7fe95e112d3202a2d22815bb866fe519ab599457a19f3a28e98ce522386a7ff50300000071880819",
  "target": "0000000000000008887100000000000000000000000000000000000000000000",
  "height": 187170,
  "time": 1693030284,
  "fee": 2249000
}

and confirm version = 3

 node
> AbstractBlock = require('hsd/lib/primitives/abstractblock.js');
[class AbstractBlock extends Struct]

> AbstractBlock.fromMiner(Buffer.from('000000008c97e96400000000310350e263534903d8194fcf35eb69f3bbf5c82d00000000000000082f75e18de7b77385757b685791d99a0f9488fcaa445988cd310350e26353490bf76cae42d25c1a76ce8ea07abbd5f5fb93ad6b54764de3b3626937333e52c8b69115ae5ce121a67cba117c2ff82432dd0a9618994b1491bd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bbac9de7fded5561d39537c5058f9f3a5ff6f317b3511339b0a796dd627828e7fe95e112d3202a2d22815bb866fe519ab599457a19f3a28e98ce522386a7ff50300000071880819', 'hex'))
AbstractBlock {
  version: 3,
  prevBlock: <Buffer 00 00 00 00 00 00 00 08 2f 75 e1 8d e7 b7 73 85 75 7b 68 57 91 d9 9a 0f 94 88 fc aa 44 59 88 cd>,
  merkleRoot: <Buffer 7f e9 5e 11 2d 32 02 a2 d2 28 15 bb 86 6f e5 19 ab 59 94 57 a1 9f 3a 28 e9 8c e5 22 38 6a 7f f5>,
  witnessRoot: <Buffer 0b ba c9 de 7f de d5 56 1d 39 53 7c 50 58 f9 f3 a5 ff 6f 31 7b 35 11 33 9b 0a 79 6d d6 27 82 8e>,
  treeRoot: <Buffer 31 03 50 e2 63 53 49 0b f7 6c ae 42 d2 5c 1a 76 ce 8e a0 7a bb d5 f5 fb 93 ad 6b 54 76 4d e3 b3>,
  reservedRoot: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
  time: 1693030284,
  bits: 419989617,
  nonce: 0,
  extraNonce: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
  mask: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
  mutable: false,
  _hash: null,
  _maskHash: <Buffer 62 69 37 33 3e 52 c8 b6 91 15 ae 5c e1 21 a6 7c ba 11 7c 2f f8 24 32 dd 0a 96 18 99 4b 14 91 bd>
}

@nodech nodech merged commit 6dc5249 into handshake-org:master Aug 26, 2023
@rithvikvibhu rithvikvibhu deleted the fix-bip9-signalling branch August 26, 2023 09:55
nodech added a commit that referenced this pull request Aug 26, 2023
nodech added a commit that referenced this pull request Aug 26, 2023
@nodech nodech mentioned this pull request Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants