GithubHelp home page GithubHelp logo

miner's Introduction

miner's People

Contributors

dwymi02 avatar hacashcom avatar jcb55 avatar sir-daniel avatar toni-d-e-v avatar victoryang00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

miner's Issues

Miner Relay Service fails to start

Attempted to start [Miner Relay Service] on a Windows machine, which failed.
Following are the console messages showing the reported problem:

.\hacash_miner_relay_service_2021_07_19_01.exe
Load ini config file: "relayservice.config.ini" at time:07/31 14:01:59
config server_listen_port==0 do not start server.
config http_api_listen_port==0 do not start http api service.
connecting server <:0>... [Miner Relay Service] connect to server <:0> error:
dial tcp :0: connectex: The requested address is not valid in its context.
[Miner Relay Service] Reconnection will be initiated in two minutes...
connecting server <:0>... [Miner Relay Service] connect to server <:0> error:
dial tcp :0: connectex: The requested address is not valid in its context.
[Miner Relay Service] Reconnection will be initiated in two minutes...
Got signal: interrupt <=== [Killed vi CTRL+C ...]

The contents of the file [relay_service.config.ini]:

server_connect = 127.0.0.1:3350
server_listen_port = 19991

http_api_listen_port = 8080

accept_hashrate = true
report_hashrate = true

[store]
enable = true
data_dir = ./hacash_relay_service_data
save_mining_block_stuff = true
save_mining_hash = true
save_mining_nonce = true

Problem has been isolated to source file [miner/minerrelayservice/config.go]

There are two lines that need to be changed:

  • On line [# 51] [cnf.ServerTcpListenPort = cnfsection.Key("server_listen_port").MustInt(0)]
    Code should be changed to [cnf.ServerTcpListenPort = cnfsection.Key("server_listen_port").MustInt(19991)]

  • On line [#52] [cnf.HttpApiListenPort = cnfsection.Key("http_api_listen_port").MustInt(0)]
    Code should be changed to [cnf.HttpApiListenPort = cnfsection.Key("http_api_listen_port").MustInt(8080)]

Full Node Miner Supervene Config Not Mining on All Cores

After the recent update back in mid-May, full node miners are not mining at "full throttle" as set by their supervene param in the config file. It will always mine with only 1 core regardless of what the supervene param is set to.

For example, if I mine with a 48 core processor and set supervene = 48 then only a single (1) core will mine.

Syncing blocks first time can be fast or slow. It depends on how one configure hacash.config.ini

This issue can be easily replicated by running a full node. Each method should be run independently, one must remove the file again and re-download files.

Fast method:
If hacash.config.ini is run using this configuration:

enabled:
[p2p], [diamond_minder], [service]

data_dir = hacash_mainnet_data


[p2p]
name = hnode_test1
listen_port = 3337
boot_nodes = 182.92.163.225:3337,47.244.26.14:3337


[miner]
;enable = true
supervene = 1
rewards = xxxx
message = unknown


[minerpool]
;enable = true
data_dir = hacash_minerpool_data
console_http_port = 3340
listen_port = 3339
fee_percentage = 0.05
rewards_password = private key


[diamondminer]
enable = true
supervene = 11
fee_amount = ㄜ9:245
fee_password = private key
rewards = xxxxx


[service]
enable = true
deprecated_http_port = 3338

The output would be:

got blocks: 6001 ~ 7000, inserting... OK
sync blocks: 7001... got blocks: 7001 ~ 8000, inserting... OK
sync blocks: 8001... got blocks: 8001 ~ 9000, inserting... OK
sync blocks: 9001... got blocks: 9001 ~ 10000, inserting... OK
sync blocks: 10001... got blocks: 10001 ~ 11000, inserting... OK
sync blocks: 11001... got blocks: 11001 ~ 12000, inserting... OK
sync blocks: 12001... got blocks: 12001 ~ 13000, inserting... OK
sync blocks: 13001... got blocks: 13001 ~ 14000, inserting... OK
sync blocks: 14001... got blocks: 14001 ~ 15000, inserting... OK
sync blocks: 15001... got blocks: 15001 ~ 16000, inserting... OK

Slow method:
if hacash.config.ini is run using this configuration:

enabled:
[p2p], [miner], service


data_dir = hacash_mainnet_data


[p2p]
name = hnode_test1
listen_port = 3337
boot_nodes = 182.92.163.225:3337,47.244.26.14:3337


[miner]
enable = true
supervene = 1
rewards = xxxx
message = unknown


[minerpool]
;enable = true
data_dir = hacash_minerpool_data
console_http_port = 3340
listen_port = 3339
fee_percentage = 0.05
rewards_password = private key


[diamondminer]
;enable = true
supervene = 11
fee_amount = ㄜ9:245
fee_password = YOUR PRIVATE KET OR PASSWORD HERE
rewards = xxxxx


[service]
enable = true
deprecated_http_port = 3338


The output would be:

f3d..., difficulty: 4294967294, size: 0.000000kb, time: 09/14 01:44:25
⬤ mining new block height: 15, txs: 0, hash: f1bff307243b1fbb1fc73afee549c327477234e17534c3fa0fcb0c367f1da86d, coinbase: 1NpcusWsFysWWoQXxTM21X8gn7d98xbkDC + ㄜ1:248, successfully!
do mining... block height: 16, txs: 0, prev: f1bff307243b1fbb1fc73afee549c
327..., difficulty: 4294967294, size: 0.000000kb, time: 09/14 01:44:26
⬤ mining new block height: 16, txs: 0, hash: df366f1a3ac7a1828143b0e2a8c3c
6dbe0b42ce1d73f50ebe990b9911dbbafa7, coinbase: 1NpcusWsFysWWoQXxTM21X8gn7d
98xbkDC + ㄜ1:248, successfully!
do mining... block height: 17, txs: 0, prev: df366f1a3ac7a1828143b0e2a8c3c
6db..., difficulty: 4294967294, size: 0.000000kb, time: 09/14 01:44:27
⬤ mining new block height: 17, txs: 0, hash: 252bde5d3777170ba1253a8f77dab
9ece1473948a100a46b5dc84219a9af1deb, coinbase: 1NpcusWsFysWWoQXxTM21X8gn7d
98xbkDC + ㄜ1:248, successfully!
do mining... block height: 18, txs: 0, prev: 252bde5d3777170ba1253a8f77dab
9ec..., difficulty: 4294967294, size: 0.000000kb, time: 09/14 01:44:28
⬤ mining new block height: 18, txs: 0, hash: e8436b3c8cf82b79309e56ce5673b
42a1a479eb3ddff0149985cf5c3f50deac1, coinbase: 1NpcusWsFysWWoQXxTM21X8gn7d
98xbkDC + ㄜ1:248, successfully!
do mining... block height: 19, txs: 0, prev: e8436b3c8cf82b79309e56ce5673b
42a..., difficulty: 4294967294, size: 0.000000kb, time: 09/14 01:44:29
⬤ mining new block height: 19, txs: 0, hash: 8106cee92b6256e3a5f3e78b60c7e
a706010a653d9b6186be20695c7285bc1a3, coinbase: 1NpcusWsFysWWoQXxTM21X8gn7d
98xbkDC + ㄜ1:248, successfully!
do mining... block height: 20, txs: 0, prev: 8106cee92b6256e3a5f3e78b60c7e
a70..., difficulty: 4294967294, size: 0.000000kb, time: 09/14 01:44:30

Doing the first method will save a lot of hours in syncing blocks. I hope that whatever the configuration be made, the syncing of blocks should be fast.

I need your help!

Hello!
I have read this code and your websites.
In miner, there is autobid flag.
Would you mind if I ask you?

Can someone enable or disable autobid flag programmatically?

Thanks.

[Help] build command-line-arguments: cannot load bufio: malformed module path "bufio": missing dot in first path element

root@ashermanangan:~/golang/src/github.com/hacash/miner/run/main# go run main.go
go: finding github.com/hacash/miner/miner latest
go: finding github.com/hacash/miner/minerpool latest
go: finding github.com/hacash/miner/console latest
go: finding github.com/hacash/miner/localcpu latest
go: finding github.com/hacash/miner/diamondminer latest
go: finding github.com/hacash/miner/memtxpool latest
build command-line-arguments: cannot load bufio: malformed module path "bufio": missing dot in first path element
root@x:~/golang/src/github.com/hacash/miner/run/main#

echo $GOROOT
/root/bin/go
echo $GOBIN
/root/bin/go/bin
echo $GOPATH
/root/golang
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/root/bin/go/bin

How can I build and run the main.go from hacash/miner/run/main?

Pool Miner Displayed Mining Missing Hacash Blocks

RE: Pool Miner Displayed Mining Missing Hacash Blocks

DATE : Dec-07-2021

AUTHOR : MKD

Summary of Problem : There are gaps in recorded blocks for the Pool Miner.

Information on the currently running executable follows :

-rwxrwxrwx 1 root root 12628568 Dec 7 13:20 poolworker_AStoneOnyx_12_07_2021*

poolworker_AStoneOnyx_12_07_2021: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2dc4a90fa7126da43d9a0df264984bcad89b0436, for GNU/Linux 3.2.0, with debug_info, not stripped

Following are log entries from my presently running Pool Miner :

do mining height:‹298759›, cbmn:1... upload:‹298758›0000000af9cea7e45d7e7804..., time: 83s
do mining height:‹298766›, cbmn:1... upload:‹298759›0000001692d07bc412698d0f..., time: 506s
do mining height:‹298767›, cbmn:1... upload:‹298766›00000000b9982f5d7bc80aca..., time: 104s
do mining height:‹298768›, cbmn:1... upload:‹298767›0000005987df70a3822653db..., time: 116s
do mining height:‹298769›, cbmn:1... upload:‹298768›000000663f010714a77e521e..., time: 23s
do mining height:‹298771›, cbmn:1... upload:‹298769›0000007bf5eda956cc536af9..., time: 63s
do mining height:‹298774›, cbmn:1... upload:‹298771›000000070a33e43841e56e89..., time: 700s
do mining height:‹298776›, cbmn:1... upload:‹298774›000000004421e2b26b5ad2fe..., time: 771s
do mining height:‹298777›, cbmn:1... upload:‹298776›000000836585dfaadfb250b7..., time: 45s
do mining height:‹298778›, cbmn:1... upload:‹298777›0000003c15b6d4080735fdc6..., time: 286s
do mining height:‹298779›, cbmn:2... upload:‹298778›00000155387af67a40aa2b11..., time: 36s
do mining height:‹298781›, cbmn:1... upload:‹298779›00000015d22acebdd7ab2fcb..., time: 317s
do mining height:‹298782›, cbmn:2... upload:‹298781›00000006c3930aecb32007ac..., time: 270s
do mining height:‹298784›, cbmn:2... upload:‹298782›00000001edc79fb3b06497f7..., time: 369s
do mining height:‹298786›, cbmn:1... upload:‹298784›00000002c628c37408f68e5d..., time: 451s
do mining height:‹298787›, cbmn:2... upload:‹298786›000000fcd344e19726e988e1..., time: 32s
do mining height:‹298788›, cbmn:1... upload:‹298787›0000000a1714cbbe71889354..., time: 228s
do mining height:‹298789›, cbmn:1... upload:‹298788›000000050f37d8810bbb67d6..., time: 613s
do mining height:‹298792›, cbmn:1... upload:‹298789›000000054a842375a619ce86..., time: 1015s
do mining height:‹298793›, cbmn:1... upload:‹298792›00000008b25ae539ecd0a564..., time: 892s
do mining height:‹298796›, cbmn:2... upload:‹298793›00000001ca3f4d7d881e9a15..., time: 505s
do mining height:‹298797›, cbmn:2... upload:‹298796›00000007ba67112fa25d80fd..., time: 395s
do mining height:‹298798›, cbmn:2... upload:‹298797›00000029a99be3bb212ead7b..., time: 50s
do mining height:‹298799›, cbmn:1... upload:‹298798›00000019b5f97616d7317292..., time: 330s
do mining height:‹298803›, cbmn:1... upload:‹298799›0000000c53703f36d4575a96..., time: 786s
do mining height:‹298804›, cbmn:1... upload:‹298803›0000000521119faf422dce21..., time: 406s
do mining height:‹298809›, cbmn:1... upload:‹298804›000000111f6bf39a1bfd1562..., time: 1143s
do mining height:‹298811›, cbmn:1... upload:‹298809›00000006c2d51c9632c5a1cd..., time: 142s
do mining height:‹298812›, cbmn:1... upload:‹298811›0000000620c53af6424bb42b..., time: 440s
do mining height:‹298813›, cbmn:1... upload:‹298812›0000038e7b4b8e62f9f52a8f..., time: 8s
do mining height:‹298814›, cbmn:1... upload:‹298813›0000008429126f1c758e28fb..., time: 9s
do mining height:‹298817›, cbmn:1... upload:‹298814›0000003ea3a4545135993ae2..., time: 523s
do mining height:‹298818›, cbmn:1... upload:‹298817›000000d5a8c7716d933523b8..., time: 86s
do mining height:‹298819›, cbmn:1... upload:‹298818›0000062733bde55177e18632..., time: 6s
do mining height:‹298821›, cbmn:1... upload:‹298819›000000140233c3bcc442dfab..., time: 300s
do mining height:‹298822›, cbmn:1... upload:‹298821›0000000dfa0d2f1c277d0a17..., time: 176s
do mining height:‹298823›, cbmn:2... upload:‹298822›0000000a817f6bb46d2f6d77..., time: 288s
do mining height:‹298824›, cbmn:1... upload:‹298823›000000343b86b64b9e0d2d37..., time: 42s
do mining height:‹298826›, cbmn:1... upload:‹298824›000000019011069966328d61..., time: 452s
do mining height:‹298831›, cbmn:2... upload:‹298826›00000003643e8f9de74ed79d..., time: 1169s
do mining height:‹298832›, cbmn:1... upload:‹298831›00000000cff5c8d303312b4f..., time: 346s
do mining height:‹298834›, cbmn:1... upload:‹298832›000000055e59a03abb5fa604..., time: 460s
do mining height:‹298836›, cbmn:1... upload:‹298834›000000253de76339ce2aabaa..., time: 287s
do mining height:‹298837›, cbmn:1... upload:‹298836›0000001517676699142974ac..., time: 219s
do mining height:‹298839›, cbmn:1... upload:‹298837›00000001fbb36b28193d411c..., time: 376s
do mining height:‹298841›, cbmn:1... upload:‹298839›0000001222af293814f1f0a3..., time: 498s
do mining height:‹298842›, cbmn:1... upload:‹298841›000000127470303e14b333f9..., time: 439s
do mining height:‹298843›, cbmn:1... upload:‹298842›000000053333e7e908966f66..., time: 537s
do mining height:‹298844›, cbmn:1... upload:‹298843›00000005c23a979b99d3ad03..., time: 48s
do mining height:‹298846›, cbmn:1... upload:‹298844›0000003f8a2cae6674bf4680..., time: 164s
do mining height:‹298848›, cbmn:1... upload:‹298846›000000027973cc43d5cc3231..., time: 887s
do mining height:‹298851›, cbmn:1... upload:‹298848›00000005c9560d3391fa9bec..., time: 459s
do mining height:‹298852›, cbmn:1... upload:‹298851›00000007d1c868752c418111..., time: 255s
do mining height:‹298853›, cbmn:1... upload:‹298852›00000006003899cdf986aa3c..., time: 315s
do mining height:‹298854›, cbmn:1... upload:‹298853›00000005cbde659a48373dd2..., time: 623s
do mining height:‹298856›, cbmn:1... upload:‹298854›000000840685dcf816bb61f7..., time: 152s
do mining height:‹298857›, cbmn:1... upload:‹298856›0000000741451241380cbbff..., time: 459s
do mining height:‹298858›, cbmn:1... upload:‹298857›000000aa0d99b551fd006834..., time: 66s
do mining height:‹298859›, cbmn:2... upload:‹298858›00000018b26de631dfdf88ab..., time: 221s
do mining height:‹298862›, cbmn:1... upload:‹298859›00000003fb09bd8ba66b915d..., time: 3819s

The log file information slightly edited, removing the hash rate ...

The problem appears to sporadic, sometimes missing one block, sometimes missing multiple blocks ...

My local Hacash repository was wiped clean and the current code was pulled from github.
My test Pool Server and Pool Miner have been running from today, starting around 13:24:35.

THANX(MKD).

Doesn't compile

Hello! Doesn't compile. And it does not start from a zip archive. Ubuntu 20.04
Снимок экрана (174)
Снимок экрана (172)

Summary of Data Races associated with [*DiamondMiner]

Summary of Data Races associated with [*DiamondMiner]

  • Text file of instrumented Diamond Miner [DiamondMiner_log_Sep_21_2021.txt], available via Github Gist [https://gist.github.com/dwymi02/95140687b566efa22939dec3cd14dd6d]

  • The instrumented binary was built from refreshed code, dated Sep-21-2021.
    The source code repository was wiped clean and "git clone ..." was used to create the updated code base.

  • The instrumented code was built with "-race", e.g., "go build -race".

  • The directory [hacash_mainnet_data/] was completely removed, to allow the Hacash blockchain to be built from scratch, also allowing for additional Data Races to be uncovered, if any.

  • In searching for Data Races I tried to group them based on specific Hacash components.
    Grep was used to search for known Hacash components, following is a list of potential Data Races, based on Hacash components:

    • A search for [*P2P] returned 109 hits
    • A search for [*Block_v1] returned 4 hits
    • A search for [*ChainState] returned 3 hits
    • A search for [*DiamondMiner] returned 45 hits
    • A search for [*DeprecatedApiService] returned 33 hits
    • A search for [*Transaction_2_Simple] returned 14 hits
      While there are large numbers of potential hits, there Hacash components may or may not be proximate to the actual Data Race.

    For each Hacash component I will list the specific Data Race.
    When the current code does not match what was previously built, a [*** NOTE ***] will be included
    In the event the stack trace that is too lengthy, the results will be truncated.
    If it is necessary, the full log will be provided, as needed.

    For the specific Read and Write that are involved in the Data Race, the [<===] will be used to identify where the specific Read/Write occurred, based on current source available ...

    Once the Data Race has been documented, an issue will be opened on Github.
    I will leave it to your team to decide how the Data Race is to be handled.
    You can opt to fix the Data Race or simply close the issue. as you so choose.
    This decision I leave with you and your team ...

=-=-=-=-=-=-=-=-=-=-=-=-=-

Data Races associated with [*DiamondMiner]

  • DiamondMiner Data Race # 1:
    ❂❂❂❂❂❂ [Diamond Miner] Success find a diamond: <0000000000NTMYBY>, number: 38588, nonce: 3551341568, extmsg: d1150d79e37b8e079381de807434b86137f92277835b49408d4ca4fc4263aa6e.

    #22memtxpool add diamond create tx: a378eecaafc42f7761a96fdc1d16a9c0ed92b01a3b618cf851480d49674e2dbb , diamond: 38588 NTMYBY

    WARNING: DATA RACE
    Write at 0x00c4201cef48 by goroutine 69:
    miner/diamondminer.(*DiamondMiner).successFindDiamondAddTxPool()
    miner/diamondminer/success.go:36 +0x68b

    Previous read at 0x00c4201cef48 by goroutine 67:
    miner/diamondminer.(*DiamondMiner).doAutoBidForMyDiamond()
    miner/diamondminer/autobid.go:38 +0x3c9

    Write:
    [miner/diamondminer/success.go:36]
    func (d *DiamondMiner) successFindDiamondAddTxPool(diamondCreateAction *actions.Action_4_DiamondCreate) {

    tx, e := transactions.NewEmptyTransaction_2_Simple(d.Config.FeeAccount.Address)
    if e != nil {
    return
    }
    tx.Fee = *(d.Config.FeeAmount.Copy())
    //rand.Read(tx.Fee.Numeral)
    //fmt.Println(diamondCreateAction)
    tx.AppendAction(diamondCreateAction)
    // fill sign
    signprivkey := make(map[string][]byte, 0)
    signprivkey[string(d.Config.FeeAccount.Address)] = d.Config.FeeAccount.PrivateKey
    err := tx.FillNeedSigns(signprivkey, nil)
    if err != nil {
    return // error end
    }
    // put into the txpool
    if d.txpool == nil {
    fmt.Println("[Diamond Miner Error] txpool not set")
    return
    }
    err = d.txpool.AddTx(tx)
    if err != nil {
    fmt.Println("[Diamond Miner Error] AddTx error", err)
    return
    }
    d.currentSuccessMiningDiamondTx = tx <=== Write
    // ok
    fmt.Printf("[Diamond Miner] Diamond %d <%s> add to txpool, hx %s.\n", diamondCreateAction.Number, diamondCreateAction.Diamond, tx.Hash().ToHex())
    }

    Read:
    [miner/diamondminer/autobid.go:38 +0x3c9]
    func (d *DiamondMiner) doAutoBidForMyDiamond() {
    //fmt.Println("- doAutoBidForMyDiamond")

    firstFeeTxs := d.txpool.GetDiamondCreateTxs(1) // 取出第一枚钻石挖掘交易
    if firstFeeTxs == nil || len(firstFeeTxs) == 0 {
    return // 没有钻石
    }
    firstFeeTx := firstFeeTxs[0]
    // 放弃竞争的地址
    for _, iaddr := range d.Config.AutoBidIgnoreAddresses {
    if bytes.Compare(firstFeeTx.GetAddress(), *iaddr) == 0 {
    if !d.Config.Continued {
    // 非连续挖矿时,停止本机的挖掘
    //fmt.Println("diamond miner stop all, because fee addr:", iaddr.ToReadable())
    d.StopAll()
    }
    return
    }
    }
    // 我自己排第一位
    if bytes.Compare(firstFeeTx.GetAddress(), d.Config.FeeAccount.Address) == 0 {
    if !d.Config.Continued {
    // 非连续挖矿时,停止本机的挖掘
    //fmt.Println("diamond miner stop all, because fee addr:", firstFeeTx.GetAddress().ToReadable())
    d.StopAll()
    }
    return
    }
    if d.currentSuccessMiningDiamondTx == nil { <=== Read
    return
    }
    // 比较钻石序号
    curact := transactions.CheckoutAction_4_DiamondCreateFromTx(d.currentSuccessMiningDiamondTx)
    firstact := transactions.CheckoutAction_4_DiamondCreateFromTx(firstFeeTx)
    if curact == nil || firstact == nil {
    return
    }
    if curact.Number != firstact.Number {
    d.currentSuccessMiningDiamondTx = nil // 无效的挖掘
    return
    }

    // 开始竞价
    topfee := firstFeeTx.GetFee()
    myfee, e1 := topfee.Add(d.Config.AutoBidMarginFee)
    if e1 != nil {
    fmt.Println("doAutoBidForMyDiamond Error:", e1)
    return
    }
    if newmyfee, _, e2 := myfee.CompressForMainNumLen(4, true); e2 == nil && newmyfee != nil {
    myfee = newmyfee // 向上压缩长度
    }
    // 是否高于我设定的最高价
    if d.Config.AutoBidMaxFee.LessThan(topfee) {
    return
    }
    if d.Config.AutoBidMaxFee.LessThan(myfee) {
    myfee = d.Config.AutoBidMaxFee // 已达到最高价
    }

    // 更新交易费用
    newtx := d.currentSuccessMiningDiamondTx
    newtx.SetFee(myfee)
    newtx.ClearHash() // 重置哈希缓存
    // 私钥
    allPrivateKeyBytes := make(map[string][]byte, 1)
    allPrivateKeyBytes[string(d.Config.FeeAccount.Address)] = d.Config.FeeAccount.PrivateKey
    // do sign
    newtx.FillNeedSigns(allPrivateKeyBytes, nil)
    // add to pool
    err4 := d.txpool.AddTx(newtx)
    if err4 != nil {
    fmt.Println("doAutoBidForMyDiamond Add to Tx Pool, Error: ", err4.Error())
    return
    }

    // 成功
    fmt.Printf("diamond auto bid name: <%s>, tx: <%s>, fee: %s => %s \n",
    string(curact.Diamond), newtx.Hash().ToHex(),
    topfee.ToFinString(), myfee.ToFinString(),
    )
    }

=-=-=-=-=-

  • DiamondMiner Data Race # 2:
    WARNING: DATA RACE
    Read at 0x00c4200226b8 by goroutine 94:
    miner/diamondminer.(*DiamondMiner).RunMining.func1.1()
    miner/diamondminer/worker.go:79 +0x45c

    Previous write at 0x00c4200226b8 by goroutine 52:
    miner/diamondminer.(*DiamondMiner).StopAll()
    miner/diamondminer/worker.go:20 +0x129
    miner/diamondminer.(*DiamondMiner).RunMining()
    miner/diamondminer/worker.go:31 +0x96
    miner/diamondminer.(*DiamondMiner).loop()
    miner/diamondminer/loop.go:12 +0x2a0

    Read:
    [miner/diamondminer/worker.go:79]
    func (d *DiamondMiner) RunMining(prevDiamond *stores.DiamondSmelt, diamondCreateActionCh chan *actions.Action_4_DiamondCreate) {
    d.changeLock.Lock()
    defer d.changeLock.Unlock()

    // stop prev all
    d.StopAll()

    fmt.Printf("do diamond mining... number: %d, supervene: %d, start worker:", prevDiamond.Number+1, d.Config.Supervene)

    d.stopMarksLocker.Lock()
    var stopMark byte = 0
    d.stopMarks[&stopMark] = &stopMark
    defer d.stopMarksLocker.Unlock()

    // do mining
    go func(supervene int, stopMark *byte, prevDiamond *stores.DiamondSmelt, diamondCreateActionCh chan *actions.Action_4_DiamondCreate) {

      var current_i uint32 = 0
      var current_lock = sync.Mutex{}
    
      for i := 0; i < supervene; i++ {
      	go func(i int) {
      	NEXTMINING:
      		var my_i uint32 = 0
      		current_lock.Lock()
      		current_i++
      		my_i = current_i
      		current_lock.Unlock()
      		// call mining
      		tarnumber := int(prevDiamond.Number) + 1
      		retExtMsg := bytes.Repeat([]byte{0}, 32) // 随机字段值,让同一个地址配置也可以挖不同的的钻石
      		mnstart, mnend := my_i, my_i+1
      		if uint32(tarnumber) > actions.DiamondCreateCustomMessageAboveNumber {
      			mnstart, mnend = 0, 4294967290
      			rand.Read(retExtMsg)
      		}
      		fmt.Printf(" #%d", my_i)
      		retNonce, diamondFullStr := x16rs.MinerHacashDiamond(mnstart, mnend, tarnumber, stopMark, prevDiamond.ContainBlockHash, d.Config.Rewards, retExtMsg)
      		retNonceNum := binary.BigEndian.Uint64(retNonce)
      		if retNonceNum > 0 {
      			fmt.Printf("\n❂❂❂❂❂❂ [Diamond Miner] Success find a diamond: <%s>, number: %d, nonce: %d, extmsg: %s.\n\n",
      				diamondFullStr, tarnumber, retNonceNum, hex.EncodeToString(retExtMsg))
      			// success
      			diamondCreateActionCh <- parsediamondCreateAction(diamondFullStr, prevDiamond, retNonce, d.Config.Rewards, retExtMsg)
      			// set all stop
      			if !d.Config.Continued {
      				// 非连续挖矿
      				*stopMark = 1
      				return
      			}
      			// 连续不停的挖矿
      		}
    
      		if *stopMark == 1 {                             <=== Read
      			return // set stop
      		}
      		// LOOP NEXT
      		goto NEXTMINING
      	}(i)
      }
    

    }(d.Config.Supervene, &stopMark, prevDiamond, diamondCreateActionCh)

    }

    Write:
    [miner/diamondminer/worker.go:20]
    func (d *DiamondMiner) StopAll() {
    d.stopMarksLocker.Lock()
    defer d.stopMarksLocker.Unlock()
    for _, v := range d.stopMarks {
    *v = 1 // stop <=== Write ???
    }
    // clear
    d.stopMarks = map[*byte]*byte{}
    }

=-=-=-=-=-

hacash_node run error with gpu enabled

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: 找不到 -lOpenCL
/usr/bin/ld: /tmp/go-link-1851901072/000004.o: in function `_cgo_97ab22c4dc7b_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:60: 警告: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status

Duplicate Diamond minted

On Sep-05-2021 a duplicate diamond was minted for diamond # 37638. This error resulted in a series of continued failures, which were only resolved when the diamond miner was recycled.

There are two issues that need to be addressed:

#1 -- Why was a diamond that was previously successfully bid # 26052, Born Block Height # 212535, allowed to be minted?
#2 -- The recovery from this error was not properly handled and needs to be addressed.

This problem is documented in Section # 3 of gist [https://gist.github.com/dwymi02/3d7cabb56a91fb1650ed8377712e9a41]

It should be noted that at the time of the error, the running executable was an instrumented diamond build, [go build -race] ...

THANX(MKD).

Summary of Data Races associated with [*MemTxPool]

RE : MemTxPool_Data_Races_Sep-21-2021.txt
Summary of Data Races associated with [*MemTxPool]

  • Text file of instrumented Diamond Miner [DiamondMiner_log_Sep_21_2021.txt], available via Github Gist [https://gist.github.com/dwymi02/95140687b566efa22939dec3cd14dd6d]

  • The instrumented binary was built from refreshed code, dated Sep-21-2021.
    The source code repository was wiped clean and "git clone ..." was used to create the updated code base.

  • The instrumented code was built with "-race", e.g., "go build -race".

  • The directory [hacash_mainnet_data/] was completely removed, to allow the Hacash blockchain to be built from scratch, also allowing for additional Data Races to be uncovered, if any.

  • In searching for Data Races I tried to group them based on specific Hacash components.
    Grep was used to search for known Hacash components, following is a list of potential Data Races, based on Hacash components:

    • A search for [*P2P] returned 109 hits
    • A search for [*Block_v1] returned 4 hits
    • A search for [*ChainState] returned 3 hits
    • A search for [*DiamondMiner] returned 45 hits
    • A search for [*DeprecatedApiService] returned 33 hits
    • A search for [*MemTxPool] returned 29 hits
    • A search for [*Transaction_2_Simple] returned 14 hits
      While there are large numbers of potential hits, there Hacash components may or may not be proximate to the actual Data Race.

    For each Hacash component I will list the specific Data Race.
    When the current code does not match what was previously built, a [*** NOTE ***] will be included
    In the event the stack trace that is too lengthy, the results will be truncated.
    If it is necessary, the full log will be provided, as needed.

    For the specific Read and Write that are involved in the Data Race, the [<===] will be used to identify where the specific Read/Write occurred, based on current source available ...

    Once the Data Race has been documented, an issue will be opened on Github.
    I will leave it to your team to decide how the Data Race is to be handled.
    You can opt to fix the Data Race or simply close the issue. as you so choose.
    This decision I leave with you and your team ...

=-=-=-=-=-=-=-=-=-=-=-=-=-

Data Races associated with [*MemTxPool]

  • MemTxPool Data Race # 1:
    discover new block height: 276596, txs: 3, hash: 00000000016661d799a938aab229f4f13a25b211a1e307b0f1e4148956eef71a, time: 09/21 16:14:54, try to inserting ... ok.

    WARNING: DATA RACE
    Read at 0x00c4206080e0 by goroutine 64:
    service/deprecated.(*DeprecatedApiService).dealHome()
    miner/memtxpool/txpool.go:64 +0x1ac5
    service/deprecated.(*DeprecatedApiService).(service/deprecated.dealHome)-fm()
    service/deprecated/http.go:82 +0x5f
    net/http.HandlerFunc.ServeHTTP()
    /opt/go/src/net/http/server.go:1947 +0x51
    net/http.(*ServeMux).ServeHTTP()
    /opt/go/src/net/http/server.go:2340 +0x9f
    net/http.serverHandler.ServeHTTP()
    /opt/go/src/net/http/server.go:2697 +0xb9
    net/http.(*conn).serve()
    /opt/go/src/net/http/server.go:1830 +0x7dc

    Previous write at 0x00c4206080e0 by goroutine 40:
    miner/memtxpool.(*MemTxPool).RemoveTxs()
    miner/memtxpool/remove.go:19 +0x223
    miner/memtxpool.(*MemTxPool).loop()
    miner/memtxpool/loop.go:22 +0x220

    Read:
    [miner/memtxpool/txpool.go:64]
    func (p *MemTxPool) GetTotalCount() (uint64, uint64) {
    return p.txTotalCount, p.txTotalSize <=== Read
    }

    Write:
    [miner/memtxpool/remove.go:19]
    x
    func (p *MemTxPool) RemoveTxs(txs []interfaces.Transaction) {
    p.changeLock.Lock()
    defer p.changeLock.Unlock()

    // remove
    for _, tx := range txs {
    txhx := tx.Hash()
    p.diamondCreateTxGroup.RemoveByTxHash(txhx)
    if hav := p.simpleTxGroup.RemoveByTxHash(txhx); hav != nil {
    // sub count
    p.txTotalCount -= 1
    p.txTotalSize -= uint64(hav.size) <=== Write
    }
    }

    }

=-=-=-=-=-

  • MemTxPool Data Race # 2:
    WARNING: DATA RACE
    Read at 0x00c4206080d8 by goroutine 64:
    service/deprecated.(*DeprecatedApiService).dealHome()
    miner/memtxpool/txpool.go:64 +0x1aec
    service/deprecated.(*DeprecatedApiService).(service/deprecated.dealHome)-fm()
    service/deprecated/http.go:82 +0x5f
    net/http.HandlerFunc.ServeHTTP()
    /opt/go/src/net/http/server.go:1947 +0x51
    net/http.(*ServeMux).ServeHTTP()
    /opt/go/src/net/http/server.go:2340 +0x9f
    net/http.serverHandler.ServeHTTP()
    /opt/go/src/net/http/server.go:2697 +0xb9
    net/http.(*conn).serve()
    /opt/go/src/net/http/server.go:1830 +0x7dc

    Previous write at 0x00c4206080d8 by goroutine 40:
    miner/memtxpool.(*MemTxPool).RemoveTxs()
    miner/memtxpool/remove.go:18 +0x1d5
    miner/memtxpool.(*MemTxPool).loop()
    miner/memtxpool/loop.go:22 +0x220

    Read:
    [miner/memtxpool/txpool.go:64]
    func (p *MemTxPool) GetTotalCount() (uint64, uint64) {
    return p.txTotalCount, p.txTotalSize <=== Read
    }

    Write:
    [miner/memtxpool/remove.go:18]
    func (p *MemTxPool) RemoveTxs(txs []interfaces.Transaction) {
    p.changeLock.Lock()
    defer p.changeLock.Unlock()

    // remove
    for _, tx := range txs {
    txhx := tx.Hash()
    p.diamondCreateTxGroup.RemoveByTxHash(txhx)
    if hav := p.simpleTxGroup.RemoveByTxHash(txhx); hav != nil {
    // sub count
    p.txTotalCount -= 1 <=== Write
    p.txTotalSize -= uint64(hav.size)
    }
    }

    }

=-=-=-=-=-

  • MemTxPool Data Race # 3:
    diamond auto bid name: , tx: <3ffa6eaffbf9f1bfa0d17fbf54afbad0d243781b0f1659a8968bb1a005c0b2a2>, fee: ㄜ1,401:245 => ㄜ1,402:245

    WARNING: DATA RACE
    Write at 0x00c4208a4178 by goroutine 116:
    miner/memtxpool.(*TxGroup).removeItemUnsafe()
    miner/memtxpool/group.go:155 +0x48c
    miner/memtxpool.(*TxGroup).RemoveItem()
    miner/memtxpool/group.go:138 +0x8a
    miner/memtxpool.(*MemTxPool).AddTx()
    miner/memtxpool/add.go:71 +0x109c
    miner/diamondminer.(*DiamondMiner).doAutoBidForMyDiamond()
    miner/diamondminer/autobid.go:80 +0xa67

    Previous read at 0x00c4208a4178 by goroutine 64:
    service/deprecated.(*DeprecatedApiService).dealHome()
    miner/memtxpool/item.go:26 +0x1889
    service/deprecated.(*DeprecatedApiService).(service/deprecated.dealHome)-fm()
    service/deprecated/http.go:82 +0x5f
    net/http.HandlerFunc.ServeHTTP()
    /opt/go/src/net/http/server.go:1947 +0x51
    net/http.(*ServeMux).ServeHTTP()
    /opt/go/src/net/http/server.go:2340 +0x9f
    net/http.serverHandler.ServeHTTP()
    /opt/go/src/net/http/server.go:2697 +0xb9
    net/http.(*conn).serve()
    /opt/go/src/net/http/server.go:1830 +0x7dc

    Write:
    [miner/memtxpool/group.go:155]
    func (g *TxGroup) removeItemUnsafe(item *TxItem) bool {

    key := string(item.hash)
    if havtx, ok := g.items[key]; ok {
    if g.Count == 1 {
    g.Head = nil
    g.Tail = nil
    } else if havtx == g.Head {
    g.Head = g.Head.next
    g.Head.prev = nil
    } else if havtx == g.Tail {
    g.Tail = g.Tail.prev
    g.Tail.next = nil
    } else {
    havtx.prev.next = havtx.next <=== Write
    havtx.next.prev = havtx.prev // drop
    }
    delete(g.items, key)
    g.Count -= 1
    return true
    }
    return false
    }

    Read:
    [miner/memtxpool/item.go:26]
    func (p *TxItem) GetNext() *TxItem {
    return p.next <=== Read
    }

=-=-=-=-=-=-=-=-=-=-=-=-=-

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.