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

Commit

Permalink
DERO AstroBWT CPU miner more optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainDero committed Mar 6, 2020
1 parent 325806e commit 450d42b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
17 changes: 4 additions & 13 deletions astrobwt/astrobwt_optimized.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,11 @@ func POW_optimized_v1(inputdata []byte, max_limit int) (outputhash [32]byte, suc
/* for i := range data.stage1_result{
data.stage1_result[i] =0
}*/
for i := range data.stage2 {
data.stage2[i] = 0
}
/*for i := range data.stage2_result{
data.stage2_result[i] =0
}*/

key := sha3.Sum256(inputdata)

salsa.XORKeyStream(data.stage1[1:stage1_length+1], data.stage1[1:stage1_length+1], &counter, &key)

sort_indices(stage1_length+1, data.stage1[:], data.stage1_result[:], data)

key = sha3.Sum256(data.stage1_result[:])

stage2_length := stage1_length + int(binary.LittleEndian.Uint32(key[:])&0xfffff)

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

salsa.XORKeyStream(data.stage2[1:stage2_length+1], data.stage2[1:stage2_length+1], &counter, &key)

sort_indices(stage2_length+1, data.stage2[:], data.stage2_result[:], data)

key = sha3.Sum256(data.stage2_result[:stage2_length+1])
for i := range data.stage2{
data.stage2[i] =0
}

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

// there is an issue above, if the last byte of input is 0x00, initialbytes are wrong
// there is an issue above, if the last byte of input is 0x00, initialbytes are wrong, this fix may not be complete
if N > 3 && input[N-2] == 0 {
backup_byte := output[0]
output[0] = 0
Expand Down
12 changes: 7 additions & 5 deletions cmd/dero-miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ func mineblock() {
runtime.LockOSThread()
threadaffinity()

iterations_per_loop := uint32(31.0 * float32(astrobwt.MAX_LENGTH) / float32(max_pow_size))

for {
mutex.RLock()
myjob := job
Expand All @@ -481,7 +483,7 @@ func mineblock() {
n, err := hex.Decode(work[:], []byte(myjob.Blockhashing_blob))
if err != nil || n != 76 {
time.Sleep(time.Second)
globals.Logger.Errorf("Blockwork could not decoded successfully (%s) , err:%s n:%d", myjob.Blockhashing_blob, err, n)
globals.Logger.Errorf("Blockwork could not decoded successfully (%s) , err:%s n:%d %+v", myjob.Blockhashing_blob, err, n, myjob)
continue
}

Expand Down Expand Up @@ -514,7 +516,7 @@ func mineblock() {
}
}
} else {
for i := uint32(0); i < 32; i++ {
for i := uint32(0); i < iterations_per_loop; i++ {
binary.BigEndian.PutUint32(nonce_buf, i)
//pow := astrobwt.POW_0alloc(work[:])
pow, success := astrobwt.POW_optimized_v1(work[:],max_pow_size)
Expand Down Expand Up @@ -550,10 +552,10 @@ func usage(w io.Writer) {
//io.WriteString(w, completer.Tree(" "))
io.WriteString(w, "\t\033[1mhelp\033[0m\t\tthis help\n")
io.WriteString(w, "\t\033[1mstatus\033[0m\t\tShow general information\n")
io.WriteString(w, "\t\033[1mbye\033[0m\t\tQuit the daemon\n")
io.WriteString(w, "\t\033[1mbye\033[0m\t\tQuit the miner\n")
io.WriteString(w, "\t\033[1mversion\033[0m\t\tShow version\n")
io.WriteString(w, "\t\033[1mexit\033[0m\t\tQuit the daemon\n")
io.WriteString(w, "\t\033[1mquit\033[0m\t\tQuit the daemon\n")
io.WriteString(w, "\t\033[1mexit\033[0m\t\tQuit the miner\n")
io.WriteString(w, "\t\033[1mquit\033[0m\t\tQuit the miner\n")

}

Expand Down
2 changes: 1 addition & 1 deletion config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ import "github.com/blang/semver"

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

0 comments on commit 450d42b

Please sign in to comment.