Skip to content
This repository was archived by the owner on Apr 3, 2022. It is now read-only.

Commit 450d42b

Browse files
committed
DERO AstroBWT CPU miner more optimizations
1 parent 325806e commit 450d42b

3 files changed

Lines changed: 12 additions & 19 deletions

File tree

astrobwt/astrobwt_optimized.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,11 @@ func POW_optimized_v1(inputdata []byte, max_limit int) (outputhash [32]byte, suc
3939
/* for i := range data.stage1_result{
4040
data.stage1_result[i] =0
4141
}*/
42-
for i := range data.stage2 {
43-
data.stage2[i] = 0
44-
}
45-
/*for i := range data.stage2_result{
46-
data.stage2_result[i] =0
47-
}*/
4842

4943
key := sha3.Sum256(inputdata)
50-
5144
salsa.XORKeyStream(data.stage1[1:stage1_length+1], data.stage1[1:stage1_length+1], &counter, &key)
52-
5345
sort_indices(stage1_length+1, data.stage1[:], data.stage1_result[:], data)
54-
5546
key = sha3.Sum256(data.stage1_result[:])
56-
5747
stage2_length := stage1_length + int(binary.LittleEndian.Uint32(key[:])&0xfffff)
5848

5949
if stage2_length > max_limit {
@@ -69,10 +59,11 @@ func POW_optimized_v1(inputdata []byte, max_limit int) (outputhash [32]byte, suc
6959
}
7060

7161
salsa.XORKeyStream(data.stage2[1:stage2_length+1], data.stage2[1:stage2_length+1], &counter, &key)
72-
7362
sort_indices(stage2_length+1, data.stage2[:], data.stage2_result[:], data)
74-
7563
key = sha3.Sum256(data.stage2_result[:stage2_length+1])
64+
for i := range data.stage2{
65+
data.stage2[i] =0
66+
}
7667

7768
copy(outputhash[:], key[:])
7869
pool.Put(data)
@@ -213,7 +204,7 @@ func sort_indices(N int, input_extra []byte, output []byte, d *Data) {
213204
output[i] = input_extra[indices[i]&((1<<21)-1)]
214205
}
215206

216-
// there is an issue above, if the last byte of input is 0x00, initialbytes are wrong
207+
// there is an issue above, if the last byte of input is 0x00, initialbytes are wrong, this fix may not be complete
217208
if N > 3 && input[N-2] == 0 {
218209
backup_byte := output[0]
219210
output[0] = 0

cmd/dero-miner/miner.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ func mineblock() {
468468
runtime.LockOSThread()
469469
threadaffinity()
470470

471+
iterations_per_loop := uint32(31.0 * float32(astrobwt.MAX_LENGTH) / float32(max_pow_size))
472+
471473
for {
472474
mutex.RLock()
473475
myjob := job
@@ -481,7 +483,7 @@ func mineblock() {
481483
n, err := hex.Decode(work[:], []byte(myjob.Blockhashing_blob))
482484
if err != nil || n != 76 {
483485
time.Sleep(time.Second)
484-
globals.Logger.Errorf("Blockwork could not decoded successfully (%s) , err:%s n:%d", myjob.Blockhashing_blob, err, n)
486+
globals.Logger.Errorf("Blockwork could not decoded successfully (%s) , err:%s n:%d %+v", myjob.Blockhashing_blob, err, n, myjob)
485487
continue
486488
}
487489

@@ -514,7 +516,7 @@ func mineblock() {
514516
}
515517
}
516518
} else {
517-
for i := uint32(0); i < 32; i++ {
519+
for i := uint32(0); i < iterations_per_loop; i++ {
518520
binary.BigEndian.PutUint32(nonce_buf, i)
519521
//pow := astrobwt.POW_0alloc(work[:])
520522
pow, success := astrobwt.POW_optimized_v1(work[:],max_pow_size)
@@ -550,10 +552,10 @@ func usage(w io.Writer) {
550552
//io.WriteString(w, completer.Tree(" "))
551553
io.WriteString(w, "\t\033[1mhelp\033[0m\t\tthis help\n")
552554
io.WriteString(w, "\t\033[1mstatus\033[0m\t\tShow general information\n")
553-
io.WriteString(w, "\t\033[1mbye\033[0m\t\tQuit the daemon\n")
555+
io.WriteString(w, "\t\033[1mbye\033[0m\t\tQuit the miner\n")
554556
io.WriteString(w, "\t\033[1mversion\033[0m\t\tShow version\n")
555-
io.WriteString(w, "\t\033[1mexit\033[0m\t\tQuit the daemon\n")
556-
io.WriteString(w, "\t\033[1mquit\033[0m\t\tQuit the daemon\n")
557+
io.WriteString(w, "\t\033[1mexit\033[0m\t\tQuit the miner\n")
558+
io.WriteString(w, "\t\033[1mquit\033[0m\t\tQuit the miner\n")
557559

558560
}
559561

config/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ import "github.com/blang/semver"
2020

2121
// right now it has to be manually changed
2222
// do we need to include git commitsha??
23-
var Version = semver.MustParse("2.2.0-1.Atlantis.Astrobwt+05032020")
23+
var Version = semver.MustParse("2.2.0-4.Atlantis.Astrobwt+05032020")

0 commit comments

Comments
 (0)