Skip to content

Commit

Permalink
ethash: fix initialization flaw
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Oct 5, 2020
1 parent 523f284 commit 3fc6dd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions consensus/ethash/ethash.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ func NewShared(progpowNumber *big.Int) *Ethash {
if progpowNumber == nil {
progpowNumber = new(big.Int).SetUint64(uint64(math.MaxUint64))
}
if sharedEngines == nil {
sharedEngines = make(map[uint64]*Ethash)
}
sharedEngine, exist := sharedEngines[progpowNumber.Uint64()]
if !exist {
sharedEngine = New(Config{"", 3, 0, false, "", 1, 0, false, ModeNormal, progpowNumber, nil}, nil, false)
Expand Down
11 changes: 5 additions & 6 deletions consensus/ethash/progpow.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package ethash

import (
"encoding/binary"
"math/bits"

"golang.org/x/crypto/sha3"
"math/bits"
)

const (
Expand Down Expand Up @@ -310,15 +310,14 @@ func progpowLoop(seed uint64, loop uint32, mix *[progpowLanes][progpowRegs]uint3
gOffset := mix[loop%progpowLanes][0] % (64 * datasetSize / (progpowLanes * progpowDagLoads))

var (
srcCounter = uint32(0)
dstCounter = uint32(0)
srcCounter uint32
dstCounter uint32
randState kiss99State
srcSeq [32]uint32
dstSeq [32]uint32
rnd = kiss99
//iMax = uint32(0)
index = uint32(0)
data_g []uint32 = make([]uint32, progpowDagLoads)
index uint32
data_g []uint32 = make([]uint32, progpowDagLoads)
)
// 256 bytes of dag data
dag_item := make([]byte, 256)
Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/progpow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"bytes"
"encoding/json"
"fmt"
"golang.org/x/crypto/sha3"
"io/ioutil"
"path/filepath"
"strconv"
"testing"

"github.com/ethereum/go-ethereum/common"
"golang.org/x/crypto/sha3"
)

func TestRandomMerge(t *testing.T) {
Expand Down

0 comments on commit 3fc6dd8

Please sign in to comment.