Skip to content

Instantly share code, notes, and snippets.

@HAOYUatHZ
Last active October 15, 2018 04:24
Show Gist options
  • Save HAOYUatHZ/ffaf6f8e417e72fd57d39989b5af62c9 to your computer and use it in GitHub Desktop.
Save HAOYUatHZ/ffaf6f8e417e72fd57d39989b5af62c9 to your computer and use it in GitHub Desktop.

BTM Pool

config the node

  • when testing, could try switching to the testnet or solonet
    • ./bytomd init --chain_id testnet
    • or ./bytomd init --chain_id solonet , with a lower difficulty, in order to mine with cpu
  • could use -r "your/directory" to specify the data directory when init with init or run with node
    • the directory will be created if not existed

procedure

  • need to build an account and an addr immediately after u init the node, otherwise, the rewards will be sent to an empty addr
  • currently bytom doesn't support specifying the receive addr for rewards, and will use a same one by default
  • API doc
  • the pool /get-work-json from a node
  • send jobs to miners
    • as for the protocol, https://github.com/HAOYUatHZ/B3-Mimic/blob/master/docs/STRATUM-BTM.md can be helpful
      • a miner will only receive a job by login or by being notified by the pool
        • both use submit to submit
        • a miner will not getjob actively
    • a mock B3 miner: https://github.com/HAOYUatHZ/B3-Mimic/blob/master/main.go
      • Version, Height, Timestamp, Bits are little-endian
      • about target
        • .
          var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
          
          func GetTargetHex(diff int64) string {
              padded := make([]byte, 32)
          
              diffBuff := new(big.Int).Div(Diff1, big.NewInt(diff)).Bytes()
              copy(padded[32-len(diffBuff):], diffBuff)
              buff := padded[0:4]
              targetHex := hex.EncodeToString(Reverse(buff))
              return targetHex
          }
          
        • targethex sent from the pool is target1(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) divided by the poolDiff, which is adjusted dynamically in order to ensure a miner submitting shares periodically, e.g., 3 times per minute
          • ffff3f00 is corresponding to 1024,c5a70000 is corresponding to 100001
    • the pool need to validate the share
      • header_hash
      • then follow the tensority algo to calc the hash result
        • unfortunately the verification speeds of gonum version, cpp_openblas version, cpp_simd version are all too slow
        • a working pool has to use gpu
          • cpp tensority, this repo also points out how to opt it using gpu
  • retarget
    • see above, asjusted dynamically to make a miner submit 3 times / min

batch tx

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