-
Notifications
You must be signed in to change notification settings - Fork 2
How to build BTM pool
martinbtm edited this page Sep 6, 2021
·
1 revision
- when testing, could try switching to the
testnet
orsolonet
./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 withinit
or run withnode
- the directory will be created if not existed
- 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- need to set-up mining address in advance, using
/set-minining-address
- need to set-up mining address in advance, using
- 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
- both use
- a miner will only receive a job by
- 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
- can take advantage of
types.BlockHeader{}
'sHash()
in"github.com/bytom/protocol/bc/types"
if using golang - https://github.com/HAOYUatHZ/B3-Mimic/blob/master/docs/blhr_hash_V3.go can be helpful if using other language
- can take advantage of
- 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
- header_hash
- if a block is mined, the pool
/submit-work-json
to a node
- as for the protocol, https://github.com/HAOYUatHZ/B3-Mimic/blob/master/docs/STRATUM-BTM.md can be helpful
- retarget
- see above, asjusted dynamically to make a miner submit 3 times / min
- the addr for mainnet starts with
bm
- length:
- normal: 42
- mul-sig: 62
- length:
- tool
- a new addr for change will be generated each time